Home

Awesome

FreeRTOS Ported to Raspberry Pi 2B

Fork from James Walmsley's RPi 1 FreeRTOS build, modified for framebuffer support and the RPi2B. https://github.com/jameswalmsley/RaspberryPi-FreeRTOS

The USB/Ethernet portion is a port of USPi, a LAN9514 USB driver. https://github.com/rsta2/uspi

TCP/IP portion is the official FreeRTOS driver with modifications for compatability. http://www.freertos.org/FreeRTOS-Labs/RTOS_labs_download.html

In it’s current state, some debug statements are left in, sockets can not be accepted, and interrupts will sometimes become disabled and cause a hang. All of the current issues and many of the previous issues were due to interrupts being disabled while the ethernet task was attempting to use INT 9 (USB) for a transaction. It appears as though the implementation of the FreeRTOS queue calls portYIELD_WITHIN_API which switches to another task from within a critical section where interrupts are disabled. In one test case, the addition of a new client to the router caused a packet of length 0x156 to be sent to the RPi with a mysterious IP protocol of 0x96, unexpected packets like this cause the RPi to hang while processing the packet. Only ARP packets have been tested to work reliably. It is possible that it is unable to accept sockets for similar reasons. Further development should continue here.

Howto Build

Type make

You need to modify the arm-non-eabi- toolchain locations in the Makefile:

kernel.elf: LDFLAGS += -L"/usr/lib/gcc/arm-none-eabi/4.9.3" -lgcc
kernel.elf: LDFLAGS += -L"/usr/lib/arm-none-eabi/lib" -lc

On Ubuntu you can install the toolchain with: sudo apt-get install gcc-arm-none-eabi

Format your SD card as FAT32

Copy the bootcode.bin and start.elf from here https://github.com/raspberrypi/firmware/tree/master/boot

Copy the config.txt from /boot_stuff onto the SD card to fix over/underscanning

Copy the kernel7.img generated by make

You should see the green ACT LED continuously blink as proof the task schedualer is working.

##Configuration GCC -finstrument-functions enables tracing at the beginning and end of every function. You can add attribute((no_instrument_function)) to functions to disable tracing in critical sections.

The framebuffer is explicitly for debug information, this build does not take full advantage of the RPi GPU. Printing to the screen takes several milliseconds so it is adviseable to disable it. In the demo main.c, set loaded = 0.