Table of Contents
U-Boot
U-Boot is the most popular open-source bootloader, supporting almost all router architectures.
Overview
U-Boot (Das U-Boot) is an open-source embedded bootloader developed by DENX.
Official Website: https://www.denx.de/wiki/U-Boot/
Main Features:
- Fully open source
- Supports multiple CPU architectures (MIPS/ARM/PowerPC/x86)
- Rich boot commands
- Supports network boot (TFTP/NFS)
- Powerful environment variable system
- Can load from Flash, network, or serial
Architecture Support
MIPS
- Common in MediaTek MT7620/MT7621
- Some TP-Link, Xiaomi, Huawei models
- Typical address: 0x9f000000 (Flash)
ARM
- Broadcom BCM47xx/BCM53xx series
- Qualcomm IPQ series
- Some Xiaomi/Netgear/ASUS models
x86
- Software routers
- Intel/AMD platforms
Boot Process
Power-On Initialization
U-Boot 1.1.4 (Dec 6 2021 - 11:13:09) CPU: MediaTek MT7621AT RAM: 256MB DDR3 Flash: W25Q128JV
Auto Boot
- Reads environment variable bootcmd
- Executes boot command
- Loads kernel from Flash/network
- Passes parameters to kernel
Interrupt Auto Boot
Press any key during boot to enter command line:
Hit any key to stop autoboot: 0
Common Commands
Environment Variables
# View all environment variables printenv # View specific variable printenv ipaddr printenv bootcmd # Set variable setenv ipaddr 192.168.1.1 setenv serverip 192.168.1.100 # Save to Flash saveenv # Restore defaults env default -a saveenv
Storage Operations
# Read Flash info sf probe # Read memory md.l 0x81000000 10 # Read 10 32-bit words md.b 0x81000000 100 # Read 100 bytes # Write memory mw.l 0x81000000 0x12345678 1
TFTP Boot
# Set environment variables setenv ipaddr 192.168.1.1 # Router IP setenv serverip 192.168.1.100 # TFTP server IP # Load firmware from TFTP to memory tftpboot 0x81000000 openwrt.bin # Or shorthand tftp 0x81000000 openwrt.bin # Boot firmware bootm 0x81000000
Flash Operations
# Erase Flash partition # Syntax: erase <start> +<length> erase 0x9f020000 +0x300000 # Copy data # Syntax: cp.b <src> <dst> <length> cp.b 0x81000000 0x9f020000 0x300000 # Write from memory to Flash sf write 0x81000000 0x9f020000 0x300000
Boot Commands
# Boot directly from specified address bootm 0x9f020000 # Boot from network bootp 0x81000000 firmware.bin bootm 0x81000000 # Boot from SD card (some devices) load mmc 0:1 0x81000000 uImage bootm 0x81000000
Other Commands
# Reset reset # Print version version # Help help # List devices printenv bootdev
Environment Variables Detail
bootcmd
Defines auto boot command:
bootcmd=bootm 0x9f020000 # Or network boot bootcmd=tftp 0x81000000 openwrt.bin; bootm 0x81000000
bootargs
Parameters passed to the kernel:
bootargs=console=ttyS0,115200 root=/dev/mtdblock2 rootfstype=squashfs mtdparts=spi0.0:256k(u-boot),64k(u-boot-env),3000k(kernel),-(rootfs)
mtdparts
Flash partition definition:
mtdparts=spi0.0:256k(u-boot),64k(config),3000k(kernel),-(rootfs)
TFTP Server Configuration
Windows
Using TFTPD64:
- Set TFTP root directory
- Confirm firewall allows it
- Ensure wired connection is used
Linux
sudo apt install tftpd-hpa sudo systemctl start tftpd-hpa # Put firmware in /srv/tftp/
macOS
sudo launchctl load -w /System/Library/LaunchDaemons/tftp.plist # Put firmware in /private/tftpboot/
Common Issues
bootcmd is empty
# Restore defaults setenv bootcmd bootm 0x9f020000 saveenv reset
TFTP Connection Failed
- Confirm computer and router IP are on the same subnet
- Check firewall
- Confirm TFTP server is running
- Use ping to test connectivity
Flash Write Failed
- Confirm address is correct
- Flash may be corrupted
- Try erasing before writing
Environment Variables Lost
- Environment variables are stored in a specific Flash partition
- Use saveenv to save
- Recovery method: setenv default and saveenv
Breed vs U-Boot Comparison
| Feature | Breed | U-Boot |
| βββ | βββ | βββ |
| Open source | β | β |
| Web interface | β | β |
| Multiple firmware backup | β | β |
| Command complexity | Simple | Complex |
| Device support | Limited | Wide |