This is not a tutorial, it's some hints to get up and going. All of this assumes you are using Linux. (As you should!)
This setup will let you boot the rPi from a folder on your disk over the network. This makes life much easier if you are iterating over changes. All you need is an easy way to reboot the pi (cable with switch or a switchable power supply).
Based on documentation from rPi foundation.
- https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/README.md
- https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/net.md
- https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/net_tutorial.md
On new rPi's (3B+) netboot support is build in, they don't need an SD card to boot from. I do recommend you setup the bootloader debug output via UART, so you don't have to guess what it's doing. For that you do need an SD card.
Older versions need some extra setup. They need an up to date firmware on an SD card, and optionally a configuration file. See documentation linked above or the files in this repository.
Install dnsmasq
to act as a (fake/proxy) DHCP server that tells the rPi where to boot from.
This only works if you plug the rPi into the same network as your PC. I recommend you plug it into a switch along with your PC and the cable to your router.
If you plug the pi directly into your PC (and you use wifi or a second connection for Internet), you'll have to change the configuration to dnsmasq actually hands out IP addresses instead of just acting as proxy. More info on that on the Glorious Arch Wiki
Add to the end of /etc/dnsmasq.conf
:
port=0 # Disable DNS
dhcp-range=192.168.0.255,proxy # Proxy DHCP to the real server (adjust for your network if it's not 192.168.0.xxx based).
log-dhcp # Enabled debug log (so you don't have to guess.)
enable-tftp # Enable the required sub-service
tftp-root=/srv/tftp # Change to suite your needs
pxe-service=0,"Raspberry Pi Boot" # Required. See rPi foundation docs.
Don't enable tftp-secure
, it only adds complexity and you should just turn off dnsmasq when you don't use it.
View logs with journalctl -f -u dnsmasq.service
.
Don't forget to start dnsmasq
, it's best left disabled (no autostart).
The rpi reads files in order:
/<serialnr>/start.elf
/autoboot.txt
/config.txt
/recovery.elf
/start.elf
/fixup.dat
For more details, see the docs. The short version is: Put bootcode.bin
, start.elf
, and fixup.dat
in the TFTP root and it will boot from there.
You also need to supply your kernel image (kernel8.img
), and you can optionally supply a file to be loaded after the kernel (in Linux used for the device tree blob). Again, see docs.
Definitely use this to get going: "Bare Metal Programming on Raspberry Pi 3" by "bztsrc"
Arch Linux packages for 64 bit ARMv8:
aarch64-elf-gcc-linaro-bin
and aarch64-elf-newlib-linaro-bin
Add to your bashrc
:
export PATH=$PATH:/usr/aarch64-elf/bin