Search by Tags

Flashing Embedded Linux to iMX7 Modules

 
Applicable for

Tags

Compare with Revision




Subscribe for this article updates

This article shows how to flash Embedded Linux onto Toradex Colibri iMX7S/iMX7D modules using the flashing utilities provided by Toradex images.

Prerequisites

The preparation steps need to be executed on the x86/x86-64 development host running a Linux distribution (e.g. Fedora or Ubuntu).

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

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

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install dosfstools e2fsprogs gawk mtools parted
sudo apt-get install zlib1g:i386 liblzo2-2:i386 libuuid1:i386 libusb-1.0-0:i386

E.g. for Ubuntu 14.04 (32-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 (32 and 64-bit)

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

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

Preparation

Warning: V2.7 Beta 1 release suffers a bug which does not allow to use an USB flash drive for flashing.

This prepares a SD card or USB flash drive for later use on the carrier board with the module which is to be flashed.

  1. Download the binary image and extract it with root permissions. The binary image files are named as follows:

    • Starting with version 2.7.2
      <module-type>_<image-name>_<version>.tar.bz2 where <module_type> is one of Apalis-iMX6, Apalis-T30, Apalis-TK1, Colibri-iMX6, Colibri-iMX7, Colibri-T20, Colibri-T30, or Colibri-VF and is one of LXDE-Image or Console-Image.
    • Older versions
      <module_type>_LinuxImageVx.yz.tar.bz2 where <module_type> is one of Apalis_iMX6, Apalis_T30, Apalis_TK1, Colibri_iMX6, Colibri_iMX7, Colibri_T20, Colibri_T30 or Colibri_VF.

    Binary images of the Toradex BSPs can be downloaded from http://developer1.toradex.com/files/toradex-dev/uploads/media/Colibri/Linux/Images/.

  2. Use any FAT formatted SD/uSD card or USB flash drive with enough free space (1GB or more recommended).

    Note: U-Boot expects a partition table (MBR) on the SD card or USB flash drive and the FAT partition to be the first partition!

  3. Find the mount point of your SD/uSD card or USB flash drive by e.g. using df or lsblk:

    [user@host ~]$ df
    Filesystem              1K-blocks      Used Available Use% Mounted on
    ...
    /dev/mmcblk0p1            7582228   2808272   4773956  38% /media/KERNEL
    [user@host ~]$ lsblk
    NAME                         MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
    ...
    mmcblk0                      179:0    0   7.3G  0 disk  
    └─mmcblk0p1                  179:1    0   7.3G  0 part  /media/KERNEL
    
  4. Run the update.sh script with the -o argument pointing to the mount point of the SD card or USB flash drive. For example assuming the SD card is mounted at /media/KERNEL:

    ./update.sh -o /media/KERNEL/
    

    At this point the SD/uSD card or USB flash drive should contain U-Boot, optionally the Linux kernel, the flashing scripts and the ext3 (for eMMC modules) resp. UBI (for NAND modules) root file system images.

Note: With the V2.6 Alpha 1 release updating using the USB flash drive does not work on Colibri iMX7S.

Flashing from U-Boot

Follow this step to upgrade or re-flash the module.

  1. Insert the prepared media into carrier board
    • SD card into SD card/MMC SDIO-socket (X15 on Evaluation Board, X10 on Iris)
    • USB flash drive using a standard USB host plug (e.g. X31/X32 on Evalution Board, X11 on Iris, top X6 on Viola)
  2. Connect the serial console to your host PC
    • Evaluation Board V3.1a/V3.2a: 115200 baud on UART_A (lower X25 resp. X27 depending on JP17/19) without any handshake
    • Iris V1.1a: 115200 baud on UART_A (X13) without any handshake
  3. Apply power or reset
  4. You should see U-Boot starting up

    • Hit any key immediately to stop auto booting

      U-Boot 2015.04+fslc+g10bc451 (Jun 28 2016 - 13:08:25)
      
      CPU:   Freescale i.MX7SOLO rev1.0 at 792 MHz
      CPU:   Temperature 37 C
      Reset cause: POR
      I2C:   ready
      DRAM:  256 MiB
      PMIC: RN5T567 LSIVER=0x1 OTPVER=0xd
      NAND:  512 MiB
      MMC:   FSL_SDHC: 0
      No panel detected: default to vga-rgb
      Display: vga-rgb (640x480)
      Video: 640x480x18
      In:    serial
      Out:   serial
      Err:   serial
      Model: Toradex Colibri iMX7 Solo 256MB V1.1A, Serial# 02794104
      Net:   FEC0
      Normal Boot
      Hit any key to stop autoboot:  0 
      Colibri iMX7 # 
      
    • At this point the U-Boot prompt should be visible.

    • Use run setupdate and run update command to update the module

      Colibri iMX7 # run setupdate
      ...
      Colibri iMX7 # run update
      ...
      

      Note: When updating from a release prior to V2.7, after running run update a reset is required and a second update step using run setupdate && run recreate_bcb && run update will be required to upgrade the Boot Configuration Block (BCB). The update scripts will print a warning to remind you when this additional step is necessary.

    • Alternatively, you can use individual commands to flash only the kernel, device tree or the root file system like this:

      Colibri iMX7 # run setupdate
      ...
      Colibri iMX7 # run prepare_ubi
      ...
      Colibri iMX7 # run update_kernel
      Colibri iMX7 # run update_fdt
      Colibri iMX7 # run update_kernel
      ...
      

Note: V2.6 Alpha 1, Colibri iMX7S: After flashing the environment is cleared, and the standard device tree imx7d-colibri.dtb gets loaded. Use the following commands to load the Colibri iMX7S device tree:

Colibri iMX7 # setenv fdt_file imx7s-colibri.dtb
Colibri iMX7 # saveenv

Note: On older V1.1A modules a direct update to 2.7b2 or later is not easy to do and we recommend updating to V2.6.1Beta1 first.

Flashing from Scratch

In case the module doesn't show any boot loader output or hangs at very early stages use the Recovery Mode to restore the module.

  1. Enter the recovery mode by pressing the "Recovery Mode" button on the Colibri Evaluation Board while power-cycling (make sure that there is no SD-card in the SD-card slot at the time of power-cycling).
  2. Connect the module using the USB device port and check whether your development host enumerated the module on the USB bus using lsusb:

    $ lsusb
    
    Bus 002 Device 038: ID 15a2:0076 Freescale Semiconductor, Inc.
    ...
    
  3. Download a U-Boot into the device memory using ./update.sh -d (from within the unpacked Toradex image):

    $ ./update.sh -d
    Colibri iMX7 rootfs detected
    Put the module in recovery mode and press [ENTER]...
    
    [sudo] password for user: 
    config file imx_flash/imx_usb.conf
    ...
    
  4. On the target, use the following commands to erase the flash completely and rewrite the boot configuration block as well as the Toradex config block:

    Colibri iMX7 # nand erase.chip
    Colibri iMX7 # run setupdate
    Colibri iMX7 # run create_bcb
    Colibri iMX7 # cfgblock create
    Is the module an IT version? [y/N] N
    Enter the module version (e.g. V1.1B): V1.1A
    Enter module serial number: 02794100
    Toradex config block successfully written
    Colibri iMX7 # run update
    ...