Environment size must be set (it was optional for old tools). Skip all
configuration line without a correct value for the environment size.
Signed-off-by: Stefano Babic <sbabic@denx.de>
Use GNUInstallDirs to get the path where to install artifacts. This
solves the issue with OE if multilib is set.
Signed-off-by: Stefano Babic <sbabic@denx.de>
Create a libubootenv.pc file for pkg-config. Allows to use
PKG_CHECK_MODULE in autoconf-based projects or :
ubootenv_dep = dependency('libubootenv', version : '>= 0.2')
for meson build system.
Fixes:
$: meson build
The Meson build system
Cross C compiler: arm-poky-linux-gnueabi-gcc ...
[...]
Cross dependency libubootenv found: NO (tried pkgconfig)
With this commit:
$: meson builld
The Meson build system
Cross C compiler: arm-poky-linux-gnueabi-gcc ...
[...]
Cross dependency libubootenv found: YES 0.2
Build targets in project: 1
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
This allows linking from C++ applications without the need of using
extern "C" when including libuboot header file.
This follows the guide line of many other libraries.
Fixes:
foo.cpp:(.text+0x19) : undefined reference to « libuboot_initialize(uboot_ctx**, uboot_env_device*) »
...
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
libubootenv/src/uboot_env.c: In function ‘fileprotect’:
libubootenv/src/uboot_env.c:557:3: warning: ignoring return value of ‘write’,
declared with attribute warn_unused_result [-Wunused-result]
write(fd_force_ro, &c_unprot_char, 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libubootenv/src/uboot_env.c:560:3: warning: ignoring return value of ‘write’,
declared with attribute warn_unused_result [-Wunused-result]
write(fd_force_ro, &c_prot_char, 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libubootenv/src/uboot_env.c: In function ‘check_env_device.isra.4’:
libubootenv/src/uboot_env.c:44:30: warning: ‘__builtin___sprintf_chk’ may write
a terminating nul past the end of the destination [-Wformat-overflow=]
#define SYS_UBI_VOLUME_NAME "/sys/class/ubi/ubi%d/ubi%d_%d/name"
^
libubootenv/src/uboot_env.c:44:30: note: in definition of macro ‘SYS_UBI_VOLUME_NAME’
#define SYS_UBI_VOLUME_NAME "/sys/class/ubi/ubi%d/ubi%d_%d/name"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862:0,
from libubootenv/src/uboot_env.c:17:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10:
note: ‘__builtin___sprintf_chk’ output between 32 and 61 bytes into a destination of size 40
return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Stefano Babic <sbabic@denx.de>
In the function ubi_get_vol_id, when we search the volume id
with the volume name, we try all id from 0 to num_volume. But
the volume id may be greater than the actual number of volume.
To avoid this issue, we try all the id from 0 to 128 (max ubi
volume id).
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Some block devices support physical write protection. The kernel
provides a standard interface to enable or disable protection in
/sys/class/block/*/force_ro.
This patch adds functionality to automatically detect these memory
types. If read-only mode is enabled on the partition on which the
uboot environment must be written, libubootenv temporarily switches
to read/write mode.ease enter the commit message for your changes.
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
The libubootenv code uses some C99 constructs, but old compilers such
as gcc 4.7 don't default to -std=c99. This commit makes sure libubootenv
is built with -std=gnu99.
Fixes:
src/uboot_env.c:897:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < strlen(pval); i++) {
^
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
Whilst working on the Reproducible Builds effort [0] we noticed
that libubootenv could not be built reproducibly.
This is due to the docs using absolute build paths. This was
originally filed in Debian as #939547 [1].
[0] https://reproducible-builds.org/
[1] https://bugs.debian.org/939547
Signed-off-by: Chris Lamb <lamby@debian.org>
The environement may be read and write from
a file or a mtd (raw nor or raw nand). This
commit add the support of ubi volume.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
This commit add a flag device_type in
struct uboot_flash_env, then we could
manage the read and write according to
the device type.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
The flash type MTD_DATAFLASH and MTD_UBI_VOLUME aren't
supported by function devread and devwrite. So it's not
usefull to accept them when checking the device type.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Acked-by: Stefano Babic <sbabic@denx.de>
When the function devwrite write the environement
to a nand, the value returned is always 0. But,
the check on the value returned is done on the
environment size, so we return the size of data
written.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Acked-by: Stefano Babic <sbabic@denx.de>
When the function devread read the environement
from a nand, the value returned is always 0. But,
the check on the value returned is done on the
environment size, so we return the size of data
read.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Acked-by: Stefano Babic <sbabic@denx.de>
<pthread.h> include doesn't seem to be necessary inside the library.
So, drop the header completely.
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
Acked-by: Stefano Babic <sbabic@denx.de>
flags are not working because the .flags variable is not parsed when
wnvironment is loaded.
Signed-off-by: Stefano Babic <sbabic@denx.de>
Reported-by: Lukasz Domowy <lukasz.odw39@gmail.com>
Reported-by: Uwe Schuster <uwe.schuster68@gmail.com>
Starting with glibc 2.28, include file sys/stat.h will have a
definition for struct statx, in which case include file linux/stat.h should be
avoided, in order to prevent a duplicate definition.
This commit fixes (if _GNU_SOURCE is defined):
/usr/include/linux/stat.h:56:8: error: redefinition of ‘struct statx_timestamp’
struct statx_timestamp {
^~~~~~~~~~~~~~~
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
Since commit [1] in U-Boot, this is the file with the initial environment
delivered with the bootloader.
So, let's set this name as default.
tested with buildroot as follows:
1) # fw_printenv
Cannot read environment, using default
baudrate=115200
...
2) # fw_setenv foo bar
Cannot read environment, using default
3) # fw_printenv foo
foo=bar
[1] bdaa73a5b3 (diff-b67911656ef5d18c4ae36cb6741b7965)
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
Tested-by: Joris Offouga <offougajoris@gmail.com>
This commit fixes :
src/fw_printenv.c:142:4: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
for (int i = 0; i < argc; i++) {
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
When fw_setenv calls function 'set_obsolete_flag' to set environment
flags from active to obsolete, the flags are addressed without an
offset from struct uboot_env_redund. Thus the redundant environment
flags are not updated, but the first byte of CRC32 is clean. The
redundant environment becomes invalid.
The issue is fixed by adding flags offset for setting obsolete flag.
Signed-off-by: Leo Ruan <tingquan.ruan@cn.bosch.com>
Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
Acked-by: Stefano Babic <sbabic@denx.de>
The fw_utils load environment variables from a persistent storage
(e.g. SPI flash) at first. If there is no valid environment in the
persistent storage, fw_utils accept a file which contains an initial
environment of U-Boot.
If no valid environment can be found from the persistent storage and
given file, fw_utils continue to work on an empty environment.
Specially, fw_setenv stores the environment to persistent storage.
This leads problem on booting.
This commit fixes the problem by making fw_utils return error in
case of no valid environment in persistent storage and given file.
Signed-off-by: Leo Ruan <tingquan.ruan@cn.bosch.com>
Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
Acked-by: Stefano Babic <sbabic@denx.de>
Initial version, tested with the following backends:
- files
- NOR flash
- eMMC device
Environment in UBI volumes is not supported, environment in NAND is not
yet tested.
Signed-off-by: Stefano Babic <sbabic@denx.de>