diff mbox

[U-Boot,v4,01/18] mmc: show hardware partition sizes in mmcinfo output

Message ID 1419328233-6977-2-git-send-email-Diego.SantaCruz@spinetix.com
State Accepted
Delegated to: Pantelis Antoniou
Headers show

Commit Message

Diego Santa Cruz Dec. 23, 2014, 9:50 a.m. UTC
There is currently no command that will provide an overview of the hardware
partitions present on an eMMC device, one has to switch to every partition
via "mmc dev" and run mmcinfo for each to get the partition's capacity.
This commit adds a few lines of output to mmcinfo with the sizes of the
present partitions, like this:

Device: OMAP SD/MMC
Manufacturer ID: fe
OEM: 14e
Name: MMC16
Tran Speed: 52000000
Rd Block Len: 512
MMC version 4.41
High Capacity: Yes
Capacity: 13.8 GiB
Bus Width: 4-bit
User Capacity: 13.8 GiB
Boot Capacity: 16 MiB
RPMB Capacity: 128 KiB
GP1 Capacity: 64 MiB
GP2 Capacity: 64 MiB

Signed-off-by: Diego Santa Cruz <Diego.SantaCruz@spinetix.com>
---
 common/cmd_mmc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Pantelis Antoniou Jan. 19, 2015, 3:37 p.m. UTC | #1
Hi Diego,

> On Dec 23, 2014, at 11:50 , Diego Santa Cruz <Diego.SantaCruz@spinetix.com> wrote:
> 
> There is currently no command that will provide an overview of the hardware
> partitions present on an eMMC device, one has to switch to every partition
> via "mmc dev" and run mmcinfo for each to get the partition's capacity.
> This commit adds a few lines of output to mmcinfo with the sizes of the
> present partitions, like this:
> 
> Device: OMAP SD/MMC
> Manufacturer ID: fe
> OEM: 14e
> Name: MMC16
> Tran Speed: 52000000
> Rd Block Len: 512
> MMC version 4.41
> High Capacity: Yes
> Capacity: 13.8 GiB
> Bus Width: 4-bit
> User Capacity: 13.8 GiB
> Boot Capacity: 16 MiB
> RPMB Capacity: 128 KiB
> GP1 Capacity: 64 MiB
> GP2 Capacity: 64 MiB
> 
> Signed-off-by: Diego Santa Cruz <Diego.SantaCruz@spinetix.com>
> ---
> common/cmd_mmc.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
> 
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 96478e4..fa765d7 100644
> --- a/common/cmd_mmc.c
> +++ b/common/cmd_mmc.c
> @@ -73,6 +73,8 @@ U_BOOT_CMD(
> 
> static void print_mmcinfo(struct mmc *mmc)
> {
> +	int i;
> +
> 	printf("Device: %s\n", mmc->cfg->name);
> 	printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24);
> 	printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff);
> @@ -92,6 +94,21 @@ static void print_mmcinfo(struct mmc *mmc)
> 
> 	printf("Bus Width: %d-bit%s\n", mmc->bus_width,
> 			mmc->ddr_mode ? " DDR" : "");
> +
> +	if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
> +		puts("User Capacity: ");
> +		print_size(mmc->capacity_user, "\n");
> +		puts("Boot Capacity: ");
> +		print_size(mmc->capacity_boot, "\n");
> +		puts("RPMB Capacity: ");
> +		print_size(mmc->capacity_rpmb, "\n");
> +		for (i = 0; i < ARRAY_SIZE(mmc->capacity_gp); i++) {
> +			if (mmc->capacity_gp[i]) {
> +				printf("GP%i Capacity: ", i);
> +				print_size(mmc->capacity_gp[i], "\n");
> +			}
> +		}
> +	}
> }
> static struct mmc *init_mmc_device(int dev, bool force_init)
> {
> -- 
> 2.2.1
> 

Applied with a minor edit removing the superfluous parentheses.

— Pantelis
Stephen Warren Jan. 22, 2015, 6:42 p.m. UTC | #2
On 12/23/2014 02:50 AM, Diego Santa Cruz wrote:
> There is currently no command that will provide an overview of the hardware
> partitions present on an eMMC device, one has to switch to every partition
> via "mmc dev" and run mmcinfo for each to get the partition's capacity.
> This commit adds a few lines of output to mmcinfo with the sizes of the
> present partitions, like this:
>
> Device: OMAP SD/MMC
> Manufacturer ID: fe
> OEM: 14e
> Name: MMC16
> Tran Speed: 52000000
> Rd Block Len: 512
> MMC version 4.41
> High Capacity: Yes
> Capacity: 13.8 GiB
> Bus Width: 4-bit
> User Capacity: 13.8 GiB
> Boot Capacity: 16 MiB
> RPMB Capacity: 128 KiB
> GP1 Capacity: 64 MiB
> GP2 Capacity: 64 MiB

I have an MMC device which has at least boot HW partitions, yet with the 
very latest code in u-boot.git, I don't see the additional lines 
mentioned above. My HW partitions are still working fine, since I can 
select a boot partition and mmcinfo shows the correct "Capacity" for it:

Any ideas why?

Tegra124 (Jetson TK1) # mmc dev 0
switch to partitions #0, OK
mmc0(part 0) is current device
Tegra124 (Jetson TK1) # mmcinfo
Device: Tegra SD/MMC
Manufacturer ID: 45
OEM: 100
Name: SEM16
Tran Speed: 52000000
Rd Block Len: 512
MMC version 4.5
High Capacity: Yes
Capacity: 14.7 GiB <<<< Sounds right for a 16GB device with partitions
Bus Width: 8-bit
Erase Group Size: 512 KiB
<<<< No HW partition information is printed here

Tegra124 (Jetson TK1) # mmc dev 0 1 <<<< select "boot0" HW partition
switch to partitions #1, OK
mmc0(part 1) is current device
Tegra124 (Jetson TK1) # mmcinfo
Device: Tegra SD/MMC
Manufacturer ID: 45
OEM: 100
Name: SEM16
Tran Speed: 52000000
Rd Block Len: 512
MMC version 4.5
High Capacity: Yes
Capacity: 4 MiB <<<< "boot0" partition size correctly reported
Bus Width: 8-bit
Erase Group Size: 512 KiB
Pantelis Antoniou Jan. 22, 2015, 7:45 p.m. UTC | #3
Hi Stephen,

> On Jan 22, 2015, at 20:42 , Stephen Warren <swarren@wwwdotorg.org> wrote:
> 
> On 12/23/2014 02:50 AM, Diego Santa Cruz wrote:
>> There is currently no command that will provide an overview of the hardware
>> partitions present on an eMMC device, one has to switch to every partition
>> via "mmc dev" and run mmcinfo for each to get the partition's capacity.
>> This commit adds a few lines of output to mmcinfo with the sizes of the
>> present partitions, like this:
>> 
>> Device: OMAP SD/MMC
>> Manufacturer ID: fe
>> OEM: 14e
>> Name: MMC16
>> Tran Speed: 52000000
>> Rd Block Len: 512
>> MMC version 4.41
>> High Capacity: Yes
>> Capacity: 13.8 GiB
>> Bus Width: 4-bit
>> User Capacity: 13.8 GiB
>> Boot Capacity: 16 MiB
>> RPMB Capacity: 128 KiB
>> GP1 Capacity: 64 MiB
>> GP2 Capacity: 64 MiB
> 
> I have an MMC device which has at least boot HW partitions, yet with the very latest code in u-boot.git, I don't see the additional lines mentioned above. My HW partitions are still working fine, since I can select a boot partition and mmcinfo shows the correct "Capacity" for it:
> 
> Any ideas why?
> 
> Tegra124 (Jetson TK1) # mmc dev 0
> switch to partitions #0, OK
> mmc0(part 0) is current device
> Tegra124 (Jetson TK1) # mmcinfo
> Device: Tegra SD/MMC
> Manufacturer ID: 45
> OEM: 100
> Name: SEM16
> Tran Speed: 52000000
> Rd Block Len: 512
> MMC version 4.5
> High Capacity: Yes
> Capacity: 14.7 GiB <<<< Sounds right for a 16GB device with partitions
> Bus Width: 8-bit
> Erase Group Size: 512 KiB
> <<<< No HW partition information is printed here
> 
> Tegra124 (Jetson TK1) # mmc dev 0 1 <<<< select "boot0" HW partition
> switch to partitions #1, OK
> mmc0(part 1) is current device
> Tegra124 (Jetson TK1) # mmcinfo
> Device: Tegra SD/MMC
> Manufacturer ID: 45
> OEM: 100
> Name: SEM16
> Tran Speed: 52000000
> Rd Block Len: 512
> MMC version 4.5
> High Capacity: Yes
> Capacity: 4 MiB <<<< "boot0" partition size correctly reported
> Bus Width: 8-bit
> Erase Group Size: 512 KiB

That is really weird; are you sure you got the latest version of u-boot
containing those patches?

>       if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) {
> 

The test for printing out the capacities is as above, you should
get the printouts.

Interesting; for reference on beaglebone black I get for the onboard eMMC:

> mmc1(part 0) is current device
> U-Boot# mmc info
> Device: OMAP SD/MMC
> Manufacturer ID: fe
> OEM: 14e
> Name: MMC02
> Tran Speed: 52000000
> Rd Block Len: 512
> MMC version 4.41
> High Capacity: No
> Capacity: 1.8 GiB
> Bus Width: 4-bit
> Erase Group Size: 512 KiB
> HC WP Group Size: 0 Bytes
> User Capacity: 1.8 GiB
> Boot Capacity: 1 MiB ENH
> RPMB Capacity: 128 KiB ENH

Regards

— Pantelis
Stephen Warren Jan. 22, 2015, 7:59 p.m. UTC | #4
On 01/22/2015 12:45 PM, Pantelis Antoniou wrote:
> Hi Stephen,
>
>> On Jan 22, 2015, at 20:42 , Stephen Warren <swarren@wwwdotorg.org> wrote:
>>
>> On 12/23/2014 02:50 AM, Diego Santa Cruz wrote:
>>> There is currently no command that will provide an overview of the hardware
>>> partitions present on an eMMC device, one has to switch to every partition
>>> via "mmc dev" and run mmcinfo for each to get the partition's capacity.
>>> This commit adds a few lines of output to mmcinfo with the sizes of the
>>> present partitions, like this:
>>>
>>> Device: OMAP SD/MMC
>>> Manufacturer ID: fe
>>> OEM: 14e
>>> Name: MMC16
>>> Tran Speed: 52000000
>>> Rd Block Len: 512
>>> MMC version 4.41
>>> High Capacity: Yes
>>> Capacity: 13.8 GiB
>>> Bus Width: 4-bit
>>> User Capacity: 13.8 GiB
>>> Boot Capacity: 16 MiB
>>> RPMB Capacity: 128 KiB
>>> GP1 Capacity: 64 MiB
>>> GP2 Capacity: 64 MiB
>>
>> I have an MMC device which has at least boot HW partitions, yet with the very latest code in u-boot.git, I don't see the additional lines mentioned above. My HW partitions are still working fine, since I can select a boot partition and mmcinfo shows the correct "Capacity" for it:
>>
>> Any ideas why?
>>
>> Tegra124 (Jetson TK1) # mmc dev 0
>> switch to partitions #0, OK
>> mmc0(part 0) is current device
>> Tegra124 (Jetson TK1) # mmcinfo
>> Device: Tegra SD/MMC
>> Manufacturer ID: 45
>> OEM: 100
>> Name: SEM16
>> Tran Speed: 52000000
>> Rd Block Len: 512
>> MMC version 4.5
>> High Capacity: Yes
>> Capacity: 14.7 GiB <<<< Sounds right for a 16GB device with partitions
>> Bus Width: 8-bit
>> Erase Group Size: 512 KiB
>> <<<< No HW partition information is printed here
>>
>> Tegra124 (Jetson TK1) # mmc dev 0 1 <<<< select "boot0" HW partition
>> switch to partitions #1, OK
>> mmc0(part 1) is current device
>> Tegra124 (Jetson TK1) # mmcinfo
>> Device: Tegra SD/MMC
>> Manufacturer ID: 45
>> OEM: 100
>> Name: SEM16
>> Tran Speed: 52000000
>> Rd Block Len: 512
>> MMC version 4.5
>> High Capacity: Yes
>> Capacity: 4 MiB <<<< "boot0" partition size correctly reported
>> Bus Width: 8-bit
>> Erase Group Size: 512 KiB
>
> That is really weird; are you sure you got the latest version of u-boot
> containing those patches?
>
>>        if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) {

Ah, my device is MMC 4.5, and the version numbers aren't monotonic:

#define MMC_VERSION_4_41	(MMC_VERSION_MMC | 0x429)
#define MMC_VERSION_4_5		(MMC_VERSION_MMC | 0x405)

Should that be 0x450, or do we need some more complex version comparison 
logic?

FWIW, if I hack the test you quoted to always pass, then the data that's 
printed looks plausible. At the very least, the boot capacity agrees 
with Linux.
Pantelis Antoniou Jan. 22, 2015, 8:48 p.m. UTC | #5
Hi Stephen,

> On Jan 22, 2015, at 21:59 , Stephen Warren <swarren@wwwdotorg.org> wrote:
> 
> On 01/22/2015 12:45 PM, Pantelis Antoniou wrote:
>> Hi Stephen,
>> 
>>> On Jan 22, 2015, at 20:42 , Stephen Warren <swarren@wwwdotorg.org> wrote:
>>> 
>>> On 12/23/2014 02:50 AM, Diego Santa Cruz wrote:
>>>> There is currently no command that will provide an overview of the hardware
>>>> partitions present on an eMMC device, one has to switch to every partition
>>>> via "mmc dev" and run mmcinfo for each to get the partition's capacity.
>>>> This commit adds a few lines of output to mmcinfo with the sizes of the
>>>> present partitions, like this:
>>>> 
>>>> Device: OMAP SD/MMC
>>>> Manufacturer ID: fe
>>>> OEM: 14e
>>>> Name: MMC16
>>>> Tran Speed: 52000000
>>>> Rd Block Len: 512
>>>> MMC version 4.41
>>>> High Capacity: Yes
>>>> Capacity: 13.8 GiB
>>>> Bus Width: 4-bit
>>>> User Capacity: 13.8 GiB
>>>> Boot Capacity: 16 MiB
>>>> RPMB Capacity: 128 KiB
>>>> GP1 Capacity: 64 MiB
>>>> GP2 Capacity: 64 MiB
>>> 
>>> I have an MMC device which has at least boot HW partitions, yet with the very latest code in u-boot.git, I don't see the additional lines mentioned above. My HW partitions are still working fine, since I can select a boot partition and mmcinfo shows the correct "Capacity" for it:
>>> 
>>> Any ideas why?
>>> 
>>> Tegra124 (Jetson TK1) # mmc dev 0
>>> switch to partitions #0, OK
>>> mmc0(part 0) is current device
>>> Tegra124 (Jetson TK1) # mmcinfo
>>> Device: Tegra SD/MMC
>>> Manufacturer ID: 45
>>> OEM: 100
>>> Name: SEM16
>>> Tran Speed: 52000000
>>> Rd Block Len: 512
>>> MMC version 4.5
>>> High Capacity: Yes
>>> Capacity: 14.7 GiB <<<< Sounds right for a 16GB device with partitions
>>> Bus Width: 8-bit
>>> Erase Group Size: 512 KiB
>>> <<<< No HW partition information is printed here
>>> 
>>> Tegra124 (Jetson TK1) # mmc dev 0 1 <<<< select "boot0" HW partition
>>> switch to partitions #1, OK
>>> mmc0(part 1) is current device
>>> Tegra124 (Jetson TK1) # mmcinfo
>>> Device: Tegra SD/MMC
>>> Manufacturer ID: 45
>>> OEM: 100
>>> Name: SEM16
>>> Tran Speed: 52000000
>>> Rd Block Len: 512
>>> MMC version 4.5
>>> High Capacity: Yes
>>> Capacity: 4 MiB <<<< "boot0" partition size correctly reported
>>> Bus Width: 8-bit
>>> Erase Group Size: 512 KiB
>> 
>> That is really weird; are you sure you got the latest version of u-boot
>> containing those patches?
>> 
>>>       if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) {
> 
> Ah, my device is MMC 4.5, and the version numbers aren't monotonic:
> 
> #define MMC_VERSION_4_41	(MMC_VERSION_MMC | 0x429)
> #define MMC_VERSION_4_5		(MMC_VERSION_MMC | 0x405)
> 

Gah. That’s bad. I believe that’s a bug.

> Should that be 0x450, or do we need some more complex version comparison logic?
> 

Frankly I hope not. 0x450 should be used. But that would require changing all the
others version definitions cause for instance MMC_VERSION_4_1 = 0x401.

> FWIW, if I hack the test you quoted to always pass, then the data that's printed looks plausible. At the very least, the boot capacity agrees with Linux.

Thanks for the report; I’ll get it fixed.

Regards

— Pantelis
Diego Santa Cruz Jan. 23, 2015, 8:30 a.m. UTC | #6
> -----Original Message-----
> From: Stephen Warren [mailto:swarren@wwwdotorg.org]
> Sent: Thursday, January 22, 2015 8:59 PM
> To: Pantelis Antoniou
> Cc: Diego Santa Cruz; u-boot@lists.denx.de
> Subject: Re: [U-Boot] [PATCH v4 01/18] mmc: show hardware partition sizes in
> mmcinfo output
> 
> On 01/22/2015 12:45 PM, Pantelis Antoniou wrote:
> > Hi Stephen,
> >
> >> On Jan 22, 2015, at 20:42 , Stephen Warren <swarren@wwwdotorg.org> wrote:
> >>
> >> On 12/23/2014 02:50 AM, Diego Santa Cruz wrote:
> >>> There is currently no command that will provide an overview of the
> hardware
> >>> partitions present on an eMMC device, one has to switch to every partition
> >>> via "mmc dev" and run mmcinfo for each to get the partition's capacity.
> >>> This commit adds a few lines of output to mmcinfo with the sizes of the
> >>> present partitions, like this:
> >>>
> >>> Device: OMAP SD/MMC
> >>> Manufacturer ID: fe
> >>> OEM: 14e
> >>> Name: MMC16
> >>> Tran Speed: 52000000
> >>> Rd Block Len: 512
> >>> MMC version 4.41
> >>> High Capacity: Yes
> >>> Capacity: 13.8 GiB
> >>> Bus Width: 4-bit
> >>> User Capacity: 13.8 GiB
> >>> Boot Capacity: 16 MiB
> >>> RPMB Capacity: 128 KiB
> >>> GP1 Capacity: 64 MiB
> >>> GP2 Capacity: 64 MiB
> >>
> >> I have an MMC device which has at least boot HW partitions, yet with the
> very latest code in u-boot.git, I don't see the additional lines mentioned
> above. My HW partitions are still working fine, since I can select a boot
> partition and mmcinfo shows the correct "Capacity" for it:
> >>
> >> Any ideas why?
> >>
> >> Tegra124 (Jetson TK1) # mmc dev 0
> >> switch to partitions #0, OK
> >> mmc0(part 0) is current device
> >> Tegra124 (Jetson TK1) # mmcinfo
> >> Device: Tegra SD/MMC
> >> Manufacturer ID: 45
> >> OEM: 100
> >> Name: SEM16
> >> Tran Speed: 52000000
> >> Rd Block Len: 512
> >> MMC version 4.5
> >> High Capacity: Yes
> >> Capacity: 14.7 GiB <<<< Sounds right for a 16GB device with partitions
> >> Bus Width: 8-bit
> >> Erase Group Size: 512 KiB
> >> <<<< No HW partition information is printed here
> >>
> >> Tegra124 (Jetson TK1) # mmc dev 0 1 <<<< select "boot0" HW partition
> >> switch to partitions #1, OK
> >> mmc0(part 1) is current device
> >> Tegra124 (Jetson TK1) # mmcinfo
> >> Device: Tegra SD/MMC
> >> Manufacturer ID: 45
> >> OEM: 100
> >> Name: SEM16
> >> Tran Speed: 52000000
> >> Rd Block Len: 512
> >> MMC version 4.5
> >> High Capacity: Yes
> >> Capacity: 4 MiB <<<< "boot0" partition size correctly reported
> >> Bus Width: 8-bit
> >> Erase Group Size: 512 KiB
> >
> > That is really weird; are you sure you got the latest version of u-boot
> > containing those patches?
> >
> >>        if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) {
> 
> Ah, my device is MMC 4.5, and the version numbers aren't monotonic:
> 
> #define MMC_VERSION_4_41	(MMC_VERSION_MMC | 0x429)
> #define MMC_VERSION_4_5		(MMC_VERSION_MMC | 0x405)
> 
> Should that be 0x450, or do we need some more complex version comparison
> logic?
> 
> FWIW, if I hack the test you quoted to always pass, then the data that's
> printed looks plausible. At the very least, the boot capacity agrees
> with Linux.

Thanks for spotting this, looking at all the defines in mmc.h they are

#define MMC_VERSION_UNKNOWN	(MMC_VERSION_MMC)
#define MMC_VERSION_1_2		(MMC_VERSION_MMC | 0x102)
#define MMC_VERSION_1_4		(MMC_VERSION_MMC | 0x104)
#define MMC_VERSION_2_2		(MMC_VERSION_MMC | 0x202)
#define MMC_VERSION_3		(MMC_VERSION_MMC | 0x300)
#define MMC_VERSION_4		(MMC_VERSION_MMC | 0x400)
#define MMC_VERSION_4_1		(MMC_VERSION_MMC | 0x401)
#define MMC_VERSION_4_2		(MMC_VERSION_MMC | 0x402)
#define MMC_VERSION_4_3		(MMC_VERSION_MMC | 0x403)
#define MMC_VERSION_4_41		(MMC_VERSION_MMC | 0x429)
#define MMC_VERSION_4_5		(MMC_VERSION_MMC | 0x405)
#define MMC_VERSION_5_0		(MMC_VERSION_MMC | 0x500)

I do not get it why MMC_VERSION_4_41 is 0x429, it should be 0x404 to follow the sequence.

Wouldn't it be sane to change it to be

#define MMC_VERSION_4_41		(MMC_VERSION_MMC | 0x404)

I checked mmc_startup() and these defines are not matching bitfields in CSD nor EXT_CSD, so I think it should be safe to change them.

Best,

Diego

--
Diego Santa Cruz, PhD
Technology Architect
T +41 21 341 15 50
diego.santacruz@spinetix.com
spinetix.com
Pantelis Antoniou Jan. 23, 2015, 8:34 a.m. UTC | #7
Hi Diego,

> On Jan 23, 2015, at 10:30 , Diego Santa Cruz <Diego.SantaCruz@spinetix.com> wrote:
> 
>> -----Original Message-----
>> From: Stephen Warren [mailto:swarren@wwwdotorg.org]
>> Sent: Thursday, January 22, 2015 8:59 PM
>> To: Pantelis Antoniou
>> Cc: Diego Santa Cruz; u-boot@lists.denx.de
>> Subject: Re: [U-Boot] [PATCH v4 01/18] mmc: show hardware partition sizes in
>> mmcinfo output
>> 
>> On 01/22/2015 12:45 PM, Pantelis Antoniou wrote:
>>> Hi Stephen,
>>> 
>>>> On Jan 22, 2015, at 20:42 , Stephen Warren <swarren@wwwdotorg.org> wrote:
>>>> 
>>>> On 12/23/2014 02:50 AM, Diego Santa Cruz wrote:
>>>>> There is currently no command that will provide an overview of the
>> hardware
>>>>> partitions present on an eMMC device, one has to switch to every partition
>>>>> via "mmc dev" and run mmcinfo for each to get the partition's capacity.
>>>>> This commit adds a few lines of output to mmcinfo with the sizes of the
>>>>> present partitions, like this:
>>>>> 
>>>>> Device: OMAP SD/MMC
>>>>> Manufacturer ID: fe
>>>>> OEM: 14e
>>>>> Name: MMC16
>>>>> Tran Speed: 52000000
>>>>> Rd Block Len: 512
>>>>> MMC version 4.41
>>>>> High Capacity: Yes
>>>>> Capacity: 13.8 GiB
>>>>> Bus Width: 4-bit
>>>>> User Capacity: 13.8 GiB
>>>>> Boot Capacity: 16 MiB
>>>>> RPMB Capacity: 128 KiB
>>>>> GP1 Capacity: 64 MiB
>>>>> GP2 Capacity: 64 MiB
>>>> 
>>>> I have an MMC device which has at least boot HW partitions, yet with the
>> very latest code in u-boot.git, I don't see the additional lines mentioned
>> above. My HW partitions are still working fine, since I can select a boot
>> partition and mmcinfo shows the correct "Capacity" for it:
>>>> 
>>>> Any ideas why?
>>>> 
>>>> Tegra124 (Jetson TK1) # mmc dev 0
>>>> switch to partitions #0, OK
>>>> mmc0(part 0) is current device
>>>> Tegra124 (Jetson TK1) # mmcinfo
>>>> Device: Tegra SD/MMC
>>>> Manufacturer ID: 45
>>>> OEM: 100
>>>> Name: SEM16
>>>> Tran Speed: 52000000
>>>> Rd Block Len: 512
>>>> MMC version 4.5
>>>> High Capacity: Yes
>>>> Capacity: 14.7 GiB <<<< Sounds right for a 16GB device with partitions
>>>> Bus Width: 8-bit
>>>> Erase Group Size: 512 KiB
>>>> <<<< No HW partition information is printed here
>>>> 
>>>> Tegra124 (Jetson TK1) # mmc dev 0 1 <<<< select "boot0" HW partition
>>>> switch to partitions #1, OK
>>>> mmc0(part 1) is current device
>>>> Tegra124 (Jetson TK1) # mmcinfo
>>>> Device: Tegra SD/MMC
>>>> Manufacturer ID: 45
>>>> OEM: 100
>>>> Name: SEM16
>>>> Tran Speed: 52000000
>>>> Rd Block Len: 512
>>>> MMC version 4.5
>>>> High Capacity: Yes
>>>> Capacity: 4 MiB <<<< "boot0" partition size correctly reported
>>>> Bus Width: 8-bit
>>>> Erase Group Size: 512 KiB
>>> 
>>> That is really weird; are you sure you got the latest version of u-boot
>>> containing those patches?
>>> 
>>>>       if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) {
>> 
>> Ah, my device is MMC 4.5, and the version numbers aren't monotonic:
>> 
>> #define MMC_VERSION_4_41	(MMC_VERSION_MMC | 0x429)
>> #define MMC_VERSION_4_5		(MMC_VERSION_MMC | 0x405)
>> 
>> Should that be 0x450, or do we need some more complex version comparison
>> logic?
>> 
>> FWIW, if I hack the test you quoted to always pass, then the data that's
>> printed looks plausible. At the very least, the boot capacity agrees
>> with Linux.
> 
> Thanks for spotting this, looking at all the defines in mmc.h they are
> 
> #define MMC_VERSION_UNKNOWN	(MMC_VERSION_MMC)
> #define MMC_VERSION_1_2		(MMC_VERSION_MMC | 0x102)
> #define MMC_VERSION_1_4		(MMC_VERSION_MMC | 0x104)
> #define MMC_VERSION_2_2		(MMC_VERSION_MMC | 0x202)
> #define MMC_VERSION_3		(MMC_VERSION_MMC | 0x300)
> #define MMC_VERSION_4		(MMC_VERSION_MMC | 0x400)
> #define MMC_VERSION_4_1		(MMC_VERSION_MMC | 0x401)
> #define MMC_VERSION_4_2		(MMC_VERSION_MMC | 0x402)
> #define MMC_VERSION_4_3		(MMC_VERSION_MMC | 0x403)
> #define MMC_VERSION_4_41		(MMC_VERSION_MMC | 0x429)
> #define MMC_VERSION_4_5		(MMC_VERSION_MMC | 0x405)
> #define MMC_VERSION_5_0		(MMC_VERSION_MMC | 0x500)
> 
> I do not get it why MMC_VERSION_4_41 is 0x429, it should be 0x404 to follow the sequence.
> 
> Wouldn't it be sane to change it to be
> 
> #define MMC_VERSION_4_41		(MMC_VERSION_MMC | 0x404)
> 
> I checked mmc_startup() and these defines are not matching bitfields in CSD nor EXT_CSD, so I think it should be safe to change them.
> 

Changing them is one thing; we have to change the version printout too.

> Best,
> 
> Diego
> 

Regards

— Pantelis

> --
> Diego Santa Cruz, PhD
> Technology Architect
> T +41 21 341 15 50
> diego.santacruz@spinetix.com
> spinetix.com
>
Diego Santa Cruz Jan. 23, 2015, 8:43 a.m. UTC | #8
> -----Original Message-----
> From: Pantelis Antoniou [mailto:panto@antoniou-consulting.com]
> Sent: Friday, January 23, 2015 9:35 AM
> To: Diego Santa Cruz
> Cc: Stephen Warren; u-boot@lists.denx.de
> Subject: Re: [U-Boot] [PATCH v4 01/18] mmc: show hardware partition sizes in
> mmcinfo output
> 
> Hi Diego,
> 
> > On Jan 23, 2015, at 10:30 , Diego Santa Cruz <Diego.SantaCruz@spinetix.com>
> wrote:
> >
> >> -----Original Message-----
> >> From: Stephen Warren [mailto:swarren@wwwdotorg.org]
> >> Sent: Thursday, January 22, 2015 8:59 PM
> >> To: Pantelis Antoniou
> >> Cc: Diego Santa Cruz; u-boot@lists.denx.de
> >> Subject: Re: [U-Boot] [PATCH v4 01/18] mmc: show hardware partition sizes
> in
> >> mmcinfo output
> >>
> >> On 01/22/2015 12:45 PM, Pantelis Antoniou wrote:
> >>> Hi Stephen,
> >>>
> >>>> On Jan 22, 2015, at 20:42 , Stephen Warren <swarren@wwwdotorg.org> wrote:
> >>>>
> >>>> On 12/23/2014 02:50 AM, Diego Santa Cruz wrote:
> >>>>> There is currently no command that will provide an overview of the
> >> hardware
> >>>>> partitions present on an eMMC device, one has to switch to every
> partition
> >>>>> via "mmc dev" and run mmcinfo for each to get the partition's capacity.
> >>>>> This commit adds a few lines of output to mmcinfo with the sizes of the
> >>>>> present partitions, like this:
> >>>>>
> >>>>> Device: OMAP SD/MMC
> >>>>> Manufacturer ID: fe
> >>>>> OEM: 14e
> >>>>> Name: MMC16
> >>>>> Tran Speed: 52000000
> >>>>> Rd Block Len: 512
> >>>>> MMC version 4.41
> >>>>> High Capacity: Yes
> >>>>> Capacity: 13.8 GiB
> >>>>> Bus Width: 4-bit
> >>>>> User Capacity: 13.8 GiB
> >>>>> Boot Capacity: 16 MiB
> >>>>> RPMB Capacity: 128 KiB
> >>>>> GP1 Capacity: 64 MiB
> >>>>> GP2 Capacity: 64 MiB
> >>>>
> >>>> I have an MMC device which has at least boot HW partitions, yet with the
> >> very latest code in u-boot.git, I don't see the additional lines mentioned
> >> above. My HW partitions are still working fine, since I can select a boot
> >> partition and mmcinfo shows the correct "Capacity" for it:
> >>>>
> >>>> Any ideas why?
> >>>>
> >>>> Tegra124 (Jetson TK1) # mmc dev 0
> >>>> switch to partitions #0, OK
> >>>> mmc0(part 0) is current device
> >>>> Tegra124 (Jetson TK1) # mmcinfo
> >>>> Device: Tegra SD/MMC
> >>>> Manufacturer ID: 45
> >>>> OEM: 100
> >>>> Name: SEM16
> >>>> Tran Speed: 52000000
> >>>> Rd Block Len: 512
> >>>> MMC version 4.5
> >>>> High Capacity: Yes
> >>>> Capacity: 14.7 GiB <<<< Sounds right for a 16GB device with partitions
> >>>> Bus Width: 8-bit
> >>>> Erase Group Size: 512 KiB
> >>>> <<<< No HW partition information is printed here
> >>>>
> >>>> Tegra124 (Jetson TK1) # mmc dev 0 1 <<<< select "boot0" HW partition
> >>>> switch to partitions #1, OK
> >>>> mmc0(part 1) is current device
> >>>> Tegra124 (Jetson TK1) # mmcinfo
> >>>> Device: Tegra SD/MMC
> >>>> Manufacturer ID: 45
> >>>> OEM: 100
> >>>> Name: SEM16
> >>>> Tran Speed: 52000000
> >>>> Rd Block Len: 512
> >>>> MMC version 4.5
> >>>> High Capacity: Yes
> >>>> Capacity: 4 MiB <<<< "boot0" partition size correctly reported
> >>>> Bus Width: 8-bit
> >>>> Erase Group Size: 512 KiB
> >>>
> >>> That is really weird; are you sure you got the latest version of u-boot
> >>> containing those patches?
> >>>
> >>>>       if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) {
> >>
> >> Ah, my device is MMC 4.5, and the version numbers aren't monotonic:
> >>
> >> #define MMC_VERSION_4_41	(MMC_VERSION_MMC | 0x429)
> >> #define MMC_VERSION_4_5		(MMC_VERSION_MMC | 0x405)
> >>
> >> Should that be 0x450, or do we need some more complex version comparison
> >> logic?
> >>
> >> FWIW, if I hack the test you quoted to always pass, then the data that's
> >> printed looks plausible. At the very least, the boot capacity agrees
> >> with Linux.
> >
> > Thanks for spotting this, looking at all the defines in mmc.h they are
> >
> > #define MMC_VERSION_UNKNOWN	(MMC_VERSION_MMC)
> > #define MMC_VERSION_1_2		(MMC_VERSION_MMC | 0x102)
> > #define MMC_VERSION_1_4		(MMC_VERSION_MMC | 0x104)
> > #define MMC_VERSION_2_2		(MMC_VERSION_MMC | 0x202)
> > #define MMC_VERSION_3		(MMC_VERSION_MMC | 0x300)
> > #define MMC_VERSION_4		(MMC_VERSION_MMC | 0x400)
> > #define MMC_VERSION_4_1		(MMC_VERSION_MMC | 0x401)
> > #define MMC_VERSION_4_2		(MMC_VERSION_MMC | 0x402)
> > #define MMC_VERSION_4_3		(MMC_VERSION_MMC | 0x403)
> > #define MMC_VERSION_4_41		(MMC_VERSION_MMC | 0x429)
> > #define MMC_VERSION_4_5		(MMC_VERSION_MMC | 0x405)
> > #define MMC_VERSION_5_0		(MMC_VERSION_MMC | 0x500)
> >
> > I do not get it why MMC_VERSION_4_41 is 0x429, it should be 0x404 to follow
> the sequence.
> >
> > Wouldn't it be sane to change it to be
> >
> > #define MMC_VERSION_4_41		(MMC_VERSION_MMC | 0x404)
> >
> > I checked mmc_startup() and these defines are not matching bitfields in CSD
> nor EXT_CSD, so I think it should be safe to change them.
> >
> 
> Changing them is one thing; we have to change the version printout too.
> 

Of course, dumb me..., forget my idea. So changing the others to 0x410, 0x420, ... 0x450, etc., as you propose, would keep version comparisons as they are and the version printout would be easier to handle.

Thanks for volunteering to fix it.

Regards,

Diego
diff mbox

Patch

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 96478e4..fa765d7 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -73,6 +73,8 @@  U_BOOT_CMD(
 
 static void print_mmcinfo(struct mmc *mmc)
 {
+	int i;
+
 	printf("Device: %s\n", mmc->cfg->name);
 	printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24);
 	printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff);
@@ -92,6 +94,21 @@  static void print_mmcinfo(struct mmc *mmc)
 
 	printf("Bus Width: %d-bit%s\n", mmc->bus_width,
 			mmc->ddr_mode ? " DDR" : "");
+
+	if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) {
+		puts("User Capacity: ");
+		print_size(mmc->capacity_user, "\n");
+		puts("Boot Capacity: ");
+		print_size(mmc->capacity_boot, "\n");
+		puts("RPMB Capacity: ");
+		print_size(mmc->capacity_rpmb, "\n");
+		for (i = 0; i < ARRAY_SIZE(mmc->capacity_gp); i++) {
+			if (mmc->capacity_gp[i]) {
+				printf("GP%i Capacity: ", i);
+				print_size(mmc->capacity_gp[i], "\n");
+			}
+		}
+	}
 }
 static struct mmc *init_mmc_device(int dev, bool force_init)
 {