Changes

How to modify the uboot environment from userspace

60 bytes added, 19:19, 12 October 2010
no edit summary
This is my first wiki page so please be benevolent with the formatting :-)
== 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):
make env
This will give us fw_printenv, in order to get fw_setenv we just have to change the name of the file. Magic!!
cp fw_printenv fw_setenv
The next thing we will need is the fw_env.config file with the appropiate settings for our board. Here comes the confusion  :-)
In this file you have to specify:
1.- #MTD device name2.- #Device Offset3.- #Environment Size4.- #Flash sector size5.- #Number of sectors (ignored in NOR)
  Ok, so in order to get all this information the easyest thing is to read it from dmesg or from /proc/mtd
cat /proc/mtd
All my initial confusion comes from using an incorrect kernel, my first tries where with 2.6.28.10 and the driver used to read mtd was NAND, in the kernel configuration file I only had  :
CONFIG_MTD_NAND=y
being the output of /proc/mtd:
<br>
dev: size erasesize name
mtd4: 1f880000 00040000 "File System"
<br> through "dmesg" I could see this line indicating something was wrong:
through "dmesg" I could see this line indicating something was wrong:<br>
[ 1174.517120] Creating 5 MTD partitions on "omap2-onenand":
[ 1174.522552] 0x00000000-0x00080000 &nbsp;: "X-Loader" [ 1174.528381] 0x00080000-0x00260000 &nbsp;: "U-Boot" [ 1174.533508] 0x00260000-0x00280000 &nbsp;: "U-Boot Env"
[ 1174.538177] mtd: partition "U-Boot Env" doesn't start on an erase block boundary -- force read-only
[ 1174.548126] 0x00280000-0x00780000 &nbsp;: "Kernel" [ 1174.553192] 0x00780000-0x20000000 &nbsp;: "File System"
But if we use the aproppiate kernel, in my case 2.6.33.7-0 with the onenand driver instead of the nand driver:
CONFIG_MTD_ONENAND=y
The output of /proc/mtd is different:
<br>
dev: size erasesize name
mtd4: 1fa80000 00040000 "File System"
 <br> I'll continue in a couple of hours.
== Feedback and Contributing ==
0
edits