Jump to content

NFS Boot from SPI


Piv Klit

Recommended Posts

Looking in the forums for a few days and reading up on a lot of stuff, I got the zero to boot from spi and USB, fairly easy once you got the right commands, and replacing "linux-u-boot-next-orangepipc2_5.34_arm64" with the version on the image for the board. 
 

Quote

The procedure didn't really change, you need to activate the spi-jedec-nor overlay in /boot/armbianEnv.txt :

overlays=spi-jedec-nor

param_spinor_spi_bus=0

Then, after reboot, you should get from "cat /proc/mtd", something like that :
dev: size erasesize name

mtd0: 00200000 00001000 "spi0.0"
Then

cat /usr/lib/linux-u-boot-next-orangepipc2_5.34_arm64/sunxi-spl.bin /usr/lib/linux-u-boot-next-orangepipc2_5.34_arm64/u-boot.itb > /usr/lib/linux-u-boot-next-orangepipc2_5.34_arm64/u-boot-sunxi-with-spl.bin

and flash with

flashcp /usr/lib/linux-u-boot-next-orangepipc2_5.34_arm64/u-boot-sunxi-with-spl.bin /dev/mtd0


The I tried NFS shares and that worked fine to, but now I want to boot directly from another server, providing different folders for each board that I have and use spi for the boot. 
The reading the forum again to find out more about NFS booting, and mostly found this "hurray I got it to work" then kind of leaving the rest of us hanging there thinking HOW??? :D

I was then reading about uboot and found out that it have ethernet enabled, so guess it´s prepared for this kind of booting.
So I need to change something in uboot so it will know what ip and folder to look after, since I'm looking into booting different boards?

Oh and heres a picture of my crazy project. 


24991386_515020648885013_8887273542297869213_n.jpg.f98464199a73da4824803157cb6b5528.jpg
 

Link to comment
Share on other sites

## set this to NFS root path (ip:path)
## or else provide dhcp option 17 (root-path)

#setenv nfs_root

# for DHCP
setenv net_setup "ip=dhcp"

# for static configuration see documentation
# https://github.com/torvalds/linux/blob/master/Documentation/filesystems/nfs/nfsroot.txt
# setenv net_setup "ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip>"

# you may need to add extra kernel arguments specific to your device
setenv bootargs "console=tty1 console=ttyS0,115200 root=/dev/nfs ${net_setup} rw rootflags=noatime,nodiratime disp.screen0_output_mode=1920x1080p60 panic=10 consoleblank=0 enforcing=0 logle

if test -n ${nfs_root}; then
     setenv bootargs "${bootargs} nfsroot=${nfs_root}"
fi

tftp ${kernel_addr_r} ${serverip}:vmlinuz-4.14.91-sunxi
tftp ${ramdisk_addr_r} ${serverip}:uInitrd-4.14.91-sunxi
tftp ${fdt_addr_r} ${serverip}:sun8i-h2-plus-orangepi-zero.dtb
bootz ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
 

save and do mkimage -C none -A arm -T script -d boot.cmd boot.scr.uimg

copy boot.scr.uimg, vmlinuz,uInitrd, *.dtb to tftp folder and boot.

Working for me

Link to comment
Share on other sites

For building nfs image and vmlinuz,uInitrd, *.dtb 

On ubuntu 18.04 

apt -y install git

git clone https://github.com/armbian/build

cd build

./compile.sh ROOTFS_TYPE=nfs

wait.....................................................................DONE

cd output/images

ls

.....nfsboot-rootfs.tgz

.....nfsboot.img

 

.....nfsboot-rootfs.tgz tar -xzf to nfs export dir

fdisk -l .....nfsboot.img

         ........Orangepizero_Ubuntu_bionic_next_......._nfsboot.img1               8192 131071  122880    60M            83 Linux

8192 * 512 = 4194304

mount -o loop,offset=4194304  .....nfsboot.img /mnt

copy vmlinuz,uInitrd, and dtb  for you platform to tftp dir

 

 

Link to comment
Share on other sites

Hi @zux

Thanks for the extra instructions.

I get stuck at 'Uncompressing Linux... done, booting the kernel.'

This is what I've done:

 

=> setenv serverip 192.168.1.209
=> setenv ipaddr 192.168.1.170
=> setenv fdtfile sun8i-h2-plus-orangepi-zero.dtb
=> setenv tftpblocksize 1024
=> usb start
=> tftp ${kernel_addr_r} vmlinuz-4.19.17-sunxi
ethernet@1c30000 Waiting for PHY auto negotiation to complete. done
Using ethernet@1c30000 device
TFTP from server 192.168.1.209; our IP address is 192.168.1.170
Filename 'vmlinuz-4.19.17-sunxi'.
Load address: 0x42000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ################################################################
         4.4 MiB/s
done
Bytes transferred = 7313648 (6f98f0 hex)
=> tftp ${fdt_addr_r} ${fdtfile}
Using ethernet@1c30000 device
TFTP from server 192.168.1.209; our IP address is 192.168.1.170
Filename 'sun8i-h2-plus-orangepi-zero.dtb'.
Load address: 0x43000000
Loading: ######
         3.4 MiB/s
done
Bytes transferred = 28787 (7073 hex)
=> setenv nfs_ip 192.168.1.209
=> setenv rootpath /nfsboot/ubuntu/
=> setenv bootargs earlyprintk console=ttyAMA0 console=tty1 ip=dhcp root=/dev/nfs rootwait
=> bootz ${kernel_addr_r} - ${fdt_addr_r}
## Flattened Device Tree blob at 43000000
   Booting using the fdt blob at 0x43000000
   Loading Device Tree to 49ff5000, end 49fff072 ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.

If anyone can help it would be much appreciated.

Link to comment
Share on other sites

I got it working with:

 

setenv fdtfile sun8i-h2-plus-orangepi-zero.dtb
usb start
setenv serverip 192.168.1.209
setenv ipaddr 192.168.1.170
tftp ${kernel_addr_r} vmlinuz-4.19.17-sunxi
tftp ${fdt_addr_r} ${fdtfile}
setenv bootargs earlyprintk console=ttyS0,115200 ip=dhcp rootwait nolock rw nfsroot=192.168.1.209:/nfsboot/ubuntu/,v3 root=/dev/nfs rootdelay=7
bootz ${kernel_addr_r} - ${fdt_addr_r}

Is there a way to 'saveenv' directly to the SPI flash or do I need to modify u-boot with my settings before compiling?

Link to comment
Share on other sites

For anyone else who is stuck,

I had lots of issues because my TFTP server was on a different server to where DHCP is served from, I think U-boot expects the TFTP to come from the same source as DHCP server with the default settings.

 

here is my boot.scr.uimg:


setenv fdtfile sun8i-h2-plus-orangepi-zero.dtb
setenv serverip 192.168.1.209
setenv ipaddr 192.168.1.170
tftp ${kernel_addr_r} vmlinuz-4.19.17-sunxi
tftp ${fdt_addr_r} ${fdtfile}
tftp ${ramdisk_addr_r} uInitrd
usb start
setenv bootargs earlyprintk console=ttyS0,115200 ip=dhcp rootwait nolock rw nfsroot=192.168.1.209:/nfsboot/ubuntu/,v3 root=/dev/nfs rootdelay=7
bootz ${kernel_addr_r} - ${fdt_addr_r} ${ramdisk_addr_r}

and my /etc/export (NFS shares)


# /etc/exports: the access control list for filesystems which may be exported
#               to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/nfsboot                192.168.*(rw,sync,no_root_squash,no_subtree_check)
/nfsboot/ubuntu                192.168.*(rw,sync,no_root_squash,no_subtree_check)
#

 

Link to comment
Share on other sites

 

Quote

I had lots of issues because my TFTP server was on a different server to where DHCP is served from, I think U-boot expects the TFTP to come from the same source as DHCP server with the default settings.

 :)

Dude 

option tftp-server-name "a.b.c.d"; // option 66 from RFC

 

life hack

option host-name = concat("node", concat (
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), "",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), "",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), "",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), "",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), "",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2)
            ));
will do hostname like node+MAC

 

option root-path = concat("192.168.11.130:/mnt/main/arms_hdd/", concat (
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), ":",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), ":",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2)
            ));
mount dir is "MAC" but need use ${nfs_root} int boot.cmd

Link to comment
Share on other sites

ahh sorry, sure thats params just for dhcpd.conf

example

subnet 10.100.100.0 netmask 255.255.255.0 {
 range 10.100.100.10 10.100.100.200;
 option routers 10.100.100.1;
 option broadcast-address 10.100.100.255;
 option domain-name-servers 192.168.11.1;
 option domain-name "cluster";
 option host-name = concat("node", concat (
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), "",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), "",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), "",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), "",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), "",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2)
            ));

 option subnet-mask 255.255.255.0;
 option root-path = concat("192.168.11.5:/mnt/main/arms_hdd/", concat (
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,1,1))),2), ":",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,2,1))),2), ":",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,3,1))),2), ":",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,4,1))),2), ":",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,5,1))),2), ":",
                suffix (concat ("0", binary-to-ascii (16, 8, "", substring(hardware,6,1))),2)
            ));
 default-lease-time 604800;
 max-lease-time 604800;
}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines