Tag: RIOT

HOWTO: RIOT – from zero to “hello world” run test in 8 commands (no hardware required)

Let’s assume you really decided not to RTFM. Here it goes, ready to copy-paste:

sudo apt-get install build-essential pkg-config valgrind sudo bridge-utils
sudo dpkg --add-architecture i386
apt-get update
sudo apt-get install libc6-dev-i386 libc6-dbg:i386
git clone git://github.com/RIOT-OS/RIOT.git
cd RIOT/examples/hello-world/
make BOARD=native
./bin/native/hello-world.elf

Done.

You just (and only) saved yourselves approximately 8 minutes of reading the RIOT-OS introduction wiki page.


Let’s detail that.

$ sudo apt-get install build-essential pkg-config valgrind sudo bridge-utils

This will install the needed toolchain, and a bit of extra stuff as well, not really needed for this example, such as valgrind and bridge-utils. But you’ll get your host – almost – setup for RIOT development. If your’re reading this blog, I’d be surprised if this install anything on your system: as for me it only installed bridge-utils, because my OS install is relatively fresh after an HDD failure. Notice the bit of recursive irony of running a sudo apt-get install [...] sudo. Also note that git should be added to this list.

$ sudo dpkg --add-architecture i386
$ apt-get update
$ sudo apt-get install libc6-dev-i386 libc6-dbg:i386

I’m running an amd64 64-bit architecture OS (Debian stretch aka testing). RIOT support 8, 16 and 32-bit platforms, and I guess (and actually hope) that 64-bit support is not a high emergency feature on its roadmap considering the targeted hardware. So OK, let’s install a 32-bit gcc toolchain as well.

$ git clone git://github.com/RIOT-OS/RIOT.git

Get the sources – duh!

$ cd RIOT/examples/hello-world/
$ make BOARD=native

And here is the output:

jbm@sumo:~/sandbox/RIOT/examples/hello-world$ make BOARD=native
Building application "hello-world" for "native" with MCU "native".

"make" -C /home/jbm/sandbox/RIOT/boards/native
"make" -C /home/jbm/sandbox/RIOT/boards/native/drivers
"make" -C /home/jbm/sandbox/RIOT/core
"make" -C /home/jbm/sandbox/RIOT/cpu/native
"make" -C /home/jbm/sandbox/RIOT/cpu/native/periph
"make" -C /home/jbm/sandbox/RIOT/drivers
"make" -C /home/jbm/sandbox/RIOT/sys
"make" -C /home/jbm/sandbox/RIOT/sys/auto_init
 text data bss dec hex filename
 27453 420 47688 75561 12729 /home/jbm/sandbox/RIOT/examples/hello-world/bin/native/hello-world.elf

One does not build from RIOT source code top-level directory, but from an application directory. And the build system will check that and guide you, as it guided me:

jbm@sumo:~/sandbox/RIOT$ make BOARD=native
Welcome to RIOT - The friendly OS for IoT!

You executed 'make' from the base directory.
You should run 'make' in your application's directory instead.

Please see our Quick Start Guide at:
 https://github.com/RIOT-OS/RIOT/wiki/Quick-Start-Guide
Or ask questions on our mailing list:
 users@riot-os.org (http://lists.riot-os.org/mailman/listinfo/users)

Makefile:6: recipe for target 'all' failed
make: *** [all] Error 1

So cd to your application directory, and build from there specifying the target hardware. Since we have no hardware, we’ll build a host executable using the native hardware platform.

$ ./bin/native/hello-world.elf

Run your application as a Linux process.

And here is the output:

jbm@sumo:~/sandbox/RIOT/examples/hello-world$ ./bin/native/hello-world.elf 
RIOT native interrupts/signals initialized.
LED_RED_OFF
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.

main(): This is RIOT! (Version: 2016.07-devel-176-g16da-sumo)
Hello World!
You are running RIOT on a(n) native board.
This board features a(n) native MCU.

And that’s it.

So far, that’s what I call “developer friendly”.

If you’ve read this far, you should now really, really, go back to RIOT introduction wiki page  – read time is only about 8 minutes.