Search by Tags

Flashing Embedded Linux over Ethernet

 

Article updated at 07 Aug 2019
Compare with Revision




It is possible to flash an embedded Linux image to a target module using two methods:

  • Toradex Easy Installer flashing: the preferred method for flashing. Check out the Toradex Easy Installer article for comprehensive information, including supported and pre-installed modules.
  • Legacy flashing: the flashing method prior to Toradex Easy Installer, uses bash script.

Note: Legacy flashing method does not imply that the embedded Linux image is legacy. There are pre-built Toradex images that are provided in both legacy and Toradex Easy Installer formats. Consult the image releases for a list of images in both formats.

Attention: If your Computer on Module is supported by the Toradex Easy Installer, the legacy flashing method is considered deprecated and you shouldn't use it.

It is possible to flash Embedded Linux to our modules using U-Boot and TFTP (Trivial File Transfer Protocol) over Ethernet.

TFTP allows a client to download files from a remote host. More specifically, the module with U-Boot being the client will download file(s) specified by the update scripts from the TFTP server specified by the environment variable "serverip". The TFTP server, usually running on the development host, should serve a folder which contains all files needed for flashing.

The instructions provided in this article are compatible with the legacy flashing method. To flash from Toradex Easy Installer using a custom server feed, please refer to the Toradex Easy Installer article.

Prerequisites

The preparation steps need to be executed on a x86-64 development host running a Linux distribution (e.g. Fedora or Ubuntu). Please note that there is no support for 32 bit hosts.

The following host applications and libraries are a pre-requisite for executing the update script and the 64-bit host tools contained in the image tarball.

E.g. for Ubuntu 14.04 (64-bit)

sudo apt-get update
sudo apt-get install dosfstools e2fsprogs gawk mtools parted
sudo apt-get install zlib1g liblzo2-2 libuuid1 libusb-1.0-0

E.g. for Fedora 21 (64-bit)

yum install dosfstools e2fsprogs gawk mtools parted 
yum install zlib lzo libuuid libusbx

On older distros (e.g. Ubuntu 12.04) the tool to create a FAT filesystem was named mkfs.vfat while the update.sh script uses mkfs.fat. If you get an error that mkfs.fat is missing then find the full path to mkfs.vfat and create a symlink by doing the following:

trdx@trdx:~$ sudo sh -c "command -v mkfs.vfat"
/sbin/mkfs.vfat
trdx@trdx:~$ sudo ln -s /sbin/mkfs.vfat /sbin/mkfs.fat

Network Setup

There are two options for setting up the network.

  • Configure the workstation with a predefined network (using a dedicated network interface for the embedded board, this is our recommended network setup).
  • Configure U-Boot to use an existing network (e.g. your corporate network, which typically uses dynamic network configuration using DHCP).

Dedicated Network

Using a dedicated network allows to use a static private network range. We recommend to use the 192.168.10.0/24 network and assign the static IP 192.168.10.1 to the workstation. By default U-Boot comes with a static IP configuration which assumes the host to be reachable at 192.168.10.1 (see e.g. include/configs/colibri_vf.h)

#define CONFIG_IPADDR          192.168.10.2
#define CONFIG_NETMASK         255.255.255.0
#define CONFIG_SERVERIP        192.168.10.1

Existing Network

You can use U-Boot's dhcp command to get a dynamic IP address from the dhcp server on the connected network. By default, U-Boot will automatically try to download a boot file from the TFTP server, even if the dhcp server does not specify a boot file. To use DHCP only for IP assignment, use the autoload environment variable.

# setenv autoload 0
# dhcp
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
*** Unhandled DHCP Option in OFFER/ACK: 19
*** Unhandled DHCP Option in OFFER/ACK: 19
DHCP client bound to address 192.168.10.138 (1010 ms)

A static configuration can be used by setting the ipaddr environment variable:

# setenv ipaddr [board_ip]

In either case, make sure that the serverip environment variable points to the development host.

# setenv serverip [ip_of_development_host]

Verify configuration

Either configuration method should end up with a network setup working for TFTP. Use U-Boot's ping command to test if the network is working as expected

# ping ${serverip}
Using FEC device
host 192.168.10.1 is alive

For more information about how to setup the network for embedded Linux development refer to Network Setup for Development.

TFTP Configuration

For flashing over Ethernet a TFTP server is needed on the host machine. U-Boot will be the TFTP client.

More information about installing and configuring a TFTP server can be found in "TFTP Server" of the How to setup Networking for Embedded Linux Application Development article.

Flashing

Using the update script provided with our images, run it against ‘/srv/tftp/’ folder we created above, just like we do when using an SD card.

This folder will have the same role of an SD card for example:

$ update.sh -o /srv/tftp/

Note: For modules with eMMC (Apalis/Colibri iMX6, Apalis/Colibri T30, and Apalis TK1) remember to use also the ‘-c’ option to split the resulting rootfs into chunks usable for TFTP transmission. Starting with BSP version 2.7 Beta1 and later the ‘-c’ option has been removed and the resulting rootfs is by default split into chunks usable for TFTP transmission.

$ update.sh -c -o /srv/tftp/

Assuming that the module has a working U-Boot, run the following U-Boot commands to finish the update:

# run setupdate
# run update