dwelch67/raspberrypi

USB device mode boot recipe for A+/Zero/CM

ali1234 opened this issue · 1 comments

Here's a Makefile recipe for booting a USB-device capable Pi over USB cable without an SD card. You only need rpiboot from the tools repository, start.elf, and your program binary. The FAT image is treated the same as the one on SD card would be, so this can also work with a full Linux kernel.img, config.txt, initrd etc. However the size is quite limited so it's not really practical to boot a full OS this way. It might be useful to someone doing bare metal work though.

all: fatimage

fatimage: blinker01.bin start.elf
    dd if=/dev/zero of=fatimage bs=1M count=4
    mkfs.vfat fatimage
    mkdir -p .fatmnt
    sudo mount -o loop fatimage .fatmnt/
    sudo cp start.elf .fatmnt/
    sudo cp blinker01.bin .fatmnt/kernel.img
    sudo umount .fatmnt
    rmdir .fatmnt

clean:
    rm -f fatimage

run: all
    sudo rpiboot -b fatimage

This is no longer required - you can just drop all the boot files into a directory and use rpiboot -d.