Ham Radio


From George Smart's Wiki

Jump to: navigation, search

Our group were recently donated some ST STM32W evaluation boards. It features a 32-bit ARM® Cortex™-M3 microprocessor and a 2.4 GHz IEEE 802.15.4-compliant transceiver suitable for ZigBee. This page documents my getting Contiki programs go build on the device.

STM32w Starter Kit Board

Despite the STM32w being on the Contiki OS Supported Hardware list, it was a little fiddly.


With The Ubuntu Repository Binaries

To compile for the STM32w, you need to specify a target device of mb851:

george@georgesmartbox:~/contiki/examples/hello-world$ make TARGET=mb851 hello-world | tee temp
arm-none-eabi-gcc -DCONTIKI=1 -DCONTIKI_TARGET_MB851=1 -mthumb -mcpu=cortex-m3 -D
"PLATFORM_HEADER=\"hal/micro/cortexm3/compiler/gnu.h\"" -D BOARD_HEADER=\"board.h\" -g -Wall -Wno-strict-aliasing 
-D ENABLE_ADC_EXTENDED_RANGE_BROKEN -D __SOURCEFILE__=\"rimeaddr.c\" -Os -ffunction-sections   -I. 
-I../../platform/mb851/. -I../../platform/mb851/dev -I../../cpu/stm32w108/. -I../../cpu/stm32w108/dev 
-I../../cpu/stm32w108/hal -I../../cpu/stm32w108/simplemac -I../../cpu/stm32w108/hal/micro/cortexm3 
-I../../cpu/stm32w108/hal/micro/cortexm3/stm32w108 -I../../core/dev -I../../core/lib -I../../core/net -I../../core/net/mac 
-I../../core/net/rime -I../../core/net/rpl -I../../core/sys -I../../core/cfs -I../../core/ctk -I../../core/lib/ctk -I../../core/loader 
-I../../core/. -I../../platform/mb851/ -MMD -c ../../core/net/rime/rimeaddr.c -o obj_mb851/rimeaddr.o
/usr/arm/none-eabi/libexec/gcc/arm-none-eabi/4.3.3/cc1: error while loading shared libraries: libmpfr.so.1:
  cannot open shared object file: No such file or directory
make: *** [obj_mb851/rimeaddr.o] Error 1

The making of hello-world didn't go very well at all... Apparently I was missing libmpfr.so.1 which provides a library for multiple-precision floating-point computation with correct rounding which is efficient with well-defined semantics. I just had no idea where to find it. I checked the apt-file database with no luck. I Googled for it with no luck. I am currently waiting for an answer to my question on the mailing list.

Compiling Our Own Binaries

David Mills recommended the use of summon-arm-toolchain for working with ARM chips. The project provides a script that is run. I then took my office cup to the staff room, and went to fill it with tea!

For several reasons I couldn't progress to far with the compiled version. I got a known bug about moving the location counter to the start which is required because of the CoffeeFS system:

../../cpu/stm32w108/gnu.ld:206 cannot move location counter backwards (from 0801f800 to 00000000)
collect2: ld returned 1 exit status

Steal the Binaries from Contiki Instant 2.6

The quickest way to avoid this was to simply steal the CodeSourcery binaries from ContikiInstant2.6. They are offered here in tar-bzip2 format ContikiInstant CodeSourcery Files

From these files, put them somewhere where you can find them. My computer's previous failed attempts from the repository installs had put the files in /usr/arm so I decided to follow trend. I extracted the zip file and then moved the Sourcery_G++_Lite folder to become /usr/arm/none-eabi/. I then created symlinks from here to /usr/local/bin/ to the following files:

  • /usr/local/bin/arm-none-eabi-objdump -> /usr/arm/none-eabi/bin/arm-none-eabi-objdump
  • /usr/local/bin/arm-none-eabi-objcopy -> /usr/arm/none-eabi/bin/arm-none-eabi-objcopy
  • /usr/local/bin/arm-none-eabi-gcc -> /usr/arm/none-eabi/bin/arm-none-eabi-gcc
  • /usr/local/bin/arm-none-eabi-ar -> /usr/arm/none-eabi/bin/arm-none-eabi-ar
  • /usr/local/bin/arm-none-eabi-size -> /usr/arm/none-eabi/bin/arm-none-eabi-size

At this point, I was able to compile Contiki to a binary, but unable to flash the device. The computer was able to see the development board, but it wasn't presenting a USB Serial Port as the Contiki flasher tool expected.

[4577085.967054] generic-usb 0003:0483:5741.0007: input,hidraw2: USB HID v1.11 Mouse
   [STMicroelectronics STM32W Composite Device ] on usb-0000:00:1a.0-1.3/input2


While fiddling with the device to try and find out where to flash, I noticed that the device spawned /dev/ttyACM0. To this end, I connected to it with serialdump-linux -b115200 /dev/ttyACM0 and got the following my pressing buttons...

george@georgesmartbox:~/contiki/tools/stm32w$ ./serialdump-linux -b115200 /dev/ttyACM0 
connecting to /dev/ttyACM0 (115200) [OK]
SimpleMAC (1.1.0) Sample Application: 'Planet role'!
Enter ? for list of commands
> Sleep... (perform UART activity to wake)
Inactive node joining network and becoming a planet
Trying channel 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Did not join.  Returning to inactive state.
> Sleep... 

Dirty Attempt at Flashing

So I read through the make files to see what's going on. I run throught he flashing sequence and got the .bin file from objcopy (from the .mb851 file). From here, it's just a matter of actually flashing the file...

$ sudo /home/george/contiki/tools/stm32w/stm32w_flasher/stm32w_flasher -f -i rs232 -p /dev/ttyACM0 -r example-broadcast.bin
[sudo] password for george: 
INFO: STM32W flasher utility version 2.0.0b2  for Linux
ERROR: Failed to detect port type for /dev/ttyACM0
ERROR: Trouble while resetting board on port : '/dev/ttyACM0'
ERROR: Error while initiliazing interface

But as you can see this failed too. I read that there are some updates to stm32w_flasher, so I have sent a message asking for help. Lets see!