out
08
2010

accessing u-boot with picocom to transfer files via serial interface

There is a how-to with minicom too, this is using picocom to transfer files via serial interface (ymodem). First start with some parameters, in this case I’m using ttyUSB0.

$ picocom --baud 115200 --send-cmd="sb -vv" --receive-cmd="rb -vvv" /dev/ttyUSB0

Then:

U-Boot > loady
## Ready for binary (ymodem) download to 0x90800000 at 115200 bps...

Type C-a C-s and choose the file.

*** file: /tftpboot/uImage
sb -vv /tftpboot/uImage
Sending: uImage
Ymodem sectors/kbytes sent:   0/ 0kRetry 0: NAK on sector
Retry 0: NAK on sector
Bytes Sent:2203904   BPS:7800
Sending:Transfer complete*** exit status: 0
0(STX)/0(CAN) packets, 6 retries
## Total Size      = 0x0021a0e4 = 2203876 Bytes
U-Boot >

* The sb and rb utility are on lrzsz package [ $sudo apt-get install lrzsz ]

** Other reference

set
09
2010

unnamed files

I’m a heavy user of command line interface and often named files without extension. This behavior forces me to use file utility every time I have doubts.

$ file stick-note1
stick-note1: ASCII text

When organizing my home/ I came across with many files like that, so I decided make this script to walk throughout files and check if it’s text file without extension and put .txt after.

download script

$ python names.py
This only change the file on current directory and it’s a “works for me” approach. Adapt to your needs.

set
08
2010

Installing Buildroot toolchain for Nuttx

On my previous post I discussed some stats using Buildroot toolchain to build Nuttx. Today I’ll add the necessary steps to build on Ubuntu. Ubuntu is de-facto GNU/Linux distribution (although I’m Gentoo user) and many users, from different areas, uses it [they are not necessary command line experts] so I decided to publish my raw tutorial. If you are familiarized installing files from source-code you probably won’t need this…

1. Dependencies

$ sudo apt-get install libncurses5-dev
$ sudo apt-get install bison
$ sudo apt-get install flex
$ sudo apg-get install libgmp3-dev
$ sudo apg-get install libmpc-dev
$ sudo apg-get install libmpfr-dev
$ sudo apg-get install binutils-dev

2. Download

$ mkdir Nuttx
$ cd Nuttx

$ wget http://sourceforge.net/projects/nuttx/files/nuttx/nuttx-5.10/nuttx-5.10.tar.gz/download
$ wget http://sourceforge.net/projects/nuttx/files/buildroot/buildroot-1.8/buildroot-1.8.tar.gz/download

$ ls
buildroot-1.8.tar.gz  nuttx-5.10.tar.gz

3. Install

$ tar zxf buildroot-1.8.tar.gz
$ tar zxf nuttx-5.10.tar.gz

$ cd misc/
$ ln -s ../nuttx-5.10 nuttx

You need define some Nuttx files before:

$ cd nuttx/
$ cd tools/
$ ./configure.sh nucleus2g/nsh # or ./configure <board-name>
$ cd -

$ cd ../misc

I’m building a toolchain for arm cortex-m3 but check configs/ to other configuration files.

$ cd buildroot-1.8/
$ cp configs/cortexm3-defconfig-4.3.3 .
$ mv cortexm3-defconfig-4.3.3 .config

$ make menuconfig
[If you don't have any changes, just click on 'exit' and save the configuration]

$ make
[will download and build all necessary files]

$ cd build_arm_nofpu/staging_dir/bin
$ export PATH=`pwd`:$PATH
$ cd -

$ cd ../nuttx
[use normally]

I usually create an script to (re)define the $PATH for necessary building tools, something like:

$ echo “export PATH=\”"$PATH”\”" > compiler.sh

set
06
2010

Compiler for Nuttx

I was following this thread on Nuttx maillist on recommended compiler to build Nuttx RTOS. As a matter of practicality I guess that many users use CodeSourcery arm-none-linux-gnueabi but today I decided test the code generated for Cortex-M3 (LPC1768) using the toolchain from Buildroot. As Greg Nutt said (text adapted):

They were configured using OABI [old arm ABI], but I prefer them because (1) they are not EABI and reliably link code with -O3 or -Os, making it up to half the size, and (2) include nuttx “built in” — they really should be called arm-nuttx-gcc tools.

Here my stats (defconfig):

$ arm-none-eabi-size nutt
text         data   bss       dec        hex      filename
71000     324    2248   73572   11f64   nuttx

$ arm-elf-size nuttx
text         data    bss      dec         hex     filename
56172     330    2248   58750    e57e   nuttx

The final .bin has an delta of 16K. As I’m using one parallel JTAG (flash rates @ 0.2 KiB/S) this means almost 1 minute reduction in each flash write_image. If you check Make.defs note that MAXOPTIMIZATION for CodeSourcery isn’t using optimize for size option (-Os). As explained on config/<board>/README.txt it doesn’t work with this kind of optimization level [tested with 2009q1].

ago
20
2010

TTMMHTW: web, qt, foss, openocd, freertos

Some things that made me happy this week.

ago
19
2010

Cadê meu diploma?

Os alunos da Unifei esperam meses após a colação para pegar o diploma… Para não ter que ficar verificando o PDF, fiz um script para saber se você pode passar no DRA. Seu uso é bem simples, veja um exemplo com meu amigo @Gui_Itajuba (update: aliás, já esta a um bom tempo com ele em mãos):

$ python cademeudiploma.py “Guilherme Bicalho de Pádua”
Pode passar no DRA ;-)

Se não sair nenhuma resposta, seu nome ainda não está na lista :-(

Agradecimentos ao YQL e ao @pedrovalente por desenvolver e compartilhar a tabela de acesso a documentos PDF.

ago
14
2010

Building GCC [4.6] on MacOSX

The objective here is describe a didactic way to build GNU GCC on MacOSX.  In order to compile GCC you need three libraries: GMP, MPFR and MPC. To organize I usually create folders for each purpose. In this case, three, respectively: source, build and install. [It's not a rule].  My original enviroment is MacOSX 10.6.4 and gcc version 4.2.1 (Apple Inc. build 5659). All files will be on GCC folder, the description below shows:

$ mkdir ~/Projects/GCC # compiler + libs
$ mkdir ~/Projects/GCC/libs # gmp, mpfr and mpc
$ mkdir ~/Projects/GCC/libs/files # downloaded files
$ mkdir ~/Projects/GCC/libs/install # store libs objects and include

Step #1 – Download

$ cd ~/Projects/GCC/libs/files
$ wget ftp://ftp.gmplib.org/pub/gmp-5.0.1/gmp-5.0.1.tar.bz2
$ wget http://www.mpfr.org/mpfr-current/mpfr-3.0.0.tar.bz2
$ wget http://www.multiprecision.org/mpc/download/mpc-0.8.2.tar.gz

Step #2 – Unpack

$ cd ~/Projects/GCC/libs/
$ tar jxvf files/gmp-5.0.1.tar.bz2
$ tar jxvf files/mpfr-3.0.0.tar.bz2
$ tar zxvf files/mpc-0.8.2.tar.gz

Step #3 – Build: GMP

$ cd ~/Projects/GCC/libs/

$ mkdir gmp-build
$ cd gmp-build
$ ../gmp-5.0.1/configure –prefix=$(cd ../install && pwd)
$ make install

Note 1: I’m using with ABI=64
Note 2 : Maybe you’ll get some unresolved symbols to GMP and MPFR on linking time, never mind.

Step #4 – Build: MPFR

$ cd ~/Projects/GCC/libs/

$ mkdir mpfr-build
$ cd mpfr-build
$ ../mpfr-3.0.0/configure –prefix=$(cd ../install && pwd) –with-gmp=~/Projects/GCC/libs/install
$ make install

Note: Before prefix and with-xxx there are two hyphen (not one as showed). It’s an Wordpress issue, I don’t know how to avoid concatenation.

Step #5 – Build: MPC

$ cd ~/Projects/GCC/libs/

$ mkdir mpc-build
$ cd mpc-build
$ ../mpc-0.8.2/configure –prefix=$(cd ../install && pwd) –with-gmp=~/Projects/GCC/libs/install –with-mprf=~/Projects/GCC/libs/install
$ make install

Problems? If something goes wrong…

../../mpc-0.8.2/src/mpc.h:25:17: error: gmp.h: No such file or directory
../../mpc-0.8.2/src/mpc.h:26:18: error: mpfr.h: No such file or directory

I fixed by adding symbolic links:

$ cd ~/Projects/GCC/libs/mpc-0.8.2/src/
$ ln -s ../../install/include/mpf2mpfr.h .
$ ln -s ../../install/include/mpfr.h .
$ ln -s ../../install/include/gmp.h .

Step #6 – Download & Build GCC (~4.6)

I used GCC from git (fda0037801fb258a2191aba59e1e9f0df019e3b6) and I don’t know if it will work on newer versions. You’ll have to try. Sorry. [Howto: GitMirror]. Use git checkout to specify one commit.

$ cd ~/Projects/GCC/

$ git clone git://gcc.gnu.org/git/gcc.git

$ mkdir build
$ mkdir install

$ cd build
$ ../gcc/configure –prefix=$(cd ../install/ && pwd) –with-gmp=/Users/maluta/Projects/GCC/libs/install –with-mpfr=/Users/maluta/Projects/GCC/libs/install –with-mpc=/Users/maluta/Projects/GCC/libs/install –disable-checking –enable-werror –enable-languages=c

$ make
$ make install

Step #7 – Test

The binary files will be placed in ~/Projects/GCC/install/bin

$ ~/Projects/GCC/install/bin
$ ./gcc -v

Using built-in specs.
COLLECT_GCC=./gcc
COLLECT_LTO_WRAPPER=/Users/maluta/Projects/GCC/install/libexec/gcc/x86_64-apple-darwin10.4.0/4.6.0/lto-wrapper
Target: x86_64-apple-darwin10.4.0
Configured with: ../gcc/configure –prefix=/Users/maluta/Projects/GCC/install –with-gmp=/Users/maluta/Projects/GCC/libs/install –with-mpfr=/Users/maluta/Projects/GCC/libs/install –with-mpc=/Users/maluta/Projects/GCC/libs/install –disable-checking –enable-werror –enable-languages=c
Thread model: posix
gcc version 4.6.0 20100508 (experimental) (GCC)

Although I focused on OSX build/installation the steps described are the same to any architecture. Build an compiler – especially a cross-compiler (no that case) – demands time and patience to understand many particularities.

Enjoy ;-)

ago
13
2010

TTMMHTW: multitouch, rtos, productivity, qml, …

Some things that made me happy this week.