This page lists the main source components of the bootloader and their roles. Paths are relative to the Neutron project root.
Assembly
boot/start.S
- First code executed after load at 0x80000.
- Parks secondary cores; detects EL; drops from EL2 to EL1; disables MMU/caches; sets stack to 0x80000; zeroes BSS; calls
neutron_main. - Defines a minimal exception vector table (all slots branch to an unhandled-exception stub).
- Must be assembled with access to
include/aarch64.hfor SPSR and related constants.
Bootloader Core (C)
neutron/main.c
- Entry point
neutron_main()called fromstart.S. - Initialises UART, prints banner and CPU/mailbox info, initialises SD card, mounts FAT32, reads
ATOM.BINinto 0x100000, checks NKRN magic, callsbl_load_kernel(), thenbl_boot_kernel()with the kernel entry address and pointer toboot_info_t. - On any fatal error (SD init, FAT32 mount, file not found, bad magic, load failure), prints a message and halts in a WFE loop.
neutron/bootloader.c
bl_load_kernel(uintptr_t src, boot_info_t *out_info): Validates the NKRN header atsrc, checks payload size and CRC32, copies payload toheader.load_addr, fillsboot_info_tatBOOT_INFO_ADDR(0x1000). ReturnsBL_OKor an error code.bl_boot_kernel(uintptr_t entry_addr, boot_info_t *info): Executes DSB/ISB, then calls the kernel atentry_addrwithx0=info. Does not return.- Also provides
crc32()(IEEE 802.3) and internal helpersbl_memcpyandbl_memset(no libc).
Drivers
driver/uart.c
- PL011 UART at
UART0_BASE(0x3F201000). Configures GPIO 14/15 as ALT0, sets baud (115200, 48 MHz clock), 8N1, FIFO enabled. Providesuart_init,uart_putc,uart_puts,uart_getc,uart_printf, and hex/decimal output helpers.
driver/gpio.c
- BCM2837 GPIO at
GPIO_BASE. Implementsgpio_set_func,gpio_set_pull,gpio_set,gpio_clear,gpio_get. Used by the UART driver to mux the UART pins.
driver/mbox.c
- VideoCore mailbox at
MBOX_BASE. Implementsmbox_call()and wrappersmbox_get_board_revision()andmbox_get_arm_mem_size(). Uses a 16-byte-aligned buffer for property tags.
driver/sdcard.c
- SD/MMC card initialisation and block read. Uses the EMMC/SDHCI controller (see
include/sdcard.hfor register layout). Providessdcard_init(),sdcard_read_block(),sdcard_read_blocks().
driver/fat32.c
- Read-only FAT32. Reads MBR, finds first partition, parses BPB, walks FAT and directory to find a file by name. Provides
fat32_mount()andfat32_read_file(). Used to readATOM.BINfrom the SD card.
Linker Script
linker/bootloader.ld
ENTRY(_start). Load address 0x80000. Sections:.text.boot,.vectors(0x800-aligned),.text,.rodata,.data,.bss. Exports__bss_start,__bss_end, and_stack_top(0x80000).
Headers
- include/platform.h: MMIO base, UART/GPIO/SDHOST/MBOX addresses, kernel load/staging addresses, register offsets.
- include/bootloader.h: NKRN magic and header layout,
boot_info_t,BOOT_INFO_ADDR,bl_load_kernel,bl_boot_kernel,crc32. - include/uart.h, include/gpio.h, include/mbox.h, include/sdcard.h, include/fat32.h: Driver APIs.
- include/aarch64.h: SPSR and related constants for EL2 to EL1.
Build Output
- Object files go under
build/(e.g.build/boot/start.o,build/neutron/main.o). - The linker produces
build/neutron.elf;objcopy -O binaryproducesbin/kernel8.img.
For driver details and register usage, see Drivers.