Configure U-Boot from Linux

Updating the U-Boot configuration stored on SD card

When booting from MMC, the U-Boot configuration is loaded from a file called uEnv.txt on the boot partition. To view or change this file from Linux, mount the boot partition and edit the file with a text editor. For example,

$ mkdir /mnt
$ mount /dev/mmcblk0p1 /mnt
$ vi /mnt/uEnv.txt

[[ .. make changes .. ]]

$ umount /mnt

Writing the U-Boot configuration stored in NAND

The U-Boot source includes a utility called mkenvimage that will prepare a U-Boot configuration for nandwrite. After building U-Boot, the utility is located at tools/mkenvimage. To use the tool, first save the U-Boot configuration file, then invoke mkenvimage as follows:

tools/mkenvimage -s 131072 -o ~/uEnv.dat ~/uEnv.txt

This will create a uEnv.dat file from a uEnv.txt file. To write the uEnv.dat file to NAND, copy it to the target board and run:

flash_erase /dev/mtd6 0 0
nandwrite -p /dev/mtd6 uEnv.dat

The U-Boot Env is stored in NAND partition 6 for every MitySOM-335x configuration as explained in the UBIFS NAND boot Wiki page.

Reading the U-Boot configuration stored in NAND

U-Boot also includes a utility to inspect the installed environment, fw_printenv, located in tools/env. To build the fw_printenv tool, build the env target and transfer the program to the device:

~/u-boot-mityarm-335x> make HOSTCC=arm-arago-linux-gnueabi-gcc env
~/u-boot-mityarm-335x> scp tools/env/fw_printenv root@

The /etc/fw_env.config file will need to be created to tell fw_printenv where to find the U-Boot configuration. For a 512MB NAND module, /etc/fw_env.config should appear as follows:

# MTD Device Name    Device offset    Env. size    Flash sector size         Number of sectors
/dev/mtd6            0x0000           0x20000      0x40000
These settings may need to change based on the amount of NAND installed on your MitySOM-335x module:
  1. All NAND sizes use /dev/mtd6 "Device Name" with a 0x0000 "Device Offset."
  2. All NAND sizes use a 0x20000 byte "Env. size."
  3. The "Flash Sector Size" depends on the NAND size:
    1. 256MB NAND (128kB): 0x20000
    2. 512MB NAND (256kB): 0x40000
    3. 1GB NAND (512kB): 0x80000
  4. All NAND sizes use a blank "Number of Sectors" field. It will default to 1, the only amount supported by the 335x U-Boot.

The source of these values can be found in the UBIFS NAND boot Wiki page.

Go to top
Add picture from clipboard (Maximum size: 600 MB)