How to load files from an EMMC's General Purpose Partition or Boot Partition, using Uboot
Solution 1
Yes, you can access the GP partitions from uboot.
As described here http://u-boot.10912.n7.nabble.com/How-to-access-GP-partitions-from-uboot-2015-04-td212394.html you can use the "mmc partconf" command's last argument to tell the eMMC to bring out different parts (e.g. the GP instead of the user area). After you run that command, and execute a "mmc read" command, you'll notice that you are reading from a different area.
Take care though. At least in my u-boot version (2017), u-boot does not know that is has to re-read the partition table, and for optimization purposes, it won't. I had to do a small patch in part.c in blk_get_device_by_str to force part_init to execute each time. Then, when you do a "mmc part", you should see the GP partition table as well, and can do any file operation as you would normally do. Don't foget that doing an "mmc rescan" or any reset of the eMMC will loose the GP state, and you'll have to switch back to the GP again to read it.
Solution 2
We have managed to access GP partitions from U-Boot. U-boot 2017 didn't recognize our GP partitions due to not supporting MMC version 5.1 (5.0 was last supported and therefore fallback to version 4.0 was done for some reason) After enabling version 5.1 in our U-Boot code it is recognized:
=> mmc info
Device: OMAP SD/MMC
Manufacturer ID: 11
OEM: 100
Name: 008G3
Tran Speed: 52000000
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 7.3 GiB
Bus Width: 8-bit
Erase Group Size: 4 MiB
HC WP Group Size: 4 MiB
User Capacity: 7.3 GiB
Boot Capacity: 8 MiB ENH
RPMB Capacity: 4 MiB ENH
GP1 Capacity: 4 MiB ENH WRREL
GP2 Capacity: 4 MiB ENH WRREL
Now From U-Boot (environment or console) you can perform the following: (Note; our eMMC is connected as mmc device 0
mmc dev 0 #select device 0
mmc partconf-partenable 0; #store the active bootpartition
mmc partconf 0 1 7 4; #configure device 0 (first parameter) to use User partiton (the 7) to GP1 (first GP) (4)
mmc partconf 0 1 7 5; #configure device 0 (first) to use userpartition second (GP2) (parameter 5)
#Now display partition (which won't work, explained below)
=> mmc part
Partition Map for MMC device 0 -- Partition Type: DOS
Part Start Sector Num Sectors UUID Type
bad MBR sector signature 0x0000
=>
#now load a file with filename from the ext4 filesystem (see below)
=> ext4load mmc 0:0 0x80000000 FILE_NAME.txt
15 bytes read in 2 ms (6.8 KiB/s)
#restore active partition
=> mmc partconf 0 1 ${boot_part_enabled} 1 #restore the boot_partition (this parameter boot_part_enabled is set from 'mmc partconf-partenable 0' at the beginning)
In order to do this, we have pre-formatted and created the GP partitions from linux once:
mkfs.ext4 /dev/mmcblk1gp1
mount /dev/mmcblk1gp1 /media/gp1
echo "SOMELINEOFTEXT" > /media/gp1/FILE_NAME.txt
reboot
now you can read it from u-boot
Related videos on Youtube
Comments
-
GeminiDakota almost 2 years
Is UBoot able to boot via fatload/ext4load from an EMMC's General Purpose Partition or Boot Partition? I am able to show files from the User area, just not partitions created as hardware partitions. These partitions can be created by using UBoot's "mmc hwpartition" command. It seems odd UBoot can create these partitions, but doesn't seem to be able to use them. I am using the latest version (2016.4) of Xilinx's UBoot, which is based based on the UBoot
Using UBoot's "mmc info" command, UBoot can definitely see the Boot Partition and General Purpose Partitions (GP 1/2/3/4):
zynq-uboot> mmc info Device: sdhci@e0100000 Manufacturer ID: fe OEM: 14e Name: MMC04 Tran Speed: 52000000 Rd Block Len: 512 MMC version 4.4.1 High Capacity: Yes Capacity: 2.7 GiB Bus Width: 4-bit Erase Group Size: 4 MiB HC WP Group Size: 4 MiB User Capacity: 2.7 GiB Boot Capacity: 16 MiB ENH RPMB Capacity: 128 KiB ENH GP1 Capacity: 128 MiB GP2 Capacity: 64 MiB GP3 Capacity: 128 MiB GP4 Capacity: 512 MiB
Normally, I am able to use the UBoot commands: fatload/fatls or ext4load/ext4ls in order to show contents of a given partition based on its filesystem type.
Working example of fatls command - please note this is showing the contents of the User area (size 2.7GB from above).
zynq-uboot> fatls mmc 0:1 17488 devicetree.dtb 962589 fpga.bit 54 uenv.txt 6709360 uimage 1555344 boot.bin 33 image.chk 83493724 image.tgz 7 file(s), 0 dir(s)
The GP partitions, when mounted in linux, contain my root filesystem, kernel image, etc. I would like to be able to boot from a GP partition via fatload/ext4load commands and use the User area for other purposes that storing my boot files.
I have found other posts about this topic, however, they don't seem to have been answered yet: https://lists.denx.de/pipermail/u-boot/2014-July/184731.html
Any help would be appreciated!
-
GeminiDakota about 7 years@TomRini Thanks for your reply. There is only one device that shows up and is working. Using "mmc list" command, it shows: sdhci@e0100000: 0 (eMMC) sdhci@e0101000: 1 Attempting to switch to the 2nd device using command "mmc dev 1", fails with message "Card did not respond to voltage select". I'm not sure what exactly this 2nd device is, but if this is where General Purpose Partitions would show up, I'd expect there to be more than just the 1 additional device.
-
Tom Rini about 7 yearswhat I mean is that you can use 'mmc dev 0 1' to switch to the first hardware partition on the eMMC. I don't know (and can't easily test at the moment) if once you do 'mmc dev 0 1' to switch to the first hardware partition if 'fatls mmc 0' will now be looking at partition 1 of the eMMC, due to 'mmc dev' command or still be looking at partition 0.
-
GeminiDakota about 7 years@TomRini, Using the command: "mmc part", this shows my software partitions created using fdisk. It does not show any GPPs or boot partitions. Similarly, the command "mmc dev <dev#> <partition#>", allows me to switch to the partitions show in the "mmc part" command.
-
GeminiDakota about 7 years@TomRini Also,after looking at the uboot source, I'm pretty sure the functionality to boot from GPPs is not there. The only place these seem to be referenced is the mmc command, which simply get's its information from the ECSD register. The notion of GPP/boot partitions doesn't seem to get carried over to the fatls/ext4ls commands, which would need to be able to pull my kernel image from the boot/GPP areas. Thanks again for taking a look! I'm going to move on and just use software partitions to boot from for now.
-
-
GeminiDakota over 5 yearsThanks. It's been over a year since I originally asked my question and I don't readily have that setup to test this answer. This sounds right, so I'll mark it as the solution.