STM32/ARM Cortex-M3 HOWTO: Development under Ubuntu (Debian)

Compile Olimex blinky

At this point you have created the toolchain and flashed a program into your board.

Now let's do a quick test to see that our gcc toolchain is working, and we are going to test it on the same blinky example as before.

mkdir -p ~/stm32/stm32-example
cd ~/stm32/stm32-example
wget http://olimex.com/dev/soft/arm/STR/STM32-BLINK-LED-GCC-ECLIPSE-projects.rar
unrar x STM32-BLINK-LED-GCC-ECLIPSE-projects.rar 
cd projects/stm_h103/

And now let's recompile and see what we get.

make clean 
make

And hopefully you don't get any compile warnings at this point....

But let's check what we got.

ls --sort=time -1

Then the top of the list should be something like this:

main.bin
main.list
main.o
main.out
stm32f10x_gpio.o
stm32f10x_rcc.o
....

main.bin

So what are those files anyway? main.bin is a good file to know about since that is the file you are going to flash onto the board.

main.out

With the strange .out name, we find the elf-file. In there we have a lot of funny stuff to play with, and and since it is a elf this file is often called main.elf. But first let's check that we did produce code for the Cortex-M3, and for that we can use readelf from binutils.

arm-none-eabi-readelf -A main.out

then we something like this:

Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "CORTEX-M3"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Microcontroller
  Tag_THUMB_ISA_use: Thumb-2
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align8_needed: Yes
  Tag_ABI_align8_preserved: Yes, except leaf SP
  Tag_ABI_enum_size: small
  Tag_ABI_optimization_goals: Aggressive Debug

main.list

Another fun thing is to use objdump to look at the elf with the -S flag.

arm-none-eabi-objdump -S main.out

The makefile does this for us and the result is stored in main.list. Here you can find both assembler and c-code interleaved so you can check the compiler results. You can open it in a normal editor and have a quick look.

vi main.list

That's that, we compiled the blinky... now let's move forward to the next part and see if we can't actually get something on to the board.

Fatal error: Uncaught Error: Call to a member function link_ext() on null in /customers/9/b/5/fun-tech.se/httpd.www/stm32/class.page.php:62 Stack trace: #0 /customers/9/b/5/fun-tech.se/httpd.www/stm32/gcc/compile_blinky.php(142): page->getFoot() #1 {main} thrown in /customers/9/b/5/fun-tech.se/httpd.www/stm32/class.page.php on line 62