sbabic / libubootenv

Generic library and tools to access and modify U-Boot environment from User Space
72 stars 39 forks source link

writelist sequence in fw_env.config does not work #32

Closed Sperrus closed 1 week ago

Sperrus commented 1 week ago

Hi,

I have a fw_env.config file in YAML format on my device that looks like this:

uboot:
  size: 0x20000
  lockfile: /var/lock/fw_printenv.lock
  devices:
    - path: /dev/mmcblk0boot0
      offset: 0x1000000
    - path: /dev/mmcblk0boot1
      offset: 0x1000000

swupdate:
  size: 0x4000
  lockfile: /var/lock/swupdate.lock
  devices:
    - path: /dev/mmcblk0boot0
      offset: 0x1200000
    - path: /dev/mmcblk0boot1
      offset: 0x1200000

With this config fw_printenv works without problem and prints all variables.

As soon as I add a writelist sequence like this

  writelist:
    - var1:so
    - var2:so
    - var3:do

anywhere in the file I only get the output "Cannot initialize environment".

I am on version 0.3.5 773.

sbabic commented 1 week ago

Where have you added the writelist ? This is a feature in U-Boot and must belong to "uboot" section.

The error says that the format of fw_env.config is wrong and cannot be parsed.

Sperrus commented 1 week ago

Thanks for your reply.

I added it in the uboot section like this:

uboot:
  size : 0x20000
  lockfile : /var/lock/fw_printenv.lock
  writelist:
    - var1:so
    - var2:so
    - var3:do
  devices:
    - path : /dev/mmcblk1boot0
      offset : 0x1000000
    - path : /dev/mmcblk1boot1
      offset : 0x1000000

swupdate:
  size : 0x4000
  lockfile : /var/lock/swupdate.lock
  devices:
    - path : /dev/mmcblk1boot0
      offset : 0x1200000
    - path : /dev/mmcblk1boot1
      offset : 0x1200000

This is similar to how it is done in the documentation and should be normal yaml syntax

sbabic commented 1 week ago

I have tested with current master and I cannot reproduce the issue. Anyway, writelist is supported only in -master, 0.3.5 does not contain commit commit 6b1c689 for writelist support. Please test with current master.

Sperrus commented 1 week ago

Thanks for your reply,

indeed, the meta-swupdate layer pulls the 3f4d15e36ceb58085b08dd13f3f2788e9299877b commit which does not include the commit required for writelist to work. I just tried with the current master and it works. Thanks for the heads up.

I experimented a bit with the functionality and it seems the o (write once) flag is treated the same as the r (read only) flag, even if the variable does not exist yet. Not sure if this is intentional.