Tuesday, December 18, 2012

Modify U-boot Configuration in Linux User Space!

Have you ever thought to change the U-boot settings once, after you got the Linux console? Well, you might be thinking to entering into the U-boot setting prompt to do this. But there is a beautiful method already exist to achieve this operation!

Well, here I'm not giving anything from the sky or vanishing anything like a magician, but trying to show a Utility tool (you can't say exactly it's a tool, better it can be consider as one option ;) ) which already available :0 .

All you have to do is, to try some geeky way (though very simple) only at once and do the magic always.
The key tool which you have to enable is "fw_printenv" from the U-boot.

Follow the below steps to make the wonders in U-boot from your own lovely Linux console ;)

  1. Step 1: Generate the "fw_printenv" utility tool in U-boot
    • give 'env' (optional parameter) in u-boot and compile it. Be patient for the compilation ;)
    • The above step generate the 'fw_printenv' in the U-Boot directory tools/env 
    • Copy the 'fw_env.config' file too.
  2. Step 2: Well, we copied, but where to paste it ! Follow the steps ;)
    • Copy fw_printenv to /sbin on the root file system of your own board.
    • The interesting thing here is that the fw_printenv binary also contains the code for fw_setenv. The functions of fw_setenv are run when the program is invoked with the name "fw_setenv". this is most easily accomplished by creating a symbolic link from fw_printenv to fw_setenv, as in "ln -sf /sbin/fw_printenv /sbin/fw_setenv"
  3. Step 3: Create config file for the utility, in order to take place the action.
    • Remember, you copied 'fw_env.config' from 'u-boot/tools/env/' path? But you didn't play with it yet right? ;) Well, this is the right time for that! All you have to do is, copy the fw_env.config into /etc path. Finished? Relaxed? No...remember, this is a geeky professional way dude ;)
    • Open the 'fw_env.config' and make required changes related to env size, flash sector size and number of sectors according to flash which you are using. You have to change the fw_env.config with respect to your system modification rather than simply putting it into /etc. you can easily check this from /proc/mtd.
Once you configure the appropriate values in fw_env.config, then rest of the stuffs are pretty easy.
From the Linux console, you can print the u-boot setting by giving the fw_printenv where as with fw_setenv , you can edit the u-boot settings!!! Easy right?

Well, I would like to share two good web links also for your better understanding..
  1. U-boot environment variable in Linux
  2. U-boot environment
Do experiments...create wonders...Happy coding...

No comments: