BBB-WIRELESS, TFTP BOOT VIA USB_ETHERNET (RNDIS) – VIRTUALBOX. “THE EASY AND DUMP APPROACH”

Okay, So I received this new beautiful Credit Card size Beaglebone black (BBB) Wireless board as gift from one of my colleague (Thanks buddy). The board is so beautiful and compact that for one moment I thought of not even unpacking it …… but moment gone….. board unpacked. 😜

Figure-1: Beaglebone Back (BBB) Wireless

The board ships with pre-installed Debian distribution in its internal eMMC flash memory. By default the board boots from its internal flash memory when powered on. Its fun to see BBB booting its pre-installed Linux Image BUT being Engineer its more fun to boot the platform/board with your own Linux distribution/Compiled Images. So I compiled the linux components (Kernel, u-boot, FileSystem) and placed them in an external SD-Card. Luckily after few trials, the board booted successfully from external SD-Card on compiled Images.

NOTE: We will cover SD-Card booting and Compiling Linux Binaries  e.g. u-boot, Kernel, Root File System in next article. For now you can get the compiled binaries from here.  

Compiling and booting Linux on any platform is totally fun but tedious job as well. You compile it, copy it to memory (sd-card, eMMC etc.), test it and the process repeats unless the bugs are fixed and requirements are met. Especially if you have to copy binaries to SD-Card …. that plugging and un-plugging  of SD-Card during compilation and Testing is totally shit and annoying.

So to reduce this tedious process of plugging and unplugging, I decided to load Linux kernel and dtb (Device tree binaries) using TFTP (Trivial File Transfer Protocol) [1]. I had this VirtualBox with Linux Lite installed on my Laptop. So I decided to host TFTP server on Virtual Machine (VirtualBox). This is where the fun begun and off-course by fun I mean MESS.  Not only this … the bad news was the new BBB-Wireless doesn’t have any dedicated ETHERNET port. This was a total chaos.

Its time to get help from Internet. Voila, every resource on the Internet combining BBB and TFTP mentions “CONNECT YOUR BBB TO PC VIA RJ-45 ETHERNET CABLE“. Man we don’t have Ethernet Port on the new BBB-Wireless. 😢

WAIT… its not a dead end. “Where there is a well, there is a way”! Indeed there is no Ethernet port but do we have any other interface on the board that can host Network traffic💡? Yes we do have. Its the same USB port through which power is given to the board. USBs can host Network traffic via Microsoft proprietary protocol called RNDIS (Remote Network Driver Interface Specification) [2]. 

So lets load Linux Kernel and .dtb from TFTP server via this RNDIS interface. Note I mentioned Kernel and .dtb only which means the board must already have u-boot either in flash memory or SD-Card Plus it must have RNDIS support (Don’t panic it will most probably be compiled with RNDIS support; if not compile it with “_usbspl_” config file. So Relax its a trivial issue.).

SERVER CONFIGURATION:

Let’s configure TFTP server on the host PC (VirtualBox). Optionally we will install TFTP client to check connection.

  • The following commands installs TFTP server, client and internet Deamon on host Machine.
$ sudo apt-get install xinetd tftpd tftp

Create (if not exists) or Open the file tftp in /etc/xinetd.d/ directory. 

$ sudo vim /etc/xinetd.d/tftp

Put the following configurations in the tftp file and save it.

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

Create tftpboot directory in /var/lib/tftpboot as indicated by the  server_args option in the previous step. Also give full read/write access to the directory.

$ sudo mkdir /var/lib/tftpboot

$ sudo chmod -R 777 /var/lib/tftpboot

$ sudo chown -R nobody /var/lib/tftpboot

Start/Restart the xinetd service and verify the status.

$ sudo service xinetd restart       #for newer systems

$ sudo /etc/init.d/xinetd restart   #for older systems

$ sudo /etc/init.d/xinetd status


Disable the Firewall on Virtual Machine (VirtualBox). This is a bad bad bad step but unfortunately I couldn’t make TFTP server respond to external devices on VirtualBox without this step. Never do this on production PC especially if it is connected to INTERNET. That’s why i named it “the dump approach“. 

$ sudo ufw disable

$ sudo ufw status

TESTING TFTP SERVER

Now that we have configured TFTP server, let’s test it on same machine to verify it’s indeed up and running.

  • Create a dummy file say test.txt and place it in the /var/lib/tftpboot directory.
  • From Terminal enter the following command to activate TFTP Client.
$ tftp
  • Connect Client to local machine.
tftp> connect localhost 
  • Request the sample file i.e. test.txt
tftp> get test.txt
  • A message similar to the following will be displayed indicating number of bytes received that subsequently means the TFTP server is indeed up and running. Finally quit the client.
Received N bytes in XYZ seconds.
tftp> quit

  • Copy Linux binaries i.e. uImage + .dtb file (download here) into TFTP directory i.e. /var/lib/tftpboot

Congratulation, you have successfully configured TFTP server on your Virtual machine PC. Now its time to connect BBB and load Kernel and dtb binaries.

BBB -WIRELESS SETUP

Great. Now that everything on host PC side is setup its time to configure BBB for TFTP boot. Connect your BBB via Serial Port to host PC and Power up your board using USB cable to get u-boot Terminal on Serial Port Software e.g. Minicom etc. Figure-2. (More on this in next article if you don’t know how to do it!).

Figure-2: u-boot Terminal

Let’s do few more settings. To establish communication between two PCs, we need to establish a local network. PCs communicate with each other on network via IP addresses. Every network needs a network administrator (DHCP server) that can assign IP address to every existing computers on the network and any new computer that wants to connect to the network. Our application is simple and we don’t want to go into that complexities. So we will manually set BBB and Host IP addresses via u-boot environment variables.

  • In order to set board/host PC IP addresses, enter the following commands in the u-boot terminal shown in Figure-2.
=> setenv ipaddr 192.168.0.2

=> setenv serverip 192.168.0.1
  1. ipaddr: IP address of BBB-Wirelss
  2. serverip: IP address of host PC (VirtualBox in our case)
  • Inform u-boot to use USB-Ethernet interface as active interface for network traffic/operations.
=> setenv ethact usb_ether

Now since USB Ethernet connects directly to Host PC, they both form point-to-point communication with no agent (like DHCP server) to assign IP addresses. As a quick reminder from Network:

  • In point-to-point communication we needs MAC addresses (Link Layer OSI-Model) of machines along with IP addresses (Network Layer OSI-Model) as this is the only you can actually unambiguously address a device that is connected to the same link (e.g., Ethernet). 
  • Let’s assign virtual MAC addresses to BBB USB interface and Host PC adapter.
=> setenv usbnet_devaddr f8:dc:7a:00:00:01
=> setenv usbnet_hostaddr f8:dc:7a:00:00:02

usbnet_devaddr: The virtual MAC address of the device (the board side).
usbnet_hostaddr: The virtual MAC address of the host (the PC side).

Note: These addresses are arbitrary (as Virtual).

  • Virtual Machines are normally slow – as running inside another OS as a process. In VirtualBox, in order to access an external device, it needs to be mentioned explicitly via main menu (see Figure-4). It’s take time to click that Device -> USB -> XYZ device option. In order for u-boot to wait that long for the connection to establish; set timeout variable i.e.  cdc_connect_timeout to some bigger number (Not sure its seconds/milliseconds whatever). 

=> setenv cdc_connect_timeout 500
  • Let’s load the Kernel image into beaglebone internal SD-RAM memory via TFTP protocol.
=> tftpboot 0x82000000 uImage
Figure-3: Establishing connection
  • At this point you should be able to see a new hardware entry into your VirtualBox Devices USB List – Figure-4. Click the device to connect it to VirtualBox.
Figure-4: RNDIS Device connection
  • Once you connect the device, a moment later you should see that beautiful terminal screen (see Figure-5) indicating loading Kernel Image (uImage) from TFTP server.  
Figure-5: TFTP boot
  • Similarly load the .dtb file using the same previous method i.e.
=> tftpboot 0x82000000 am335x-boneblack.dtb

Congratulations You successfully loaded Linux binaries using your TFTP Server. See you in the next tutorial….

REFERENCES:

[1] – Trivial File Transfer Protocol

[2] – USB RNDIS



159 thoughts on “BBB-WIRELESS, TFTP BOOT VIA USB_ETHERNET (RNDIS) – VIRTUALBOX. “THE EASY AND DUMP APPROACH””

Leave a Reply

Your email address will not be published. Required fields are marked *