bedrock[RTOS] is a tickless nanokernel RTOS in C11 with no dynamic allocation. It is for microcontroller firmware. Supported targets: ARM Cortex-M3 (QEMU LM3S6965, STM32F103C8 Blue Pill), ARM Cortex-M0+ (RP2040, Raspberry Pi Pico) and RISC-V RV32 (QEMU virt).
arm-none-eabi-gccfor Cortex-M3, STM32F103 and RP2040riscv64-elf-gccfor RISC-V- chorus 1.1.0 or newer
qemu-system-armandqemu-system-riscv32to run on QEMUgccfor host tests and for the RP2040 image tools- Renode 1.16.1, only to run STM32F103 and RP2040 tests without hardware, plus Renode_RP2040 for RP2040
- kconfig-tools and
zig, only for Kconfig
Arch Linux:
sudo pacman -S arm-none-eabi-gcc qemu-system-arm riscv64-elf-gcc qemu-system-riscvUbuntu (Cortex-M only):
sudo apt install gcc-arm-none-eabi qemu-system-armChorus:
sudo curl -L -o /usr/local/bin/chorus https://github.com/z3nnix/chorus/releases/download/1.1.0/chorus.bin
sudo chmod +x /usr/local/bin/choruschorusThe result is bedrock_example.elf and the libbedrock_kernel.a, libbedrock_hal.a, libbedrock_lib.a libraries for Cortex-M.
RISC-V:
chorus riscv32The result is bedrock_example_riscv32.elf, the test_*_riscv32.elf tests and the libbedrock_*_riscv32.a libraries.
RP2040:
chorus rp2040The result is bedrock_example_rp2040.uf2, bedrock_example_rp2040.elf, the test_*_rp2040.elf tests and the libbedrock_*_rp2040.a libraries.
STM32F103C8:
chorus stm32f103The result is bedrock_example_stm32f103.bin, bedrock_example_stm32f103.elf and the test_*_stm32f103.elf tests.
Clean:
chorus cleanCortex-M (LM3S6965):
chorus runRISC-V (virt):
chorus run-riscv32Exit QEMU with Ctrl+A, then X.
Hold BOOTSEL, connect the Pico over USB and copy bedrock_example_rp2040.uf2 to the RPI-RP2 drive. Output goes to UART0: TX on GP0, RX on GP1, 115200 8N1. The port has been tested in Renode only, not on hardware yet.
In Renode, with Renode_RP2040 cloned to <path>:
renode --disable-gui --console -e '$rp2040=@<path>; $fw=@'"$PWD"'/test_scheduler_rp2040.elf; $out=@/tmp/uart.txt; include @'"$PWD"'/boards/rpi-pico/renode.resc; emulation RunFor "2"; quit'
cat /tmp/uart.txtFlash bedrock_example_stm32f103.bin at 0x08000000, for example with st-flash write bedrock_example_stm32f103.bin 0x08000000. The board runs at 72 MHz from an 8 MHz crystal. Output goes to USART1: TX on PA9, RX on PA10, 115200 8N1. The port has been tested in Renode only, not on hardware yet.
In Renode:
renode --disable-gui --console -e '$fw=@'"$PWD"'/test_scheduler_stm32f103.elf; $out=@/tmp/uart.txt; include @'"$PWD"'/boards/stm32f103c8-bluepill/renode.resc; emulation RunFor "2"; quit'
cat /tmp/uart.txtThe tests run on Linux x86-64 with a mock HAL:
chorus host
./test_scheduler_hostThe binaries are test_task_delete_host, test_scheduler_host, test_semaphore_host, test_mutex_host, test_mqueue_host, test_sleep_list_host, test_pool_host, test_uart_rx_host and test_shell_host. Each one prints PASS or FAIL per case and === All Tests Complete === at the end.
test_uart_rx and test_shell wait for the line bedrock on the console: printf 'bedrock\n' | ./test_uart_rx_host, the same pipe into qemu-system-*, or sysbus.uart0 WriteLine "bedrock" (sysbus.usart1 on STM32F103) in Renode after emulation RunFor "0.5".
The same tests under QEMU: chorus test-scheduler, chorus test-semaphore and so on for Cortex-M, chorus test-scheduler-riscv32 and so on for RISC-V. RP2040 and STM32F103 tests run in Renode, see above.
Defaults are in include/bedrock/br_config.h. To use Kconfig instead, put kconfig-tools in 3rd/tools/kconfig and run:
chorus build-tools
chorus defconfig
chorus menuconfigFor RISC-V use chorus defconfig-riscv32, for RP2040 chorus defconfig-rp2040, for STM32F103 chorus defconfig-stm32f103 instead of chorus defconfig.
This generates include/generated/autoconf.h, which takes precedence over the defaults.
- chorus: build system
- QEMU: Cortex-M and RISC-V emulation
- Renode: STM32F103 and RP2040 emulation, Renode_RP2040: RP2040 models
/kernel, /arch, /boards, /include, /lib and /examples are under GPL-3.0 with the bedrock[RTOS] runtime exception, see LICENSE.md. Application code linked with the kernel can use any license. Changes to bedrock[RTOS] itself stay under GPL-3.0.
/docs is under CC BY-SA 4.0, see LICENSE-CC-BY-SA-4.0.md.