An application that runs on RIOT OS should have at least 2 files. The first thing is a Makefile in which we set various variables in order to do the compilation process properly. The second thing is a C program with a main function. Let's go ahead and write a new hello world program for RIOT OS. There's no need to mention that we should have downloaded RIOT OS source code first. It should be saved in somewhere in my file system.
We start creating our program by first creating a new directory for our new program. We can do that anywhere in your file system and I will have it helloworld. Inside it, create a Makefile. The easiest way to do is copying the sample Makefile provided to us by RIOT OS.
cp ../../RIOT/dist/Makefile ./
Now, edit the Makefile to have a content like the following. We basically changed the application name, modified the path to RIOT OS source code and uncommented few lines.
It's time to add our C program with the main function. Following sample code shows my C program saved with the name main.c inside the same helloworld directory.
Now we can compile and run our simple program to see how it works. We can do that by first issuing the command make inside the helloworld directory. The executable ELF file will be available inside the same directory but deep inside few other child directories. We can run the program as follows.
It should show the output of our program and hangup. To terminate the execution of RIOT system, we have to give a Ctrl+C.