<feed xmlns='http://www.w3.org/2005/Atom'>
<title>u-boot.git/tools/env, branch v2022.04</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/'/>
<entry>
<title>fw_env: simplify logic &amp; code paths in the fw_env_open()</title>
<updated>2022-02-11T16:29:23+00:00</updated>
<author>
<name>Rafał Miłecki</name>
<email>rafal@milecki.pl</email>
</author>
<published>2022-01-12T11:47:06+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=07c79dd5fdeaefb39c9e7a97f3b66de63109a18d'/>
<id>07c79dd5fdeaefb39c9e7a97f3b66de63109a18d</id>
<content type='text'>
Environment variables can be stored in two formats:
1. Single entry with header containing CRC32
2. Two entries with extra flags field in each entry header

For that reason fw_env_open() has two main code paths and there are
pointers for CRC32/flags/data.

Previous implementation was a bit hard to follow:
1. It was checking for used format twice (in reversed order each time)
2. It was setting "environment" global struct fields to some temporary
   values that required extra comments explaining it

This change simplifies that code:
1. It introduces two clear code paths
2. It sets "environment" global struct fields values only once it really
   knows them

To be fair there are *two* crc32() calls now and an extra pointer
variable but that should be cheap enough and worth it.

Signed-off-by: Rafał Miłecki &lt;rafal@milecki.pl&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Environment variables can be stored in two formats:
1. Single entry with header containing CRC32
2. Two entries with extra flags field in each entry header

For that reason fw_env_open() has two main code paths and there are
pointers for CRC32/flags/data.

Previous implementation was a bit hard to follow:
1. It was checking for used format twice (in reversed order each time)
2. It was setting "environment" global struct fields to some temporary
   values that required extra comments explaining it

This change simplifies that code:
1. It introduces two clear code paths
2. It sets "environment" global struct fields values only once it really
   knows them

To be fair there are *two* crc32() calls now and an extra pointer
variable but that should be cheap enough and worth it.

Signed-off-by: Rafał Miłecki &lt;rafal@milecki.pl&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fw_env: make flash_io() take buffer as an argument</title>
<updated>2022-02-11T16:29:23+00:00</updated>
<author>
<name>Rafał Miłecki</name>
<email>rafal@milecki.pl</email>
</author>
<published>2022-01-12T11:47:05+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=f178f7c9550c4fd9c644f79a1eb2dafa5bcdce25'/>
<id>f178f7c9550c4fd9c644f79a1eb2dafa5bcdce25</id>
<content type='text'>
It's usually easier to understand code &amp; follow it if all arguments are
passed explicitly. Many coding styles also discourage using global
variables.

Behaviour of flash_io() was a bit unintuitive as it was writing to a
buffer referenced in a global struct. That required developers to
remember how it works and sometimes required hacking "environment"
global struct variable to read data into a proper buffer.

Signed-off-by: Rafał Miłecki &lt;rafal@milecki.pl&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It's usually easier to understand code &amp; follow it if all arguments are
passed explicitly. Many coding styles also discourage using global
variables.

Behaviour of flash_io() was a bit unintuitive as it was writing to a
buffer referenced in a global struct. That required developers to
remember how it works and sometimes required hacking "environment"
global struct variable to read data into a proper buffer.

Signed-off-by: Rafał Miłecki &lt;rafal@milecki.pl&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fw_setenv: Unbreak fw_setenv caused by buggy MEMISLOCKED use</title>
<updated>2021-12-20T14:21:48+00:00</updated>
<author>
<name>Joakim Tjernlund</name>
<email>joakim.tjernlund@infinera.com</email>
</author>
<published>2021-12-08T14:33:11+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=08cf1a5e6995697bcf2405ae50826634bc43d78a'/>
<id>08cf1a5e6995697bcf2405ae50826634bc43d78a</id>
<content type='text'>
Commit "fw_setenv: lock the flash only if it was locked before"
checks for Locked status with uninitialized erase data.
Address by moving the test for MEMISLOCKED.

Fixes: 8a726b852502 ("fw_setenv: lock the flash only if it was locked before")
Signed-off-by: Joakim Tjernlund &lt;joakim.tjernlund@infinera.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commit "fw_setenv: lock the flash only if it was locked before"
checks for Locked status with uninitialized erase data.
Address by moving the test for MEMISLOCKED.

Fixes: 8a726b852502 ("fw_setenv: lock the flash only if it was locked before")
Signed-off-by: Joakim Tjernlund &lt;joakim.tjernlund@infinera.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tools: env: Handle shorter read calls</title>
<updated>2021-09-02T15:19:58+00:00</updated>
<author>
<name>Thibault Ferrante</name>
<email>thibaultferrante@gmail.com</email>
</author>
<published>2021-08-24T15:29:50+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=6628813f9d400c49da4926f01833063a30151cdb'/>
<id>6628813f9d400c49da4926f01833063a30151cdb</id>
<content type='text'>
On some cases, the actual number of bytes read can be shorter
than what was requested. This can be handled gracefully by
taking this difference into account instead of exiting.

Signed-off-by: Thibault Ferrante &lt;thibault.ferrante@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On some cases, the actual number of bytes read can be shorter
than what was requested. This can be handled gracefully by
taking this difference into account instead of exiting.

Signed-off-by: Thibault Ferrante &lt;thibault.ferrante@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tools: env: return error if ubi_update_start() fails</title>
<updated>2021-01-22T21:58:55+00:00</updated>
<author>
<name>Martin Hundebøll</name>
<email>martin@geanix.com</email>
</author>
<published>2020-11-30T11:11:32+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=09779488a924dbc4eb3b4ae145632f22b7f5a36c'/>
<id>09779488a924dbc4eb3b4ae145632f22b7f5a36c</id>
<content type='text'>
The UBI_IOCVOLUP ioctl can fail if exclusive access to the volume isn't
obtained. If this happens, the flush operation doesn't return error,
leaving the caller without knowledge of missing flush.

Fix this by forwarding the error (-1) from ubi_update_start().

Fixes: 34255b92e6e ("tools: env: Add support for direct read/write UBI volumes")
Signed-off-by: Martin Hundebøll &lt;martin@geanix.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The UBI_IOCVOLUP ioctl can fail if exclusive access to the volume isn't
obtained. If this happens, the flush operation doesn't return error,
leaving the caller without knowledge of missing flush.

Fix this by forwarding the error (-1) from ubi_update_start().

Fixes: 34255b92e6e ("tools: env: Add support for direct read/write UBI volumes")
Signed-off-by: Martin Hundebøll &lt;martin@geanix.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tools: env: Avoid an uninited warning with was_locked</title>
<updated>2020-08-05T12:18:34+00:00</updated>
<author>
<name>Simon Glass</name>
<email>sjg@chromium.org</email>
</author>
<published>2020-08-01T16:30:39+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=7b27e0fe13d8d44da6cd357a69668a726b852502'/>
<id>7b27e0fe13d8d44da6cd357a69668a726b852502</id>
<content type='text'>
Set this variable to 0 to avoid a warning about an unused variable. This
happens on gcc 7.5.0 for me.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Set this variable to 0 to avoid a warning about an unused variable. This
happens on gcc 7.5.0 for me.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tools: env: Fix printf() warning in fw_env</title>
<updated>2020-08-05T12:18:34+00:00</updated>
<author>
<name>Simon Glass</name>
<email>sjg@chromium.org</email>
</author>
<published>2020-08-01T16:30:38+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=d9cd4d2a8d429068a6a5061a33459ae3ae113ef8'/>
<id>d9cd4d2a8d429068a6a5061a33459ae3ae113ef8</id>
<content type='text'>
The printf() string produces a warning about %d not matching size_t. Fix
it and put the format string on one line to avoid a checkpatch warning.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The printf() string produces a warning about %d not matching size_t. Fix
it and put the format string on one line to avoid a checkpatch warning.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fw_setenv: lock the flash only if it was locked before</title>
<updated>2020-07-31T14:13:00+00:00</updated>
<author>
<name>Ivan Mikhaylov</name>
<email>fr0st61te@gmail.com</email>
</author>
<published>2020-07-10T16:54:18+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=db82015929aeff6b58982a22d61ab8c5b87752f3'/>
<id>db82015929aeff6b58982a22d61ab8c5b87752f3</id>
<content type='text'>
With current implementation of fw_setenv, it is always locks u-boot-env
region if lock interface is implemented for such mtd device. You can
not control lock of this region with fw_setenv, there is no option for
it in config or in application itself. Because of this situation may
happen problems like in this thread on xilinx forum:
https://forums.xilinx.com/t5/Embedded-Linux/Flash-be-locked-after-use-fw-setenv-from-user-space
/td-p/1027851

A short summary of that link is: some person has issue with some spi
chip which has lock interface but doesn't locks properly which leads to
lock of whole flash memory on lock of u-boot-env region. As resulted
solution hack was added into spi-nor.c driver for this chip with lock
disablement.

Instead fix this problem by adding logic to fw_setenv only lock the
flash if it was already locked when we attempted to use it.

Signed-off-by: Ivan Mikhaylov &lt;fr0st61te@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With current implementation of fw_setenv, it is always locks u-boot-env
region if lock interface is implemented for such mtd device. You can
not control lock of this region with fw_setenv, there is no option for
it in config or in application itself. Because of this situation may
happen problems like in this thread on xilinx forum:
https://forums.xilinx.com/t5/Embedded-Linux/Flash-be-locked-after-use-fw-setenv-from-user-space
/td-p/1027851

A short summary of that link is: some person has issue with some spi
chip which has lock interface but doesn't locks properly which leads to
lock of whole flash memory on lock of u-boot-env region. As resulted
solution hack was added into spi-nor.c driver for this chip with lock
disablement.

Instead fix this problem by adding logic to fw_setenv only lock the
flash if it was already locked when we attempted to use it.

Signed-off-by: Ivan Mikhaylov &lt;fr0st61te@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tools: fw_env: Fix warning when reading too little</title>
<updated>2020-06-02T17:06:14+00:00</updated>
<author>
<name>Harald Seiler</name>
<email>hws@denx.de</email>
</author>
<published>2020-05-28T15:54:45+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=50bb682c5cc52769e7cbd835a00dbcbc75a4f0e7'/>
<id>50bb682c5cc52769e7cbd835a00dbcbc75a4f0e7</id>
<content type='text'>
When using CONFIG_ENV_IS_IN_FAT and the config-file specifies a size
larger than what U-Boot wrote into the env-file, a confusing error
message is shown:

    $ fw_printenv
    Read error on /boot/uboot.env: Success

Fix this by showing a different error message when read returns too
little data.

Signed-off-by: Harald Seiler &lt;hws@denx.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When using CONFIG_ENV_IS_IN_FAT and the config-file specifies a size
larger than what U-Boot wrote into the env-file, a confusing error
message is shown:

    $ fw_printenv
    Read error on /boot/uboot.env: Success

Fix this by showing a different error message when read returns too
little data.

Signed-off-by: Harald Seiler &lt;hws@denx.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>tools/env/fw_env.h: remove env.h</title>
<updated>2020-05-25T15:54:53+00:00</updated>
<author>
<name>Romain Naour</name>
<email>romain.naour@gmail.com</email>
</author>
<published>2020-05-21T21:22:06+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=2aca8804d8d5f84d2d661e76e8d232c5c12445b5'/>
<id>2aca8804d8d5f84d2d661e76e8d232c5c12445b5</id>
<content type='text'>
As reported by Nicolas Carrier on the Buildroot mailing list [1],
there is a new build issue while building a program which interacts with
the u-boot environment. This program uses the headers of the ubootenv
library provided by uboot-tools.

This is a recent change from uboot [2] adding "#include &lt;env.h&gt;" to
fw_env.h. Adding env.h require a board configuration to build since
it also include compiler.h (and others uboot internal includes).

env.h include seems not needed since env_set() is not used in fw_env tool.

Nicolas removed env.h from fw_env tool and fixed it's build issue.

This problem is present since uboot v2019.10.

[1] http://lists.busybox.net/pipermail/buildroot/2020-April/280307.html
[2] https://gitlab.denx.de/u-boot/u-boot/-/commit/9fb625ce05539fe6876a59ce1dcadb76b33c6f6e

Reported-by: Nicolas Carrier &lt;nicolas.carrier@orolia.com&gt;
Signed-off-by: Romain Naour &lt;romain.naour@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As reported by Nicolas Carrier on the Buildroot mailing list [1],
there is a new build issue while building a program which interacts with
the u-boot environment. This program uses the headers of the ubootenv
library provided by uboot-tools.

This is a recent change from uboot [2] adding "#include &lt;env.h&gt;" to
fw_env.h. Adding env.h require a board configuration to build since
it also include compiler.h (and others uboot internal includes).

env.h include seems not needed since env_set() is not used in fw_env tool.

Nicolas removed env.h from fw_env tool and fixed it's build issue.

This problem is present since uboot v2019.10.

[1] http://lists.busybox.net/pipermail/buildroot/2020-April/280307.html
[2] https://gitlab.denx.de/u-boot/u-boot/-/commit/9fb625ce05539fe6876a59ce1dcadb76b33c6f6e

Reported-by: Nicolas Carrier &lt;nicolas.carrier@orolia.com&gt;
Signed-off-by: Romain Naour &lt;romain.naour@gmail.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
