SK-AM62B-P1: Read/Set u-boot environment variables from Linux

Part Number: SK-AM62B-P1

Tool/software:

Hi team,

I'm trying to implement the feature of dual image in our target board based on SDK 09.02.01.09. I've created two partitions as rootfs in the SD card and have been able to switch both partitions manually in the u-boot prompt.

So the next I'd like to add some variables during run time in the environment file (uEnv.txt or uboot.env) that can be recognized by u-boot, and it can then do something like recovery actions according to the variables in that file. I save the environment file in /boot with the command in u-boot prompt:

---

Writing environment to SD card
   => env export -t $loadaddr
   => fatwrite mmc ${mmcdev} ${loadaddr} ${bootenvfile} ${filesize}

---

I've installed "fw_printenv" & "fw_setenv" to rootfs by adding "IMAGE_INSTALL:append = " u-boot-fw-utils" in build/local.conf and generated a u-boot config fragment to enable the following options:

---

CONFIG_ENV_SIZE=0x20000
CONFIG_ENV_OFFSET=0x680000
CONFIG_CMD_ASKENV=y
CONFIG_CMD_NVEDIT_INFO=y
CONFIG_ENV_IS_IN_MMC=y
CONFIG_SYS_MMC_ENV_DEV=1
CONFIG_SYS_MMC_ENV_PART=1

---

Then created a plain file "fw_env.config" with the content (I'm not sure if the offset and size are correct...):

---

/dev/mmcblk0boot0       0x680000        0x20000

---

But still can't read the environment file in Linux.

root@ti-am62xx:/# fw_printenv
Cannot read environment, using default
Cannot read default environment from file

In fact, I've been following several threads in TI E2E forums but still can't figure out where the problems are. Any tips are welcome! Thanks in advance.

  • Hi,

    Have you configured the /etc/fw_env.config file?

    Please share it.

    Setting up fw printenv to modify u-boot environment variables - RidgeRun Developer Wiki

    Regards,
    Aparna

  • Hi Aparna,

    Thank you for the reply.

    Currently I'm using the SD card for the test so that the /etc/fw_env.config file I configurated is :

    root@ti-am62xx:/# cat /etc/fw_env.config
    # Block device example
    /dev/mmcblk1 0x680000 0x20000

    And execute fw_printenv:

    root@ti-am62xx:/# fw_printenv
    Cannot read environment, using default
    Cannot read default environment from file

    The following is my block information:

    root@ti-am62xx:/# lsblk
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
    mmcblk1 179:0 0 29.7G 0 disk
    |-mmcblk1p1 179:1 0 128M 0 part /boot
    |-mmcblk1p2 179:2 0 2.4G 0 part /
    `-mmcblk1p3 179:3 0 2.4G 0 part
    mmcblk0 179:32 0 29.6G 0 disk
    |-mmcblk0p1 179:33 0 128M 0 part
    `-mmcblk0p2 179:34 0 384.8M 0 part
    mmcblk0boot0 179:64 0 31.5M 1 disk
    mmcblk0boot1 179:96 0 31.5M 1 disk

    mmcblk0 is eMMC but I want to verify the setup before moving on eMMC settings.

    Regards,

    Dicky

  • Hi,

    Is this issue still seen?

    Apologies for not posting a reply. I had missed this one.

    Regards,
    Aparna

  • Hi Aparna,

    No, I couldn't still read the environmental variables properly:

    root@ti-am62xx:/# fw_printenv
    Warning: Bad CRC, using default environment
    bootcmd=run envboot; run distro_bootcmd;
    bootdelay=2
    baudrate=115200
    loadaddr=0x82000000
    arch=arm
    cpu=armv8
    board=am62x

    .....

    The following is my fw_env.config setting:

    # Block device example
    /dev/mmcblk1 0x680000 0x20000

    I don't know where I can confirm the values of offset and size are correct since there is no references in the u-boot code.

    Regards,

    Dicky