Project

General

Profile

MitySOM 335x Network Boot

It is possible to boot MitySOM modules from USB or network. This can be useful if the MitySOM is unable to boot from flash and must be recovered. Booting from the network also enables rapid development since the kernel, filesystem, and software packages don't need to be installed onto an SD card. This article currently covers the setup for USB booting, although U-Boot will also search for Ethernet boot servers.

The boot environment will be provided by a Linux PC connected to the board via a mini USB cable. The PC provides several functions: a DHCP/BOOTP server, a tftp server, and an NFS server. U-boot, its SPL, and the Linux kernel are loaded over TFTP; the root filesystem is loaded over NFS.

Note: Direct network booting hasn't been successful. Possibly due to needing to configure phy delay skew.

Host Configuration

The host PC must be able to provide DHCP, TFTP, and NFS. The packages providing these services can be installed on Ubuntu 12.04 with the following command:

sudo apt-get install isc-dhcp-server tftpd-hpa xinetd nfs-kernel-server

It is also necessary to define a static IP address for the usb0 interface. This way the server services can bind to ports on the address regardless of the state of the SOM. Open /etc/network/interfaces, and add an entry for usb0:

/etc/network/interfaces:

allow-hotplug usb0
iface usb0 inet static
        address 192.168.2.1
        network 192.168.2.0
        netmask 255.255.255.0
        broadcast 192.168.2.255
        up /etc/network/if-up.d/usb-interfaces

On newer versions of Ubuntu (Known problem with ubuntu 16.04) it will be necessary to make the following changes to disable renaming of the network interfaces.
/etc/default/grub
Change the line from this:

GRUB_CMDLINE_LINUX="" 

To this:

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0" 

And then generate a new grub file with the following command:

sudo grub-mkconfig -o /boot/grub/grub.cfg

If using Network Manager (default in Ubuntu 12.04), it must be configured to allow ifupdown to handle network interfaces.

/etc/NetworkManager/NetworkManager.conf:

[main]
plugins=ifupdown

[ifupdown]
managed=false

Restart NetworkManager for it to detect that usb0 is manually set

sudo service network-manager restart

Use nmcli dev status to verify usb0 is now unmanaged

 $ nmcli dev status
DEVICE     TYPE              STATE        
eth1       802-3-ethernet    connected    
eth0       802-3-ethernet    unavailable  
usb0       802-3-ethernet    unmanaged    

Each of the installed packages must now be configured.

DHCP Server

The DHCP server provides a different boot image depending on the stage of the SOM's boot process. The AM335x processor boot ROM will first be provided an SPL image; the SPL a U-Boot image; and the U-Boot a Linux kernel image.

The DHCP server daemon stores its configuration in a file at /etc/dhcp/dhcpd.conf. Add a subnet declaration for the USB RNDIS subnet. A sample dhcpd.conf is provided below:

/etc/dhcp/dhcpd.conf:

subnet 192.168.2.0 netmask 255.255.255.0
{
  range dynamic-bootp 192.168.2.2 192.168.2.100;
  option routers 192.168.2.1;

  if substring (option vendor-class-identifier, 0, 10) = "AM335x ROM" 
  {
    filename "u-boot-spl.bin";
  }
  elsif substring (option vendor-class-identifier, 0, 10) = "DM814x ROM" 
  {
    filename "u-boot-spl.bin";
  }
  elsif substring (option vendor-class-identifier, 0, 16) = "MitySOM 335x SPL" 
  {
    filename "u-boot.img";
  }
  else
  {
    filename "uImage";
  }

  range 192.168.2.101 192.168.2.199;
}

The DHCP server must be configured to listen on the usb0 interface, and it should not listen on any other interface. To configure this, edit /etc/default/isc-dhcp-server. The service can optionally be restarted after the change is made, but the if-up script will restart it once a USB cable is connected to the SOM.

/etc/default/isc-dhcp-server:

INTERFACES="usb0" 

NFS Server

The NFS server must be configured to export a share for /export/rootfs if booting completely from the network, or another path if using a custom SPL or the SOM's uEnv.txt. Add the following to /etc/exports:

/export/rootfs *(rw,nohide,insecure,no_subtree_check,async,no_root_squash)

Create the /export/rootfs folder and extract the MitySOM 335x filesystem to /export/rootfs. Restart the nfs server. On Ubuntu 12.04,

service nfs-kernel-server restart

TFTP Server

The TFTP server is generally managed by the xinetd daemon or a separate application. The TFTP has to be configured correctly or clients will have trouble downloading files.

One of the following options will help you configure TFTP on your host machine.

Option 1 (Older Ubuntu Releases): xinted.d configuration

Edit /etc/xinetd.d/tftp to set the directory to /tftpboot:

service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
}

Option 2 (Newer Ubuntu Releases with tftpd-hpa isntalled): tftpd-hpa configuration

Edit /etc/default/tftpd-hpa to set the TFTP_DIRECTORY variable:

...
TFTP_DIRECTORY="/tftpboot" 
...

Restart the TFTP Server

After changing the configuration, restart the tftp service:

$ sudo service tftpd-hpa restart

if-up.d Script

Because the SOM's USB interface will be re-initialized several times during its boot process, the DHCP server may need to be restarted automatically on the host PC. This is done by an ifup script. On Ubuntu 12.04, this script is /etc/network/if-up.d/usb-interfaces.

For debugging, it may be useful to capture the network packets transferred across the USB interface. tcpdump can be added to the if-up script for this purpose.

/etc/network/if-up.d/usb-interfaces:

if [ "$IFACE" = usb0 ]; then
  sudo service isc-dhcp-server restart
  #sudo tcpdump -ni usb0 -s0 -w /tmp/`date +"%Y-%m-%d_%H-%M-%S"`.pcap
fi

Building U-Boot

Follow the Critical Link u-boot build instructions with one difference: the final build command should be as follows.

makearm mityarm335x_usbspl

https://support.criticallink.com/redmine/projects/armc8-platforms/wiki/Das_U-Boot_Port

This will build a version of the spl and u-boot images that boot only from the network. These are the binaries that must be copied to your /tftpboot directory.

sudo cp u-boot.img /tftpboot/
sudo cp spl/u-boot-spl.bin /tftpboot/

Note: If the board will boot with both interfaces connected, it may be necessary to change the U-Boot kernel argument ip=dhcp to ip=all. This will cause the kernel to acquire DHCP leases on each interface before attempting to mount the root filesystem over NFS. If using a USB-loaded u-boot environment, the default arguments can be changed in include/configs/mityarm335x.h -- see CONFIG_EXTRA_ENV_SETTINGS.

Expected behavior of ip=all

If only the USB interface is available, ip=all will cause the kernel to try to get an IP on eth0 even though it is not needed. The kernel will loop trying to get an IP, causing the boot to hang until an Ethernet cable is plugged in.

If both USB and Ethernet interfaces are up, ip=all will cause the kernel to get an IP for each interface. The interface in the appropriate subnet will be used to contact the NFS server.

Expected behavior of ip=dhcp

If only the USB interface is available, ip=dhcp will cause the kernel to only get an IP on usb0. This is the default configuration which assumes all network resources will be provided by the host computer.

If both USB and Ethernet interfaces are up, ip=dhcp will cause the kernel to only get an IP on eth0. To change the order, the kernel's default device order would need to be changed (it is dynamically created; this may need some kernel hacking). An alternative would be to create an initrd image that sets up the NFS mount over the correct interface. These configurations are not currently supported.

Board Setup

The BOOTCONFIG pins must be set to the following pattern to boot from the USB interface: 110101110000, where 0 is a jumper.

BOOTCONFIG [0..11]
::[:]:[:]:::[:][:][:][:]

Connect a USB cable between the board and a Linux PC.

A Linux Kernel with built-in RNDIS drivers is required to find a boot server over USB. Otherwise, the kernel will also attempt connection over Ethernet.

See https://support.criticallink.com/redmine/projects/armc8-platforms/wiki/Linux_Kernel for build instructions. The article https://support.criticallink.com/redmine/projects/arm9-platforms/wiki/Enabling_USB_RNDIS_Support describes to enable RNDIS support. Once the kernel is built, copy the uImage to /tftpboot.

sudo cp arch/arm/boot/uImage /tftpboot/

Bridging Internet Connection

https://developer.ridgerun.com/wiki/index.php/How_to_use_USB_device_networking#Bridging_host_PC_to_allow_device_to_reach_the_Internet

Host PC:

Add the following to /etc/network/if-up.d/usb-interfaces

if [ "$IFACE" = usb0 ]; then
    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables -P FORWARD ACCEPT
    iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.2.0/24

Target:

Verify route contains default gateway

root@mitysom-335x ~ $ route 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.2.1     0.0.0.0         UG    0      0        0 usb0
192.168.2.0     *               255.255.255.0   U     0      0        0 usb0

Otherwise can be manually set
$ route add default gw 192.168.2.1

If you want to use static address instead of dhcp
/etc/network/interfaces

auto usb0
iface usb0 inet static
        address 192.168.2.2
        network 192.168.2.0
        netmask 255.255.255.0
        gateway 192.168.2.1

Manually set dns
rm /etc/resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf

Multiple SOMs to One Computer

In order to support booting multiple SOMs, a bridge interface can be used to combine multiple USB network interfaces into one subnet. The bridge device, br0, is given a static IP address, and the usb* devices are bridged with it, allowing packets to flow between any interface connected to the bridge.

/etc/network/interfaces

allow-hotplug usb0
allow-hotplug usb1
iface usb0 inet manual
iface usb1 inet manual

auto br0
iface br0 inet static
    address 192.168.2.1
    network 192.168.2.0
    netmask 255.255.255.0
    broadcast 192.168.2.255
    bridge_ports usb0 usb1

The bridge interface is always up on the host PC, so it is no longer necessary to run an if-up script to restart the DHCP server. Instead, configure the DHCP server to listen only on br0. br0 should be used as the "USB network" instead of usb0 for all service configurations.

References

http://processors.wiki.ti.com/index.php/Ubuntu_12.04_Set_Up_to_Network_Boot_an_AM335x_Based_Platform
http://processors.wiki.ti.com/index.php/Sitara_Linux_Program_the_eMMC_on_Beaglebone_Black#Create_a_Network_Bootable_U-Boot_Image

Go to top
Add picture from clipboard (Maximum size: 600 MB)