Tool/software:
How do I set up tftp and nfs on my host machine to boot Linux on my board?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
How do I set up tftp and nfs on my host machine to boot Linux on my board?
The purpose of this document is to show how to set up a board to boot with TFTP and NFS. This is useful for developers so that they can rebuild and edit the kernel without having to unplug the SD card repeatedly.
Disclaimer: These instructions assume that the user is trying to build the ti-linux-6.6.y kernel and is using an SK-TDA4VM. The instructions should carry over to most (if not all) Jacinto devices however.
Item | Description |
---|---|
Host machine | host machine where the tftp and nfs servers are run |
Ethernet cable | cable to connect the host machine to the target |
USB to ethernet adapter | adapter to connect the host machine to the target (may not be necessary) |
sudo apt install network-manager
picocom
is used to interface with the device over the serial port.
$ picocom -b 115200 /dev/ttyUSB2
Connect the board to the host machine. Note the interface that the board is associated with. The interface is likely to be enxxx
. You can also check which interface appears with ifconfg
when plugging in the cable.
# ethernet cable (and adapter) is unplugged
$ ifconfig
# note interfaces
# plug in cable
$ ifconfig
# note the new interface
You will then configure the interface's ip address.
$ nmcli con add type ethernet ifname <enxxx> ip4 192.168.1.1/24
The target needs to have an SD card with a boot partition already set up. Primarily, the boot partition needs to contain the following files:
tiboot3.bin
tispl.bin
u-boot.img
uEnv.txt
(not required)This can be accomplished by flashing the SD card with a default wic image that corresponds with the board. There are other more involved ways to do it, but this is the easiest.
Hypothetically, you'll be rebuilding and reloading the kernel if you are developing with tftp and nfs. The following are steps to do that.
$ wget https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz
$ tar -xf https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz
$ export PATH=$PATH:arm-gnu-toolchain-13.3.rel1-x86_64-aarch64-none-linux-gnu/bin
$ export ARCH=arm64
$ export CROSS_COMPILE=aarch64-none-linux-gnu-
$ git clone -b ti-linux-6.6.y https://git.ti.com/git/ti-linux-kernel/ti-linux-kernel.git
$ cd ti-linux-kernel
$ make defconfig ti_arm64_prune.config
$ make -j`nproc` Image modules dtbs
$ cd ../
$ sudo apt install tftpd-hpa
Check which directory is being exported. The sed
command sets TFTP_DIR
to make copying future commands easier.
$ grep TFTP_DIRECTORY /etc/default/tftpd-hpa
$ export TFTP_DIR=`sed -n 's/TFTP_DIRECTORY="\(.*\)"/\1/p' /etc/default/tftpd-hpa`
Copy the kernel Image and device tree blob into the exported directory.
$ cp ti-linux-kernel/arch/arm64/boot/Image $TFTP_DIR/
$ cp ti-linux-kernel/arch/arm64/boot/dts/ti/k3-j721e-sk.dtb $TFTP_DIR/
If the tftp directory requires super user permissions to access, you can execute the following command to give your user read, write, and execution permissions:
$ sudo setfacl -m u:`whoami`:rwx $TFTP_DIR
Reset your tftp server just to ensure there are no issues:
$ sudo /etc/init.d/tftpd-hpa restart
Boot the board and stop it at the u-boot prompt:
Hit any key to stop autoboot: 0
=>
Set environment variables:
=> setenv ipaddr 192.168.1.100
=> setenv serverip 192.168.1.1
Transfer the Image and device-tree blob:
=> tftp 0x80000000 Image
=> tftp 0x83000000 k3-j721e-sk.dtb
$ sudo apt install nfs-kernel-server
Use a rootfs tarball for the relevant board. For example, you can use the tisdk-default-image-j721e-sk.rootfs.tar.xz
. This can be built using Yocto.
$ mkdir nfsroot
$ tar -xf tisdk-default-image-j721e-sk.rootfs.tar.xz -C nfsroot
$ echo "$PWD/nfsroot 192.168.1.100(rw,no_root_squash,no_subtree_check)" >> /etc/exports
$ sudo exportfs -r
Reset the board and stop at the u-boot prompt.
You'll need to replace the <nfsroot-directory>
with the correct path.
=> setenv ipaddr 192.168.1.100
=> setenv serverip 192.168.1.1
=> setenv bootcmd 'tftp 0x80000000 Image; tftp 0x83000000 k3-j721e-sk.dtb; booti 0x80000000 - 0x83000000'
=> setenv bootargs root=/dev/nfs rw ip=192.168.1.100:::::eth0 console=ttyS2,115200n8 nfsroot=192.168.1.1:<nfsroot-directory>,nfsvers=3,tcp
=> boot
uEnv.txt
if you want them to remain between resets.fdtoverlay
application and then use newly generated device-tree blob to boot$ fdtoverlay -i <base-dtb> -o <new-dtb> <overlay-dtbo>