// embedded systems project
FreeRTOS on RISC-V
FreeRTOS ported to 64-bit RISC-V and booted on QEMU, from the startup code and linker script up.
A port of the FreeRTOS kernel to RV64 on QEMU's virt machine: bare-metal startup in assembly, a linker script that lays out RAM from 0x80000000, machine-mode timer interrupts driving a 1 kHz tick, and two preemptive tasks that prove the scheduler. Built for the CENG507 embedded systems course.
- year
- 2026
- type
- embedded systems project
- group
- systems
the problem
//01the problem
A real-time OS hides the hardware from applications, but first someone has to tame the hardware: start the core with no firmware, lay out memory, take the timer interrupt and save every register on a context switch. The goal was to do that by hand on an open instruction set.
how it works
//02how it works
- 01
Bare metal, from the reset vector
An assembly startup file sets up the stack and jumps to C with no BIOS at all. A linker script places code, data and a 64 KB stack in RAM from 0x80000000 on QEMU's virt machine.
- 02
The timer drives the scheduler
The machine-mode timer, through MTIME and MTIMECMP, raises a 1 kHz tick. mtvec points at the FreeRTOS trap handler, which saves the context in assembly and lets the kernel preempt.
- 03
Proven by tasks, checked in the disassembly
Two tasks with different periods interleave under preemption. The build emits an ELF with symbols, a raw binary and a full disassembly listing, targeting rv64imac_zicsr with the lp64 ABI.
measured
//03measured
- 1 kHz
- scheduler tick
- machine-mode timer via mtime and mtimecmp
- 64 KB
- stack laid out by the linker script
- ram from 0x80000000 on qemu virt
- 0
- lines of bios
- assembly startup jumps straight to c
highlights
//04highlights
- Boots with no firmware on QEMU's virt machine
- Preemptive scheduling on a 1 kHz tick, stack overflow checks on
- RV64IMAC with Zicsr, medany code model
- Course project for CENG507, Embedded Systems
built with
- C
- RISC-V assembly
- FreeRTOS
- QEMU
- GNU toolchain
- Make
//05contact
Say hello. I read everything.
Email is the fastest way to reach me. For anything that needs a conversation, book a call.
to
- name
- Khaled Saeed
- country
- Lebanon