Prerequisites
Ensure the following tools are installed and available on your PATH before building:
| Tool | Purpose |
|---|
arm-none-eabi-gcc | C compiler for ARM bare-metal targets |
arm-none-eabi-as | ARM assembler |
arm-none-eabi-ld | ARM linker |
arm-none-eabi-objcopy | ELF to raw binary conversion |
qemu-system-arm | ARM system emulator (QEMU target only) |
gdb-multiarch | Debugger with ARM support (optional, for GDB sessions) |
On Debian/Ubuntu: sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi qemu-system-arm gdb-multiarch
Clone the repository
git clone https://github.com/Martin-ing/Proyecto1cc7.git
cd Proyecto1cc7
Build
The build system reads platform-specific memory-map definitions from .venv.qemu or .venv.beagle at compile time and selects the matching linker script automatically.
Build for QEMU
make TARGET=qemu
# or use the shorthand target
make qemu
The QEMU build compiles with -O0 -g3 (no optimisation, full debug info) and links against linker/linker_qemu.ld.Key compiler flags applied by both methods:| Flag | Description |
|---|
-mcpu=cortex-a8 | Target the Cortex-A8 core |
-mfpu=neon | Enable the NEON FPU |
-mfloat-abi=hard | Use hardware floating-point ABI |
-nostdlib -nostartfiles | No standard library or C runtime startup |
-ffreestanding | Freestanding (bare-metal) environment |
QEMU memory map (from OS/.venv.qemu, enforced by linker/linker_qemu.ld):| Region | Base | Size |
|---|
| OS text/data/bss | 0x00010000 | 64 KB |
| Process 1 (P1) | 0x00060000 | 64 KB |
| P1 stack | 0x00070000 | 4 KB |
| Process 2 (P2) | 0x00080000 | 64 KB |
| P2 stack | 0x00090000 | 4 KB |
| UART0 | 0x101f1000 | — |
| Timer | 0x101e2000 | — |
| Interrupt controller | 0x10140000 | — |
Verify output binaries
Both methods produce the same artifacts under bin/:bin/program.elf ← ELF with debug symbols (used by QEMU -kernel and GDB)
bin/program.bin ← Raw binary (used for flashing)
bin/program.map ← Linker map (build_and_run.sh only)
Build for BeagleBone Black
make TARGET=beagle
# or use the shorthand target
make beagle
The BeagleBone build compiles with -O2 and links against linker/linker_beagle.ld.BeagleBone Black memory map (from OS/.venv.beagle, enforced by linker/linker_beagle.ld):| Region | Base | Size |
|---|
| OS text/data/bss | 0x82000000 | 256 KB |
| Process 1 (P1) | 0x82100000 | 64 KB |
| P1 stack | 0x82110000 | 4 KB |
| Process 2 (P2) | 0x82200000 | 64 KB |
| P2 stack | 0x82210000 | 4 KB |
| UART0 | 0x44E09000 | — |
| Timer | 0x48040000 | — |
| Interrupt controller | 0x48200000 | — |
| Clock/power manager | 0x44E00000 | — |
Verify output binaries
bin/program.elf ← ELF image
bin/program.bin ← Raw binary for U-Boot
Run
Launch QEMU with a GDB server
qemu-system-arm \
-M versatilepb \
-cpu cortex-a8 \
-kernel bin/program.elf \
-nographic \
-S -s
-S halts the CPU at startup; -s opens a GDB server on localhost:1234. QEMU will wait silently until a debugger connects or you resume execution.
make qemu runs this exact command automatically after a successful build.Connect GDB (optional)
In a second terminal:gdb-multiarch bin/program.elf
Then inside GDB:set architecture arm
target remote :1234
file bin/program.elf
break main
continue
Resume and observe UART output
To run without halting (no GDB), omit the -S -s flags:qemu-system-arm -M versatilepb -cpu cortex-a8 -kernel bin/program.elf -nographic
build_and_run.sh qemu uses this form — it builds and immediately launches QEMU without pausing.The OS schedules two user processes in round-robin. Each prints to UART0. Expected output:----From OS: hola
----From P1: 0
----From P2: a
----From OS: hola
----From P1: 1
----From P2: b
----From OS: hola
----From P1: 2
----From P2: c
...
Press Ctrl+A then X to exit QEMU when running with -nographic.
build_and_run.sh beagle does not flash or boot the board automatically. You must transfer bin/program.bin manually via U-Boot.
Boot the board into U-Boot
Connect a 3.3 V USB-to-serial adapter to the BeagleBone Black’s UART0 debug header (J1) and open a serial terminal at 115200 8N1. Power on the board and interrupt the U-Boot autoboot by pressing any key.
Transfer the binary
Transfer bin/program.bin to the board. The most common method is TFTP — serve the file from your host and load it from U-Boot:setenv serverip 192.168.1.100
setenv ipaddr 192.168.1.200
tftp 0x82000000 program.bin
0x82000000 matches OS_BASE in OS/.venv.beagle and ORIGIN(os_ram) in linker/linker_beagle.ld. The image must be loaded at this address.
Boot the image
U-Boot jumps to the OS entry point (_start) and begins execution. UART0 output appears on the same serial console.
Clean
Remove all build artifacts:
This deletes the entire bin/ directory.