Skip to content

Latest commit

 

History

History
95 lines (65 loc) · 2.45 KB

building.md

File metadata and controls

95 lines (65 loc) · 2.45 KB

Building

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

Prerequisites

  • arm-none-eabi-gcc toolchain
  • qemu-system-arm (for running on QEMU)
  • Go compiler (to build chorus, if not using a prebuilt binary)

Installing on Arch Linux

sudo pacman -S arm-none-eabi-gcc 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:

Artifact Description
libbedrock_kernel.a Kernel: scheduler, tasks, time, IPC
libbedrock_hal.a HAL: timer, context switch, UART, startup
libbedrock_lib.a Library: static pool allocator
bedrock_example.elf Example 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

Variable Description
CC C compiler (arm-none-eabi-gcc)
AR Archiver (arm-none-eabi-ar)
OBJCOPY Object copy tool (arm-none-eabi-objcopy)
CFLAGS Compiler flags (C11, Cortex-M3, thumb, includes, config defines)
LDFLAGS Linker flags (nostdlib, gc-sections, linker script)

Compile-Time Configuration

Configuration values are passed as -D flags in CFLAGS:

Define Default Description
CONFIG_MAX_TASKS 16 Maximum number of tasks
CONFIG_NUM_PRIORITIES 8 Number of priority levels
CONFIG_DEFAULT_STACK_SIZE 1024 Default stack size in bytes
CONFIG_TICKLESS 1 Enable tickless operation
CONFIG_TASK_STATS 1 Per-task CPU time accounting
BR_HAL_SYS_CLOCK_HZ 16000000 System clock frequency

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

Link Order

The linker processes libraries left-to-right:

main.o -lbedrock_hal -lbedrock_kernel -lbedrock_lib -lgcc

The kernel does not use libc. memcpy and memset, including calls generated by the compiler, come from lib/br_string.c in libbedrock_lib.a, so it goes after the kernel and HAL. -lgcc provides compiler runtime helpers such as 64-bit division.