Docs / Building

Building

bedrock[RTOS] uses chorus as its build system. Chorus is included as a git submodule at 3rd/tools/chorus.

Prerequisites

Installing on Arch Linux

sudo pacman -S arm-none-eabi-gcc arm-none-eabi-newlib qemu-system-arm

Building Chorus

cd 3rd/tools/chorus
go build -o chorus .
sudo cp chorus /usr/local/bin/

Build

From the project root:

chorus

This produces:

ArtifactDescription
libbedrock_kernel.aKernel: scheduler, tasks, time, IPC
libbedrock_hal.aHAL: timer, context switch, UART, startup
libbedrock_lib.aLibrary: static pool allocator
bedrock_example.elfExample application linked with all libraries

Clean

chorus clean

Removes all *.o, *.a, *.elf, *.bin files.

Running on QEMU

qemu-system-arm -M lm3s6965evb -nographic -kernel bedrock_example.elf

Press Ctrl+A, then X to exit QEMU.

Build Configuration

The chorus.build file defines variables and compile-time configuration.

Variables

VariableDescription
CCC compiler (arm-none-eabi-gcc)
ARArchiver (arm-none-eabi-ar)
OBJCOPYObject copy tool (arm-none-eabi-objcopy)
CFLAGSCompiler flags (C11, Cortex-M3, thumb, includes, config defines)
LDFLAGSLinker flags (nostdlib, gc-sections, linker script)

Compile-Time Configuration

Configuration values are passed as -D flags in CFLAGS:

DefineDefaultDescription
CONFIG_MAX_TASKS16Maximum number of tasks
CONFIG_NUM_PRIORITIES8Number of priority levels
CONFIG_DEFAULT_STACK_SIZE1024Default stack size in bytes
CONFIG_TICKLESS1Enable tickless operation
BR_HAL_SYS_CLOCK_HZ16000000System clock frequency

To change a value, edit the CFLAGS line in chorus.build.

The linker processes libraries left-to-right. The link command places project libraries before system libraries:

main.o -lbedrock_kernel -lbedrock_hal -lbedrock_lib -lc -lnosys -lgcc

This ensures that references from kernel/HAL code to memcpy, memset etc. are resolved by -lc.