* [U-Boot-Users] using static variables
@ 2006-03-24 16:33 David Ho
2006-03-24 17:16 ` Wolfgang Denk
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: David Ho @ 2006-03-24 16:33 UTC (permalink / raw)
To: u-boot
Hi,
I would appreciate if an u-boot expert can explain the use of static
variables in u-boot.
My understanding is that when u-boot is still running in flash static
variables are not modifiable. Once u-boot moves to RAM, what will
happen to static variables? I don't quite understand how the
mechanism work before and after relocation.
I asked this question because I need a saved copy of a write only
latch/register, which I have to initialize early.
I have added a field in the global_data struct previously for this.
Seeing that introduced changes in the common code I would like to
choose a method I can use to localize it in my board specific code.
Will I be able to use static variables in board_early_init_r?
Are there some other mehods I have not noticed?
Regards,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot-Users] using static variables
2006-03-24 16:33 [U-Boot-Users] using static variables David Ho
@ 2006-03-24 17:16 ` Wolfgang Denk
2006-03-27 20:11 ` David Ho
2006-03-27 6:30 ` Tore Martin Hagen
2006-03-27 8:42 ` Sam Song
2 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Denk @ 2006-03-24 17:16 UTC (permalink / raw)
To: u-boot
Dear David,
in message <4dd15d180603240833y237b9199lcd4af04a824fff68@mail.gmail.com> you wrote:
>
> My understanding is that when u-boot is still running in flash static
> variables are not modifiable. Once u-boot moves to RAM, what will
Correct.
> happen to static variables? I don't quite understand how the
> mechanism work before and after relocation.
Static variables with nonzero initialial values (the data segment)
are copied to RAM, too, and magicly become writable. Static variables
with (implicit or explicit) zero initialial values (the bss segment)
will have space allocated in the new created and zeroed bss segment.
> I asked this question because I need a saved copy of a write only
> latch/register, which I have to initialize early.
>
> I have added a field in the global_data struct previously for this.
Thisi s discouraged. If each board would do this we'd have a terrible
mess soon.
> Seeing that introduced changes in the common code I would like to
> choose a method I can use to localize it in my board specific code.
Good idea.
> Will I be able to use static variables in board_early_init_r?
No, as this is still running from ROM.
> Are there some other mehods I have not noticed?
Use free registers, on chip memory, etc.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Use the Force, Luke.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot-Users] using static variables
2006-03-24 16:33 [U-Boot-Users] using static variables David Ho
2006-03-24 17:16 ` Wolfgang Denk
@ 2006-03-27 6:30 ` Tore Martin Hagen
2006-03-27 7:30 ` Wolfgang Denk
2006-03-27 8:42 ` Sam Song
2 siblings, 1 reply; 6+ messages in thread
From: Tore Martin Hagen @ 2006-03-27 6:30 UTC (permalink / raw)
To: u-boot
David Ho wrote:
>Hi,
>
>
>Are there some other mehods I have not noticed?
>
>
>
Since your flash is up and running the easyest is probably to erase a
flash sector before starting up and then write directly to that address.
/Tore Martin Hagen
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot-Users] using static variables
2006-03-27 6:30 ` Tore Martin Hagen
@ 2006-03-27 7:30 ` Wolfgang Denk
0 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Denk @ 2006-03-27 7:30 UTC (permalink / raw)
To: u-boot
In message <442786A3.5000909@slb.com> you wrote:
>
> Since your flash is up and running the easyest is probably to erase a
> flash sector before starting up and then write directly to that address.
This does not work, because you cannot run any flash driver code
(which will set the flash into programming mode and thus prevent
reading normal data) while you are still running from flash (so you
need to be able to fetch instructions and data from flash).
And it is a very bad idea anyway as each reset would reduce the
filetime of your product.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I wish Captain Vimes were here. He wouldn't have known what to do
either, but he's got a much better vocabulary to be baffled in.
- Terry Pratchett, _Guards! Guards!_
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot-Users] using static variables
2006-03-24 16:33 [U-Boot-Users] using static variables David Ho
2006-03-24 17:16 ` Wolfgang Denk
2006-03-27 6:30 ` Tore Martin Hagen
@ 2006-03-27 8:42 ` Sam Song
2 siblings, 0 replies; 6+ messages in thread
From: Sam Song @ 2006-03-27 8:42 UTC (permalink / raw)
To: u-boot
David Ho <davidkwho@gmail.com> wrote:
> Are there some other mehods I have not noticed?
>
Seems you could use Alarm registers in RTC chip
if had. I tried it on DS1337 and worked.
Regards,
Sam
___________________________________________________________
??1G???????????
http://cn.mail.yahoo.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot-Users] using static variables
2006-03-24 17:16 ` Wolfgang Denk
@ 2006-03-27 20:11 ` David Ho
0 siblings, 0 replies; 6+ messages in thread
From: David Ho @ 2006-03-27 20:11 UTC (permalink / raw)
To: u-boot
Thanks guys,
Using a pre-initialized static variable, I have managed to set the the
write only latch early with the initialized value while running in
flash (board_early_init_f) and only modify the latch and static
variable in (board_early_init_r), by then the variable is modifable.
Thanks again, David
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-03-27 20:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-24 16:33 [U-Boot-Users] using static variables David Ho
2006-03-24 17:16 ` Wolfgang Denk
2006-03-27 20:11 ` David Ho
2006-03-27 6:30 ` Tore Martin Hagen
2006-03-27 7:30 ` Wolfgang Denk
2006-03-27 8:42 ` Sam Song
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.