tftp and NFS booting on Beagle Bone Black Wireless and Pocket Beagle

BeagleBoneBlack Wireless board  booting through tftp and NFS
BeagleBoneBlack Wireless board booting through tftp and NFS

Here are details about booting the Beagle Bone Black Wireless board through NFS. I’m writing this here because it doesn’t seem to be documented anywhere else (except in our Linux kernel and driver development course, for which I had to support this feature).

Why

Booting a board on a root filesystem that is a directory on your workstation (development PC) or on a server, shared through the network, is very convenient for development purposes.

For example, you can update kernel modules or programs by recompiling them on your PC, and the target board will immediately “see” the updates. There’s no need to transfer them in some way.

Doing this is quite straightforward on boards that have an Ethernet port, and well documented throughout the Internet (see our instructions). However, things get more complicated with boards that have no such port, such as the Beagle Bone Black Wireless or the Pocket Beagle.

The Beagle Bone Black Wireless board has WiFi support, but booting on NFS directly from the kernel (instead of using an initramfs) is another kind of challenge.

Something easier to use is networking over USB device (also called USB gadget as our operating system is running on the USB device side), which is supported by both Linux and U-Boot.

Note that the below instructions also work on the original Beagle Bone Black, bringing the convenience of not having to use an RJ45 cable. All you need is the USB device cable that you’re using for power supply too.

These instructions should also support the Pocket Beagle board, which is similar, though much simpler.

Preparing U-Boot

This part may just work out of the box if the U-Boot version on your board is recent and was built using the default configuration for your board.

If that’s not the case, you can reflash U-Boot on your board using our instructions.

Now, let’s configure networking in U-Boot:

  • ipaddr: IP address of the board
  • serverip: IP address of your PC or server
setenv ipaddr 192.168.0.100
setenv serverip 192.168.0.1

Make sure that this address belongs to a separate network segment from the one used by your PC to connect to the network.

We also need to configure Ethernet over USB device:

  • ethact: controls which interface is currently active.
  • usbnet_devaddr: MAC address on the device side
  • usbnet_hostaddr: MAC address on the host side
setenv ethact usb_ether
setenv usbnet_devaddr f8:dc:7a:00:00:02
setenv usbnet_hostaddr f8:dc:7a:00:00:01
saveenv

Note that the above MAC addresses are arbitrary.

Configure your PC

These instructions have been tested on Ubuntu 18.04, but they should be easy to adapt on other GNU/Linux distributions.

To configure your network interface on the workstation side, we need to know the name of the network interface connected to your board.

However, you won’t be able to see the network interface corresponding to the Ethernet over USB device connection yet, because it’s only active when the board turns it on, from U-Boot or from Linux. When this happens, the network interface name will be enx. Given the value we gave to usbnet_hostaddr, it will therefore be enxf8dc7a000001.

Then, instead of configuring the host IP address from NetWork Manager’s graphical interface, let’s do it through its command line interface, which is so much easier to use:

nmcli con add type ethernet ifname enxf8dc7a000001 ip4 192.168.0.1/24

To download the kernel and device tree blob which are also on your PC, let’s install a TFTP server on it:

sudo apt install tftpd-hpa

You can then test the TFTP connection, which is also a way to test that USB networking works. First, put a small text file in /var/lib/tftpboot.

Then, from U-Boot, do:

tftp 0x81000000 textfile.txt

The tftp command should have downloaded the textfile.txt file from your development workstation into the board’s RAM at location 0x81000000. You can verify that the download was successful by dumping the contents of memory:

md 0x81000000

We are now ready to load and boot a Linux kernel!

Kernel configuration

These instructions were tested with Linux 4.19

Configuring and cross-compiling the Linux kernel for the board is outside the scope of this article, but again, such information is easy to find (such as in our training slides).

Here, we’re just sharing the Linux kernel configuration settings that are needed for networking over USB device. Since they are not supported by the default configuration file for the omap2plus CPU family (for several reasons that were discussed on the Linux kernel mainling list), it took a bit of time to figure out which ones were needed. Here they are:

Add the below options to support networking over USB device:

  • CONFIG_USB_GADGET=y
  • CONFIG_USB_MUSB_HDRC=y: Driver for the USB OTG controller
  • CONFIG_USB_MUSB_GADGET=y: Use the USB OTG controller in device (gadget) mode
  • CONFIG_MUSB_DSPS=y
  • Check the dependencies of CONFIG_AM335X_PHY_USB. You need to set CONFIG_NOP_USB_XCEIV=y to be able to set CONFIG_AM335X_PHY_USB=y
  • Find the ”USB Gadget precomposed configurations” menu and set it to static instead of module so that CONFIG_USB_ETH=y

How did I found out which settings were needed? I had to check the device tree to find the USB device controller. Then, using git grep, I found the driver that was supporting the corresponding compatible string. Then, looking at the Makefile in the driver directory, I found which kernel configuration settings were needed.

When compiling is over, copy the zImage and am335x-boneblack-wireless.dtb files to the TFTP server home directory (/var/lib/tftpboot).

You also need an NFS server on your workstation:

sudo apt install nfs-kernel-server

Then edit the /etc/exports file as root to add the following line, assuming that the IP address of your board will be 192.168.0.100:

/home/user/nfsroot 192.168.0.100(rw,no_root_squash,no_subtree_check)

(If you don’t have a root filesystem yet, you can use the one in our lab data archive.)

Then, restart the NFS server:

sudo /etc/init.d/nfs-kernel-server restart

Configuring the kernel command line

Back to the U-Boot command line, configure the kernel command line by setting the bootargs environment variable (all in just one line):

setenv bootargs root=/dev/nfs rw ip=192.168.0.100:::::usb0 console=ttyO0,115200n8 g_ether.dev_addr=f8:dc:7a:00:00:02 g_ether.host_addr=f8:dc:7a:00:00:01 nfsroot=192.168.0.1:/home//linux-kernel-labs/modules/nfsroot,nfsvers=3

Also set the series of commands to run at boot time:

setenv bootcmd 'tftp 0x81000000 zImage; tftp 0x82000000 am335x-boneblack-wireless.dtb; bootz 0x81000000 - 0x82000000'
saveenv

You are ready to boot:

boot

Now check the kernel log and make sure an IP address is correctly assigned to your board by Linux. If NFS booting doesn’t work yet, that could be because of NFS server or client issues. If that’s the case, you should find details in the NFS server logs in /var/log/syslog on your PC.

Author: Michael Opdenacker

Michael Opdenacker is the founder of Bootlin. He is best known for all the free embedded Linux and kernel training materials that he created together with Thomas Petazzoni. He is always looking for ways to increase performance, reduce size and boot time, and to maximize Linux' world domination. More details...

7 thoughts on “tftp and NFS booting on Beagle Bone Black Wireless and Pocket Beagle”

    1. That should be relatively easy to do with the Raspberry Pi, as we don’t have the complexity of networking over USB device. You setup the NFS server on the same way, boot your kernel with “root=/dev/nfs ip=…. nfsroot=…” and this should work.

      I’m sure you’ll find someone who has done that before.
      See https://elixir.bootlin.com/linux/latest/source/Documentation/filesystems/nfs/nfsroot.txt for the full reference.

      Happy booting 😉
      Michael.

  1. This worked!!
    I’m able to load a kernel and everything required over USB.
    one note tho, for some reason, I couldnt get ping or tftp to work after the setup directly, it started working after host restart. maybe some networking service needs to be restarted for it to catch.

  2. Hi, my beaglebone USB ethernet connection is renamed to enp0s29u1u2 but not to enx… . I think this is related to Predictable Network Interface Names.
    “””
    1. Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: eno1)
    2. Names incorporating Firmware/BIOS provided PCI Express hotplug slot index numbers (example: ens1)
    3. Names incorporating physical/geographical location of the connector of the hardware (example: enp2s0)
    4. Names incorporating the interfaces’s MAC address (example: enx78e7d1ea46da)
    5. Classic, unpredictable kernel-native ethX naming (example: eth0)

    Policy 4) is not used by default, but is available if the user chooses it.
    “””
    Where can I enable policy 4?
    My host is Ubuntu 18.04.

  3. Hi, I’ve the following questions:
    1.The values of usbnet_devaddr and usbnet_hostaddr can be any arbitrary value or is it board specific.
    2. In the host PC is it necessary to have the DHCP server for the corresponding interface.

    1. Hi Gokul,
      Thanks for the questions!
      Yes, the usbnet_devaddr and usbnet_hostaddr values can be any arbitrary. I updated the text to explain this.
      No, on the PC side, you don’t need any DHCP server. Using a fixed IP address is fine. That’s what we’re setting with the “nmcli” command.
      Cheers,
      Michael.

Leave a Reply