I'm trying to build a fully "diskless" raspi3 environment, by having the pi load u-boot from the network (similar to the usual pxelinux setup for x86)

I've gotten the pi to get an ip address via dhcp and connect to my tftp server to fetch bootcode.bin, start.elf and config.txt.

I can use the following config.txt:


And it fetches the u-boot image. However I cannot figure out how to make it load the boot.scr over tftp so u-boot does something useful (like loading a linux kernel and initrd and booting up a full system).

If I use an sdcard with the same config.txt it will load boot.scr from the sdcard itself.

Is this possible?

1 Answer 1


This is definitely possible.

By default u-boot performs run distro_bootcmd on boot. This is defined at compile-time by the CONFIG_BOOTCOMMAND variable.

I can simply set my own CONFIG_BOOTCOMMAND and compile u-boot:

cat <<EOF >> include/configs/rpi.h
#define CONFIG_BOOTCOMMAND             \\
    "setenv autoload no;"              \\
    "setenv autostart no;"             \\
    "bootp;"                           \\
    "tftp 0x100000 /rpi/boot.scr;"     \\
    "source 0x100000;"
make rpi_3_32b_defconfig
make all

This is the quick'n'dirty way. Digging a bit deeper I found that distro_bootcmd should already do what I need.

The command's behaviour is controlled by the variable BOOT_TARGET_DEVICES at compile time. For instance for the rpi it's at include/configs/rpi.h:

#define BOOT_TARGET_DEVICES(func) \
    func(MMC, mmc, 0) \
    func(USB, usb, 0) \
    func(PXE, pxe, na) \
    func(DHCP, dhcp, na)

The PXE target looks for an extlinux config file the same way pxelinux does, so by placing a config file in pxelinux.cfg/default-arm I can instruct u-boot to load a kernel and initrd, or do something else.

The DHCP target seems to try to load the file provided by the dhcp server, or a default <IP>.img if none was specified. (<IP> is the ip address in hex).

So loading u-boot.img with no sdcard/msd present (or with no boot.scr or boot.scr.uimg in / or /boot) should trigger the DHCP and PXE boot right out of the box.

I'm not sure why this wasn't working for me, probably a network setup issue or a bad u-boot image. Haven't had a chance to play with the pi again yet.

BTW, u-boot docs are awesome. I don't think I've come accross such good documentation in the past.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.