Porting RIOT to 8051 Architecture

Hello Everyone,

I am considering porting RIOT for a device that uses the 8051 architecture (Si1062 using the C8051F930). Issue #1587 briefly talked about a 8051 port but ended with no result.

My question is has anyone attempted porting RIOT for an 8051 controller successfully? How much effort roughly would this task take for a novice?

I have already ported RIOT for the TI LTS compiler and the armcc compiler, and completed rudimentary ports for an EZR32, CC1310 and ATxmega.

My two issues would be with:

  1. thread_arch.c -> the assembly for context_switches would be challenging.

  2. I would use the Keil C51 compiler.

Any comments would help, even if it is a suggestion to not proceed due to the difficulty involved.

Thank you,


Hi Madison, I haven’t used any 8051 architecture devices myself, but I think the biggest difficulties will probably be getting everything to compile with a new toolchain which is not gcc based (we have support for clang as well, but the clang developers work hard to be gcc compatible). Like you wrote, the context switching will likely need to be written in assembly, but those functions should be pretty easy to implement for someone with experience in 8051 assembly. Also you will need to make sure that the cpu_init function sets up stack pointer, clock configuration, and interrupts. I don’t know about the c51 compiler, but you might have to work with some linker configuration (ldscripts or whatever the linker for the 8051 uses) to make sure that all functions and variables are placed correctly in ROM and RAM. I suggest you examine the avr and cortexm CPU initialization and context switch code to see what you will need to implement for the 8051 architecture, especially read all the code comments as well, these parts are described what they are expected to do, at least in the cortex implementation. You will also need to implement all the peripheral drivers that you want to use, such as uart and gpio. You will likely need to implement some glue layer between uart_stdio and the C51 libc if you want to be able to use printf etc. If the toolchain uses newlib, then everything should be good to go, but other libc implementations will probably need some small adaptation. Look at the avr port for an example of how to use some other libc than newlib.

Good luck on your port, Joakim