Skip to content

About

Minimal single-stage bootloader for AM335x (BeagleBone Black) written from scratch. No U-Boot.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NothanOS Bootloader

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.

What it does

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)

Project Structure

├── 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

Build

Requirements

  • 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 python3
make          # Build → outputs build/MLO
make clean    # Clean build artifacts
make size     # Show binary size

Output 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

Deploy to SD Card

The AM335x ROM looks for a file named MLO on the first FAT32 partition of the SD card.

cp build/MLO /media/sdcard/

How it works

  1. ROM bootloader (built into AM335x silicon) finds MLO on the SD card and loads it into SRAM at 0x402F0400
  2. This bootloader sets up the vector table, exception stacks, disables watchdog, initializes all DPLLs, DDR, UART, and MMC
  3. Reads the kernel image from raw SD sectors into DDR at 0x80000000
  4. Validates the kernel entry instruction and jumps with ARM Linux boot ABI (r0=0, r1=machine type, r2=atags)

Target Hardware

  • SoC: Texas Instruments AM335x (ARM Cortex-A8)
  • Board: BeagleBone Black
  • RAM: 512MB DDR3 @ 400MHz
  • Boot media: microSD card

About

Minimal single-stage bootloader for AM335x (BeagleBone Black) written from scratch. No U-Boot.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages