I want to write a Linux kernel with U-Boot into a mmc hwpartition of an eMMC storage on an i.MX6 board:
TX6UL U-Boot > mmc info
Device: FSL_SDHC
Manufacturer ID: 11
OEM: 100
Name: 004G6
Tran Speed: 52000000
Rd Block Len: 512
MMC version 5.0
High Capacity: Yes
Capacity: 8 MiB
Bus Width: 4-bit
Erase Group Size: 4 MiB
HC WP Group Size: 4 MiB
User Capacity: 8 MiB WRREL
Boot Capacity: 2 MiB ENH
RPMB Capacity: 512 KiB ENH
GP1 Capacity: 8 MiB WRREL
GP2 Capacity: 1.8 GiB ENH WRREL
The general-purpose hwpartition GP1 was intended to be used for the kernel. Usually the following commands are used to write the image (assuming a tftp-server is running and hosting the image as file uImage_txul):
TX6UL U-Boot > tftp ${loadaddr} uImage_txul
TX6UL U-Boot > mmc write ${loadaddr} 0xXXXX 0xYYYY
How to find out the needed adresses 0xXXXX 0xYYYY to write the image into the hwpartition GP1?
Best Answer
The short answer to burning u-boot to the mmc is probably
but it depends on how you've setup the mmc. This command will write 1048576 (0x800 * 512) bytes from ${fileaddr} to the mmc starting at address 0.
For a longer and more complete answer on writing the mmc. Let's say you are going to setup the mmc the way the manufacturer suggests.
Let's assume you already have the files you need, if not you can build these with Yocto. I can provide details on that if you like.
Let's also assume you already at least sideloaded u-boot, it looks like you have it running somehow.
First thing you'll need to partition the mmc. You can't do this from u-boot, so you'll need to setup a network boot. It seems you already have a tftp server with your files in it, you'll also need to setup an nfs server and extract rootfs to there. Let's say you setup your nfs server file system at /nfsroot. Set the following variables to enable net boot.
Boot to the Linux prompt and from there run
and setup partitions as follows
Switch back to u-boot and you should now be able to see your partitions
Note that partition 1 starts at sector 2048 which is 0x800. Partition 2 starts at 32768 which is 0x8000. You should now see where these numbers come from.
We updated u-boot.bin with the commands above, but notice that it also overwrites the Device Table (DT). So to update the DT, use
There also may be an environment variable set with these commands, ${fdtsave}, if so, you can just use
To update the partitions, you will need to create the disk images on your linux box, then tftp them to the TX6UL and burn them with the mmc write command. To make the image for the first partition, you could use these commands on your linux box.
Then in u-boot
You can see the contents of the partition from u-boot using
Similarly for the second partition, from your linux box use something like
And then from u-boot
If you want to see the contents of the second partition from u-boot
To boot from the new partitions, set init back to normal in the boot arguments
And don't forget to either change the partition id or the env variable to point to the new file system. In this case
Hope this helps.