Skip to contentSkip to conversation

Copy environment variables to another board

U-Boot Giuseppe Modugno 4 participants 10 messages Dec 30, 2008 – Jan 5, 2009

lore
Share & tools
lore
#0 lore raw

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.

#1 lore raw

Dear "Giuseppe Modugno",

Quoted 11 lines · In message <[email protected]> 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

Signature · 5 lines
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
#2 lore raw
Quoted 2 lines · Wolfgang Denk

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.

Quoted 4 lines

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.

#3 lore raw
Quoted 3 lines

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.

Quoted 2 lines

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

#4 lore raw
Quoted 7 lines · Alessandro Rubini
Quoted 3 lines

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.

Quoted 7 lines
Quoted 2 lines

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

#5 lore raw
In reply to Giuseppe Modugno

Dear "Giuseppe Modugno",

Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 5 lines

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

Quoted 3 lines · inconsistent input. In your previous message you
Quoted 3 lines

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?

Quoted 5 lines

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

Signature · 6 lines
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
#6 lore raw
Quoted 11 lines · Wolfgang Denk

It is difficult to make recommendations when you're providing

Quoted 3 lines · inconsistent input. In your previous message you
Quoted 3 lines

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.

Quoted 9 lines
Quoted 5 lines

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

#7 lore raw

Dear Giuseppe,

Quoted 7 lines · in message <[email protected]> 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.

Quoted 7 lines
Quoted 4 lines

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.

Quoted 3 lines

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

Signature · 6 lines
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_
#8 lore raw

Dear Giuseppe Modugno,

Quoted 10 lines
Quoted 6 lines

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.

Quoted 1 line

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

#9 lore raw
In reply to Wolfgang Denk
Quoted 1 line · Wolfgang Denk

Assuming both boards have the same configuration (or, more

precisely,

Quoted 1 line

at least the same size of environment and environment sectors),

Yes, they are the same.

Quoted 4 lines

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