persistent environment

Vincent Legoll vincent.legoll at gmail.com
Sat Sep 14 09:06:23 CEST 2024


Hello Simon,

On Thu, Sep 12, 2024 at 1:02 AM Simon Glass <sjg at chromium.org> wrote:
> Looking at env_erase()
> It calls drv->erase() which for mmc is:
> .erase = ENV_ERASE_PTR(env_mmc_erase)
>
> I see this:
>
> if (IS_ENABLED(CONFIG_SYS_REDUNDAND_ENVIRONMENT)) {
>    copy = 1;
>
>    if (IS_ENABLED(ENV_MMC_HWPART_REDUND)) {
>       ret = mmc_set_env_part(mmc, copy + 1);
>       if (ret)
>          goto fini;
>    }
>
> which suggests that perhaps it is failing there as mmc_set_env_part()
> has that error message "MMC partition switch failed". Do you want a
> redundant environment?

Your answer made me look at the code, and now I think I'm confused.

No, I don't need/want a redundant env, I'm just trying to setup a persistent
env. on the SD card from which I boot.

The error that happen at "env save" also happen at boot (see previously
attached bootlog), and at "mmc dev  1 3" command, see below.

mmc 0 is the on-board soldered eMMC
mmc 1 is the SD card I'm booting from

I'm using a GPT partition table on both devices as I would on any other
block device, is that OK to save an environment ?

The test on following line is failing:
https://github.com/u-boot/u-boot/blob/master/drivers/mmc/mmc-uclass.c#L478

I've put a debug print after this test, and you can see it in the
following (at the end):

=> mmc info
Device: mmc at fe2e0000
Manufacturer ID: d6
OEM: 3
Name: 58A441
Bus Speed: 150000000
Mode: HS200 (200MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 57.6 GiB
Bus Width: 8-bit
Erase Group Size: 512 KiB
HC WP Group Size: 8 MiB
User Capacity: 57.6 GiB WRREL
Boot Capacity: 4 MiB ENH
RPMB Capacity: 4 MiB ENH
Boot area 0 is not write protected
Boot area 1 is not write protected

=> mmc part

Partition Map for mmc device 0  --   Partition Type: EFI

Part    Start LBA       End LBA         Name
        Attributes
        Type GUID
        Partition GUID
  1     0x00008000      0x00ffffff      "EFI"
        attrs:  0x0000000000000000
        type:   c12a7328-f81f-11d2-ba4b-00a0c93ec93b
                (system)
        guid:   ef98a377-91ef-4ba5-8279-c06cea50cd37
  2     0x01000000      0x01ffffff      "root_void"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
                (linux)
        guid:   c560bc7e-1096-4f10-8244-ff84c5059405
  3     0x02000000      0x0733bfde      "obsd"
        attrs:  0x0000000000000000
        type:   824cc7a0-36a8-11e3-890a-952519ad3f61
                (824cc7a0-36a8-11e3-890a-952519ad3f61)
        guid:   fb5f3a56-7e69-497d-854f-1a4ef4362785

=> mmc dev 1
switch to partitions #0, OK
mmc1 is current device

=> mmc info
Device: mmc at fe2c0000
Manufacturer ID: 1b
OEM: 534d
Name: 00000
Bus Speed: 50000000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 29.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes

=> mmc part

Partition Map for mmc device 1  --   Partition Type: EFI

Part    Start LBA       End LBA         Name
        Attributes
        Type GUID
        Partition GUID
  1     0x00000040      0x00003fff      "loader"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
                (linux)
        guid:   2fa7d6f9-1c60-4cee-9b64-a068ba2b493a
  2     0x00004000      0x00007fff      "uboot"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
                (linux)
        guid:   b849290b-0840-4ab5-849c-ccba99439131
  3     0x00008000      0x0000ffff      "env"
        attrs:  0x0000000000000000
        type:   3de21764-95bd-54bd-a5c3-4abe786f38a8
                (u-boot-env)
        guid:   6d006d1c-794e-4408-b0a4-f52b6b3fac4a
  4     0x00010000      0x0010ffff      "efi"
        attrs:  0x0000000000000000
        type:   c12a7328-f81f-11d2-ba4b-00a0c93ec93b
                (system)
        guid:   3587cde4-bf68-4e24-b74f-164015d47b9c
  5     0x00110000      0x007fffff      "root"
        attrs:  0x0000000000000000
        type:   0fc63daf-8483-4772-8e79-3d69d8477de4
                (linux)
        guid:   d74fd9eb-00df-4bc8-94db-ddd4fade2040

=> mmc dev 0
switch to partitions #0, OK
mmc0(part 0) is current device

=> mmc dev 1 3
mmc_select_hwpart() - 2 - ERROR EMEDIUMTYPE because MMCPART_NOAVAILABLE
switch to partitions #3, ERROR

--
Vincent Legoll


More information about the U-Boot mailing list