raspberry pi pxe boot
Following this RPi U-Boot Howto.
I setup a cross compile chroot to build u-boot for my Raspberry 1:
sudo debootstrap sid sid
sudo chroot sid
dpkg --add-architecture armhf
apt-get update
apt install git-core gcc-arm-linux-gnueabi
cd /tmp
git clone git://git.denx.de/u-boot.git
cd u-boot
export CROSS_COMPILE=arm-linux-gnueabi-
make rpi_defconfig
make -j5 -s
Download the latest Jessie Lite Image and wrote it to my SDCARD (/dev/sdb in my case):
cd /tmp
wget https://downloads.raspberrypi.org/raspbian_lite_latest -O raspbian_lite_latest.zip
unzip raspbian_lite_latest.zip
dd if=2016-05-27-raspbian-jessie-lite.img of=/dev/sdb bs=1M
Setup NFS root, copy the Kernel to the tftproot and install u-boot:
cd /tmp
mkdir pi
mount /dev/sdb2 pi
mount /dev/sdb1 pi/boot
mkdir /var/lib/tftpboot/pi
cp pi/boot/kernel.img /var/lib/tftpboot/pi/zImage
cp pi/boot/*.dtb /var/lib/tftpboot/pi/
mv pi/boot/kernel.img{,.old}
cp /tmp/sid/tmp/u-boot/uboot.bin pi/kernel.img
cp -a pi /mnt
umount pi/boot
umount pi
Setup NFS export:
/mnt/pi 10.0.0.1(rw,no_root_squash,async,no_subtree_check)
Configure dhcp:
host pi1 {
hardware ethernet TH:AT:IS:MY:MA:C0;
fixed-address 10.0.0.1;
filename "/pi/boot.scr.uimg";
option root-path "/mnt/pi";
}
Create the boot script that actually loads and boots the kernel
/var/lib/tftpboot/pi/boot.scr
:
setenv fdtfile /pi/bcm2708-rpi-b.dtb
setenv tftpblocksize 1024
usb start
tftp ${kernel_addr_r} /pi/zImage
tftp ${fdt_addr_r} ${fdtfile}
setenv bootargs earlyprintk console=ttyAMA0 console=tty1 ip=dhcp root=/dev/nfs rootwait smsc95xx.macaddr=TH:AT:IS:MY:MA:C0
bootz ${kernel_addr_r} - ${fdt_addr_r}
I needed to set my MAC as it would generate a new one on every boot.
Convert boot script to something u-boot can handle:
cd /var/lib/tftpboot/pi
mkimage -A arm -O linux -T script -C none -n boot.scr -d boot.scr boot.scr.uimg
Boot the Pi, interrupt u-boot and setup it’s environment:
setenv bootcmd 'dhcp; source ${fileaddr}'
saveenv
reset
I havn’t found a way to set config.txt options though.