OS/. The Makefile reads the correct file at build time based on the TARGET variable and converts every entry into a C preprocessor flag.
Environment files
- .venv.beagle
- .venv.qemu
OS/.venv.beagle
How the Makefile loads the environment
The Makefile selects the correct environment file usingmake’s include directive:
Makefile
TARGET defaults to beagle when not specified. Every variable in the included file becomes an ordinary Makefile variable available for use in flag construction.
PLATFORM_FLAGS
Immediately after loading the environment file, the Makefile constructsPLATFORM_FLAGS — a list of -D defines passed to every C and assembly compilation unit:
Makefile
| Flag | Source variable | Purpose |
|---|---|---|
PLATFORM_TARGET | PLATFORM_TARGET | Selects platform branch (0 = BeagleBone, 1 = QEMU) |
PLATFORM_UART0_BASE | UART0_BASE | Base address of the UART peripheral |
PLATFORM_TIMER_BASE | TIMER_BASE | Base address of the timer peripheral |
PLATFORM_INTC_BASE | INTC_BASE | Base address of the interrupt controller |
PLATFORM_CM_PER_BASE | CM_PER_BASE | Base address of the Clock Manager (0 on QEMU) |
PLATFORM_OS_BASE | OS_BASE | Load address of the OS image |
PLATFORM_OS_STACK | OS_STACK | Top of the OS stack |
P1_BASE | P1_BASE | Load address of process 1 |
P1_STACK | P1_STACK | Top of the process 1 stack |
P2_BASE | P2_BASE | Load address of process 2 |
P2_STACK | P2_STACK | Top of the process 2 stack |
plataform.h — address aliases
OS/plataform.h maps the PLATFORM_* defines to shorter, canonical names used throughout the OS and library source:
OS/plataform.h
.venv entry produces a hard #error rather than a silent wrong-address bug.
| Alias in source | Provided by |
|---|---|
UART0_BASE | PLATFORM_UART0_BASE |
DMTIMER2_BASE | PLATFORM_TIMER_BASE |
INTCPS_BASE | PLATFORM_INTC_BASE |
CM_PER_BASE | PLATFORM_CM_PER_BASE |
Platform conditionals in source code
Bothuart.c and timer.c use #if PLATFORM_TARGET == 1 / #else blocks to select the correct register layout at compile time. No runtime branching occurs.
uart.c
OS/uart.c
timer.c
Lib/timer.c
Build variable summary
TARGET | .venv file | Linker script | C optimization | Assembly debug |
|---|---|---|---|---|
beagle (default) | OS/.venv.beagle | linker/linker_beagle.ld | -O2 | none |
qemu | OS/.venv.qemu | linker/linker_qemu.ld | -O0 -g3 | -g |
Adding a new platform
To support an additional board or emulator, four changes are required:Create a new environment file
Add
OS/.venv.<platform> following the same key=value format as .venv.beagle and .venv.qemu. Assign a unique PLATFORM_TARGET integer.Add a new linker script
Create
linker/linker_<platform>.ld with MEMORY regions that match the target board’s RAM layout and the addresses in your new .venv file.Extend the Makefile
Add a new
ifeq ($(TARGET), <platform>) branch to load the environment file and select the linker script and compiler flags.OS/plataform.h does not need to change for a new platform — it already exposes generic aliases (UART0_BASE, DMTIMER2_BASE, INTCPS_BASE, CM_PER_BASE) driven entirely by the PLATFORM_* defines coming from the .venv file.