How to flash image from SD card to eMMC in i.MX boards

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to flash image from SD card to eMMC in i.MX boards

How to flash image from SD card to eMMC in i.MX boards

Introduction

There are some cases where it is needed to flash the image from a removable boot source (e.g. an SD card) to another boot source (e.g. eMMC), according to our documentation this can be done via dd but this does not work in the case you would like to do all the process in the board caused by the eMMC partition structure.

Required equipment.

  • i.MX93 FRDM board (this is the selected board for this post, it works for others).
  • Debug USB-C cable.
  • Data USB-C cable.
  • Micro SD (64GB memory used in this test).
  • Personal computer.

The default partition configuration for an eMMC device is as follows:

eMMC default structure.png

Where:

- Boot areas are used for bootloader and environment configurations.

- Replay-protected memory-block area (RPMB) is used to store secure data.

- User area used for application data such as file system, usually divided in two or more partitions.

In the case of an image, the eMMC is organized according to the next diagram:

eMMC structure.png

- Boot area 1 is used to store SPL and U-boot with no file system in a fixed offset according to each processor as mentioned in i.MX Linux User's Guide section 4.3 Preparing an SD/MMC card to boot.

- User area partition 1 uses a FAT format where Kernel and Device Tree files are stored.

- User area partition 2 is used for root file system with Ext3/Ext4 format.

Exception

Our documentation has a method to flash .wic image which contains all the mentioned above or each part manually using an SD card connected to a host Linux machine via dd command:

sudo dd if=<image name>.wic of=/dev/sdx bs=1M && sync

Or set up the partitions manually such as bootloader:

sudo dd if=<U-Boot image> of=/dev/sdx bs=1k seek=<offset> conv=fsync

Also, copying the kernel image and DTB file and the root file system as mentioned in i.MX Linux User's Guide.

This method works for SD card since the data is stored in user area and the offset changes to burn the bootloader. This fails when we try to flash the image from SD card to eMMC.

How to reproduce the issue?

First, we need to erase the eMMC, here a post to achieve this task.

Format boot partition of eMMC from U-boot - NXP Community

How to flash image from SD card to eMMC?

With the eMMC erased, we need a boot source to store and flash the image, in this case the SD card.

Once the image is flashed into the Micro SD, we need to copy the necessary files such as bootloader and image. By default, our BSP has a User Area space of <>GB and we need to increase it to save the bootloader and the image, here the steps:

Verify the device and partition numeration:

lsblk

The command to increase the size of the partition is the next:

parted /dev/<storage unit> unit MiB resizepart <partition> <size in bytes>

And the command to apply the changes is:

resize2fs /dev/<storage and partition unit>

 In this case, the device and partition we need to change is mmcblk0p2 so, the command is as follows:

parted /dev/mmcblk0 unit MiB resizepart 2 10000 

I increased the partition size by 10000 MB; this will be enough to store the required files.

And now, we need to apply the changes:

resize2fs /dev/mmcblk0p2

In the board will look like this:

Screenshot 2025-07-03 123208.png

Now, let's copy the bootloader and root file system in SD. In this post we will use SCP:

Screenshot 2025-07-03 124054.png

Now, we need to boot from SD card and run the next commands:

As is mentioned in Linux User's guide, we need to flash the .wic image. This contains all the necessary data to flash the entire image but when flashing from SD card to eMMC we need to follow additional steps to unlock the partition used to store the bootloader:

sudo dd if=<image name>.wic of=/dev/sdx bs=1M && sync

Disable write protection:

echo 0 > /sys/block/<storage and partition unit>/force_ro

And flash the bootloader:

dd if=<bootloader> of=/dev/<storage and partition unit> bs=1K seek=0

In the board will look like this:Screenshot 2025-07-07 161944.png

With this process now it is needed to reboot the board, change boot mode switches to boot from eMMC, and the board will boot normally, the user can perform an image flashing to simplify development workflow and also an alternative to update OS without external host dependencies.

 

 

 

无评分
版本历史
最后更新:
‎07-08-2025 01:46 PM
更新人: