Introduction

Flashing an eMMC of produced board is one of the crucial manufacturing procedures. This post series presents how one can take advantage of i.MX6 features and open source tools to prepare themselves with quite robust and easy to use process.

Target reference platform is Hummingboard Edge.

General concept

The general concept is inspired by this great bootlin (former FreeElectrons) post: I’ve run into some issues while trying to do something similar on Hummingbard Edge, so decided to share my experience.

The general flow looks like:

  • Load U-Boot to DDR using Serial Download Protocol
  • U-Boot enters fastboot mode
  • Pull in the image via fastboot protocol

In the first post, we will focus on loading U-Boot to DDR using SDP.

Hardware preparation

Before we start, we need to prepare hardware first. HB Edge has USBOTG signals connected to the upper back USB-A connector:

hb usb back

To utilize it we should prepare cable as suggested by the SolidRun wiki

They suggest cutting two USB cables in half to create USB-A male-male cable. To make things easier we can buy one of those directly. An example of such is this one

We still need one more rework:

  • Remove the main insulation from the middle of the cable,
  • Cut the power wire (usually the read one),
  • Solder it back with additional series resistance. SolidRun suggest to use 1-10 Ohms. I am using 2×10 Ohm resistors in parallel which gives me around 5 Ohms.

Resistors soldered on prototype board:

resistors on prototype board

Additional series resistance in power wire path:

power cable soldered to resistors

Connect USB A host to host cable to USB OTG port (upper port of U5 USB connector on HB Edge board).

Now we should check whether the cable was prepared correctly. If it is, the USB device should be detected as Freescale SoC in Recovery Mode:

It may be convenient to set up an udev rule right away, so we can have access to device as a user later:

imx-usb-loader

This is an open-source alternative to NXP mfgtool, which allows sending binaries over UART or USB.

Getting imx_usb_loader:

Output are 2 files: imx_uart and imx_usb that allow to send files to platform using UART or USB respectively.

imx_usb_loader is able to download a single file u-boot.imx. In case of boards with SPL support, we have 2 binaries: SPL and u-boot.img. Loading of both of them is possible using imx_usb_loader, but it is required to take advantage of the U-Boot Serial Download Protocol support

U-Boot SDP support was introduced in October 2017. So we need at least v2017.11 release. I’m using the most recent v2018.01.

Following additional configuration options have to be selected to enable SDP support in U-Boot:

Load SPL and u-boot.img separately

  • Copy SPL and u-boot.img output files to the root directory of the imx_usb_loader tool
  • Send SPL via USB:

output:

  • HB serial console output will show:

Notice that once SPL is loaded, and target board enters SDP handler state, the USB device seen by host PC will change.

In my case it changed from:

to:

It does not look like a proper USB device VID / PID pair. Even if we set those in imx_usb.conf:

We are getting following error message from the tool:

The U-Boot SDP documentation states that those values should be set by configuration options: CONFIG_G_DNL_(VENDOR|PRODUCT)_NUM and it should default to:

Grepping U-Boot sources shows only a few of those options in some of the board config files:

Quick search through configuration options shows that gadget USB VID / PID is set through following options:

The strange thing to me is that PID defaults to 0x0, while in my case it is detected as 0x0000:0x0fff.

Setting those to the ones as described in the documentation:

Gives us following results:

  • lsusb output gives following output:

Note that in this case the PID is also different than specified in the configuration.

I have also used the recent master branch and above information applies there as well.

In this case, we are able to flash u-boot.img via SDP.

On more thing to do before flashing u-boot.img is to add VID / PID pair to imx_usb config:

Now we can download SPL and u-boot.img with command below:

output of u-boot.img booting:

The interesting thing is that whenever we enter U-Boot prompt and enter SDP mode:

The USB PID seen by my host PC changes to the one set in the configuration:

Load SPL and u-boot.img in one run

It is possible to download both SPL and u-boot.img with one imx_usb command execution. To do that, we need to create configuration files with following content:

  • imx_usb.conf:

  • mx6_usb_rom.conf

  • mx6_usb_sdp_spl.conf:

Above configuration files are also present in 3mdeb fork of imx_usb_loader

With such configuration in place, calling ./imx_usb gives following output:

and the board boots with U-Boot as shown previously.

Summary

  • imx_usb_loader is really handy tool for downloading binaries (especially the bootloader) directly into memory.
  • I’ve run into some strange behavior of U-Boot USB Gadget device PID. I will try to track down what really happens in the code there.
  • I’ve run into some outdated U-Boot documentation. I can try updating it.
  • Configuration files for imx_usb_loader can be found at 3mdeb fork
  • Final configuration of U-Boot target for Hummingboard Edge which adds SDP support can be found on 3mdeb fork
  • I am going to present next steps towards our goal in an upcoming post from this series.