All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulf Samuelsson <ulf.samuelsson@atmel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH]: Fix for bug: U-boot environment corruptby reading uninitialized flash memory instead of RAM.
Date: Sat, 10 May 2008 11:46:42 +0200	[thread overview]
Message-ID: <004901c8b3a6$00a670b0$030514ac@atmel.com> (raw)
In-Reply-To: 20080509204455.3F05024764@gemini.denx.de



> In message <3efb10970805060705l112c623at96bf0521eed8a211@mail.gmail.com> you wrote:
>>
>> Commit c0559be371b2a64b1a817088c3308688e2182f93 introduces a bug in
>> the environment setting storage in U-boot-1.3.3-rc3.
>> Settings are retrieved from dataflash when only settings in RAM are
>> valid, resulting in corrupt environment settings, failing printenv
>> command, and
>> duplicate variables.
>> 
>> This patch fixes this by always using the RAM area when it is created
>> and initialized. (Matches more the behavior as it was prior to this
>> particular commit.)
> 
> Sorry, but this patch makes littles sense to me.
> 
>> See attached (Sorry, my mailer does not handle inline-patches properly)
> 
> Chose another one? Or rather use "git-send-email" directly?
> 
> - /* if relocated to RAM */
> - if (gd->flags & GD_FLG_RELOC)
> + /* if relocated to RAM, OR if the environment in Malloc-ed RAM is valid */
> + if ((gd->flags & GD_FLG_RELOC) || (gd->env_valid))
> 
> Let's keep in mind that the normal logic of the U-Boot startup
> sequence is like this:
> 
> * U-Boot boots and initializes the RAM
> * U-Boot relocates itself into RAM, sets GD_FLG_RELOC and continues
>  running from RAM
> * U-Boot continues with the initialization, for xample by setting up
>  the malloc arena, loading the working copy of the environment into
>  RAM (after which it set's gd->env_valid), etc.
> 

When you have a dataflash, this is not the normal behaviour.

A typical behaviour of an AT91 would be:

1) BootROM copies initial bootloader (at91bootstrap/dataflashboot) to internal SRAM
2) BootROM jumps to start of initial bootloader
3) Initial bootloader does low-level init (including configuring the SDRAM controller)
4) Initial bootloader copies U-Boot from dataflash to SDRAM
5) Initial bootloader jumps to U-Boot
6) U-Boot needs to skip low-level init


> So the relocation to RAM always preceeds any use of malloc() and the
> setting of gd->env_valid. Or, put the other way round, we always set
> GD_FLG_RELOC long before gd->env_valid get's set.
> 
> Thus your change above is just redundant.
> 
> 
> Now, if your board  does  not  perform  proper  relocation  for  some
> reason, it should still set GD_FLG_RELOC at the appropriate place, i.
> e. as soon as U-Boot is ready for and starts running out of RAM.
> 
> Best regards,
> 
> Wolfgang Denk
> 


Best Regards
Ulf Samuelsson

  reply	other threads:[~2008-05-10  9:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-06 14:05 [U-Boot-Users] [PATCH]: Fix for bug: U-boot environment corrupt by reading uninitialized flash memory instead of RAM Remy Bohmer
2008-05-06 15:23 ` Haavard Skinnemoen
2008-05-07  7:52   ` Remy Bohmer
2008-05-07  9:14     ` Haavard Skinnemoen
2008-05-09 20:46   ` Wolfgang Denk
2008-05-09 20:44 ` Wolfgang Denk
2008-05-10  9:46   ` Ulf Samuelsson [this message]
2008-05-11 20:48     ` [U-Boot-Users] [PATCH]: Fix for bug: U-boot environment corruptby " Wolfgang Denk
2008-05-10 13:53   ` [U-Boot-Users] [PATCH]: Fix for bug: U-boot environment corrupt by " Remy Bohmer
2008-05-11 22:43     ` Wolfgang Denk
2008-05-12  7:25       ` Joakim Tjernlund
2008-05-28 18:25         ` Joakim Tjernlund
2008-06-04 22:05           ` Wolfgang Denk
2008-06-12  6:52             ` Joakim Tjernlund
2008-07-05 22:32               ` Wolfgang Denk
2008-07-06 10:30                 ` Joakim Tjernlund
2008-07-09 21:59                   ` Wolfgang Denk
2008-07-16 12:43             ` Remy Bohmer
2008-07-22 12:26               ` Remy Bohmer
     [not found]         ` <-6864379040381327023@unknownmsgid>
2008-05-29 18:33           ` Remy Bohmer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='004901c8b3a6$00a670b0$030514ac@atmel.com' \
    --to=ulf.samuelsson@atmel.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.