A minimal, single-stage bootloader for the AM335x (BeagleBone Black) written from scratch in C and ARM assembly. No U-Boot, no external dependencies — just bare metal.
ROM (chip) ──► Bootloader (SRAM 110KB) ──► Kernel (DDR @ 0x80000000)
The bootloader runs entirely from the AM335x internal SRAM and performs:
- Clock domain and DPLL initialization (MPU @ 1GHz, CORE @ 1GHz, PER @ 960MHz, DDR @ 400MHz)
- Watchdog timer disable
- UART0 initialization (115200 8N1)
- DDR3 memory initialization (512MB) with self-test and warm-boot detection
- MMC/SD card initialization and raw sector read
- Kernel image loading and validation
- Kernel handoff with boot parameters (ARM Linux boot ABI)
- Full exception handling (Data Abort, Prefetch Abort, Undefined Instruction)
├── src/
│ ├── arch/arm/start.S # Entry point, vector table, CPU mode setup
│ ├── main.c # Boot flow orchestration
│ ├── clock.c # DPLL and peripheral clock configuration
│ ├── ddr.c # DDR3 controller initialization
│ ├── mmc.c # MMC/SD card driver
│ ├── uart.c # UART serial driver
│ └── utils.c # Utility functions (delay, memcpy, memset)
├── include/
│ ├── am335x.h # Top-level SoC header (includes sub-headers)
│ ├── am335x_clock.h # Clock manager and DPLL registers
│ ├── am335x_ddr.h # EMIF and DDR PHY registers
│ ├── am335x_mmc.h # MMC controller registers
│ ├── am335x_pinmux.h # Pin mux and GPIO definitions
│ ├── am335x_uart.h # UART registers
│ ├── boot.h # Function prototypes
│ └── types.h # Type definitions
├── linker/
│ └── bootloader.ld # Linker script (SRAM @ 0x402F0400)
├── tools/
│ └── gp_header.py # GP header generator for AM335x ROM
└── Makefile
- OS: Ubuntu 24.04+ (or equivalent Linux)
- Python: 3.x
- Toolchain:
arm-none-eabi-gcc,arm-none-eabi-binutils
sudo apt update
sudo apt install -y gcc-arm-none-eabi binutils-arm-none-eabi python3make # Build → outputs build/MLO
make clean # Clean build artifacts
make size # Show binary sizeOutput is in build/:
build/MLO # Bootable image for SD card
build/bootloader.elf # ELF with debug symbols
build/bootloader.bin # Raw binary
build/bootloader.map # Link map
build/bootloader.dis # Disassembly
The AM335x ROM looks for a file named MLO on the first FAT32 partition of the SD card.
cp build/MLO /media/sdcard/- ROM bootloader (built into AM335x silicon) finds
MLOon the SD card and loads it into SRAM at0x402F0400 - This bootloader sets up the vector table, exception stacks, disables watchdog, initializes all DPLLs, DDR, UART, and MMC
- Reads the kernel image from raw SD sectors into DDR at
0x80000000 - Validates the kernel entry instruction and jumps with ARM Linux boot ABI (r0=0, r1=machine type, r2=atags)
- SoC: Texas Instruments AM335x (ARM Cortex-A8)
- Board: BeagleBone Black
- RAM: 512MB DDR3 @ 400MHz
- Boot media: microSD card