This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to make Uboot-envtools work on eMMC Beaglebone black

Hi there,


I would like to read and write uboot environment from rootfs and I found that uboot-envtools supported it.

I download the newest uboot version u-boot-2015.04.tar.bz2 and built with config : am335x_boneblack.config .

when I tried to modify a field in uboot-environment and save it by command saveenv, it worked well

U-Boot#saveenv
Saving Environment to MMC...
Writing to redundant MMC(1)... done

I found this page www.crashcourse.ca/.../EMMC_on_the_BBB explain about hardware partitions on eMMC, and I know uboot-enviromment will be save into mmcblk0boot0 or mmcblk0boot1 ( default config ).

When I tried to use fw_printenv with fw_env.config, I always got Bad CRC.

Hex Dump:
    # hexdump -C /dev/mmcblk0boot0
    00000000  b8 fd 66 da 02 61 72 63  68 3d 61 72 6d 00 62 61  |..f..arch=arm.ba|
    00000010  75 64 72 61 74 65 3d 31  31 35 32 30 30 00 62 6f  |udrate=115200.bo|
    00000020  61 72 64 3d 61 6d 33 33  35 78 00 62 6f 61 72 64  |ard=am335x.board|
    00000030  5f 6e 61 6d 65 3d 41 33  33 35 42 4e 4c 54 00 62  |_name=A335BNLT.b|
    .......
    00000ea0  65 6e 64 6f 72 3d 61 62  63 00 76 65 72 3d 55 2d  |endor=abc.ver=U-|
    00000eb0  42 6f 6f 74 20 32 30 31  35 2e 30 37 2d 72 63 31  |Boot 2015.07-rc1|
    00000ec0  2d 30 30 32 35 35 2d 67  30 65 36 62 37 61 32 2d  |-00255-g0e6b7a2-|
    00000ed0  64 69 72 74 79 20 28 4d  61 79 20 32 31 20 32 30  |dirty (May 21 20|
    00000ee0  31 35 20 2d 20 31 36 3a  34 31 3a 30 33 29 00 00  |15 - 16:41:03)..|
    00000ef0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00020000  06 a6 e0 be 01 61 72 63  68 3d 61 72 6d 00 62 61  |.....arch=arm.ba|
    00020010  75 64 72 61 74 65 3d 31  31 35 32 30 30 00 62 6f  |udrate=115200.bo|
    00020020  61 72 64 3d 61 6d 33 33  35 78 00 62 6f 61 72 64  |ard=am335x.board|
    .......
    00020ed0  69 72 74 79 20 28 4d 61  79 20 32 31 20 32 30 31  |irty (May 21 201|
    00020ee0  35 20 2d 20 31 36 3a 34  31 3a 30 33 29 00 00 00  |5 - 16:41:03)...|
    00020ef0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

My config:
   # cat /etc/fw_env.config
   /dev/mmcblk0boot1 0x0000 0x20000 0x20000

When I tried to write in to /dev/mmcblk0boot1, I got error: "Operation not permitted"

How could I use uboot-envtools for eMMC? I know uboot just only support save environment into hardware partitions, how to create a hardware partition, which can be write by rootfs?

Uboot mmc command supported to create hardware partitions but I don't know how to use it. How to create GP1, GP2 , GP3, GP4 partition on eMMC?

Anyone could help me?

Thanks,

Tuan Nguyen

  • Hi,

    When I tried to write in to /dev/mmcblk0boot1, I got error: "Operation not permitted"

    Please make sure that partition has write permissions.
  • Hi,

    How could I check that, mmcblk0boot1 and mmcblk0boot0 are hardware partitions I guess that were created by uboot.
    And how to fix Bad CRC when use fw_printenv ?

    fw_printenv
    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
    

    Thanks
    Tuan Nguyen

  • Hi,
    To avoid the "Bad CRC error", you have to change the *.cfg file correct value as used in u-boot's env partition .
    e2e.ti.com/.../648614
  • Hi ,

    I know I got wrong config file, how to get correct config ?

     +) MTD device name: I know its /dev/mmcblk0boot1 because CONFIG_SYS_MMC_ENV_PART  =  2 end when I dumped /dev/mmcblk0boot1, I saw my uboot-environment.

    +) Device offset: with dump result, I think it will be 0x00 or 0x20000, maybe 0x00 is start address of newest environment and 0x20000 is the older or opposite.

    +) Env size: I found CONFIG_ENV_SIZE = (128 << 10) = 128KB = 131072 B = 0x20000.

                        Same result when I did command printenv: "Environment size: 3957/131067 bytes"

     Did I miss something ? Have anyone make it work on eMMC beaglebone black ?

    Thanks

    Tuan Nguyen

  • There is a redundant environment so modify /env/fw_env.config to look like


    # Block device example
    #/dev/mmcblk0           0xc0000         0x20000
    /dev/mmcblk1boot1       0x00000         0x20000
    /dev/mmcblk1boot1       0x20000         0x40000

    This worked for me on a BBB.

    Steve K.

  • Hi Steve,

    Thank you, I tried with your configuration, and I just get only a redundant environment so I modified a little for get a newest uboot-environment.

    /dev/mmcblk0boot1 0x00000 0x20000

    /dev/mmcblk0boot1 0x20000 0x20000

    With error: Operation not permitted when using fw_setenv, I found this problem is my system forced read-only access with mmcblk1boot, so I disabled by using command :

    echo 0 > /sys/block/mmcblkXbootY/force_ro

    All work well now, thank you so much.

    Thanks
    Tuan Nguyen

  • Hi Steve,

    What's the purpose of /dev/mmcblk0boot0?

    Output of hexdump:

    ~# hexdump -C /dev/mmcblk0boot0
    00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00200000

    Thanks!

    Stefan

  • You can use /dev/mmcblk0boot0 for anything you want. The environment is stored in /dev/mmcblk0boot1.

    Steve K.