Personal tools

Log in

Changes

From IGEP - ISEE Wiki

Jump to: navigation, search

How to modify the uboot environment from userspace

2,975 bytes added, 21:42, 12 October 2010
no edit summary
This is my first wiki page so please be benevolent with the formatting :-)
== tools Tools needed ==
In order to modify the uboot environment variables from userspace we will need a program called fw_setenv, we can compile this program ourselves from the u-boot sources, follow the instructions in this wiki page and then proceed to compile with (don't modify the .h file as it says in the tools/env/README file):
<br>
 
== Finding out the correct values for fw_env.config ==
Ok, so in order to get all this information the easyest thing is to read it from dmesg or from /proc/mtd
mtd4: 1fa80000 00040000 "File System"
<brNow we can fill in all the values we needed (that's what I thought) #MTD device name ---> /dev/mtd2 ("u-boot environment")#Device Offset ----> 80.000 + 18.000#Environment Size ---> 80.000#Flash sector size ---> 40.000#Number of sectors (ignored in NOR)----> nothing Pretty easy right? wrong!!! The right values are: #MTD device name ----> /dev/mtd2#Device Offset -----> 0x0000#Environment Size -----> 0x01000#Flash sector size ------> 0x020000#Number of sectors (ignored in NOR) -----> nothing Ifigured these out by reading different posts and by trial and error, but I still don'll continue t understand the environment size value or the flash sector size, I can imagine the device offset is 0 if you specify /dev/mtd2 but I'd be great if someone could edit this page and point out why are this the correct values. == Giving it a try == In order to give it a try is better to poke with fw_printenv than with fw_setenv, because the first one just tries to read, so go ahead and try it:  fw_printenv this should output something like:  ethact=smc911x-0 distro=poky project=poky-image-sato ipaddr=192.168.254.254 netmask=255.255.255.0 gatewayip=192.168.254.10 serverip=192.168.254.10 addip=setenv bootargs ${bootargs} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}::eth0: mmc-boot=mmc init 0; if fatload mmc 0 80000000 boot.ini; then source; else if fatload mmc 0 80000000 uImage; then run mmc-bootargs; bootm; fi; fi onenand-bootargs=setenv bootargs ${bootargs-base} root=/dev/mtdblock4 rootfstype=jffs2 ; run addip onenand-boot=run onenand-bootargs; onenand read 80000000 280000 400000 ; bootm 80000000 nfs-bootargs=setenv bootargs ${bootargs-base} root=/dev/nfs nfsroot=${serverip}:/srv/nfs/${distro}/${project}/${machine} ; run addip nfs-boot=if ping ${serverip}; then run nfs-bootargs; tftp 0x80000000 ${distro}/${project}/${machine}/uImage; bootm; fi; machine=igep0020 mmc-bootargs=setenv bootargs ${bootargs-base} root=/dev/mmcblk0p2 rw rootwait dieid=${dieid#} dieid#=638a00040000000004036abc07016018 mpurate=110 stdin=serial stdout=serial stderr=serial bootargs-base=mem=512M console=ttyS2,115200n8 console=tty0 omapfb.mode=dvi:1024x768MR-16@60 mpurate=110 bootcmd=run onenand-boot; run mmc-boot; if you get something like:  Warning: Bad CRC, using default environment bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm bootdelay=5 baudrate=115200 it means the values in /etc/fw_env.config are not correct, so don't even try fw_setenv  = Using fw_setenv = Now that we found out the correct values for /etc/fw_env.config you can just use fw_setenv with the same syntax as if you were in u-boot command line, to assing a couple of hoursvalue don't use "=" but a space.  ./fw_setenv test 1234 then fw_printenv should output test=1234 notice we didn't need to use saveenv as we would do in u-boot command line.  That's it!! 
== Feedback and Contributing ==
0
edits