-
Notifications
You must be signed in to change notification settings - Fork 0
Porting Guide
This page will give you an overview on how to proceed if you want port RIOT to a new platform. You will get an overview on the controller and board specific interfaces that need to be implemented and also some of the common pitfalls and misconceptions will be pointed out.
This guide assumes that the port is done in a 'gcc' environment making use of the 'newlib'. In case some other (or none at all) C standard library is used, the part describing the system calls is to be adapted accordingly.
Things to do first:
- know the name of your board and CPU (e.g. arduino-due/sam3x8e or msba2/lpc2387)
- know your silicon (get all documentation available)
- check you have the right toolchain
- get header files for CPU register definitions (you don't want to define them by hand)
- get the memory mapping, start addresses and sizes of flash and RAM memory
- how to get your binary on the device
- how to interact with the device (which
/dev/tty*
port) - test steps above by building - flashing - running - interacting with an example known to work
- RIOT/core
- RIOT/sys
- RIOT/drivers
- RIOT/cpu
Containing controller specific code - RIOT/boards
Containing board specific code, as pin definitions etc
The interfaces that have to be implemented in the CPU specific code are defined
in RIOT/core/include/arch/
. These cover functions that are essential for
the kernel to work like interrupt handling and thread management but also provides
interfaces for timers and a generic IO function and power mode management.
List of files:
atomic_arch.h
irq_arch.h
lpm_arch.h
reboot_arch.h
thread_arch.h
Implementing these interfaces is mandatory but not limited to these.
For ARM CortexM* MCUs the most interfaces are already implemented and only leave you with
lpm_arch.h
Documentation can be found here
Board specific implementations and definition should lie in its own directory
in RIOT/boards/$BOARDNAME
. These should cover e.g. GPIO definitions, UART
configurations and configurations providing CPU frequency and timer resolutions
needed.
Mandatory however are:
- Definitions of macros to control LEDs on the board:
#define LED_GREEN_ON ....
#define LED_GREEN_OFF ....
#define LED_GREEN_TOGGLE ....
#define LED_RED_ON ....
#define LED_RED_OFF ....
#define LED_RED_TOGGLE ....
- Definition of the CPU frequency:
#define F_CPU (24000000UL)
- Implementation of
board_init
function which gets call immediately after startup code and before kernel initialization.
void board_init(void)
{
....
}
Also, for each board there has to be a Makefile.include
providing information
on the development environment. This covers the toolchain and its flags, the tool
used to flash the binary and defines the CPU used for this board. Examples can
be found in RIOT/boards/
Recommended file structure:
BOARDNAME CPUNAME
| |
+->include +->include
| | | |
| +---->board.h | +---->cpu.h
| +---->periph_conf.h | +---->cpu-conf.h
+->board.c | +---->hwtimer_cpu.h
+->Makefile | +---->[cpu-specific-headers]
+->Makefile.include +->cpu.c
+->atomic_arch.c
+->hwtimer_arch.c
+->io_arch.c
+->irq_arch.c
+->lpm_arch.c
+->reboot_arch.c
+->thread_arch.c
+->[syscalls.c]
+->[startup.c|S]
+->[linkerscript.ld]
+->Makefile
+->Makefile.include
+->periph
|
+-->gpio.c
+-->timer.c
+-->uart.c
+-->...
Work is in progress to unify interfaces for drivers of peripheral hardware
modules. This will increase portability and provides consistent usage of drivers.
To follow the progress watch RIOT/drivers/include/periph/
- Create file and folder structure
- write/find
linkerscript.ld
for your CPU - implement CPU initialisation (
cpu.c
) - implement
LED_*
macros inboard.h
- implement UART driver
- implement timer driver and map to hwtimer (hwtimer will be replaced by xtimer with #3520)
- implement stack setup and context switching in
thread_arch.c
- implement remaining CPU/core interfaces
- Congratulations, you have got a basic port
RIOT - The friendly Operating System for the Internet of Things
Homepage | [GitHub] (https://github.com/RIOT-OS/) | Developers Mailing List | Users Mailing List | Twitter @RIOT_OS
- Family: ARM
- Board: Airfy Beacon
- Board: Arduino Due
- Board: CC2538DK
- Board: HikoB Fox
- Board: IoT LAB M3
- Board: LimiFrog-v1
- Board: mbed_lpc1768
- Board: MSB-IoT
- Board: MSBA2
- Board: Nucleo-L1
- Board: Nucleo-F334
- Board: Nucleo-F303
- Board: Nucleo-F091
- Board: Mulle
- Board: OpenMote
- Board: PCA1000x (nRF51822 Development Kit)
- Board: Phytec phyWAVE-KW22
- Board: RFduino
- Board: Samr21 xpro
- Board: Spark Core
- Board: STM32F0discovery
- Board: STM32F3discovery
- Board: STM32F4discovery
- Board: UDOO
- Board: yunjia-nrf51822
- Family: ATmega
- Board: Arduino Mega2560
- Family: MSP430
- Board: MSB-430H
- Board: TelosB
- Board: WSN430
- Board: Zolertia Z1
- Board: eZ430-Chronos
- Family: native
- Board: native
- Family: x86
- Board: Intel Galileo