Booting my custom U-Boot (built with Yocto) from SD card without overwriting the preinstalled one on Verdin iMX8MP

Hi Toradex team,

I’m currently working on a Yocto project with Mender on a Verdin iMX8MP module.
Right now, I boot the board by flashing an SD card with my .gptimg image, and the system starts correctly — however, it still uses the preinstalled U-Boot stored in the eMMC.

My goal is to boot directly from the SD card using my own U-Boot binary, without overwriting or modifying the default U-Boot already flashed in the module.

I’d like to know:

  1. Is it possible to place my U-Boot binaries directly on the SD card and have the board boot from it instead of the internal eMMC?
  2. Are there any DIP switches or boot mode configurations that can force the SoC to use the U-Boot from the SD card?
  3. What is the recommended approach from Toradex to test a custom U-Boot safely (without risking the original one in eMMC)?
  4. Among the binaries generated by Yocto, which file should be used for SD booting on the Verdin iMX8MP?

Here’s what Yocto produces in my deploy directory:

flash.bin-verdin-imx8mp-sd
flash.bin.tagged
imx-boot -> flash.bin-verdin-imx8mp-sd
u-boot-sd-2024.07-r0.bin
u-boot-spl.bin-sd-2024.07-r0
u-boot-verdin-imx8mp.bin -> u-boot-sd-2024.07-r0.bin
u-boot-initial-env-verdin-imx8mp-sd-2024.07-r0

Which of these is the correct one to use for booting from SD?
And is there a recommended way to load this U-Boot without altering the factory one in eMMC?

Thanks in advance for your help and insights!

Best regards,
Stanley

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


Custom U-Boot Booting from SD Card on Verdin iMX8MP

Based on the available documentation, I can provide guidance on your U-Boot customization requirements for the Verdin iMX8MP.

1. SD Card U-Boot Binary Selection

From your Yocto build output, the correct binary for SD card booting is flash.bin-verdin-imx8mp-sd(1). This is the complete bootloader image that includes both the SPL (Secondary Program Loader) and U-Boot proper, specifically configured for SD card boot mode.

2. Boot Mode Configuration

The Verdin iMX8MP follows standard i.MX8MP boot sequence behavior(2). The SoC’s boot ROM will attempt to boot from different sources based on the boot mode pins and available bootable media. When an SD card with a proper bootloader is inserted, the boot ROM can prioritize it over the internal eMMC.

3. DIP Switch Implementation

The documentation shows that DIP switches can be used to modify boot behavior(3). For the Colibri iMX6ULL example, DIP switches were implemented to change boot processes by reading GPIO values in the board_late_init function(3):

#define DIP_SW0	IMX_GPIO_NR(4, 26)
#define DIP_SW1	IMX_GPIO_NR(4, 14)

(3)

The same concept can be applied to the Verdin iMX8MP, though you would need to identify appropriate GPIO pins from the datasheet(4).

4. U-Boot Environment Variables

The boot process can be controlled through U-Boot environment variables(2). The boot_targets variable defines the sequence of device types U-Boot will try to boot from, in priority order(2). For example:

  • boot_targets=mmc1 mmc2 dhcp would try SD card (mmc1) before internal eMMC (mmc2)(2)

5. Safe Testing Approach

The recommended approach for testing custom U-Boot safely involves:

  1. Using Recovery Mode: The recovery mode can be used to download new software even when the bootloader is no longer capable of booting(5). Enter recovery mode by pulling the dedicated recovery pin (SODIMM pin 246) down with <1kΩ during initial power on(5).

  2. SD Card Priority: Place your custom flash.bin-verdin-imx8mp-sd on the SD card’s boot partition. The boot ROM should prioritize the SD card if it contains a valid bootloader.

6. Implementation Steps

  1. Use the flash.bin-verdin-imx8mp-sd binary from your Yocto build
  2. Create a properly formatted SD card with a FAT32 boot partition
  3. Place the flash.bin file at the correct offset on the SD card
  4. Ensure no bootable SD card is present when testing recovery mode functionality(5)

7. Yocto Integration

The documentation shows that U-Boot customization can be achieved through Yocto by creating bbappend files and applying patches(6). You can modify kernel parameters and boot behavior through U-Boot configuration files(6).

Note: Always ensure you have access to the recovery mode functionality (SODIMM pin 246) on your carrier board to recover from any boot failures(5).

Best regards,
Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Thanks for your detailed answer @ToradexAI !

Here is the partition layout of my .gptimg image that I flash to the SD card using:

pv Verdin-iMX8MP_Reference-Minimal-Image.gptimg | sudo dd of=/dev/sda bs=16M conv=fsync

Here’s what I get when I mount it:

=== Partition /dev/mapper/loop0p1 ===
boot.scr  imx8mp-verdin-nonwifi-dahlia.dtb  imx8mp-verdin-nonwifi-ivy.dtb  imx8mp-verdin-nonwifi-yavia.dtb  
imx8mp-verdin-wifi-dev.dtb  imx8mp-verdin-wifi-mallow.dtb  overlays  Image.gz  overlays.txt

=== Partition /dev/mapper/loop0p2 ===
bin  boot  data  dev  etc  home  lib  lost+found  media  mnt  proc  root  run  sbin  srv  sys  tmp  uboot  usr  var

=== Partition /dev/mapper/loop0p3 ===
lost+found

=== Partition /dev/mapper/loop0p4 ===
lost+found  mender  u-boot

My question is:
Can I simply place my U-Boot binary (flash.bin-verdin-imx8mp-sd) into partition 1 (the boot partition), and the board will automatically boot from this SD card U-Boot instead of the preinstalled one in eMMC?

Or do I need to format or structure the SD card differently for the i.MX8MP ROM to detect and use the U-Boot from SD?

Thanks again for your guidance!

Best regards,
Stanley

SD Card U-Boot Placement Requirements

Based on the Toradex documentation, simply placing the U-Boot binary in partition 1 (the boot partition) will not work for the i.MX8MP boot ROM(1).

Correct U-Boot Placement for SD Card Boot

The U-Boot binary needs to be written to specific raw sectors on the SD card, not to a filesystem partition(1). According to the documentation, when deploying U-Boot to an image, you need to integrate the U-Boot artifacts into a Toradex Easy Installer package by replacing the bootloader binaries with the ones you have built(1).

Image.json Configuration

The deployment process requires adjusting the image.json file to ensure the bootloader binaries are loaded correctly(1). Here’s an example configuration from the documentation:

"name": "mmcblk0boot0",
"erase": true,
"content": {
    "filesystem_type": "raw",
    "rawfiles": [
        {
            "filename": "u-boot.imx",
            "dd_options": "seek=2"
        }
    ]
}

(1)

Recommended Approach

For your Verdin iMX8MP with Mender integration:

  1. Use Toradex Easy Installer: The recommended approach is to create a proper Toradex Easy Installer package that includes your custom U-Boot binary(1).

  2. Raw Sector Writing: The flash.bin-verdin-imx8mp-sd needs to be written to the raw SD card sectors at the correct offset, not placed in a filesystem partition(1).

  3. Preserve Your Current Setup: Since you’re using a .gptimg image with Mender, you’ll need to modify the image creation process to include your custom U-Boot at the proper raw offset while maintaining the existing partition structure.

Technical Details

The i.MX8MP boot ROM looks for the bootloader at specific raw offsets on the storage device, not within filesystem partitions(1). This is why your current partition-based approach won’t work - the boot ROM never examines the contents of filesystem partitions during the initial boot process.

The community discussion confirms this behavior, where a user discovered that for NAND flash modules, the Image Vector Table (IVT) is located at specific offsets rather than in filesystem locations(2).

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Thanks a lot for your explanation @ToradexAI

Just to confirm: would it then be simpler to flash my image using Toradex Easy Installer in order to deploy my custom U-Boot along with my .gptimg?

If that’s the recommended way, could you please tell me how the integration should be done on the Yocto side to include my own U-Boot binary in the final Toradex Easy Installer package?

Right now, when I build and deploy using Easy Installer, I get the following files:

image.json
imx-boot
Reference-Minimal-Image-imx8mp-verdin.bootfs.tar.xz
Reference-Minimal-Image-imx8mp-verdin.tar.xz
u-boot-initial-env-sd

Where exactly should I replace or reference my custom U-Boot binary (u-boot.bin or imx-boot), so that it’s flashed during installation?

Integrating Custom U-Boot in Toradex Easy Installer Package

Yes, using Toradex Easy Installer is the recommended approach for deploying your custom U-Boot along with your system image(1). This method ensures proper integration and safe deployment.

Yocto Integration Steps

1. Replace the Bootloader Binary

According to the documentation, you need to replace the imx-boot file in your Easy Installer package with your custom U-Boot binary(1). The process involves:

  1. Start from an existing sample image: Download and extract one of the Toradex prebuilt images(1)
  2. Integrate artifacts: Replace the bootloader binaries with the ones you have built(1)
  3. Use your custom binary: Replace the existing imx-boot file with your flash.bin-verdin-imx8mp-sd(1)

2. Adjust the image.json Configuration

When building U-Boot manually, you must adjust the image.json file to ensure the bootloader binaries are loaded correctly(1). Here’s the configuration example for Verdin iMX8M Plus:

"name": "mmcblk0boot0",
"erase": true,
"content": {
    "filesystem_type": "raw",
    "rawfiles": [
        {
            "filename": "u-boot.imx",
            "dd_options": "seek=2"
        }
    ]
}

(1)

3. File Naming and Structure

Based on your current Easy Installer package structure:

  • Replace the existing imx-boot file with your flash.bin-verdin-imx8mp-sd(1)
  • Rename your custom binary to match the expected filename in image.json(1)
  • Keep the existing u-boot-initial-env-sd file unless you need custom environment variables(1)

4. Yocto Recipe Customization

For automatic integration during Yocto builds, the documentation shows that you can customize the deployment process through the build system(1). The key is ensuring that your custom U-Boot artifacts are properly integrated into the standard Toradex Easy Installer package structure(1).

Boot Container for iMX8MP

Since you’re working with the Verdin iMX8MP, note that this SoC uses a boot container that includes DDR memory timings, SCU firmware, ATF, and U-Boot all stored in a single boot container(2). Your flash.bin-verdin-imx8mp-sd should already contain all these components properly integrated(2).

Verification Steps

After creating your custom Easy Installer package:

  1. Verify the binary names match what’s specified in your image.json(1)
  2. Test the deployment using Toradex Easy Installer(1)
  3. Check that the custom U-Boot is properly loaded during the installation process(1)

This approach ensures that your custom U-Boot is safely deployed without risking the original bootloader, and provides a reliable method for production deployment.

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Hi @stan!

We’re going to continue the support in this other thread.

Best regards.