i.MX Factory Flashing with UUU, Fastboot and Yocto

i.MX Factory Flashing with UUU, Fastboot and Yocto

Share this post on:

Two of our customers needed the same thing at the end of their production lines. A blank board goes in and comes out programmed, and the operator only plugs a USB cable. The first builds a 4G voice gateway for building intercom and access control systems, around an i.MX6 Solo with an eMMC, mainline U-Boot 2022.01, a 5.10 kernel and A/B updates with RAUC. The second builds an automotive connectivity module on an i.MX8DXL that boots from a FlexSPI NOR flash, with the vendor U-Boot 2020.04. Both images were built with Yocto.

We built both flows on NXP’s Universal Update Utility, uuu, with a U-Boot that serves the factory and the field from one binary, and a Yocto class that packages everything the line needs. The boot stages involved, Boot ROM, SPL and U-Boot proper, are described in our article on the arm64 boot flow, and the container images that the ROMs of the i.MX8X and i.MX9 families load in the second part of that series. What follows is the i.MX6 flow in full, then what changed on i.MX8DXL.

Contents
  1. Flashing a Board over USB
  2. Building uuu with Yocto
  3. U-Boot Configuration
  4. One Bootloader for the Factory and the Field
  5. Where U-Boot Proper Lands in RAM
  6. The i.MX6 Manufacturing Script
  7. Packaging the Factory Bundle in Yocto
  8. The Same Approach on i.MX8DXL
  9. What the Production Lines Got

Flashing a Board over USB

When the boot ROM of an i.MX finds no valid boot image, or when the boot mode pins select serial download, it enters that mode. It enumerates as a USB HID device, with the ID 15a2:0061 on the i.MX6 Solo and DualLite, and accepts images over the Serial Download Protocol (SDP). uuu speaks SDP and fastboot, and runs a script, uuu.auto, that chains the three stages of figure 1.

uuu steps on the host and the i.MX6 stages they drive: Boot ROM serial download, SPL with SDP, U-Boot fastboot, programmed eMMC
Figure 1. A manufacturing run: the board shows up on USB three times, as the ROM, the SPL and U-Boot proper.

The ROM loads the SPL into on-chip RAM. The SPL, built with SDP support, enumerates again under its own ID and receives the whole u-boot-with-spl.imx, with U-Boot proper inside it, into DRAM. U-Boot proper starts fastboot, and from then on uuu sends images and U-Boot commands until the board is programmed.

Blank boards need no jumper. The gateway straps its boot mode pins to 00, boot from fuses, and as long as the BT_FUSE_SEL fuse is not programmed, the ROM falls back to serial download on its own. The last step of the script programs the boot fuses, and the next power-on boots from the eMMC.

Building uuu with Yocto

The factory PCs had no NXP tools installed, so each bundle carries its own uuu. We build it as a native recipe, statically linked, from the mfgtools repository at the 1.4.193 release:

# uuu-mfgtools-native_1.4.193.bb
SUMMARY = "NXP Universal Update Utility (uuu), static host build"
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://LICENSE;md5=38ec0c18112e9a92cffc4951661e85a5"

inherit cmake native deploy

DEPENDS = "libusb1-native zlib-native bzip2-native lzip-native openssl-native"

SRC_URI = "git://github.com/NXPmicro/mfgtools.git;protocol=https;branch=master"
SRCREV = "e56424c825752cbc23a34fc685d9d958adc30e62"
S = "${WORKDIR}/git"

COMPATIBLE_HOST = "x86_64.*-linux"
EXTRA_OECMAKE = "-DSTATIC=ON"

do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${B}/uuu/uuu ${D}${bindir}/
}

do_deploy() {
    install -m 0755 ${B}/uuu/uuu ${DEPLOYDIR}/
}
addtask deploy after do_install before do_build

The STATIC option of the mfgtools CMake build links libusb, zlib and OpenSSL into the binary, which then runs on any x86-64 Linux host. do_deploy places it in the deploy directory, where the bundle class of a later section picks it up. On Scarthgap and older, S stays as above; on Styhead and Walnascar it becomes ${UNPACKDIR}/git; from Whinlatter (5.3) on, the git fetcher unpacks into ${UNPACKDIR}/${BP}, the default S, and the line goes away.

U-Boot Configuration

SPL and U-Boot proper come from the same tree and the same defconfig, but they do not need the same features. The SPL needs a serial console, USB gadget support and the SDP gadget. This is the patch we applied to the board defconfig:

--- a/configs/board_imx6_defconfig
+++ b/configs/board_imx6_defconfig
@@ -17,6 +17,7 @@ CONFIG_DM_GPIO=y
 CONFIG_SPL_TEXT_BASE=0x00908000
 CONFIG_SPL_MMC=y
+CONFIG_SPL_SERIAL=y
 CONFIG_SPL=y
@@ -29,6 +30,9 @@ CONFIG_SD_BOOT=y
 CONFIG_BOOTDELAY=3
+CONFIG_SPL_USB_HOST=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_SDP_SUPPORT=y

With CONFIG_SPL_USB_SDP_SUPPORT, the SPL registers an SDP loader for the boot device BOOT_DEVICE_BOARD. When it selects that device, as the next section shows, it waits for U-Boot proper over USB instead of reading it from storage.

U-Boot proper gets fastboot with the uuu extensions, the eMMC hardware partitions as fastboot targets, the ChipIdea USB device controller of the i.MX6, and the sdp command:

CONFIG_CMD_USB_SDP=y
CONFIG_USB_FUNCTION_FASTBOOT=y
CONFIG_FASTBOOT_BUF_ADDR=0x12c00000
CONFIG_FASTBOOT_FLASH=y
CONFIG_FASTBOOT_UUU_SUPPORT=y
CONFIG_FASTBOOT_FLASH_MMC_DEV=3
CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y
CONFIG_FASTBOOT_MMC_BOOT1_NAME="board_mmc0boot0"
CONFIG_FASTBOOT_MMC_BOOT2_NAME="board_mmc0boot1"
CONFIG_FASTBOOT_MMC_USER_SUPPORT=y
CONFIG_FASTBOOT_MMC_USER_NAME="board_emmc"
CONFIG_FASTBOOT_CMD_OEM_PARTCONF=y
CONFIG_USB_GADGET=y
CONFIG_USB_GADGET_MANUFACTURER="vendor"
CONFIG_USB_GADGET_VENDOR_NUM=0x0525
CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
CONFIG_CI_UDC=y

What each group of options does:

  • CONFIG_FASTBOOT_UUU_SUPPORT adds the UCmd and ACmd fastboot commands, which run any U-Boot command. Every FB: ucmd line of the script depends on it.
  • CONFIG_FASTBOOT_FLASH_MMC_DEV=3 points fastboot at the eMMC, which is MMC device 3 (the uSDHC4 controller). The *_NAME options name its two boot partitions and its user area, so that FB: flash can target them.
  • CONFIG_FASTBOOT_BUF_ADDR is the DRAM buffer that receives downloaded files.
  • CONFIG_USB_GADGET_VENDOR_NUM and CONFIG_USB_GADGET_PRODUCT_NUM give U-Boot proper the ID 0525:a4a5, which uuu recognises as a fastboot device. In the SPL, the i.MX code adds 0xfff to the product ID, which gives 0525:b4a4, the ID uuu expects for an SPL in SDP mode.
  • CONFIG_CMD_USB_SDP adds the sdp command to U-Boot proper; our board code tests this option.

One more patch was specific to this board and release. It makes the ChipIdea gadget driver use the legacy low-level initialisation, usb_lowlevel_init(), instead of the driver model path, with the matching changes in the EHCI driver. It is a local workaround that we did not send upstream:

--- a/drivers/usb/gadget/ci_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -1019,7 +1019,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 	if (!driver->bind || !driver->setup || !driver->disconnect)
 		return -EINVAL;

-#if CONFIG_IS_ENABLED(DM_USB)
+#if 0
 	ret = usb_setup_ehci_gadget(&controller.ctrl);
 #else
 	ret = usb_lowlevel_init(0, USB_INIT_DEVICE, (void **)&controller.ctrl);

The same change is made in usb_gadget_unregister_driver(), and ehci-hcd.c and ehci-mx6.c keep their non driver model functions built, since the gadget now calls them.

One Bootloader for the Factory and the Field

The same u-boot-with-spl.imx runs in the factory and on the units in the field. Three places decide which path a boot takes, as figure 2 shows.

Boot ROM, SPL and U-Boot proper each choose between the field path to Linux and the factory path to fastboot
Figure 2. The ROM, the SPL and U-Boot proper each choose between the field path and the factory path.

The ROM decision comes from the pins and the fuses, as described above. The other two are code we wrote or fixed.

In the SPL: board_boot_order()

The first boot from the eMMC stopped in the SPL. In the SPL of this board, MMC1 is the SD card slot and MMC2 is the eMMC on uSDHC4, but the mainline spl_boot_device() for i.MX6 returned BOOT_DEVICE_MMC1 for both the SD and the eMMC boot modes:

U-Boot SPL 2022.01 (Jan 10 2022 - 18:46:34 +0000)
DDR3: calibration done
Trying to boot from MMC1
Card did not respond to voltage select! : -110
spl: mmc init failed with error: -95
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Our first fix changed that return value:

--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -98,7 +98,7 @@ u32 spl_boot_device(void)
 	/* MMC/eMMC: 8.5.3 */
 	case IMX6_BMODE_MMC:
 	case IMX6_BMODE_EMMC:
-		return BOOT_DEVICE_MMC1;
+		return BOOT_DEVICE_MMC2;
 	/* NAND Flash: 8.5.2, Table 8-10 */
 	case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX:
 		return BOOT_DEVICE_NAND;

That change applies to every i.MX6 board, so the final version overrides board_boot_order() in the board file instead. It maps the SD and eMMC modes to their devices and sends every other case, including a serial download boot, to BOOT_DEVICE_BOARD, the SDP loader, which also comes second as a last resort:

--- a/board/vendor/board_imx6/board_imx6.c
+++ b/board/vendor/board_imx6/board_imx6.c
@@ -130,6 +131,40 @@ int board_early_init_f(void)
+void board_boot_order(u32 *spl_boot_list)
+{
+	u8 boot_dev;
+	u32 bootmode = readl(&src_base->sbmr2);
+	u32 bootcfg = imx6_src_get_boot_mode();
+
+	switch ((bootcfg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
+	case IMX6_BMODE_SD:
+	case IMX6_BMODE_ESD:
+		boot_dev = BOOT_DEVICE_MMC1;	/* SD card slot */
+		break;
+	case IMX6_BMODE_MMC:
+	case IMX6_BMODE_EMMC:
+		boot_dev = BOOT_DEVICE_MMC2;	/* eMMC on uSDHC4 */
+		break;
+	default:
+		boot_dev = BOOT_DEVICE_BOARD;	/* serial download */
+		break;
+	}
+
+	/* BMOD = 01: serial download forced by the pins */
+	if (((bootmode >> 24) & 0x03) == 0x01)
+		boot_dev = BOOT_DEVICE_BOARD;
+
+	spl_boot_list[0] = boot_dev;
+	spl_boot_list[1] = BOOT_DEVICE_BOARD;
+}

BMOD, bits 24 and 25 of the SBMR2 register, reports how the boot mode pins were sampled. On a blank board that fell back to serial download, the boot configuration read from the fuses is empty and lands in the default case, so the SPL goes to SDP either way. After this change, a board strapped for the eMMC reaches U-Boot proper:

U-Boot SPL 2022.01 (Jan 10 2022 - 18:46:34 +0000)
DDR3: calibration done
Trying to boot from MMC2

[...]

U-Boot 2022.01 (Jan 10 2022 - 18:46:34 +0000)

CPU:   Freescale i.MX6SOLO rev1.2 at 792 MHz
Reset cause: POR
DRAM:  512 MiB
MMC:   FSL_SDHC: 2, FSL_SDHC: 3
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0

MMC2 is selected, U-Boot proper loads its environment from the eMMC, and the normal boot of Linux follows.

In U-Boot proper: board_late_init()

U-Boot proper must not boot Linux when it came over USB. is_boot_from_usb(), already provided for the i.MX6, reads the power-down register of the first USB PHY and returns true when the PHY receiver is powered, the state in which the ROM leaves it after a serial download. When it returns true, our board code starts fastboot at once:

--- a/board/vendor/board_imx6/board_imx6.c
+++ b/board/vendor/board_imx6/board_imx6.c
@@ -185,6 +185,16 @@ int board_late_init(void)

+#ifdef CONFIG_CMD_USB_SDP
+	if (is_boot_from_usb()) {
+		printf("Boot from USB for uuun");
+		run_command("mmc dev 3", 0);
+		env_set("bootdelay", "0");
+		env_set("bootcmd", "fastboot 0");
+	}
+#endif /* CONFIG_CMD_USB_SDP */
+
 #ifdef CONFIG_CMD_BMODE
 	add_board_boot_modes(board_boot_modes);
 #endif

bootdelay at 0 skips the countdown, and bootcmd becomes fastboot 0, so uuu finds the fastboot device a moment after the SPL has handed over. Selecting mmc dev 3 first makes the eMMC the current device for the mmc commands of the script.

Where U-Boot Proper Lands in RAM

In SDP mode, the SPL receives a file at an address and then jumps to another one. uuu needs both values, and they follow from the layout of u-boot-with-spl.imx in figure 3.

Layout of u-boot-with-spl.imx on the eMMC: IVT and DCD at 1 KB, SPL, then U-Boot proper with its 64-byte header at 69 KB
Figure 3. u-boot-with-spl.imx on the eMMC: the ROM reads it at 1 KB, and U-Boot proper starts 0x11000 bytes further.

The ROM reads the boot image at 1 KB in the enabled eMMC boot partition, boot0 here, so the file starts there, with the IVT and DCD that the ROM parses, then the SPL. U-Boot proper, as a legacy image with a 64-byte header (u-boot.img), sits 0x11000 bytes into the file, which is 69 KB on the device, sector 0x8A, where the SPL looks for it. Its load address is in the mkimage line of the U-Boot build log:

$ grep -rn "u-boot-dtb.img" temp/log.do_compile*
log.do_compile.17491:778: ./tools/mkimage -A arm -T firmware -C none -O u-boot -a 0x17800000 -e 0x17800000 -n "U-Boot 2022.01 for board" -d u-boot.bin u-boot-dtb.img >/dev/null && cat /dev/null

file reads the same value from the image header:

$ file u-boot-dtb.img
u-boot-dtb.img: u-boot legacy uImage, U-Boot 2022.01 for board, Firmware/ARM, Firmware Image (Not compressed), 498284 bytes, Mon Jan 10 18:46:34 2022, Load Address: 0x17800000, Entry Point: 0x17800000, Header CRC: 0xCED54C75, Data CRC: 0x3EF2F095

The offset of U-Boot proper in the combined file comes from the legacy image magic, IH_MAGIC (0x27051956) in include/image.h. The value appears several times in u-boot.img, as constants in the code, but only the occurrence at offset 0 is the header, and its first 8 bytes are unique:

$ hexdump -C u-boot.img | grep "27 05 19 56"
00000000  27 05 19 56 ac 19 b5 65  61 dc 7f 0a 00 08 20 e8  |'..V...ea..... .|
00003360  97 89 84 17 06 89 84 17  27 05 19 56 7d e6 84 17  |........'..V}...|
00004bb0  02 20 08 bd 01 20 fc e7  27 05 19 56 80 6c 00 38  |. ... ..'..V.l.8|
00006b60  27 05 19 56 7a e6 84 17  8f e6 84 17 38 89 84 17  |'..Vz.......8...|

Searching the combined file for those 8 bytes finds them once:

$ hexdump -C u-boot-with-spl.imx | grep "27 05 19 56 ac 19 b5 65"
00011000  27 05 19 56 ac 19 b5 65  61 dc 7f 0a 00 08 20 e8  |'..V...ea..... .|

In SDP mode, the SPL runs U-Boot proper where it was written, without copying it, so the header must land 64 bytes below the load address, at 0x177fffc0. The whole file is therefore written at 0x177fffc0 minus 0x11000, that is 0x177eefc0, and the jump goes to the header, which the SPL parses before starting U-Boot proper:

SDPV: write -f u-boot-with-spl.imx -addr 0x177eefc0
SDPV: jump -addr 0x177fffc0

Both values hold only for this layout and this load address. Another CONFIG_SPL_PAD_TO, which places U-Boot proper at 0x11000, or another CONFIG_SYS_TEXT_BASE moves them, which is why the generated script carries a warning next to these two lines.

The i.MX6 Manufacturing Script

This is the uuu.auto generated by the class of the next section, which fills in UBOOT_HEX_SIZE_IN_SECTORS:

uuu_version 1.4.193

SDP: boot -f u-boot-with-spl.imx

# The -chip parameter lets uuu find the ROM information for the SPL.
# Without it, the jump fails with "can't get rom info".
CFG: SDPU: -chip MX6D -vid 0x0525 -pid 0xb4a4

# Do not change these addresses: they follow from our U-Boot binary.
SDPV: write -f u-boot-with-spl.imx -addr 0x177eefc0
SDPV: jump -addr 0x177fffc0

FB: ucmd setenv fastboot_buffer 0x12c00000
FB: download -f u-boot-with-spl.imx

# boot0 hardware partition: U-Boot at sector 2 (1 KB)
FB: ucmd mmc dev 3 1
FB: ucmd mmc erase 0 0x4000
FB: ucmd mmc write ${fastboot_buffer} 0x2 0x${UBOOT_HEX_SIZE_IN_SECTORS}
# boot1 hardware partition: same image
FB: ucmd mmc dev 3 2
FB: ucmd mmc erase 0 0x4000
FB: ucmd mmc write ${fastboot_buffer} 0x2 0x${UBOOT_HEX_SIZE_IN_SECTORS}

# boot from boot0, back to the user area
FB: ucmd mmc partconf 3 1 1 0

# user area: GPT, A/B root file systems, data, log
FB: flash -raw2sparse board_emmc mmc.img

# boot from eMMC on uSDHC4, 1-bit bus
FB: ucmd fuse prog -y 0 5 0x1860
# BT_FUSE_SEL: boot from the fuses from now on
FB: ucmd fuse prog -y 0 6 0x10

FB: done
SDPU: done

What the less obvious lines do:

  • FB: flash always writes from offset 0 of a partition, while the ROM expects the image at 1 KB in the boot partition. The script therefore downloads the file once and writes it with mmc write at sector 2 of boot0 and boot1, after erasing their start.
  • mmc partconf 3 1 1 0 sets boot acknowledge, makes boot0 the boot partition, and gives access back to the user area.
  • FB: flash -raw2sparse converts mmc.img, the wic image of the user area, into sparse chunks on the fly, so empty blocks are not sent.

Figure 4 shows the eMMC at the end of the run.

eMMC after manufacturing: U-Boot in boot0 and boot1, A/B root and data partitions and a log partition in the user area, boot fuses programmed
Figure 4. The eMMC after manufacturing: U-Boot in both boot partitions, the A/B layout in the user area, and the boot fuses programmed.

A wrong fuse value cannot be undone, so we documented every bit in the script itself. The values come from the fuse map of the i.MX6 Solo:

Fuse wordBitsMeaning
5 (0x450)0x60, BOOT_CFG1 bits 5 and 6boot from MMC or eMMC
5 (0x450)0x1800, BOOT_CFG2 bits 3 and 4use the uSDHC4 controller
5 (0x450)BOOT_CFG2 bit 6 left blank1-bit bus; 0x5860 instead of 0x1860 would select 8 bits
6 (0x460)0x10, bit 4BT_FUSE_SEL: the boot configuration fuses are valid

Once BT_FUSE_SEL is set, the ROM uses the fused configuration instead of entering serial download, and the board boots from its eMMC from then on.

Packaging the Factory Bundle in Yocto

The factory receives one directory per release, with uuu and a zip that holds uuu.auto, u-boot-with-spl.imx and mmc.img. A class inherited by the image recipe builds it after the wic image:

# fastboot-manufacturing-bundle.bbclass
MFG_DIR = "${MACHINE}-manufacturing-${DATETIME}"
MFG_DIR_LINK = "${MACHINE}-manufacturing"
BUNDLE_NAME = "${MACHINE}-manufacturing-bundle"
MFG_DIR[vardepsexclude] = "DATETIME"

do_generate_uuu_configuration() {
    UBOOT_HEX_SIZE_IN_SECTORS=$(printf "%Xn" $(stat -L -c %b ${DEPLOY_DIR_IMAGE}/${UBOOT_BINARY}))

    cat > uuu.auto << EOF
uuu_version 1.4.193
[...]
FB: ucmd mmc write ${fastboot_buffer} 0x2 0x${UBOOT_HEX_SIZE_IN_SECTORS}
[...]
FB: done
SDPU: done
EOF
}

do_manufacturing_bundle() {
    cd ${DEPLOY_DIR_IMAGE}

    install -m 755 -d ${MFG_DIR}/${BUNDLE_NAME}
    install -m 644 ${PN}-${MACHINE}.wic ${MFG_DIR}/${BUNDLE_NAME}/mmc.img
    install -m 644 ${UBOOT_BINARY}      ${MFG_DIR}/${BUNDLE_NAME}

    do_generate_uuu_configuration
    install -m 644 uuu.auto             ${MFG_DIR}/${BUNDLE_NAME}
    install -m 755 uuu                  ${MFG_DIR}

    cd ${MFG_DIR} && zip -r -j ${BUNDLE_NAME}.zip . && cd - && rm -rf ${MFG_DIR}/${BUNDLE_NAME}
    ln -snf ${MFG_DIR} ${MFG_DIR_LINK}
}
addtask do_manufacturing_bundle after do_image_complete before do_build

IMAGE_FSTYPES += "wic"
EXTRA_IMAGEDEPENDS += "virtual/bootloader uuu-mfgtools-native zip-native"
do_manufacturing_bundle[depends] += "uuu-mfgtools-native:do_deploy"
do_manufacturing_bundle[depends] += "${PN}:do_image_wic"

do_generate_uuu_configuration takes the space allocated to U-Boot, in 512-byte blocks, with stat -c %b, which is the file size rounded up to a block of the build host file system, and prints it in hexadecimal, because mmc write reads its numbers as hexadecimal. Generating the script at build time keeps that size in step with the binary in the same bundle. On the line, the operator plugs the board and runs:

sudo ./uuu <machine>-manufacturing-bundle.zip

uuu opens the zip, reads uuu.auto from it and waits for the board. Its daemon mode, -d, keeps it waiting for the next board after each run.

The Same Approach on i.MX8DXL

On the automotive module, the i.MX8DXL boots from a FlexSPI NOR flash, and the eMMC holds the system. The ROM of the i.MX8X family, to which the i.MX8DXL belongs, loads containers instead of an IVT image, with the SECO and SCU firmware in front of TF-A and U-Boot, and its serial download protocol is SDPS. Figure 5 shows the flow.

i.MX8DXL manufacturing: SDPS loads a fastboot U-Boot that writes the SPI NOR twice and the eMMC user area
Figure 5. On i.MX8DXL, a fastboot U-Boot loaded over USB programs the SPI NOR and the eMMC.

The build produces three images with imx-mkimage:

  • flash_ddr_uboot.bin: SECO firmware, SCU firmware and a U-Boot with fastboot, loaded over USB at manufacturing.
  • flash_spinor_all.bin: the production boot image for the NOR, with SECO and SCU firmware, the Cortex-M4 image and U-Boot. The build swaps the bytes of each 16-bit word and adds the FlexSPI configuration header for 200 MHz DDR. The ROM does not accept this image over SDPS, hence the separate image above.
  • flash_os.bin: a container with the kernel.

The script programs both memories:

uuu_version 1.0.1

# fastboot-enabled U-Boot, run from RAM
SDPS: boot -f flash_ddr_uboot.bin

# SPI NOR: boot image at 0 and a second copy at 4 MB
FB: ucmd setenv fastboot_buffer ${loadaddr}
FB: download -f flash_spinor_all.bin
FB: ucmd sf probe
FB[-t 40000]: ucmd sf erase 0 +${fastboot_bytes}
FB[-t 20000]: ucmd sf write ${fastboot_buffer} 0 ${fastboot_bytes}
FB[-t 40000]: ucmd sf erase 0x00400000 +${fastboot_bytes}
FB[-t 20000]: ucmd sf write ${fastboot_buffer} 0x00400000 ${fastboot_bytes}

# eMMC user area, partition 0
FB: ucmd setenv fastboot_dev mmc
FB: ucmd setenv mmcdev ${emmc_dev}
FB: ucmd mmc dev ${emmc_dev} 0
FB: flash -raw2sparse all mmc.img

# BOOT_ACK=1, BOOT_PARTITION_ENABLE=7 (user area), PARTITION_ACCESS=0
FB: ucmd mmc partconf ${emmc_dev} 1 7 0
FB: done

Three things differ from the i.MX6 script:

  • fastboot_buffer comes from ${loadaddr} in the U-Boot environment. The i.MX6 value would point outside DRAM, which starts at 0x80000000 on the i.MX8DXL.
  • FB[-t 40000] raises the timeout of a single command to 40 seconds, since erasing several megabytes of NOR takes longer than uuu waits by default.
  • No fuse is programmed by this script.

On the Yocto side, a recipe deploys uuu next to these images, and the bundle is assembled from the deploy directory in the same way as on i.MX6.

What the Production Lines Got

For both products, the factory receives a directory built by the same Yocto build as the release. It takes one cable and one command, and on i.MX6 the board ends up with its boot source locked by its fuses. The i.MX6 U-Boot also has the ums command enabled, which exposes the eMMC as a USB mass storage device. It is handy at the bench, but it shows one hardware partition at a time and needs manual switching between them, which is why the lines use fastboot.

The same pattern applies to other SoCs as long as the ROM has a USB recovery mode and a host tool can script it. Which method do you use on your production lines? Tell us in the comments.

Share this post on:

Leave a Reply

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