This article offers ideas and examples how production flashing of U-Boot and Linux for Toradex Colibri VF50 & VF61 Modules can be realized. Since Linux offers a lot flexibility when it comes to root file system used, partitioning/configuration or update procedures, this article is meant as a starting point for production programming, which might need individual adoption.
The recommended way is to use a boot loader to flash the production U-Boot boot loader and use that U-Boot to flash the Linux root file system. For Colibri VF50/VF61 the complete flashing cycle typically look like this:
Start Eboot => Flash U-Boot using Eboot => Reset => Start U-Boot => Flash Linux root file system
In the first part this article describes methods of flashing, in a second part we will see a recommendation of how to automate these steps.
By default Toradex modules are shipped with the Windows CE boot loader Eboot, the first step is therefor to switch to the U-Boot boot loader. Following are three variants how to get to a U-Boot prompt.
Eboot can be used to load the U-Boot image from SD card and flash it to the appropriate location using the "flashloader" command. This is typically very fast (~2 seconds). This method is also described in Flashing Embedded Linux to Vybrid Modules.
Note: Since Colibri VF50/VF61 went into volume production, the modules are delivered with WinCE pre-installed. Flashing U-Boot from Eboot has been tested with 1.1Beta2 and later Eboot versions. However, it is guaranteed that modules which are shipped with WinCE, have 1.1Beta2 or newer pre-installed by default.
The NXP/Freescale Vybrid SoC's internal Boot ROM offers a recover mechanism which can be used to download a boot loader over UART (serial downloader). This mode can always be used, since there is no running boot loader on the module required. However, depending on the boot loaders size, it takes up to 30 seconds to download the boot loader.
Eboot offers a TFTP Download mode which allows to download a binary into RAM and execute it directly. This can be used to download and run U-Boot. This method is reasonably fast (~10s) but also somewhat more complex (requires a local DHCP and a TFTP client). Furthermore, a custom U-Boot is required since the U-Boot's default start location in SRAM is occupied by Eboot. By using the lower main memory area (e.g. 0x80008000 as Text base) and disabling DDR3 RAM initialization, one can bootstrap U-Boot also from main memory.
Eboot also expects a specific header which contains the load address. The Toradex utility CreateTBin allows to create a binary which can be handled by Eboot (execute this command using Windows, the output file will be named u-boot_TBin.bin)
CreateTBin.exe u-boot.bin -a 0x80008000 -j
Once Eboot is in Download To RAM mode, the binary can be downloaded using TFTP (this is the command line using the Linux tftp utility)
tftp -4 -m binary 192.168.10.63 980 -c put u-boot_TBin.bin boot.bin
A tested version of U-Boot 2015.04 (V2.5 Beta 3) is available here: u-boot_TBin.bin
Once in U-Boot, there are lots of variants to fetch the root file system image. The fastest method to load data from a media is using a USB mass storage device (24 MB/s). Loading from a SD cards is somewhat slower (14 MB/s). Loading the image over network is limited to ~8 MB/s (due to 100-MBit, depending on TFTP configuration even slower).
Since Eboot allows to flash U-Boot from a SD card, using a SD card is a good common denominator (only one media required).
Please refer to the Flashing Embedded Linux to Vybrid Modules how-to create the SD card using the update.sh script and how-to use the media to flash the root file system.
Please refer to the Flashing Embedded Linux to Vybrid Modules how-to create a USB flash drive using the update.sh script and how-to use the media to flash the root file system.
Since the pre-installed boot loader does not allow a unattended/self-flashing mode, there is a automation system required. A common way is to automate the control over the serial console to execute the appropriate boot loader commands. The commands can be sent to the module using an Python script (see below). This adds some complexity, but has also advantages over unattended solutions: The production process can be altered without rebuilding software and it allows to store production log files easily.
To execute the commands on a serial console, a easy and reliable way is to use expect. The scripting language Python offers the Python variant of expect called pexect.
Since most distribution come with Python pre-installed, using a Linux distribution for production is the easiest way. Typically serial port support and pexect is not pre-installed. To install these packages on Ubuntu 14.04 LTS, use the following command:
$ sudo apt-get install python-pexpect python-serial
Python and pyserial are available on Windows too, however winexect or wexpect might be viable replacements.
An example script which flashes the Toradex Linux images from a SD card, can be found here. To flash a module, no matter if it has Eboot or U-Boot pre-installed, simply start the script on the TTY where UART_A of the module is connected to:
./vfxx-production.py --tty /dev/ttyUSB1
To use the EBoot TFTP functionality, specify the prepared U-Boot
./vfxx-production.py --tty /dev/ttyUSB1 --tftp u-boot_TBin.bin