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.

SK-AM64: Loading uEnv.txt form UBIFS parition

Part Number: SK-AM64

Hello

I'm using TMDS64GPEVM board. Revision PRC101B. I want to load U-Boot uEnv.txt from mtd parition. Regarding to this topic: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1070402/sk-am64-start-u-boot-from-ospi-with-the-sk-am64-starter-kit/3968228?fbclid=IwAR2BOQTS5gh2fgKw2Rw1P6O8ys0c-vF-1FOLDxzjk4aHq5XJ5VVq7q1twJ8#3968228

I set U-Boot config options:

CONFIG_ENV_IS_IN_FAT=n
CONFIG_ENV_IS_IN_UBI=y
CONFIG_ENV_UBI_PART="uboot_env_ubi"
CONFIG_ENV_UBI_VOLUME="uboot_env_vol"

Next I generated ubi image which consist of two paritions:

[uboot_env_ubi]

mode=ubi

image=uboot_env_ubi.ubifs

vol_id=0

vol_type=static

vol_name=uboot_env_vol

vol_size=16MiB

[rootfs]

mode=ubi

image=rootfs.ubifs

vol_id=1

vol_type=dynamic

vol_name=rootfs

vol_size=36MiB

In U-Boot prompt mtd list show me:

* nor0
  - type: NOR flash
  - block size: 0x40000 bytes
  - min I/O: 0x10 bytes
  - 0x000000000000-0x000004000000 : "nor0"
          - 0x000000000000-0x000000100000 : "ospi.tiboot3"
          - 0x000000100000-0x000000300000 : "ospi.tispl"
          - 0x000000300000-0x000000700000 : "ospi.u-boot"
          - 0x000000700000-0x000000740000 : "ospi.env"
          - 0x000000740000-0x000000780000 : "ospi.env.backup"
          - 0x000000800000-0x000003fc0000 : "ospi.rootfs"
          - 0x000003f40000-0x000003f80000 : "ospi.phypattern"

So I choose to load put my .ubi image on address 0x000000800000-0x000003fc0000 : "ospi.rootfs"

sf erase 0x800000 0x37c0000

tftp ${loadaddr} rootfs.ubi

 sf update $loadaddr 0x800000 $filesize

Then I run U-Boot command:

setenv mtdparts 'mtdparts=fc40000.spi.0:1m(ospi.tiboot3),2m(ospi.tispl),4m(ospi.u-boot),256k(ospi.env),256k(ospi.env.backup),57088k@8m(ospi.rootfs),256k@0x3fc0000(ospi.phypattern)';setenv mtdids 'nor0=fc40000.spi.0';run findfdt;run args_all;setenv bootargs console=${console} ${optargs} root=ubi0:rootfs rw ubi.mtd=ospi.rootfs rootfstype=ubifs rootwait=1;sf probe;ubi part ospi.rootfs;ubifsmount ubi0:rootfs;ubifsload ${loadaddr} /boot/Image;ubifsload ${fdtaddr} /boot/${fdtfile};run run_kern

But when U-Boot fail to load environment. It prints message:

Loading Environment from UBI... env_buf [32 bytes] too small for value of "mtdids"

env_buf [32 bytes] too small for value of "mtdids"

Could not find a valid device for fc40000.spi.0

env_buf [32 bytes] too small for value of "mtdids"

Could not find a valid device for omap2-nand.0

Partition uboot_env_ubi not found!

So my questions are:

1. Where U-Boot search partiton uboot_env_ubi? On which mtd device? How can I force U-Boot to looks for my partition on ospi.rootfs mtd device?

2. What exactly means "env_buf [32 bytes] too small for value of "mtdids""? Is there any possibility to increase env_buf without patching the code?

Thanks

BR

Jakub

  • Hello Jakub,
    Depending on your system design, there're multiple ways to load binary blob (from MTD partitions in the boot flow.
    In the referenced earlier e2e post
    e2e.ti.com/.../3968228
    "- One option to load the boot environments from OSPI instead before loading/launching kernel/dtb from the selected boot media is by plugging "sf probe; sf read ${loadaddr} 0x680000 0x40000" as listed below:"

    Note that
    - Another option is to build the u-boot environment variables directly into u-boot.
    - The same approach can be also used for loading the next stage kernel/dtb... directly from the allocated MTD partitions instead of loading them from MTD partition "ospi.rootfs". The steps is summarized in the attached PDF at the end of the same referenced e2e.

    Best,
    -Hong

  • Hello Hong.

    Thank you for replay. 

    I wants to się existing feature od uboot as I described earlyier. I don't wants to modify uboot core. Typing uboot instruction by hand to load env also is note considered. Can you please explain to me how load this env by read ubi partition?

  • Hello Jakub,
    I tested previously by loading the boot_env/kernel/DTB... directly from the MTD partitions which are allocated out of MTD partition "ospi.rootfs". In fact, UBIFS support @u-boot was not in SDK yet when I did the above test, but I'd think this way loading may be faster comparing to loading them from MTD mounted UBIFS rootfs.
    Is there a hard requirements to load boot_env/kernel/DTB @u-boot from MTD mounted UBIFS rootfs in your user case?
    Best,
    -Hong

  • Hello Hong

    This is not hard requirement, but I wanted to do this in elegant way. Also I was curious how this feature works... However I managed my issue in a way that you proposed. I have other question related to this topic:

    Where do come from all mtd partitions? It is hardcoded in U-Boot to create those mtd partitions? In our custom hardware we want to create set of partitions in automatic way, not by typing U-Boot sf commands by hand.

    - 0x000000000000-0x000004000000 : "nor0"
    - 0x000000000000-0x000000100000 : "ospi.tiboot3"
    - 0x000000100000-0x000000300000 : "ospi.tispl"
    - 0x000000300000-0x000000700000 : "ospi.u-boot"
    - 0x000000700000-0x000000740000 : "ospi.env"
    - 0x000000740000-0x000000780000 : "ospi.env.backup"
    - 0x000000800000-0x000003fc0000 : "ospi.rootfs"
    - 0x000003f40000-0x000003f80000 : "ospi.phypattern"

    Thanks

    BR

    Jakub

  • Hello Jakub,
    There're multiple ways to configure/load/modify boot environment variables, also depending on SW development or production...for example, 
    - "env export..."/"env import..." @u-boot.
    e2e.ti.com/.../3968228
    - "fw_printenv/fw_setenv", where u-boot provide fw_printenv/fw_setenv for Linux to access environment variables.
    - "uenvcmd" @u-boot to load "uEnv.txt" before loading kernel/dtb...

    Where do come from all mtd partitions? It is hardcoded in U-Boot to create those mtd partitions?

    The ospi MTD partitions for AM64x EVM is configured in "$u-boot/configs/am64x_evm_a53_defconfig" along with other environment variables...
    git.ti.com/gitweb
    It is your choice on how to configure MTD partitions, and then build into u-boot...

    There's relevant topic on "[FAQ] AM64x: How to customize QSPI/OSPI flash layout for SPL/u-boot booting from QSPI/OSPI with TI AM64x Linux SDK"
    e2e.ti.com/.../4395468

    Best,
    -Hong