All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] Copy environment variables to another board
@ 2008-12-30 10:30 Giuseppe Modugno
  2008-12-30 10:52 ` Wolfgang Denk
  0 siblings, 1 reply; 10+ messages in thread
From: Giuseppe Modugno @ 2008-12-30 10:30 UTC (permalink / raw)
  To: u-boot

I'm sorry if my question was already asked, but I didn't find an 
answer in the manual/FAQs/mailing list archive.

I have a board running U-Boot/Linux. U-Boot program, two U-Boot 
environments, Linux kernel and root filesystem for Linux are stored 
in a NOR Flash.

I finished my developing process and now I want to copy the entire U-
Boot environment to a new board. Of course, I don't want to manually 
copy all the variables in the environment.

Is there a simple way to dump the full environment in a file and copy 
it in the new board?

Thanks for your help.

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

* [U-Boot] Copy environment variables to another board
  2008-12-30 10:30 [U-Boot] Copy environment variables to another board Giuseppe Modugno
@ 2008-12-30 10:52 ` Wolfgang Denk
  2008-12-30 10:58   ` Giuseppe Modugno
  2008-12-30 11:00   ` Giuseppe Modugno
  0 siblings, 2 replies; 10+ messages in thread
From: Wolfgang Denk @ 2008-12-30 10:52 UTC (permalink / raw)
  To: u-boot

Dear "Giuseppe Modugno",

In message <495A0644.29557.A6846B@g.modugno.elettronika.it> you wrote:
>
> I have a board running U-Boot/Linux. U-Boot program, two U-Boot 
> environments, Linux kernel and root filesystem for Linux are stored 
> in a NOR Flash.
> 
> I finished my developing process and now I want to copy the entire U-
> Boot environment to a new board. Of course, I don't want to manually 
> copy all the variables in the environment.
> 
> Is there a simple way to dump the full environment in a file and copy 
> it in the new board?

Assuming both boards have the same configuration (or, more precisely,
at least the same size of environment and environment sectors),  then
you can just read the sector(s) containing the environment from their
corresponding  /dev/mtd*  devices  in  Linux and copy it to the other
system.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The great question... which I have not been able  to  answer...  is,
`What does woman want?'"                              - Sigmund Freud

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

* [U-Boot] Copy environment variables to another board
  2008-12-30 10:52 ` Wolfgang Denk
@ 2008-12-30 10:58   ` Giuseppe Modugno
  2008-12-30 11:40     ` Alessandro Rubini
  2008-12-30 21:42     ` Wolfgang Denk
  2008-12-30 11:00   ` Giuseppe Modugno
  1 sibling, 2 replies; 10+ messages in thread
From: Giuseppe Modugno @ 2008-12-30 10:58 UTC (permalink / raw)
  To: u-boot

On 30 Dec 2008 at 11:52, Wolfgang Denk wrote:
> Assuming both boards have the same configuration (or, more precisely,
> at least the same size of environment and environment sectors),  

Yes, they are the same.


> then
> you can just read the sector(s) containing the environment from their
> corresponding  /dev/mtd*  devices  in  Linux and copy it to the other
> system.

So you're proposing to use Linux to copy U-Boot environment. But on a 
new board (picked from the shelf) I don't have Linux and I should set 
some U-Boot variables to run it.

I was thinking of a "U-Boot only" procedure, like md.b (to run on the 
source board) and cp.b (to run on the destination board). In this way 
I must copy&paste the md.b text result from the terminal to a file, 
process it (on the computer) to have a binary content of the 
environment, download (by TFTP) it on the destination board and run 
cp.b.
What do you think about this procedure?

Another possibility is to printenv on the source board, copy the text 
result from the terminal into a text file, append "setenv " at the 
top of each lines, substitute = character with space, insert the 
quotes where needed and paste the result in the terminal of the 
destination board.

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

* [U-Boot] Copy environment variables to another board
  2008-12-30 10:52 ` Wolfgang Denk
  2008-12-30 10:58   ` Giuseppe Modugno
@ 2008-12-30 11:00   ` Giuseppe Modugno
  1 sibling, 0 replies; 10+ messages in thread
From: Giuseppe Modugno @ 2008-12-30 11:00 UTC (permalink / raw)
  To: u-boot

On 30 Dec 2008 at 11:52, Wolfgang Denk wrote:
> Assuming both boards have the same configuration (or, more
precisely,
> at least the same size of environment and environment sectors),  

Yes, they are the same.


> then
> you can just read the sector(s) containing the environment from their
> corresponding  /dev/mtd*  devices  in  Linux and copy it to the other
> system.

So you're proposing to use Linux to copy U-Boot environment. But on a 
new board (picked from the shelf) I don't have Linux and I should set 
some U-Boot variables to run it.
I was thinking of a "U-Boot only" procedure, like md.b (to run on the 
source board) and cp.b (to run on the destination board). In this way 

I must copy&paste the md.b text result from the terminal to a file, 
process it (on the computer) to have a binary content of the 
environment, download (by TFTP) it on the destination board and run 
cp.b.
What do you think about this procedure?

Another possibility is to printenv on the source board, copy the text 
result from the terminal into a text file, append "setenv " at the 
top of each lines, substitute = character with space, insert the 
quotes where needed and paste the result in the terminal of the 
destination board.


Best regards,
  Giuseppe

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

* [U-Boot] Copy environment variables to another board
  2008-12-30 10:58   ` Giuseppe Modugno
@ 2008-12-30 11:40     ` Alessandro Rubini
  2008-12-30 15:50       ` Giuseppe Modugno
  2008-12-30 21:42     ` Wolfgang Denk
  1 sibling, 1 reply; 10+ messages in thread
From: Alessandro Rubini @ 2008-12-30 11:40 UTC (permalink / raw)
  To: u-boot

> So you're proposing to use Linux to copy U-Boot environment. But on a 
> new board (picked from the shelf) I don't have Linux and I should set 
> some U-Boot variables to run it.

So you might prefer setting them as predefined in you configuration
file, so when the u-boot binary finds no environment on flash (crc
error) and it will use those values, until you saveenv new values.
 
> I was thinking of a "U-Boot only" procedure, like md.b (to run on the 
> source board) and cp.b (to run on the destination board).

You can unprotect, erase, and cp.b to the flash sector(s), once you
have the binary image of the environment. You can extract such
image from /dev/mtd in the running board and then use tftp (as you
suggested) on the new board.

hope this helps
/alessandro

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

* [U-Boot] Copy environment variables to another board
  2008-12-30 11:40     ` Alessandro Rubini
@ 2008-12-30 15:50       ` Giuseppe Modugno
  0 siblings, 0 replies; 10+ messages in thread
From: Giuseppe Modugno @ 2008-12-30 15:50 UTC (permalink / raw)
  To: u-boot

On 30 Dec 2008 at 12:40, Alessandro Rubini wrote:
> > So you're proposing to use Linux to copy U-Boot environment. But on
> > a new board (picked from the shelf) I don't have Linux and I should
> > set some U-Boot variables to run it.
> 
> So you might prefer setting them as predefined in you configuration
> file, so when the u-boot binary finds no environment on flash (crc
> error) and it will use those values, until you saveenv new values.

I don't like to change U-Boot default configuration. The U-Boot 
environment changes project by project. I want to avoid recompiling U-
Boot for each project. I'd like to have a single U-Boot application 
and different environment saved as files.


> > I was thinking of a "U-Boot only" procedure, like md.b (to run on
> > the source board) and cp.b (to run on the destination board).
> 
> You can unprotect, erase, and cp.b to the flash sector(s), once you
> have the binary image of the environment. You can extract such image
> from /dev/mtd in the running board and then use tftp (as you
> suggested) on the new board.

Yes, I think that is my way. Thank you all.

Best regards,
  Giuseppe Modugno

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

* [U-Boot] Copy environment variables to another board
  2008-12-30 10:58   ` Giuseppe Modugno
  2008-12-30 11:40     ` Alessandro Rubini
@ 2008-12-30 21:42     ` Wolfgang Denk
  2009-01-05  8:33       ` Giuseppe Modugno
  1 sibling, 1 reply; 10+ messages in thread
From: Wolfgang Denk @ 2008-12-30 21:42 UTC (permalink / raw)
  To: u-boot

Dear "Giuseppe Modugno",

In message <495A0CE8.31716.C0772D@g.modugno.elettronika.it> you wrote:
>
> > then
> > you can just read the sector(s) containing the environment from their
> > corresponding  /dev/mtd*  devices  in  Linux and copy it to the other
> > system.
> 
> So you're proposing to use Linux to copy U-Boot environment. But on a 
> new board (picked from the shelf) I don't have Linux and I should set 
> some U-Boot variables to run it.

It is difficult to make recommendations when you're providing
inconsistent input. In your previous message you wrote:

>> I have a board running U-Boot/Linux. U-Boot program, two U-Boot 
>> environments, Linux kernel and root filesystem for Linux are stored 
>> in a NOR Flash.

Now you claim "I don't have Linux".

Can you please decide whether or not you have Linux running on that
board?

> Another possibility is to printenv on the source board, copy the text 
> result from the terminal into a text file, append "setenv " at the 
> top of each lines, substitute = character with space, insert the 
> quotes where needed and paste the result in the terminal of the 
> destination board.

You could (and probaly should) put the constant part of your
definitions into the default environment, and use a script image for
the rest.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
egrep patterns are full regular expressions; it uses a fast  determi-
nistic algorithm that sometimes needs exponential space.
- unix manuals

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

* [U-Boot] Copy environment variables to another board
  2008-12-30 21:42     ` Wolfgang Denk
@ 2009-01-05  8:33       ` Giuseppe Modugno
  2009-01-05 14:13         ` Wolfgang Denk
  0 siblings, 1 reply; 10+ messages in thread
From: Giuseppe Modugno @ 2009-01-05  8:33 UTC (permalink / raw)
  To: u-boot

On 30 Dec 2008 at 22:42, Wolfgang Denk wrote:
> It is difficult to make recommendations when you're providing
> inconsistent input. In your previous message you wrote:
> 
> >> I have a board running U-Boot/Linux. U-Boot program, two U-Boot
> >> environments, Linux kernel and root filesystem for Linux are stored
> >> in a NOR Flash.
> 
> Now you claim "I don't have Linux".
> 
> Can you please decide whether or not you have Linux running on that
> board?

I'm sorry for the misunderstanding.

Linux really runs on my board, but only after I store the kernel and 
the root filesystem on the Flash memory. And to do these operations, 
I must have a good U-Boot environment.

So I have a source board with a good U-Boot environment and Linux, 
and a destination board (picked from the shelf) with just U-Boot and 
its default environment (no Linux runs on it).

I can copy the good U-Boot environment from the source board to a 
file by using Linux, but I can't use Linux on the destination board 
to store the good environment in the memory.

I think the best solution is to use Linux on the source board to copy 
the good U-Boot environment in a image file. On the destination 
board, I can download (by tftp) the image and store it on the Flash 
at the correct address. In this way, I'll use only U-Boot on the 
destination board to retrieve the good environment. From that, I can 
install kernel and root filesystem.


> > Another possibility is to printenv on the source board, copy the
> > text result from the terminal into a text file, append "setenv " at
> > the top of each lines, substitute = character with space, insert the
> > quotes where needed and paste the result in the terminal of the
> > destination board.
> 
> You could (and probaly should) put the constant part of your
> definitions into the default environment, and use a script image for
> the rest.

Just now I'm reading about the scripting capabilities of U-Boot. It's 
interesting. Starting from which U-Boot version they are available?


Just another question. I have two redundant U-Boot environments. 
Should I copy both of them in two different images, or are they the 
same and I can copy the first into the second?

Regards,
  Giuseppe

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

* [U-Boot] Copy environment variables to another board
  2009-01-05  8:33       ` Giuseppe Modugno
@ 2009-01-05 14:13         ` Wolfgang Denk
  2009-01-05 14:39           ` Jayakrishnan M
  0 siblings, 1 reply; 10+ messages in thread
From: Wolfgang Denk @ 2009-01-05 14:13 UTC (permalink / raw)
  To: u-boot

Dear Giuseppe,

in message <4961D3D6.22933.3E9CEE@g.modugno.elettronika.it> you wrote:
> 
> I think the best solution is to use Linux on the source board to copy 
> the good U-Boot environment in a image file. On the destination 
> board, I can download (by tftp) the image and store it on the Flash 
> at the correct address. In this way, I'll use only U-Boot on the 
> destination board to retrieve the good environment. From that, I can 
> install kernel and root filesystem.

No, that is not a good idea, as this way you would also copy
board-specific settings lime serial number, MAC address etc.
> 
> > You could (and probaly should) put the constant part of your
> > definitions into the default environment, and use a script image for
> > the rest.
> 
> Just now I'm reading about the scripting capabilities of U-Boot. It's 
> interesting. Starting from which U-Boot version they are available?

They have been present forever in U-Boot. They were added in pretty
early stages of the PPCBoot project, many, many years ago.

> Just another question. I have two redundant U-Boot environments. 
> Should I copy both of them in two different images, or are they the 
> same and I can copy the first into the second?

These are the same except for the valid flag (one byte at offset 4).

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If programming was easy, they wouldn't need something as  complicated
as a human being to do it, now would they?
                       - L. Wall & R. L. Schwartz, _Programming Perl_

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

* [U-Boot] Copy environment variables to another board
  2009-01-05 14:13         ` Wolfgang Denk
@ 2009-01-05 14:39           ` Jayakrishnan M
  0 siblings, 0 replies; 10+ messages in thread
From: Jayakrishnan M @ 2009-01-05 14:39 UTC (permalink / raw)
  To: u-boot

Dear Giuseppe Modugno,

>> I think the best solution is to use Linux on the source board to copy
>> the good U-Boot environment in a image file. On the destination
>> board, I can download (by tftp) the image and store it on the Flash
>> at the correct address. In this way, I'll use only U-Boot on the
>> destination board to retrieve the good environment. From that, I can
>> install kernel and root filesystem.
>
> No, that is not a good idea, as this way you would also copy
> board-specific settings lime serial number, MAC address etc.
>>

I also have such a requirement. So what I am doing is that the
variables that is common to all boards are kept as a script which my
terminal program (used to access serial port) can run. So in the first
boot, all these variables plus the board specific things like serial
number, MAC address, etc. will be set and saved to flash.

Regards,
Jayakrishnan

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

end of thread, other threads:[~2009-01-05 14:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-30 10:30 [U-Boot] Copy environment variables to another board Giuseppe Modugno
2008-12-30 10:52 ` Wolfgang Denk
2008-12-30 10:58   ` Giuseppe Modugno
2008-12-30 11:40     ` Alessandro Rubini
2008-12-30 15:50       ` Giuseppe Modugno
2008-12-30 21:42     ` Wolfgang Denk
2009-01-05  8:33       ` Giuseppe Modugno
2009-01-05 14:13         ` Wolfgang Denk
2009-01-05 14:39           ` Jayakrishnan M
2008-12-30 11:00   ` Giuseppe Modugno

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.