libopencm3 bare-metal Vybrid examples

As I wrote yesterday, I’m currently hacking on libopencm3 for bare-metal Vybrid development. This effort advanced quite a bit, the GitHub repository now contains code to use the UART and GPIOs from the Cortex-M4.

The Hardware I use consists of a Toradex Colibri VF61 on a Iris Carrier Board. The code should also run fine on Freescales Vybrid Tower board (TWR-VF65GS10). Currently I use the preinstalled Linux BSP consisting of U-Boot, Linux 3.0 Kernel and a OpenEmbedded based root file system.

To compile the libopencm3 examples, I use a recent Linaro bare-metal tool chain. There are two repositories: the library repository and the example repository. The latter uses git submodule to get the library. The submodule points to the upstream library, hence, for now, one need to switch that to my repository and branch:

$ export PATH=/opt/gcc-arm-none-eabi-4_6-2012q4/bin/:${PATH}
$ git clone https://github.com/falstaff84/libopencm3-examples.git
...
$ cd libopencm3-examples
$ git checkout fsl-vf6xx
...
$ git submodule init
..
$ git submodule update

$ cd libopencm3
$ git remote add falstaff https://github.com/falstaff84/libopencm3.git
$ git fetch falstaff
...
$ git checkout fsl-vf6xx
...

Now all code should be ready. You can start by compiling the library in the current libopencm3-examples/libopencm3 directory. Then, in the folder libopencm3-examples/examples/vf6xx/colibri-vf61/ two examples are available. In order to load the firmware with mqxboot later on, a binar is needed.

$ cd examples/vf6xx/colibri-vf61/uart/
$ make uart.bin
$ ls -la uart.bin
-rwxr-xr-x 1 ags ags 26788 10. Jul 00:35 uart.bin

This file now need to be copied to the target. The example makes use of UART2 which can be found on the X14 connector of the Iris Carrier Board, make sure you have a serial terminal configured at 115200 on that port before starting the firmware. Now use the utility mqxboot to start the firmware:

# mqxboot uart.bin 0x3f000000 0x1f000401
Loading uart.bin to 0x3f000000 ...
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=1024
len=164
Loaded 26788 bytes. Booting at 0x1f000401...
done

Now the firmware should print on UART2… 🙂

Hello World! 0 0.000000 0.000000
Hello World! 1 0.010000 0.010000
Hello World! 2 0.020000 0.020000
Hello World! 3 0.030000 0.030000
Hello World! 4 0.040000 0.040000
Hello World! 5 0.050000 0.050000
Hello World! 6 0.060000 0.060000
Hello World! 7 0.070000 0.070000
Hello World! 8 0.080000 0.080000
Hello World! 9 0.090000 0.090000
  1. Hi Stefan:

    I am using Linaro gcc 4.9 (2014.09). I followed your steps above and I was able to compille the whole library. I tried to compile gpio example but it gave me these kind of error:
    gpio.elf uses VFP register arguments, … libc.a (lib_a-errno.o) does not.

    It seems that libc.a is not compatible to hard-float.

    Did you encounter this kind of problem? Any way to explore further?

Leave a Comment