public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] uboot env in mmc partition
@ 2014-08-29 17:21 Naitik Amin
  2014-09-03 15:53 ` Stephen Warren
  0 siblings, 1 reply; 15+ messages in thread
From: Naitik Amin @ 2014-08-29 17:21 UTC (permalink / raw)
  To: u-boot

HI there,

I recently made changes to my system, where I created a new partition on 
my mmc. (mmcblk0p4)

Then i dd'd a uboot env image into this partition, updated the 
fw_env.config to point to /dev/mmcblk0p4. At this point, my fw_printenv 
and fw_setenv work good. So as a next step, I am tried to modify uboot to 
make it point to my env image in my new partition.

I made below changes to my config header and rebuilt the uboot. On doing 
printenv from uboot, I dont see the same env that I pushed it from linux, 
infact I see it as its defined in the config header.

Can some one help ?

/* environment setting for MMC */
#ifdef CONFIG_ENV_IS_IN_MMC
#define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
#define CONFIG_SYS_MMC_ENV_PART         4
#define CONFIG_ENV_OFFSET               0       /* just after the MBR */
#endif

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
       [not found] <OF169DD9B8.4FDAA4B7-ON85257D43.005ECECD-85257D43.005F598D@LocalDomain>
@ 2014-08-29 19:06 ` Naitik Amin
  2014-09-01  4:54   ` Hannes Petermaier
  0 siblings, 1 reply; 15+ messages in thread
From: Naitik Amin @ 2014-08-29 19:06 UTC (permalink / raw)
  To: u-boot

HI there,

I recently made changes to my system, where I created a new partition on 
my mmc. (mmcblk0p4)

Then i dd'd a uboot env image into this partition, updated the 
fw_env.config to point to /dev/mmcblk0p4. At this point, my fw_printenv 
and fw_setenv work good. So as a next step, I am tried to modify uboot to 
make it point to my env image in my new partition.

I made below changes to my config header and rebuilt the uboot. On doing 
printenv from uboot, I dont see the same env that I pushed it from linux, 
infact I see it as its defined in the config header.

Can some one help ?

/* environment setting for MMC */
#ifdef CONFIG_ENV_IS_IN_MMC
#define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
#define CONFIG_SYS_MMC_ENV_PART         4
#define CONFIG_ENV_OFFSET               0       /* just after the MBR */
#endif

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-08-29 19:06 ` [U-Boot] uboot env in mmc partition Naitik Amin
@ 2014-09-01  4:54   ` Hannes Petermaier
  2014-09-02 12:21     ` Naitik Amin
  0 siblings, 1 reply; 15+ messages in thread
From: Hannes Petermaier @ 2014-09-01  4:54 UTC (permalink / raw)
  To: u-boot

> HI there,
Hi Naitik,

> 
> I recently made changes to my system, where I created a new partition on 

> my mmc. (mmcblk0p4)

do you use MMC or eMMC ?
I guess eMMC.

> 
> Then i dd'd a uboot env image into this partition, updated the 
> fw_env.config to point to /dev/mmcblk0p4. At this point, my fw_printenv 
> and fw_setenv work good. So as a next step, I am tried to modify uboot 
to 
> make it point to my env image in my new partition.
> 
> I made below changes to my config header and rebuilt the uboot. On doing 

> printenv from uboot, I dont see the same env that I pushed it from 
linux, 
> infact I see it as its defined in the config header.
> 
> Can some one help ?
> 
> /* environment setting for MMC */
> #ifdef CONFIG_ENV_IS_IN_MMC
> #define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
> #define CONFIG_SYS_MMC_ENV_PART         4
> #define CONFIG_ENV_OFFSET               0       /* just after the MBR */
> #endif

I understand this #defines as following:

CONFIG_SYS_MMC_ENV_DEV says: use mmc-device #0
CONFIG_SYS_MMC_ENV_PART says: use partition #4
i know that u-boot is using the boot-partitions to store the environment, 
an emmc only has 2 partitions.
So #4 is a an illegal paramater

CONFIG_ENV_OFFSET is an absolute address within the device/partition so it 
is not "just after the MBR", instead the environment is "instead the MBR"

best regards,
Hannes

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-09-01  4:54   ` Hannes Petermaier
@ 2014-09-02 12:21     ` Naitik Amin
  2014-09-03  5:13       ` Hannes Petermaier
  0 siblings, 1 reply; 15+ messages in thread
From: Naitik Amin @ 2014-09-02 12:21 UTC (permalink / raw)
  To: u-boot

Hi Hannes,

Yes, its an eMMC. If I read your response correctly,
#define CONFIG_SYS_MMC_ENV_PART
Can only have 2 values, 1 & 2 is that correct ?

Pls also keep in mind that from linux, it works fine, with 
fw_env.config set to
/dev/mmcblk0p4 0 0x10000



From:   Hannes Petermaier <Hannes.Petermaier@br-automation.com>
To:     "Naitik Amin" <Naitik.Amin@ametek.com>, 
Cc:     u-boot at lists.denx.de, u-boot-bounces at lists.denx.de
Date:   09/01/2014 12:54 AM
Subject:        Re: [U-Boot] uboot env in mmc partition



> HI there,
Hi Naitik,

> 
> I recently made changes to my system, where I created a new partition on 


> my mmc. (mmcblk0p4)

do you use MMC or eMMC ?
I guess eMMC.

> 
> Then i dd'd a uboot env image into this partition, updated the 
> fw_env.config to point to /dev/mmcblk0p4. At this point, my fw_printenv 
> and fw_setenv work good. So as a next step, I am tried to modify uboot 
to 
> make it point to my env image in my new partition.
> 
> I made below changes to my config header and rebuilt the uboot. On doing 


> printenv from uboot, I dont see the same env that I pushed it from 
linux, 
> infact I see it as its defined in the config header.
> 
> Can some one help ?
> 
> /* environment setting for MMC */
> #ifdef CONFIG_ENV_IS_IN_MMC
> #define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
> #define CONFIG_SYS_MMC_ENV_PART         4
> #define CONFIG_ENV_OFFSET               0       /* just after the MBR */
> #endif

I understand this #defines as following:

CONFIG_SYS_MMC_ENV_DEV says: use mmc-device #0
CONFIG_SYS_MMC_ENV_PART says: use partition #4
i know that u-boot is using the boot-partitions to store the environment, 
an emmc only has 2 partitions.
So #4 is a an illegal paramater

CONFIG_ENV_OFFSET is an absolute address within the device/partition so it 

is not "just after the MBR", instead the environment is "instead the MBR"

best regards,
Hannes

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-09-02 12:21     ` Naitik Amin
@ 2014-09-03  5:13       ` Hannes Petermaier
  2014-09-03 12:54         ` Naitik Amin
  0 siblings, 1 reply; 15+ messages in thread
From: Hannes Petermaier @ 2014-09-03  5:13 UTC (permalink / raw)
  To: u-boot

> 
> Hi Hannes,
Hi,

> 
> Yes, its an eMMC. If I read your response correctly,
> #define CONFIG_SYS_MMC_ENV_PART
> Can only have 2 values, 1 & 2 is that correct ?
yes - i think so.
please have a look to env_mmc.c, lines 65 to 120 may be the most 
interesting for you.
There are only low-level operations performed, nobody doesn't care about 
any filesystem or "filesystems-partitiontable" at this time.

> 
> Pls also keep in mind that from linux, it works fine, with 
> fw_env.config set to
> /dev/mmcblk0p4 0 0x10000
i think this environment is its own instance and has no interaction with 
u-boot`s one, is that so?
In fact this environment is within "User-Area" of eMMC and at the place 
were part #4 starts.

best regards,
hannes

> 
> From:   Hannes Petermaier <Hannes.Petermaier@br-automation.com>
> To:     "Naitik Amin" <Naitik.Amin@ametek.com>, 
> Cc:     u-boot at lists.denx.de, u-boot-bounces at lists.denx.de
> Date:   09/01/2014 12:54 AM
> Subject:        Re: [U-Boot] uboot env in mmc partition
> 
> 
> 
> > HI there,
> Hi Naitik,
> 
> > 
> > I recently made changes to my system, where I created a new partition 
on 
> 
> 
> > my mmc. (mmcblk0p4)
> 
> do you use MMC or eMMC ?
> I guess eMMC.
> 
> > 
> > Then i dd'd a uboot env image into this partition, updated the 
> > fw_env.config to point to /dev/mmcblk0p4. At this point, my 
fw_printenv 
> > and fw_setenv work good. So as a next step, I am tried to modify uboot 

> to 
> > make it point to my env image in my new partition.
> > 
> > I made below changes to my config header and rebuilt the uboot. On 
doing 
> 
> 
> > printenv from uboot, I dont see the same env that I pushed it from 
> linux, 
> > infact I see it as its defined in the config header.
> > 
> > Can some one help ?
> > 
> > /* environment setting for MMC */
> > #ifdef CONFIG_ENV_IS_IN_MMC
> > #define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
> > #define CONFIG_SYS_MMC_ENV_PART         4
> > #define CONFIG_ENV_OFFSET               0       /* just after the MBR 
*/
> > #endif
> 
> I understand this #defines as following:
> 
> CONFIG_SYS_MMC_ENV_DEV says: use mmc-device #0
> CONFIG_SYS_MMC_ENV_PART says: use partition #4
> i know that u-boot is using the boot-partitions to store the 
environment, 
> an emmc only has 2 partitions.
> So #4 is a an illegal paramater
> 
> CONFIG_ENV_OFFSET is an absolute address within the device/partition so 
it 
> 
> is not "just after the MBR", instead the environment is "instead the 
MBR"
> 
> best regards,
> Hannes

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-09-03  5:13       ` Hannes Petermaier
@ 2014-09-03 12:54         ` Naitik Amin
  2014-09-03 13:06           ` Hannes Petermaier
  2014-09-03 13:52           ` Peter A. Bigot
  0 siblings, 2 replies; 15+ messages in thread
From: Naitik Amin @ 2014-09-03 12:54 UTC (permalink / raw)
  To: u-boot

Hi Hannes,

So I did as you had indicated and made some progress, so now, my #defines 
look as below.
#define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
#define CONFIG_ENV_OFFSET               0x21900000

I calculated the env offset from the block number it was on based on the 
first block number of the partition.

Doing this on uboot startup, I dont get the warning saying, using default 
environment. Neither it complained abt crc error. So it liked it seems. 
But what it did is it trashed the partition which had my dtb and zImage. 
Its a completely different partition. So after that, the bootup gets 
halted. Any ideas ? What may have trashed the partition ?



From:   Hannes Petermaier <Hannes.Petermaier@br-automation.com>
To:     "Naitik Amin" <Naitik.Amin@ametek.com>, 
Cc:     u-boot at lists.denx.de, u-boot-bounces at lists.denx.de
Date:   09/03/2014 01:13 AM
Subject:        Re: [U-Boot] uboot env in mmc partition



> 
> Hi Hannes,
Hi,

> 
> Yes, its an eMMC. If I read your response correctly,
> #define CONFIG_SYS_MMC_ENV_PART
> Can only have 2 values, 1 & 2 is that correct ?
yes - i think so.
please have a look to env_mmc.c, lines 65 to 120 may be the most 
interesting for you.
There are only low-level operations performed, nobody doesn't care about 
any filesystem or "filesystems-partitiontable" at this time.

> 
> Pls also keep in mind that from linux, it works fine, with 
> fw_env.config set to
> /dev/mmcblk0p4 0 0x10000
i think this environment is its own instance and has no interaction with 
u-boot`s one, is that so?
In fact this environment is within "User-Area" of eMMC and at the place 
were part #4 starts.

best regards,
hannes

> 
> From:   Hannes Petermaier <Hannes.Petermaier@br-automation.com>
> To:     "Naitik Amin" <Naitik.Amin@ametek.com>, 
> Cc:     u-boot at lists.denx.de, u-boot-bounces at lists.denx.de
> Date:   09/01/2014 12:54 AM
> Subject:        Re: [U-Boot] uboot env in mmc partition
> 
> 
> 
> > HI there,
> Hi Naitik,
> 
> > 
> > I recently made changes to my system, where I created a new partition 
on 
> 
> 
> > my mmc. (mmcblk0p4)
> 
> do you use MMC or eMMC ?
> I guess eMMC.
> 
> > 
> > Then i dd'd a uboot env image into this partition, updated the 
> > fw_env.config to point to /dev/mmcblk0p4. At this point, my 
fw_printenv 
> > and fw_setenv work good. So as a next step, I am tried to modify uboot 


> to 
> > make it point to my env image in my new partition.
> > 
> > I made below changes to my config header and rebuilt the uboot. On 
doing 
> 
> 
> > printenv from uboot, I dont see the same env that I pushed it from 
> linux, 
> > infact I see it as its defined in the config header.
> > 
> > Can some one help ?
> > 
> > /* environment setting for MMC */
> > #ifdef CONFIG_ENV_IS_IN_MMC
> > #define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
> > #define CONFIG_SYS_MMC_ENV_PART         4
> > #define CONFIG_ENV_OFFSET               0       /* just after the MBR 
*/
> > #endif
> 
> I understand this #defines as following:
> 
> CONFIG_SYS_MMC_ENV_DEV says: use mmc-device #0
> CONFIG_SYS_MMC_ENV_PART says: use partition #4
> i know that u-boot is using the boot-partitions to store the 
environment, 
> an emmc only has 2 partitions.
> So #4 is a an illegal paramater
> 
> CONFIG_ENV_OFFSET is an absolute address within the device/partition so 
it 
> 
> is not "just after the MBR", instead the environment is "instead the 
MBR"
> 
> best regards,
> Hannes

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-09-03 12:54         ` Naitik Amin
@ 2014-09-03 13:06           ` Hannes Petermaier
  2014-09-03 13:52           ` Peter A. Bigot
  1 sibling, 0 replies; 15+ messages in thread
From: Hannes Petermaier @ 2014-09-03 13:06 UTC (permalink / raw)
  To: u-boot

> 
> Hi Hannes,
Hi,

> 
> So I did as you had indicated and made some progress, so now, my 
#defines lookas below.
> #define CONFIG_SYS_MMC_ENV_DEV                0        /* device 0 */
> #define CONFIG_ENV_OFFSET                0x21900000
okay, since we don't have a 'CONFIG_SYS_MMC_ENV_PART' no partition switch 
within eMMC is performed.
So U-Boot reads/writes from Address 0x21900000 within the user-area of 
eMMC.

Can you supply your partition-layout ?

> 
> I calculated the env offset from the block number it was on based on the 
first
> block number of the partition.
Offset = block# * 512, okay ?

> 
> Doing this on uboot startup, I dontget the warning saying, using default 

> environment. Neither it complained abt crc error. So it liked it seems. 
But 
> what it did is it trashed the partition which had my dtb and zImage. Its 
a 
> completely different partition. So after that, the bootup gets halted. 
Any 
> ideas ? What may have trashed the partition ?

Maybe the blockaddress of 0x21900000 (1099776 dec) is within the partition 
where zImage/dtb is stored.
Please double-check the CONFIG_ENV_OFFSET address.


best regards,
hannes

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-09-03 12:54         ` Naitik Amin
  2014-09-03 13:06           ` Hannes Petermaier
@ 2014-09-03 13:52           ` Peter A. Bigot
  2014-09-03 14:14             ` Hannes Petermaier
  1 sibling, 1 reply; 15+ messages in thread
From: Peter A. Bigot @ 2014-09-03 13:52 UTC (permalink / raw)
  To: u-boot

On 09/03/2014 07:54 AM, Naitik Amin wrote:
> Hi Hannes,
>
> So I did as you had indicated and made some progress, so now, my #defines
> look as below.
> #define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
> #define CONFIG_ENV_OFFSET               0x21900000
>
> I calculated the env offset from the block number it was on based on the
> first block number of the partition.
>
> Doing this on uboot startup, I dont get the warning saying, using default
> environment. Neither it complained abt crc error. So it liked it seems.
> But what it did is it trashed the partition which had my dtb and zImage.
> Its a completely different partition. So after that, the bootup gets
> halted. Any ideas ? What may have trashed the partition ?

Look at: http://www.mail-archive.com/u-boot at lists.denx.de/msg146396.html

and see if that's relevant, specifically the second patch which restores 
the mmc device offset calculations to the values that correspond to the 
partition number that's represented in the device structure.

Peter

>
>
>
> From:   Hannes Petermaier <Hannes.Petermaier@br-automation.com>
> To:     "Naitik Amin" <Naitik.Amin@ametek.com>,
> Cc:     u-boot at lists.denx.de, u-boot-bounces at lists.denx.de
> Date:   09/03/2014 01:13 AM
> Subject:        Re: [U-Boot] uboot env in mmc partition
>
>
>
>> Hi Hannes,
> Hi,
>
>> Yes, its an eMMC. If I read your response correctly,
>> #define CONFIG_SYS_MMC_ENV_PART
>> Can only have 2 values, 1 & 2 is that correct ?
> yes - i think so.
> please have a look to env_mmc.c, lines 65 to 120 may be the most
> interesting for you.
> There are only low-level operations performed, nobody doesn't care about
> any filesystem or "filesystems-partitiontable" at this time.
>
>> Pls also keep in mind that from linux, it works fine, with
>> fw_env.config set to
>> /dev/mmcblk0p4 0 0x10000
> i think this environment is its own instance and has no interaction with
> u-boot`s one, is that so?
> In fact this environment is within "User-Area" of eMMC and at the place
> were part #4 starts.
>
> best regards,
> hannes
>
>> From:   Hannes Petermaier <Hannes.Petermaier@br-automation.com>
>> To:     "Naitik Amin" <Naitik.Amin@ametek.com>,
>> Cc:     u-boot at lists.denx.de, u-boot-bounces at lists.denx.de
>> Date:   09/01/2014 12:54 AM
>> Subject:        Re: [U-Boot] uboot env in mmc partition
>>
>>
>>
>>> HI there,
>> Hi Naitik,
>>
>>> I recently made changes to my system, where I created a new partition
> on
>>
>>> my mmc. (mmcblk0p4)
>> do you use MMC or eMMC ?
>> I guess eMMC.
>>
>>> Then i dd'd a uboot env image into this partition, updated the
>>> fw_env.config to point to /dev/mmcblk0p4. At this point, my
> fw_printenv
>>> and fw_setenv work good. So as a next step, I am tried to modify uboot
>
>> to
>>> make it point to my env image in my new partition.
>>>
>>> I made below changes to my config header and rebuilt the uboot. On
> doing
>>
>>> printenv from uboot, I dont see the same env that I pushed it from
>> linux,
>>> infact I see it as its defined in the config header.
>>>
>>> Can some one help ?
>>>
>>> /* environment setting for MMC */
>>> #ifdef CONFIG_ENV_IS_IN_MMC
>>> #define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
>>> #define CONFIG_SYS_MMC_ENV_PART         4
>>> #define CONFIG_ENV_OFFSET               0       /* just after the MBR
> */
>>> #endif
>> I understand this #defines as following:
>>
>> CONFIG_SYS_MMC_ENV_DEV says: use mmc-device #0
>> CONFIG_SYS_MMC_ENV_PART says: use partition #4
>> i know that u-boot is using the boot-partitions to store the
> environment,
>> an emmc only has 2 partitions.
>> So #4 is a an illegal paramater
>>
>> CONFIG_ENV_OFFSET is an absolute address within the device/partition so
> it
>> is not "just after the MBR", instead the environment is "instead the
> MBR"
>> best regards,
>> Hannes
>
>
>
>
>
>
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-09-03 13:52           ` Peter A. Bigot
@ 2014-09-03 14:14             ` Hannes Petermaier
  2014-09-03 14:23               ` Peter A. Bigot
  2014-09-03 19:17               ` Naitik Amin
  0 siblings, 2 replies; 15+ messages in thread
From: Hannes Petermaier @ 2014-09-03 14:14 UTC (permalink / raw)
  To: u-boot

> 
> On 09/03/2014 07:54 AM, Naitik Amin wrote:
> > Hi Hannes,
> >
> > So I did as you had indicated and made some progress, so now, my 
#defines
> > look as below.
> > #define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
> > #define CONFIG_ENV_OFFSET               0x21900000
> >
> > I calculated the env offset from the block number it was on based on 
the
> > first block number of the partition.
> >
> > Doing this on uboot startup, I dont get the warning saying, using 
default
> > environment. Neither it complained abt crc error. So it liked it 
seems.
> > But what it did is it trashed the partition which had my dtb and 
zImage.
> > Its a completely different partition. So after that, the bootup gets
> > halted. Any ideas ? What may have trashed the partition ?
> 
> Look at: http://www.mail-archive.com/u-boot at lists.denx.de/msg146396.html
> 
> and see if that's relevant, specifically the second patch which restores 

> the mmc device offset calculations to the values that correspond to the 
> partition number that's represented in the device structure.
> 
> Peter

Hi Peter,
i don't think that your patch has influence on this issue, due to no 
partition switching is done anymore.

Further i would like to check your patch series, i am not sure if there is 
everything ok.
I will do so tommorow - i am right in thinking that you are using MMC not 
eMMC ?

best regards,
Hannes

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-09-03 14:14             ` Hannes Petermaier
@ 2014-09-03 14:23               ` Peter A. Bigot
  2014-09-03 14:38                 ` Naitik Amin
  2014-09-03 19:17               ` Naitik Amin
  1 sibling, 1 reply; 15+ messages in thread
From: Peter A. Bigot @ 2014-09-03 14:23 UTC (permalink / raw)
  To: u-boot

On 09/03/2014 09:14 AM, Hannes Petermaier wrote:
>> On 09/03/2014 07:54 AM, Naitik Amin wrote:
>>> Hi Hannes,
>>>
>>> So I did as you had indicated and made some progress, so now, my
> #defines
>>> look as below.
>>> #define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
>>> #define CONFIG_ENV_OFFSET               0x21900000
>>>
>>> I calculated the env offset from the block number it was on based on
> the
>>> first block number of the partition.
>>>
>>> Doing this on uboot startup, I dont get the warning saying, using
> default
>>> environment. Neither it complained abt crc error. So it liked it
> seems.
>>> But what it did is it trashed the partition which had my dtb and
> zImage.
>>> Its a completely different partition. So after that, the bootup gets
>>> halted. Any ideas ? What may have trashed the partition ?
>> Look at: http://www.mail-archive.com/u-boot at lists.denx.de/msg146396.html
>>
>> and see if that's relevant, specifically the second patch which restores
>> the mmc device offset calculations to the values that correspond to the
>> partition number that's represented in the device structure.
>>
>> Peter
> Hi Peter,
> i don't think that your patch has influence on this issue, due to no
> partition switching is done anymore.

That may be the case: I missed most of the previous discussion of this 
issue.  All I know is that if mmc->part_num is 0 when the MMC 
environment code is entered, then when it leaves the capacity and lba 
fields of the device are no longer correct.  So it'd seemed plausible 
that if mmc_switch_part were invoked somewhere when looking for an 
environment partition it could explain an anomaly with subsequent use of 
the device.

> Further i would like to check your patch series, i am not sure if there is
> everything ok.
> I will do so tommorow - i am right in thinking that you are using MMC not
> eMMC ?

There is eMMC on the BeagleBone I'm using, but it's been zeroed and is 
not used.  The problem arises in SPL mode on a uSD card with two 
partitions neither of which is an environment.  For full context see the 
meta-ti email thread referenced in the cover letter.

Peter

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-09-03 14:23               ` Peter A. Bigot
@ 2014-09-03 14:38                 ` Naitik Amin
  2014-09-03 15:54                   ` Sachin Verma
  0 siblings, 1 reply; 15+ messages in thread
From: Naitik Amin @ 2014-09-03 14:38 UTC (permalink / raw)
  To: u-boot

Below is the layout of my partitions.

[root at IM /root]# cat /proc/partitions
major minor  #blocks  name

 179        0    3887104 mmcblk0
 179        1      20480 mmcblk0p1
 179        2     512000 mmcblk0p2
 179        3       1024 mmcblk0p3
 179        4         64 mmcblk0p4

Further explanation
Partition 1: Partition type: 0xB Fat32 (Holds zImage, dtb, rbf, uboot 
startup script)
Partition 2: Partititon type: 0x83 ext3 (Holds rootfs)
Partition 3: Partition type: A2 (raw) MBR looks for preloader at the 
beginning of the A2 partition. (Holds Preloader, followed by uboot)
Partition 4: Partition type: A3 (raw) To hold the uboot-env (Newly 
created)



From:   "Peter A. Bigot" <pab@pabigot.com>
To:     Hannes Petermaier <Hannes.Petermaier@br-automation.com>, 
Cc:     u-boot at lists.denx.de, Naitik Amin <Naitik.Amin@ametek.com>
Date:   09/03/2014 10:23 AM
Subject:        Re: [U-Boot] uboot env in mmc partition



On 09/03/2014 09:14 AM, Hannes Petermaier wrote:
>> On 09/03/2014 07:54 AM, Naitik Amin wrote:
>>> Hi Hannes,
>>>
>>> So I did as you had indicated and made some progress, so now, my
> #defines
>>> look as below.
>>> #define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
>>> #define CONFIG_ENV_OFFSET               0x21900000
>>>
>>> I calculated the env offset from the block number it was on based on
> the
>>> first block number of the partition.
>>>
>>> Doing this on uboot startup, I dont get the warning saying, using
> default
>>> environment. Neither it complained abt crc error. So it liked it
> seems.
>>> But what it did is it trashed the partition which had my dtb and
> zImage.
>>> Its a completely different partition. So after that, the bootup gets
>>> halted. Any ideas ? What may have trashed the partition ?
>> Look at: 
http://www.mail-archive.com/u-boot at lists.denx.de/msg146396.html
>>
>> and see if that's relevant, specifically the second patch which 
restores
>> the mmc device offset calculations to the values that correspond to the
>> partition number that's represented in the device structure.
>>
>> Peter
> Hi Peter,
> i don't think that your patch has influence on this issue, due to no
> partition switching is done anymore.

That may be the case: I missed most of the previous discussion of this 
issue.  All I know is that if mmc->part_num is 0 when the MMC 
environment code is entered, then when it leaves the capacity and lba 
fields of the device are no longer correct.  So it'd seemed plausible 
that if mmc_switch_part were invoked somewhere when looking for an 
environment partition it could explain an anomaly with subsequent use of 
the device.

> Further i would like to check your patch series, i am not sure if there 
is
> everything ok.
> I will do so tommorow - i am right in thinking that you are using MMC 
not
> eMMC ?

There is eMMC on the BeagleBone I'm using, but it's been zeroed and is 
not used.  The problem arises in SPL mode on a uSD card with two 
partitions neither of which is an environment.  For full context see the 
meta-ti email thread referenced in the cover letter.

Peter

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-08-29 17:21 Naitik Amin
@ 2014-09-03 15:53 ` Stephen Warren
  0 siblings, 0 replies; 15+ messages in thread
From: Stephen Warren @ 2014-09-03 15:53 UTC (permalink / raw)
  To: u-boot

On 08/29/2014 11:21 AM, Naitik Amin wrote:
> HI there,
>
> I recently made changes to my system, where I created a new partition on
> my mmc. (mmcblk0p4)
>
> Then i dd'd a uboot env image into this partition, updated the
> fw_env.config to point to /dev/mmcblk0p4. At this point, my fw_printenv
> and fw_setenv work good. So as a next step, I am tried to modify uboot to
> make it point to my env image in my new partition.
>
> I made below changes to my config header and rebuilt the uboot. On doing
> printenv from uboot, I dont see the same env that I pushed it from linux,
> infact I see it as its defined in the config header.
>
> Can some one help ?
>
> /* environment setting for MMC */
> #ifdef CONFIG_ENV_IS_IN_MMC
> #define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
> #define CONFIG_SYS_MMC_ENV_PART         4
> #define CONFIG_ENV_OFFSET               0       /* just after the MBR */
> #endif

I think you're confusing eMMC HW-level partitions (0=user data or 
mmcblk0, 1=mmcblk0boot0, 2=mmcblk0boot1) and SW-level (MBR/GPT) 
partitions within the user data area; /dev/mmcblk0p4.

CONFIG_SYS_MMC_ENV_PART applies to eMMC HW-level partitions.

I don't know if there's an environment variable that selects which 
SW-level partition to use. This is the feature you're looking for!

Later in the thread I saw:
#define CONFIG_ENV_OFFSET                0x21900000

That's not a good idea, since if someone repartitions the disk, that 
offset will be incorrect. Better would be to use (or add) SW-level 
partition support in the MMC environment code.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-09-03 14:38                 ` Naitik Amin
@ 2014-09-03 15:54                   ` Sachin Verma
  2014-09-03 16:03                     ` Naitik Amin
  0 siblings, 1 reply; 15+ messages in thread
From: Sachin Verma @ 2014-09-03 15:54 UTC (permalink / raw)
  To: u-boot

Hi Naitik,
On Wed, Sep 3, 2014 at 8:08 PM, Naitik Amin <Naitik.Amin@ametek.com> wrote:

> Below is the layout of my partitions.
>
> [root at IM /root]# cat /proc/partitions
> major minor  #blocks  name
>
>  179        0    3887104 mmcblk0
>  179        1      20480 mmcblk0p1
>  179        2     512000 mmcblk0p2
>  179        3       1024 mmcblk0p3
>  179        4         64 mmcblk0p4
>
> Further explanation
> Partition 1: Partition type: 0xB Fat32 (Holds zImage, dtb, rbf, uboot
> startup script)
> Partition 2: Partititon type: 0x83 ext3 (Holds rootfs)
> Partition 3: Partition type: A2 (raw) MBR looks for preloader at the
> beginning of the A2 partition. (Holds Preloader, followed by uboot)
> Partition 4: Partition type: A3 (raw) To hold the uboot-env (Newly
> created)
>
>
According to your partition layout, your environment offset must be :
(3887104 + 20480 + 512000 + 1024) = 4420608 blocks into the user partition
of eMMC.

So, the offset should be 4420608 * 512 = 2263351296 = 0x86E80000


The offset (0x21900000) you are using seems to be in your very first
partition i.e. mmcblk0 and hence it is corrupting your dtb and other files.

Best Regards,
Sachin Verma.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-09-03 15:54                   ` Sachin Verma
@ 2014-09-03 16:03                     ` Naitik Amin
  0 siblings, 0 replies; 15+ messages in thread
From: Naitik Amin @ 2014-09-03 16:03 UTC (permalink / raw)
  To: u-boot

Hi Sachin,

My paritions are not laid out in the same order of 1-4 in memory. The 
address that computed came from below

[root at IM mmcblk0p4]# ls
alignment_offset   holders            ro                 stat
dev                inflight           size               subsystem
discard_alignment  partition          start              uevent
[root at IM mmcblk0p4]# cat start
1099776

1099776 * 512 = 0x21900000




From:   Sachin Verma <simplysachin@gmail.com>
To:     Naitik Amin <Naitik.Amin@ametek.com>, 
Cc:     "Peter A. Bigot" <pab@pabigot.com>, u-boot at lists.denx.de, Hannes 
Petermaier <Hannes.Petermaier@br-automation.com>
Date:   09/03/2014 11:54 AM
Subject:        Re: [U-Boot] uboot env in mmc partition




Hi Naitik,
On Wed, Sep 3, 2014 at 8:08 PM, Naitik Amin <Naitik.Amin@ametek.com> 
wrote:
Below is the layout of my partitions.

[root at IM /root]# cat /proc/partitions
major minor  #blocks  name

 179        0    3887104 mmcblk0
 179        1      20480 mmcblk0p1
 179        2     512000 mmcblk0p2
 179        3       1024 mmcblk0p3
 179        4         64 mmcblk0p4

Further explanation
Partition 1: Partition type: 0xB Fat32 (Holds zImage, dtb, rbf, uboot
startup script)
Partition 2: Partititon type: 0x83 ext3 (Holds rootfs)
Partition 3: Partition type: A2 (raw) MBR looks for preloader at the
beginning of the A2 partition. (Holds Preloader, followed by uboot)
Partition 4: Partition type: A3 (raw) To hold the uboot-env (Newly
created)

 
According to your partition layout, your environment offset must be :  
(3887104 + 20480 + 512000 + 1024) = 4420608 blocks into the user partition 
of eMMC.
 
So, the offset should be 4420608 * 512 = 2263351296 = 0x86E80000
 
 
The offset (0x21900000) you are using seems to be in your very first 
partition i.e. mmcblk0 and hence it is corrupting your dtb and other 
files.
 
Best Regards,
Sachin Verma.
 

 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [U-Boot] uboot env in mmc partition
  2014-09-03 14:14             ` Hannes Petermaier
  2014-09-03 14:23               ` Peter A. Bigot
@ 2014-09-03 19:17               ` Naitik Amin
  1 sibling, 0 replies; 15+ messages in thread
From: Naitik Amin @ 2014-09-03 19:17 UTC (permalink / raw)
  To: u-boot

More info..

Below is what I see on bootup.

My env is at 0x100000 from base of sd card. It seems something happened on 
the hash insert.


>>>>>>>>>>>>> Boot Log >>>>>>>>>>>>>

U-Boot SPL 2013.01.01 (May 02 2014 - 11:49:21)
BOARD : Altera SOCFPGA Cyclone V Board
SDRAM: Initializing MMR registers
SDRAM: Calibrating PHY
SEQ.C: Preparing to start memory calibration
SEQ.C: CALIBRATION PASSED
ALTERA DWMMC: 0


U-Boot 2013.01.01 (Sep 03 2014 - 15:12:29)

CPU   : Altera SOCFPGA Platform
BOARD : Altera SOCFPGA Cyclone V Board
DRAM:  512 MiB
MMC:   ALTERA DWMMC: 0
env offset 1048576
CRC from Header 0x6cf572d5 Computed CRC 0x6cf572d5
" (type: m)lags type check failure for "ethaddr" <= "04:25:fe:ed:00:18
" into hash tableinsert "ethaddr=04:25:fe:ed:00:18
" (type: m)lags type check failure for "ethaddr" <= "00:b0:19:00:01:02
" into hash tableinsert "ethaddr=00:b0:19:00:01:02
In:    serial
Out:   serial
Err:   serial
Net:   mii0
Warning: failed to set MAC address

Hit any key to stop autoboot:  0
reading u-boot.scr
 **Unable to read file u-boot.scr
Optional boot script not found. Continuing to boot normally
' - try 'help'd '
' - try 'help'd 'fatload
' - try 'help'd 'fatload
" not definedcboot





From:   Hannes Petermaier <Hannes.Petermaier@br-automation.com>
To:     "Peter A. Bigot" <pab@pabigot.com>, 
Cc:     u-boot at lists.denx.de, Naitik Amin <Naitik.Amin@ametek.com>
Date:   09/03/2014 10:14 AM
Subject:        Re: [U-Boot] uboot env in mmc partition



> 
> On 09/03/2014 07:54 AM, Naitik Amin wrote:
> > Hi Hannes,
> >
> > So I did as you had indicated and made some progress, so now, my 
#defines
> > look as below.
> > #define CONFIG_SYS_MMC_ENV_DEV          0       /* device 0 */
> > #define CONFIG_ENV_OFFSET               0x21900000
> >
> > I calculated the env offset from the block number it was on based on 
the
> > first block number of the partition.
> >
> > Doing this on uboot startup, I dont get the warning saying, using 
default
> > environment. Neither it complained abt crc error. So it liked it 
seems.
> > But what it did is it trashed the partition which had my dtb and 
zImage.
> > Its a completely different partition. So after that, the bootup gets
> > halted. Any ideas ? What may have trashed the partition ?
> 
> Look at: http://www.mail-archive.com/u-boot at lists.denx.de/msg146396.html
> 
> and see if that's relevant, specifically the second patch which restores 


> the mmc device offset calculations to the values that correspond to the 
> partition number that's represented in the device structure.
> 
> Peter

Hi Peter,
i don't think that your patch has influence on this issue, due to no 
partition switching is done anymore.

Further i would like to check your patch series, i am not sure if there is 

everything ok.
I will do so tommorow - i am right in thinking that you are using MMC not 
eMMC ?

best regards,
Hannes

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-09-03 19:17 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <OF169DD9B8.4FDAA4B7-ON85257D43.005ECECD-85257D43.005F598D@LocalDomain>
2014-08-29 19:06 ` [U-Boot] uboot env in mmc partition Naitik Amin
2014-09-01  4:54   ` Hannes Petermaier
2014-09-02 12:21     ` Naitik Amin
2014-09-03  5:13       ` Hannes Petermaier
2014-09-03 12:54         ` Naitik Amin
2014-09-03 13:06           ` Hannes Petermaier
2014-09-03 13:52           ` Peter A. Bigot
2014-09-03 14:14             ` Hannes Petermaier
2014-09-03 14:23               ` Peter A. Bigot
2014-09-03 14:38                 ` Naitik Amin
2014-09-03 15:54                   ` Sachin Verma
2014-09-03 16:03                     ` Naitik Amin
2014-09-03 19:17               ` Naitik Amin
2014-08-29 17:21 Naitik Amin
2014-09-03 15:53 ` Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox