JohnSantaFe
JohnSantaFe

Reputation: 155

How to easily configure multiple u-boot variables

I need to change multiple u-boot environment variables every time I setup a new embedded device e.g. ip address, ethernet address, etc. Typing at the terminal prompt is tedious, and, I don't know if it's my terminal, buy trying to cut and paste anything more than a few characters can result in errors. Changing them in a text editor and copying that file to a specific location in flash would be much better than the terminal. Anyone have a good way to change multiple environment variables at once?

Upvotes: 0

Views: 3615

Answers (2)

shibley
shibley

Reputation: 1668

A script file is ideal for this situation. Its much better than copy & pasting for many commands and can handle much more complexity. You can enter all your commands into a text file and create a script image using mkimage (where myscript is the text file's name):

mkimage -T script -C none -n 'My Script' -d myscript myscript.img

Then you can simply load and execute myscript.img to perform all setup tasks for the device.

For example, to load and execute myscript.img from USB stick:

usb start && load usb 0:1 ${loadaddr} myscript.img && source ${loadaddr}

It is possible to add this load command to U-Boot's default environment so all you need to do is run the name of the command. You can even add logic to the default boot sequence to automatically perform the device setup if the USB device and script file are present. Depending on the U-Boot version, you can manipulate the default environment by either modifying the U-Boot source or by editing uEnv.txt (when supported).

Scripts are also useful for maintaining multiple setup configurations that would allow you to set the device up for one of many deployment or development configurations.

Upvotes: 1

connorjan
connorjan

Reputation: 24

I have been able to use PuTTY to copy and paste my variables into U-Boot. You can separate the declarations by semicolons to if you want to do all of the variables at once, like this:

    setenv ipaddr 192.168.1.5; setenv serverip 192.168.1.10;

Upvotes: 1

Related Questions