diff --git a/README.md b/README.md index 06a6d2671d5ada54439624012bbbe45b4750ec89..baeb04b08e39e27cba8d9c2a1e955aba1f05dc61 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ rkdeveloptool wl 0 debian-rockpi4.img ``` ## Console -The conection for the console is shown in the picture +The connection for the console is shown in the picture ![Console](img/console.jpg) ``` @@ -68,6 +68,14 @@ In this case, probably it will be easier to use a different pin for console grou ## Network boot In order to be able to test different kernels and rootfs network boot can be easily enabled in U-Boot by setting the default `bootcmd` to either `bootcmd_dhcp` or `bootcmd_pxe`. In order for this to work, Rock Pi 4 should be connected to a LAN which provides DHCP, TFTP and NFS server. +You can use the `setup-tftp-nfs.sh` script within the `scripts` folder as reference or to generate a TFTP & NFS server on a Debian/Ubuntu system. + +```bash +# Replace 4a with your Rock Pi model +# Replace eth0 with the network device you use (script fetches IP and subnet mask from it) +./scripts/setup-tftp-nfs.sh 4a eth0 +``` + The following example shows TFTP configuration to enable PXE boot. The files are placed inside /srv/tftp @@ -90,7 +98,7 @@ prompt 0 timeout 50 label l0 - menu label Rock Pi 4 (Debian/Testing) + menu label Rock Pi 4 (Debian/Unstable) linux vmlinuz-5.4.0-4-arm64 fdt rk3399-rock-pi-4.dtb initrd initrd.img-5.4.0-4-arm64 diff --git a/rockpi4.yml b/rockpi4.yml index a493cb63c6c5b174b8d2f7ee3cf7fa05d0a993eb..c9749377c9949b4323013da0071fc5e853142d94 100644 --- a/rockpi4.yml +++ b/rockpi4.yml @@ -6,7 +6,7 @@ architecture: arm64 actions: - action: debootstrap - suite: testing + suite: unstable components: - main mirror: https://deb.debian.org/debian diff --git a/scripts/setup-tftp-nfs.sh b/scripts/setup-tftp-nfs.sh new file mode 100755 index 0000000000000000000000000000000000000000..401e073a75af2b764d05a5cab36ba5559d88c6c8 --- /dev/null +++ b/scripts/setup-tftp-nfs.sh @@ -0,0 +1,58 @@ +#!/bin/bash +if [ "$#" -ne 2 ]; then + echo "Specify the rock pi model (e.g. [4a, 4b, 4c]) and the name of the network device (e.g. eth0, etc.)" + exit +fi + +rockpi_model=$1 +device=$2 + +echo "[$rockpi_model]" +if [[ "$rockpi_model" != "4a" ]] && [[ "$rockpi_model" != "4b" ]] && [[ "$rockpi_model" != "4c" ]]; then + echo "Invalid Rock Pi model, must be one of [4a, 4b, 4c]" + exit +fi +device_check=`ip route show dev $device 2>&1` +if [ "$device_check" = "Cannot find device \"$device\"" ]; then + echo "Unable to fetch IP and subnet addresses from $device" + exit +fi + +subnet_mask=`ip route show dev $device scope link protocol kernel | awk '{print $1}'` +server_ipaddr=`ip route show dev $device scope link protocol kernel | awk '{print $3}'` +sudo mkdir -p /srv/{nfs/debian-arm64,tftp} +sudo apt update && sudo apt install nfs-kernel-server tftpd-hpa + +# Unpack the compressed rootfs created by debos into the nfs folder +if [[ ! -f "debian-rockpi4.tar.gz" ]]; then + echo "Execute script from root of rockpi4 repository." + exit +else + sudo tar -xf debian-rockpi4.tar.gz -C /srv/nfs/debian-arm64 +fi + +# Export to all devices in the same subnet +echo -e "/srv/nfs\t$subnet_mask(rw,no_root_squash,no_subtree_check)" | sudo tee -a /etc/exports +sudo exportfs -a +sudo service nfs-kernel-server restart + +version=`ls /srv/nfs/debian-arm64/boot | grep -Po "(?<=vmlinuz-).*(?=-arm64)"` +echo "found kernel version: $version" +sudo cp /srv/nfs/debian-arm64/boot/{initrd.img,vmlinuz}-$version-arm64 /srv/tftp +sudo cp /srv/nfs/debian-arm64/usr/lib/linux-image-$version-arm64/rockchip/rk3399-rock-pi-$rockpi_model.dtb /srv/tftp +sudo mkdir /srv/tftp/pxelinux.cfg + +# Write the PXE configuration +cat <<EOF | sudo tee -a /srv/tftp/pxelinux.cfg/default-arm-rk3399-evb_rk3399 +default l0 +menu title U-Boot menu +prompt 0 +timeout 50 + +label l0 + menu label Rock Pi 4 (Debian/Unstable) + linux vmlinuz-$version-arm64 + fdt rk3399-rock-pi-$rockpi_model.dtb + initrd initrd.img-$version-arm64 + append loglevel=8 root=/dev/nfs ip=dhcp rootwait rw earlyprintk nfsroot=$server_ipaddr:/srv/nfs/debian-arm64 +EOF