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.

ago
09
2010

IP representation

Yesterday I came across with an interesting contruction for IP address. Suppose that you want store the address ‘192.168.10.33′ no matter the dot.

192<<24|168<<16|10<<8|33

That produces

3232238113 (0xc0a80a21)

To return is just get the address in hex format and split in 4 sections. Means that: c0 (192) a8  (168) 0a (10) 21 (33). An example using Python generators to return using big endian format (download).

def octet(ip):
        for i in range(-24,8,8):
                yield ip >> -i & 0xff

And got each value:

r = octet(ip)
r.next() # returns 192
r.next() # returns 168
r.next() # returns 10
r.next() # returns 33

ago
06
2010

TTMMHTW: meego, rtos, android, qemu, python, dojo

Some things that made me happy this week.
  • Video MeeGo on BeagleBoard and How-to from scratch.
  • NuttX RTOS that is ANSI/POSIX compliant.
  • ShowMeDoscreencasts to learn with the open source community.
  • BRTOS – My friend Marcelo Barros published his works on Real-time Operating System for MSP430 [code repository ] and explanations (portuguese) sub-divided in part II part III and part IV.
  • Hack a Day series on Android Development 101 Part 1 (Hello WorldPart 2 (Hello World improved) Part 3 (Introduction to DatabasesPart 4 (Advanced Database/GUI Code and DDMS) Part 5 (DroidDraw & Information Tracker Completed)
  • Writing kernels that boot with Qemu and Grub – a tutorial (also this)
  • Release of PySide 0.4.0 including Qt Mobility and Mac OS X support.
  • 5 min. video explaining Coding Dojo basics.
ago
05
2010

Latex Beamer themes

Creating your presentation slides with Latex (Beamer) is quick and easy when you have a template to based on. I’ve created one example describing the main features that an average user might need and setted to different templates. You can run by typing:

$ pdflatex file.tex

Enjoy :-)

I had to rename template file from .tex to .txt to upload. If you were compile, rename to .tex again.

  1. AnnArbor – template (.tex) and example (.pdf)
  2. CambridgeUS – template (.tex) and example (.pdf)
  3. Hannover – template (.tex) and example (.pdf)
  4. Antibes – template (.tex) and example (.pdf)
  5. Copenhagen – template (.tex) and example (.pdf)
  6. Ilmenau – template (.tex) and example (.pdf)
  7. Bergen – template (.tex) and example (.pdf)
  8. Darmstadt – template (.tex) and example (.pdf)
  9. JuanLesPins – template (.tex) and example (.pdf)
  10. Berkeley – template (.tex) and example (.pdf)
  11. Dresden – template (.tex) and example (.pdf)
  12. Luebeck – template (.tex) and example (.pdf)
  13. Berlin – template (.tex) and example (.pdf)
  14. Frankfurt – template (.tex) and example (.pdf)
  15. Madrid – template (.tex) and example (.pdf)
  16. Boadilla – template (.tex) and example (.pdf)
  17. Goettingen – template (.tex) and example (.pdf)
  18. Malmoe – template (.tex) and example (.pdf)
  19. Marburg – template (.tex) and example (.pdf)
  20. Szeged – template (.tex) and example (.pdf)
  21. PaloAlto – template (.tex) and example (.pdf)
  22. Montpellier – template (.tex) and example (.pdf)
  23. Warsaw – template (.tex) and example (.pdf)
  24. boxes – template (.tex) and example (.pdf)
  25. Pittsburgh – template (.tex) and example (.pdf)
  26. default – template (.tex) and example (.pdf)
  27. Rochester – template (.tex) and example (.pdf)
  28. Singapore – template (.tex) and example (.pdf)

I created this template to quick access what that I most use on presentations. Things I forgot on purpose: I didn’t mentioned figures, but is easy too.

Worth seeing: for diagrams I noted that Dia exports to Latex, so It’s a quick way to insert some blocks or some UML interface. Finally, embed Python inside Latex still works too :-)

** See below ONLY if you are interested in HOW I made these templates **

Of course that I didn’t create each file by hand. I used the following lines to create two script files in order to replace the text and run pdflatex. (list.txt)

for i in `cat list.txt` ; do echo  "sed -e
's/^\\\usetheme{.*/\\\usetheme{$i}/' beamer-template.tex &gt; $i-example.tex" ; done
> script.sh
for i in `cat list.txt` ; do echo "pdflatex $i-example.tex" ; done >
script-make.sh
jul
30
2010

TTMMHTW: math, research, network, syscalls and linux

Some things that made me happy this week.