How to flash eMMC from an SDCard on i.MX6Q ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to flash eMMC from an SDCard on i.MX6Q ?

8,628 Views
gregoryciapa
Contributor II

My problem is the following :

   I have successfully built an image using Buildroot ( u-boot.imx at offset 0x400 + vfat partition containing the kernel and a .dtb + ext2 partition containing the file system ) then flashed the image to an SDCard using dd. So far everything work as expected : i have set the i.MX6Q boot mode to internal and the appropriate GPIO to select the boot device - that is the SdCard slot. U-Boot runs and load the kernel as expected.

Now, as my BSP is ready, i would like the flash it to the eMMC and this is what i have tried, unsuccessfully :

  1. copy the image to an USB mass storage
  2. boot the board from the SD Card and dd the image from the USB mass storage to the /dev/mmcblk3 ( eMMC )
  3. double check the GPIO so that the internal boot mode select the eMMC boot.
  4. power up the board -> u-boot runs but all its environment variables (mmcroot, mmcdev, bootargs, ..) are not those that were saved in the BSP image so the kernel does not boot. 

Is this related to the CRC32 protection of the u-boot environment variables or something else ?

Is there a better way to achieve this ?

Thank you.

Labels (2)
Tags (3)
0 Kudos
2 Replies

7,060 Views
shivanipatel
Senior Contributor II

Hi, gregoryciapa

In order to flash an eMMC from SDCard, kindly follow the below steps:

  • Boot the board from SD Card.
  • Stop the console at u-boot and execute below command.
    • ums 0 mmc 1                 // this will mount SD card as USB Mass Storage to your system
  • Copy bootloader image from system to USB Mass Storage
    • cp <u-boot_image> /media/username/<rootfs>/home/root/
  • Eject the USB Mass Storage and terminate the ums process by pressing ctrl+c in u-boot.
  • Power Off and Power On the board and login to the kernel console.
  • Flash the bootloader image to eMMC
    • dd if=/home/root/<u-boot_image> of=/dev/mmcblk3 bs=512 seek=2 conv=fsync
  • Mount the partition 1 of SD Card to copy the kernel image and DTB file to /home/root folder.
    • mount /dev/mmcblk2p1 /mnt/
    • cp -r /mnt/zImage /mnt/imx6q-sabresd.dtb /home/root
    • umount /dev/mmcblk2p1
  • Make partitions on eMMC manually as per section 4.3.3 in this document using fdisk /dev/mmcblk3 command.
  • Format the partition 1 on eMMC as VFAT and partition 2 as ext4 with below commands
    • mkfs.vfat /dev/mmcblk3p1
    • mkfs.ext4 /dev/mmcblk3p2
  • Mount the partion 1 of eMMC and copy kernel image & DTB file.
    • mount /dev/mmcblk3p1 /mnt/
    • cp -r /home/root/zImage /home/root/imx6q-sabresd.dtb /mnt/
    • umount /dev/mmcblk3p1
  • Mount the partion 2 of eMMC & SD Card and copy the file system.
    • mount /dev/mmcblk3p2 /mnt/                                                   // mount partition 2 of SD Card
    • mkdir /home/root/rootfs && mount /dev/mmcblk3p2 rootfs     // mount partition 2 of eMMC
    • cp -ar /mnt/* /home/root/rootfs/
    • sync
    • umount /dev/mmcblk2p2
    • umount /dev/mmcblk3p2
  • Change the Boot Mode to eMMC
  • Power Up the Board. (this will boot the images from eMMC)

Hope this will help you.

Regards,

Shivani

0 Kudos

7,060 Views
gusarambula
NXP TechSupport
NXP TechSupport

Hello Gregoryciapa,

The bootloader has some differences depending on where it will be stored. If you are booting from an eMMC you would need to setup the BSP to build the bootloader for the eMMC. (The kernel and root file system remain unchanged)

You would need to add the following line to the conf/local.conf file on the build directory:

UBOOT_CONFIG = "emmc"

And then build using:

$ MACHINE=<machine name> bitbake -c deploy u-boot-imx

You can find more details of this on the i.MX Yocto Project User’s Guide inside of the Linux BSP documentation bundle.

I hope this helps!

Regards,

0 Kudos