Skip to content

About

bedrock[RTOS] - A nanokernel real-time operating system.

Topics

Resources

Code of conduct

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

bedrock[RTOS]

CI License: GPL-3.0 with runtime exception

About

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).

Dependencies

  • arm-none-eabi-gcc for Cortex-M3, STM32F103 and RP2040
  • riscv64-elf-gcc for RISC-V
  • chorus 1.1.0 or newer
  • qemu-system-arm and qemu-system-riscv32 to run on QEMU
  • gcc for 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-riscv

Ubuntu (Cortex-M only):

sudo apt install gcc-arm-none-eabi qemu-system-arm

Chorus:

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/chorus

Build

chorus

The result is bedrock_example.elf and the libbedrock_kernel.a, libbedrock_hal.a, libbedrock_lib.a libraries for Cortex-M.

RISC-V:

chorus riscv32

The result is bedrock_example_riscv32.elf, the test_*_riscv32.elf tests and the libbedrock_*_riscv32.a libraries.

RP2040:

chorus rp2040

The result is bedrock_example_rp2040.uf2, bedrock_example_rp2040.elf, the test_*_rp2040.elf tests and the libbedrock_*_rp2040.a libraries.

STM32F103C8:

chorus stm32f103

The result is bedrock_example_stm32f103.bin, bedrock_example_stm32f103.elf and the test_*_stm32f103.elf tests.

Clean:

chorus clean

Running on QEMU

Cortex-M (LM3S6965):

chorus run

RISC-V (virt):

chorus run-riscv32

Exit QEMU with Ctrl+A, then X.

Running on RP2040

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.txt

Running on STM32F103C8

Flash 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.txt

Tests

The tests run on Linux x86-64 with a mock HAL:

chorus host
./test_scheduler_host

The 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.

Configuration

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 menuconfig

For 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.

Acknowledgments

Documentation

License

/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.

About

bedrock[RTOS] - A nanokernel real-time operating system.

Topics

Resources

Code of conduct

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages