ChibiOS on my cc2520+stm32f4 boards

I have created a simple example where I use ChibiOS on my rf boards. You can download it here:

rfboard-chibios

In order to build it, you need ChibiOS with the ST libraries in the ext directory, which you can download here:

ChibiOS-RT-master

Update: The ST libraries are no longer required, but you can still use the ChibiOS-version above if you’d like. It should work just as well with the official version.

In this example, there are two threads that send and receive RF packets between two RF boards. If this program is uploaded to two RF boards, the red LED on each board should blink because the other board sends packets to switch it on and off and vice versa. The green LED is on as long as the board receives acks from the other board. Auto-ack can also be switched off – then the green LED should be on all the time.

This example also emulates an USB modem when the USB cable is plugged in, so you can use you favourite serial terminal to connect to it. The baudrate is ignored and does not matter. On Ubuntu, it will show up as something like /dev/ttyACM0 (or 1 or n) depending on whether you have other USB modems.

How to use it

  1. Open the makefile and make sure that the CHIBIOS variable is set to where the ChibiOS-RT-master directory is located. If it is in the parent directory relative to the project, it should be:
    CHIBIOS = ../ChibiOS-RT-master
  2. Build the project (to set up the required toolchain, see this post):
    make -j4
  3. Upload the program (requires a recent version of OpenOCD):
    make upload
  4. In order to test the CLI interface, make sure that your user is added to the dialout group as described here.
  5. Open /dev/ttyACM0 (or ttyACM1 or ttyACMn) in your favourite serial terminal, e.g. screen:
    screen /dev/ttyACM0
  6. You should see something like this:
    ChibiOS/RT Shell
    ch>

    In order to list all available shell commands, type help and press enter.

  7. In order to add new commands, create one like this:
    static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
    	(void)argv;
    	(void)argc;
     
    	chprintf(chp, "This is a test command.\r\n");
    }

    and add it to the shell command list:

    static const ShellCommand commands[] = {
    		{"test", cmd_test}, // This line is for the command above
    		{"mem", cmd_mem},
    		{"threads", cmd_threads},
    		{NULL, NULL}
    };

Adding security support

In order to enable encryption of the data, add -DSECURITY_CCM to USE_COPT in the makefile. It should look like this:

# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
  USE_COPT = -DSECURITY_CCM
endif

Also, make sure that rf_security_key in main.c is the same for all the RF boards.

2 thoughts on “ChibiOS on my cc2520+stm32f4 boards

  1. Pingback: CC2520 and STM32 RF boards | Benjamin's robotics

  2. Pingback: Chibi/OS | David Albert

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.