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 boardserverip
: 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 sideusbnet_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 controllerCONFIG_USB_MUSB_GADGET=y
: Use the USB OTG controller in device (gadget) modeCONFIG_USB_MUSB_DSPS=y
- Check the dependencies of
CONFIG_AM335X_PHY_USB
. You need to setCONFIG_NOP_USB_XCEIV=y
to be able to setCONFIG_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/user/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.