It can be very useful during development to be able to put most of our software on a simple network fileserver for the processor to boot from. As long as the processor can have local access to the boot loader and U-Boot, which will easily fit on a small memory device, the remainder of the software can be located on a server or workstation.
We are going to use two fundamental methods of providing files
- Trivial File Transfer Protocol (TFTP)
- Network File System (NFS)
The machine that we use as our fileserver can be
- An actual fileserver
- Our workstation
- Just about any old computer with Linux installed
- A Raspberry Pi
The machine that acts as our fileserver can run just about any modern OS, but I will be providing instructions for Ubuntu 20.04 LTS.
Please note that in this project, I use the terms fileserver and workstation. My workstation is my fileserver for this project.
We are going to place three key items on our network fileserver, and provide them using one of two methods:
- RootFS (the root file system) - NFS
- Linux Kernel - TFTP
- DTB (Device Tree Blob) - TFTP
Note: This project assumes that the QSPI NOR flash on the EVK is configured as it came from the factory, with a bootloader and U-Boot installed. If you have overwritten this flash device, please correct it.
Useful Documentation
- Layerscape Software Development Kit User Guide, Rev. 20.12 (REV 20.12)
- Layerscape Software Development Kit User Guide for Yocto (REV 3.1)
I have captured these commands in file: TFTPconsole.txt
Some useful instructions
Install tftpd-hpa
$ sudo apt install tftpd-hpa
Confirm that the service is running
$ sudo systemctl status tftpd-hpa
Configuring TFTP Server by editing the configuration file
$ sudo vi /etc/default/tftpd-hpa
Change a single line on the configuration file
- From: TFTP_OPTIONS="--secure"
- To: TFTP_OPTIONS="--secure --create"
The configuration file should look somewhat like this
$ cat /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure --create"
If not already present, make sure to create a location on our workstation for placing files
$ sudo mkdir /srv/tftp
Change owner and group of the tftp directory
$ sudo chown tftp:tftp /srv/tftp/
Restart the tftpd-hpa service with the following command
$ sudo systemctl restart tftpd-hpa
I have captured these commands in file: NFSconsole.txt
Some useful instructions
- https://community.arm.com/developer/tools-software/oss-platforms/w/docs/542/nfs-remote-network-userspace-using-u-boot
- https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-ubuntu-20-04
Install nfs-kernel-server
$ sudo apt install nfs-kernel-server
Create share directory if it doesn't already exist
$ sudo mkdir /srv/nfs
Change ownership (This step may not be all that important)
$ sudo chown nobody:nogroup /srv/nfs/
Configure the NFS exports
$ sudo vim /etc/exports
Add this line :
/srv/nfs 192.168.1.0/24(rw,nohide,insecure,no_subtree_check,sync,no_root_squash)
Restart the server
$ sudo systemctl restart nfs-kernel-server
Check the firewall to see if it is enabled and what is permitted
$ sudo ufw status
Note that if you end up needing to diagnose any NFS issues, it is useful to turn on server side debugging. You can skip this section for now, it is for your reference only.
Useful reading on the topic of debugging NFS
- https://www.serverstack.com/blog/2012/11/21/debugging-nfs-file-access-on-server-and-client-side/index.html
- https://www.thegeekdiary.com/how-to-enable-nfs-debug-logging-using-rpcdebug/
- https://man7.org/linux/man-pages/man8/rpcdebug.8.html
- https://prefetch.net/blog/2011/11/02/using-rpcdebug-to-debug-linux-nfs-client-and-server-issues/
Show NFS server statistics
$ nfsstat -s
Show NFS client statistics
$ nfsstat -c
Enable debugging
$ sudo rpcdebug -m nfsd -s all
ProTip: This command adds a lot of messages to your logfile so use it only when needed.
View messages with
$ dmesg
Disable debugging
$ sudo rpcdebug -m nfsd -c all
$ wget
https://www.nxp.com/lgfiles/sdk/lsdk2012/bootpartition_LS_arm64_lts_4.19.tgz
$ sudo mkdir /srv/tftp/bootpartition_LS_arm64_lts_4.19
$ sudo tar -xvf bootpartition_LS_arm64_lts_4.19.tgz -C /srv/tftp/bootpartition_LS_arm64_lts_4.19
$ wget
https://www.nxp.com/lgfiles/sdk/lsdk2012/rootfs_lsdk2012_ubuntu_lite_arm64.tgz
$ sudo mkdir /srv/nfs/rootfs_lsdk2012_ubuntu_lite_arm64
$ sudo tar -xvf rootfs_lsdk2012_ubuntu_lite_arm64.tgz -C /srv/nfs/rootfs_lsdk2012_ubuntu_lite_arm64
I highly recommend using a second computer to test our new fileserver. It is much easier to debug issues when you are using a known good machine instead of an unfamiliar evaluation kit.
For these tests, I am using a personal laptop running Ubuntu 20.04 LTS
I already know that my fileserver/workstation has an IP address of 192.168.1.61; make sure that you know your fileserver IP address and use it instead of mine.
To install tftp-hpa TFTP client on Ubuntu
$ sudo apt install tftp-hpa
Download the kernel over TFTP
$ tftp 192.168.1.61 -m binary -c get bootpartition_LS_arm64_lts_4.19/Image Image
Download the device tree blog over TFTP
$ tftp 192.168.1.61 -m binary -c get bootpartition_LS_arm64_lts_4.19/fsl-ls1046a-frwy.dtb
Did both files successfully download? If they did then TFTP is working properly.
Install nfs-common NFS client on Ubuntu (is probably already installed)
$ sudo apt install nfs-common
Create mount directory
$ sudo mkdir -p /nfs/general
Mount the RootFS
$ sudo mount 192.168.1.61:/srv/nfs/rootfs_lsdk2012_ubuntu_lite_arm64 /nfs/rootfs
Check to make sure you can see the directory structure and read a file and then
Unmount the RootFS
$ sudo umount /nfs/rootfs
Now that we have confirmed proper operation of the fileserver using a second computer, lets get back to our EVK.
Configure the FRWY-LS1046A-AC for our projectSet up the kit as follows
- Configured the board DIP switches to boot from QSPI instead of MicroSD
- Attach a console cable from your workstation to the MicroUSB on the EVK
- Attach an Ethernet cable to port 1 (upper left port of the four ports)
- Connect the power supply
Once power is applied to the EVK, the console adapter will be seen by your workstation
Identify the tty port
$ dmesg | grep tty
This is the response that I see on my workstation
[107308.396269] usb 1-4: cp210x converter now attached to ttyUSB0
My favorite serial port software is Tio, but feel free to use whatever you like
Install Tio with this command
$ sudo apt install tio
Connect to console while also saving a console log file
$ sudo tio /dev/ttyUSB0 -l consolelog.txt
If the EVK already tried to boot, just pull the power plug, wait five seconds, and put back in.
Press any key (like the enter key) once you see "Hit any key to stop autoboot: "
Assuming that you can see U-Boot on your console, it is time to configure U-Boot
Configure U-Boot and boot the EVKI have captured these commands in file: UBootconsole.txt
I highly recommend keeping this online reference handy
Make sure to use the proper IP address for your fileserver (192.168.1.61 in my situation)
Type these lines in to U-Boot
=> setenv serverip 192.168.1.61
=> setenv gatewayip 192.168.1.1
=> setenv netmask 255.255.255.0
=> setenv hostname ls1046afrwy
=> setenv netdev eth1
=> setenv consoledev ttyS0
=> setenv baudrate 115200
=> setenv bootfile bootpartition_LS_arm64_lts_4.19/Image
=> setenv fdtfile bootpartition_LS_arm64_lts_4.19/fsl-ls1046a-frwy-sdk.dtb
=> setenv rootpath /srv/nfs/rootfs_lsdk2012_ubuntu_lite_arm64
=> setenv nfsroot $serverip:$rootpath, nfsvers=3
=> setenv root /dev/nfs rw
=> setenv rootfstype nfs
The most important setting is bootargs as this contains the arguments sent to the Kernel.
Most of the lines above are for constructing bootargs
NOTE 1: I will provide multiple methods for specifying bootargs, below, please pick one that is appropriate for your use case.
NOTE 2: I specify the nfs version in my commands which is something rarely done. I ran in to some issues with U-Boot not connecting to my NFS server until I specified NFSv3
Specify bootargs using DHCPFirst, configure ip for dhcp
=> setenv ip dhcp
Specify bootargs using the simple method using variables already defined
=> setenv bootargs wdt_period=35 root=$root nfsroot=$nfsroot ip=$ip rootwait console=$console
Or you can write things out
=> setenv bootargs wdt_period=35 root=/dev/nfs rw nfsroot=$serverip:$rootpath,nfsvers=3 ip=dhcp rootwait console=$consoledev,$baudrate
First, configure ip for the exact network configuration
=> setenv ip $ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off
Specify bootargs using the simple method using variables already defined
=> setenv bootargs wdt_period=35 root=$root nfsroot=$nfsroot ip=$ip rootwait console=$console
Or you can write things out
=> setenv bootargs wdt_period=35 root=/dev/nfs rw nfsroot=$serverip:$rootpath,nfsvers=3 ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname:$netdev:off console=$consoledev,$baudrate
Note that $netdev must be eth1 for Port 1
Continuing with U-BootSave everything
=> saveenv
Confirm our settings. I like to make sure that bootargs is correct, as well as the bootfile and fdtfile
=> printenv bootargs
This is what my bootargs looks like, make sure to carefully inspect your version
bootargs=wdt_period=35 root=/dev/nfs rw nfsroot=192.168.1.61:/srv/nfs/rootfs_lsdk2012_ubuntu_lite_arm64,nfsvers=3 ip=dhcp rootwait console=ttyS0,115200
=> printenv bootfile
expected result is
bootfile=bootpartition_LS_arm64_lts_4.19/Image
=> printenv fdtfile
expected result is
fdtfile=bootpartition_LS_arm64_lts_4.19/fsl-ls1046a-frwy-sdk.dtb
If using DHCP, enable it now
=> dhcp
Download the kernel
=> tftp 0xa0000000 $bootfile
Download the Device Tree Blob
=> tftp 0xb0000000 $fdtfile
Boot the system
=> booti 0xa0000000 - 0xb0000000
At this point the kernel should have loaded, the RootFS mounted, and you should see a login prompt.
Extra creditAt a later time, you may want to reduce typing, so you can write a small script like this one
=> setenv netboot "tftp 0xa0000000 $bootfile; tftp 0xb0000000 $fdtfile; booti 0xa0000000 - 0xb0000000"
Make sure to save the new script
=> saveenv
The next time you want to run the script, just type
=> run netboot
Comments
Please log in or sign up to comment.