Skip to content

Instantly share code, notes, and snippets.

@sprhawk
Created October 14, 2020 16:16
Show Gist options
  • Save sprhawk/7e1695966571edb25065c5a5855be7ef to your computer and use it in GitHub Desktop.
Save sprhawk/7e1695966571edb25065c5a5855be7ef to your computer and use it in GitHub Desktop.
Yocto NFS boot

yocto

References

(old) poky-export-rootfs chromium OS nfs rootfs

check poky-contrib: scripts/runqemu-export-rootfs

Under Development Box

setup NFS

# /etc/exports
/srv/nfs/yocto/rootfs	 192.168.31.0/24(rw,sync,no_subtree_check,no_root_squash)
# /home/hongbo/Developer/iotpi.io/backupstack/backupstack-yocto/backupstack-build/tmp/work/backupstack_rk3399-poky-linux/backupstack-image/1.0-r0/rootfs/	 192.168.31.0/24(rw,sync,no_subtree_check,no_root_squash) 192.168.50.0/24(rw,sync,no_subtree_check,no_root_squash)

# /etc/network/interfaces.d/eno2
auto eth0
iface eth0 inet static
        address 192.168.31.1/24
        # gateway 192.168.31.1
        # post-up ip route add default via 192.168.31.1
        # pre-down ip route delete default via 192.168.31.1
sudo ipdown eno2
sudo ipup eno2
# /etc/sysctl.d/40-eno2.conf
net.ipv4.conf.eno2.forwarding=1
sudo iptables -t nat -A POSTROUTING -o wlo1 -j MASQUERADE
sudo iptables -A FORWARD -i eno2 -o wlo1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlo1 -o eno2 -j ACCEPT
# needs to set IMAGE_FSTYPES += "tar.gz"
sudo tar xvf tmp/deploy/images/backupstack-rk3399/backupstack-image-backupstack-rk3399.tar.gz -C tmp/work/backupstack_rk3399-poky-linux/backupstack-image/1.0-r0/rootfs/

Under Target Board

# under u-boot
setenv bootcmd_nfs 'run set_nfs_bootargs; run tftp_cmd; bootm ${kernel_addr_r} - ${fdt_addr_r}'
setenv tftp_cmd 'tftp ${kernel_addr_r} $serverip:fitImage; tftp ${fdt_addr_r} $serverip:rk3399-firefly.dtb'
setenv nfs_root "/srv/nfs/yocto/rootfs/rk3399"
# setenv nfs_root "/home/hongbo/Developer/iotpi.io/backupstack/backupstack-yocto/backupstack-build/tmp/work/backupstack_rk3399-poky-linux/backupstack-image/1.0-r0/rootfs/"
setenv boot_kernel_ip '192.168.31.100:192.168.31.1:192.168.31.1:255.255.255.0:offclouds:eth0:none'
setenv set_nfs_bootargs 'setenv bootargs root=/dev/nfs ro nfsroot=${nfs_root},nfsvers=3 ip=${boot_kernel_ip} rootwait console=tty1 console=ttyS2,1500000n8 init=/sbin/init -s initcall_debug loglevel=15'
# setenv set_nfs_bootargs 'setenv bootargs root=/dev/nfs ro nfsroot=${nfs_root},nfsvers=3 ip=${boot_kernel_ip} rootwait console=tty1 console=ttyS2,1500000n8 init=/sbin/init loglevel=5'
# setenv bootargs 'root=/dev/nfs ro nfsroot=${serverip}:/srv/nfs4/yocto/rootfs rootwait console=tty1 console=ttyS2,${baudrate}n8 init=/sbin/init -s initcall_debug loglevel=15 earlycon'
setenv serverip 192.168.31.1
setenv ipaddr 192.168.31.100
setenv boot_targets nfs ${boot_targets}
run bootcmd_nfs
run bootcmd

Notes

flash image into eMMC into console of U-boot mmc erase 0 1 to disable eMMC boot, but preserve u-boot environment

# erase MMC environment
# CONFIG_ENV_SIZE=0x8003
# CONFIG_ENV_OFFSET=0x3F8000
mmc erase 0x1fc0 10 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment