Commit Graph

354 Commits

Author SHA1 Message Date
Hector Palacios 6910a11eab recovery: turn is_dualboot_enabled() into generic function
The new function compares the value of the variable with
one given as parameter.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
2021-09-09 17:38:44 +02:00
Hector Palacios ec08b1277a recovery-initramfs-init: add support for ubisysvols
Adapt the format_ubi_volume() function to wipe out UBI volumes
instead of formatting MTD partitions.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>

https://onedigi.atlassian.net/browse/DEL-7614
2021-09-09 17:38:44 +02:00
Hector Palacios 90706f5d39 recovery: free strings returned by uboot_getenv()
The function uboot_getenv() is a wrapper over libuboot_get_env() and
requires that the returned strings are freed when no longer in use.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>

https://onedigi.atlassian.net/browse/DEL-7645
(cherry picked from commit 27ce7a4f20)
2021-08-27 12:49:31 +02:00
Hector Palacios c93945c995 recovery: [cosmetic] replace whitespaces with tabs where appropriate
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
(cherry picked from commit f806979c84)
2021-08-27 12:49:25 +02:00
Hector Palacios 846bccc8bf recovery: rework is_dualboot_enabled() function
- The function is only used internally in this file, so make it static.
- Convert the function from 'int' to 'bool', since no other values are
  evaluated.
- Only return true if the variable 'dualboot' is set to 'yes'. Before,
  the function returned true if 'dualboot' was different than 'no'.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
(cherry picked from commit 9a519570ba)
2021-08-27 12:49:22 +02:00
Hector Palacios 53759cd29c recovery: check variable returned by uboot_getenv() is not NULL
The use of this function, which is a wrapper over libuboot_get_env(),
requires checking if the returned string is NULL.
Manipulations of such string without checking whether it's NULL may lead
to segfault errors.
This was seen during firmware update on a device that didn't have the
'dualboot' variable set.

Reported-by: Chandrababu Pigilam <chandrababu.pigilam@digi.com>
Signed-off-by: Hector Palacios <hector.palacios@digi.com>

https://onedigi.atlassian.net/browse/DEL-7645
(cherry picked from commit 8a4484bbd6)
2021-08-27 12:49:16 +02:00
Gabriel Valcazar feec2aa4f7 glib-2.0: backport 2.65 patch to prevent NetworkManager segmentation faults
NetworkManager's main library went through a major overhaul in v1.22, changing
the way it interacts with glib among other things. When using a NetworkManager
version equal or newer than v1.22 along with a glib version between 2.63.3 and
2.65, a race condition can happen, randomly causing segmentation faults.

Since Yocto 3.2 uses NetworkManager 1.22.14 and glib 2.64.5, the race condition
is reproducible, but it can be fixed with the patch introduced in this commit.
The patch in question is commit e4a690f5dd959e74b2d6054826f61509892c8aa7 in the
glib git repo.

https://onedigi.atlassian.net/browse/DEL-7523

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-08-16 15:26:40 +02:00
Mike Engel 37832e8b3b glibc: upgrade to version 2.33 for eIQ support
Signed-off-by: Mike Engel <Mike.Engel@digi.com>
2021-08-11 10:39:26 +02:00
Mike Engel c47377df22 recovery-utils: add check into recover library if dualboot is enabled
This commit add a verification into the recovery library to avoid
that it is executed when in dualboot mode.

Signed-off-by: Mike Engel <Mike.Engel@digi.com>

https://onedigi.atlassian.net/browse/DEL-7580
(cherry picked from commit 30aa4a7444)
2021-07-28 17:19:44 +02:00
Gonzalo Ruiz 3e75c1ed34 recovery-initramfs: launch mdev as daemon
'mdev -s' run on ramfs initialization is able to mount external media already
detected but fails to automatically mount any media detected afterwards.
Running it as a daemon first it will also be able to mount any media detected
after 'mdev -s' is run.

Use argument '-d' to first run mdev as daemon in background.

Move 2 seconds delay to after mdev has been initialized to give external
hardware all the time possible to be successfully detected and mounted.

https://onedigi.atlassian.net/browse/DEL-7285

Signed-off-by: Gonzalo Ruiz <Gonzalo.Ruiz@digi.com>
2021-06-24 10:46:19 +02:00
Mike Engel 5c77cbb502 recovery: add swupdate parameter to select image description.
This commit adds some swupdate parameter to select the sw-description
configuration depending on the used platform.

Signed-off-by: Mike Engel <Mike.Engel@digi.com>
2021-06-08 16:25:04 +02:00
Gabriel Valcazar d5c696fd5b recovery-utils: only print open device warning when encrypting partitions
Technically, partition unencryption is safe to do in open devices, although it
implies that at least one partition has already been encrypted. If we aren't
going to encrypt any partitions, there's no need to print the warning.

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-06-02 14:45:00 +02:00
Gabriel Valcazar 8c19cda181 recovery: change way of deciding if platform uses NAND or eMMC
Instead of checking for the existence of /proc/mtd, which might lead to false
positives, check the "root" parameter in /proc/cmdline. Assume eMMC in case of
any error.

https://onedigi.atlassian.net/browse/DEL-7539

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-06-02 14:45:00 +02:00
Arturo Buzarra 8227a49140 systemd: reduce verbosity of sysv-generator
There are some init packages from the poky layer that remain using only a SysV
init script. Systemd converts these init scripts to systemd service format on
boot and shows an ugly warning for each one. To avoid flooding the console with
this kind of messages, we reduce the verbosity of these messages.

https://onedigi.atlassian.net/browse/DEL-7540

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
2021-06-01 16:26:01 +02:00
Gabriel Valcazar 94551f0c4d recovery-initramfs: correctly set environment variables containing spaces
In the libubootenv implementation of fw_setenv, multiple variables can be set
in one call. When setting a variable with a space-separated list, the app
interprets the list as new variable/value tuples, for example:

    fw_setenv myvar value1 value2 value3

Results in:

    myvar=value1
    value2=value3

This was causing the encrypted eMMC partition mechanism to break, because the
list of encrypted partitions is stored as a space-separated list in an
environment variable. Avoid this by enclosing the variable argument of
set_uboot_var() with double quotes.

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-06-01 09:47:39 +02:00
Gabriel Valcazar 737230a2f4 recovery-initramfs: automatically set an encryption key if needed
Before using the encrypted partition functionality, users have to manually
install the encryption key in the system. Failing to install said key will
result in errors later on.

Even though the installation isn't a difficult operation from a user's point of
view, the recovery script has the necessary logic to detect cases where a
partition is going to be encrypted with no key installed. Automatically
generate a key in these cases to avoid undesired behavior and to improve the
overall user experience.

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-05-27 12:10:44 +02:00
Gabriel Valcazar 158a9e1779 trustfence-tool: update to v2.5
This version adds new functionality to check if an encryption key is installed
as well as a fix for an issue that happens when encrypting partitions with long
names (over 12 characters).

https://onedigi.atlassian.net/browse/DEL-7535

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-05-27 12:10:44 +02:00
Gabriel Valcazar 32984efc90 recovery-utils: ask for confirmation when changing the encryption key
If we trigger a key change while there are partitions that are encrypted,
print a warning and ask for confirmation so users know that the operation will
erase the contents of said partitions.

Like in the partition (un)encryption mechanism, add the possibility to skip
both the warning message and the confirmation prompt.

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-05-27 12:10:44 +02:00
Gabriel Valcazar e2cd4f6d9a trustfence-initramfs: remove support for platforms with NAND internal storage
This initramfs only makes sense in platforms with an eMMC as the internal
storage, due to how the partition encryption support is implemented. In
plaatforms that use NAND instead, ths initramfs offers no functionality and
increases the recovery image size, so remove it.

https://onedigi.atlassian.net/browse/DEL-7534

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-05-27 12:10:44 +02:00
Gabriel Valcazar a432a6353a recovery-initramfs: make rootfs encryption status changeable via updates only
If we allow users to manually change the encryption status of the rootfs
partition, we run the risk of wiping it without flashing a proper replacement
image. Because of this, rootfs encryption status should be determined
automatically using information from the update package.

Have the recovery script parse the update package's description to determine
whether to encrypt the rootfs or not.

https://onedigi.atlassian.net/browse/DEL-7174

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-05-27 12:10:43 +02:00
Gabriel Valcazar 953a376d97 recovery-utils: don't allow manual (un)encryption of rootfs partition
This partition isn't blacklisted, but it should only be (un)encrypted when
providing an update package. Make it so that manual encryption status changes
for this partition aren't possible from the recovery library.

https://onedigi.atlassian.net/browse/DEL-7174

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-05-27 12:10:43 +02:00
Gabriel Valcazar 82a76a7106 trustfence: split filesystem encryption support into two variables
Previously, TRUSTFENCE_INITRAMFS_IMAGE was the only variable used to configure
rootfs encryption. Now that any partition can be encrypted and the rootfs
encryption still needs to be handled differently, use two variables instead.

    * TRUSTFENCE_ENCRYPT_PARTITIONS to control partition encryption in general
    * TRUSTFENCE_ENCRYPT_ROOTFS to control rootfs encryption

As with most trustfence functionality, enable both by default. Leave
TRUSTFENCE_INITRAMFS_IMAGE as an internal variable only.

https://onedigi.atlassian.net/browse/DEL-7174

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-05-27 12:10:43 +02:00
Gabriel Valcazar 402f9775b9 recovery-initramfs: manage update partition correctly with partition encryption
Since the update partition might be involved during a software update, we need
to make sure that its contents are accesible and safe when using the partition
encryption feature at the same time.

Mount and unmount the partition correctly if it's encrypted and cancel any
operations that will result in the deletion of the update package.

https://onedigi.atlassian.net/browse/DEL-7174
https://onedigi.atlassian.net/browse/DEL-7422

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-05-27 12:10:43 +02:00
Gabriel Valcazar d54510766a recovery-utils: add partition encryption support
Add a new function to the recovery library to be able to encrypt/unencrypt any
partition on the internal storage media. Since it's a destructive operation,
add a warning message and a confirmation prompt that can be skipped if needed.

Reflect this new functionality in the recovery-reboot app. Change the logic so
that an encryption key can be set even if there's no update package, because
now it's possible to encrypt other partitions while leaving the rootfs intact.
Also change the logic so that the app doesn't reboot into recovery mode if
there's no recovery command set.

Implement the same blacklist as the one in the recovery script.

https://onedigi.atlassian.net/browse/DEL-7174

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-05-27 12:10:43 +02:00
Gabriel Valcazar 59e652ec9b trustfence: extend partition encryption support to any partition
Modify the recovery and trustfence initramfs scripts to be able to encrypt any
partition on the internal storage media, not just the rootfs.

To implement this functionality, add a new recovery command called
'encrypt_partitions'. When used, this command must contain a comma-separated
list of the partitions that are to be encrypted by the end of the recovery
process, including partitions that were already encrypted beforehand. Any
partition that isn't in the list will be unencrypted. If the command is absent,
no changes will be made, but it's possible to pass an empty command to
unencrypt all partitions.

Include a blacklist to avoid encrypting partitions that shouldn't be encrypted,
such as partitions that need to be accessed by the ROM code/U-Boot or
partitions that contain encryption keys.

While at it, remove unnecessary "get_kernel_version" function from the script.

https://onedigi.atlassian.net/browse/DEL-7174

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-05-27 12:10:43 +02:00
Francisco Gil Martinez 562a00fe2f libgpiod: add libgpiod-tools dependence
Now libgpiod is not added automatically and we need to add the
dependence manually.
For more info see commit 4339c28ff4aa0264c34f4f183349aea20a5ff127 in
meta-openembedded layer.

https://jira.digi.com/browse/DEL-7522

Signed-off-by: Francisco Gil Martinez <francisco.gilmartinez@digi.com>
2021-05-12 08:12:21 +02:00
Arturo Buzarra a686e1f4fa packagegroup-dey-core: fix build error on platforms without systemd for system-monitor recipe
Recipe system-monitor has a dependency with systemd package, however it was
added unconditionally for all platforms. This commit adds a protection to
include this recipe only when systemd is present in the DISTRO_FEATURES

https://jira.digi.com/browse/DEL-7508

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
2021-05-05 19:18:11 +02:00
Arturo Buzarra ccaadd7c1b system-monitor: add features_check to fix build warning
This commit fixes the following warning:
    WARNING: system-monitor-0.1-r0 do_package_qa: QA Issue: system-monitor:
    recipe doesn't inherit features_check [unhandled-features-check]

https://jira.digi.com/browse/DEL-7508

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
2021-05-05 19:18:11 +02:00
Arturo Buzarra ca5a2cce23 gatesgarth migration: psplash: rework Digi customization to match new version
Commit f7a354d("Generate image headers from their PNG source, while still
including them in dist tarball") provides a default PNG files removing the image
generation in build time. This commit overwrites the default PNG with one
customized by Digi.

https://jira.digi.com/browse/DEL-7508

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
2021-05-05 19:18:11 +02:00
Gabriel Valcazar 77039b87df gatesgarth migration: Convert u-boot-fw-utils dependencies to libubootenv dependencies
Modify the recovery-utils code to reflect the change (change in C header and
linked libraries)

https://jira.digi.com/browse/DEL-7410

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-05-05 19:18:11 +02:00
Arturo Buzarra 4342546a01 gatesgarth migration: features_check class replaces distro_features_check
The 'distro_features_check' class has had its functionality expanded, as
a result the class has now been renamed to 'features_check'

https://jira.digi.com/browse/DEL-7508

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
2021-05-05 19:18:11 +02:00
Arturo Buzarra b2152d4721 gatesgarth migration: sysvinit: update to recipe v2.97
https://jira.digi.com/browse/DEL-7508

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
2021-05-05 19:18:11 +02:00
Arturo Buzarra e6cd16428a gatesgarth migration: packagegroup-dey-core: add networkmanager-nmcli package
NetworkManager recipe split the command line util in a different package, so we
added it in our default images.

https://jira.digi.com/browse/DEL-7508

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
2021-04-29 20:07:28 +02:00
Arturo Buzarra 4bff866a5d gatesgarth migration: busybox: update to version 1.32.0
https://jira.digi.com/browse/DEL-7508

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
2021-04-29 20:07:28 +02:00
Gabriel Valcazar de7d43a6f0 systemd-gpuconfig: Update recipe to new NXP BSP release imx_5.4.70_2.3.1
Add missing gpuconfig script elements

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2021-02-17 12:01:00 +01:00
Arturo Buzarra 33cc4729ae busybox: add support to ConnectCore 8M Mini DVK platform
Use the same common files for both ConnectCore 8M platforms

https://jira.digi.com/browse/DEL-7397

Signed-off-by: Arturo Buzarra <arturo.buzarra@digi.com>
2021-02-04 13:07:07 +01:00
Gabriel Valcazar f7c86fb0a4 busybox: remove default http homepage elements
We're going to be using the busybox http server to house the WebKit examples,
so we need to get rid of any files that might interfere with it. Keep the files
for the ccimx6ul, since it doesn't support WebKit.

https://jira.digi.com/browse/DEL-7314
https://jira.digi.com/browse/DEL-7339

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2020-12-17 09:33:22 +01:00
Gabriel Valcazar f91cb8d6bd Add support for the dey-image-webkit image
This image is very similar to dey-image-qt, but it includes the WebKit
packagegroup instead of the Qt one. Said packagegroup contains all of the
elements needed to run a WebKit-based browser environment in DEY.

This image requires the meta-webkit layer, so include it in our default
bblayers template. For now, include all WebKit related recipes in a dynamic
layer, because the ccimx6ul doesn't support WebKit and its projects don't need
meta-webkit at all.

https://jira.digi.com/browse/DEL-7339

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2020-12-14 11:49:33 +01:00
Hector Bujanda 65d184cac3 busybox: standby: ccimx8x/mn: configure power LED for blinking in standby
configure power LED for blinking in standby
configure power LED solid on after resume

https://jira.digi.com/browse/DEL-7330

Signed-off-by: Hector Bujanda <Hector.Bujanda@digi.com>
2020-11-24 11:41:21 +01:00
Hector Bujanda adebdabac9 recipes-core: systemd-gpuconfig: Update recipes to new BSP release imx_5.4.47_2.2.0
Includes:
gpuconfig/rc_gpu.S: Update the lib names of libOpenVG [YOCIMX-4888]

    In imx-gpu-viv 6.4.3, the 2D/3D OpenVG lib names are changed:

      libOpenVG.2d.so – > libOpenVG.2d.so.1.1.0
      libOpenVG.3d.so – > libOpenVG.3d.so.1.1.0

Signed-off-by: Hector Bujanda <Hector.Bujanda@digi.com>
2020-11-02 22:06:27 +01:00
Gabriel Valcazar a872c5f4cd trustfence-tool: update to v2.4
This version includes changes needed to reflect the OTP driver update in the
kernel.

https://jira.digi.com/browse/DEL-7261

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2020-10-05 13:06:36 +02:00
Gabriel Valcazar 7938ddef8f dey-image-recovery-initramfs: remove openssl-bin from initramfs
This package was being included as a RRECOMMENDS from libcrypto, but we don't
need it in the initramfs at all. Since our recovery image is already pretty big
compared with the recovery partition size on ccimx6ul platforms with 256 MB of
storage, remove it to make sure the image can fit.

https://jira.digi.com/browse/DEL-7253

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2020-09-29 09:48:16 +02:00
Hector Palacios 8e23fbfd13 Merge branch 'dey-3.0/master' into hpalacio/dey-3.0-merge
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
2020-09-15 08:53:28 +02:00
Mattias Lindblad 89c2e830d8 busybox: standby: update busybox timeout syntax
Signed-off-by: Mattias Lindblad <mattias.lindblad@niradynamics.se>
Reviewed-by: Hector Palacios <hector.palacios@digi.com>
2020-08-25 07:54:57 +02:00
Hector Palacios ff5d0628d9 recovery: change the way to determine if the device is closed
The old fsl_otp driver is deprecated and we need to determine
if the device is closed using a new property of the device tree
called 'digi,tf-closed'.

Assume the device is open if the property is not found.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>

https://jira.digi.com/browse/DEL-7185
(cherry picked from commit fc1a736758)
2020-07-24 13:13:43 +02:00
Hector Palacios fc1a736758 recovery: change the way to determine if the device is closed
The old fsl_otp driver is deprecated and we need to determine
if the device is closed using a new property of the device tree
called 'digi,tf-closed'.

Assume the device is open if the property is not found.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>

https://jira.digi.com/browse/DEL-7185
2020-07-24 13:12:13 +02:00
Gabriel Valcazar 212448fe2d recovery-initramfs: don't format the rootfs partition unless it's necessary
By default, we generate SWU files which update both the linux and rootfs
partitions. This, along with the fact that platforms using NAND as the storage
media require a reboot for the rootfs partition's "enc" flag to take effect,
makes it safe to format the NAND's rootfs partition before performing an
update, regardless of having to encrypt the rootfs or not.

However, customers that wish to use the swupdate feature to update just the
linux partition will find that the rootfs is completely erased after the update
is finished, because a new rootfs hasn't been written in its place.

To avoid this scenario, parse the SWU package's description to verify that it
contains a rootfs image before formatting the partition.

https://jira.digi.com/browse/DEL-7067

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2020-07-21 09:53:14 +02:00
Gabriel Valcazar 48f8720a23 recovery-initramfs: register mdev regardless of /proc/sys/kernel/hotplug
Busybox's device manager mdev was originally meant to be set up by writing its
path to /proc/sys/kernel/hotplug before launching it, but that entry no longer
exists in Linux v5.4's procfs and mdev can be launched directly.

Since mdev is the element in the recovery initramfs that is in charge of
mounting all partitions where .swu packages can be found (update partition on
the eMMC/MTD, uSD and USB), checking for the existence of the hotplug entry in
the procfs before launching mdev in v5.4 was preventing the partitions from
being mounted, and causing all software updates to fail.

While at it, move the two second delay to before mdev is launched, so all
partitions can be mounted. Otherwise, some devices such as the USB might not
be ready when mdev is launched, causing its partition to not be mounted.

https://jira.digi.com/browse/DEL-7143

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
2020-06-18 13:43:47 +02:00
Hector Bujanda 2efc2c3e42 base-files: fix checks done to execute resize2fs postinst function in kernel 5.4
MMC core block has changed in kernel 5.4 so Replay Protected Memory Block (RPMB)
and boot partitions are not listed under /proc/partitions anymore.

get_emmc_block_device() function in pkg_postinst_ontarget() method was looking
for these entries to identify the MMC partition where to execute resize2fs.

This function has been modified to do the checks inside /dev/mmcblk* where RPMB
and boot entries are still listed.

https://jira.digi.com/browse/DEL-7094

Signed-off-by: Hector Bujanda <hector.bujanda@digi.com>
2020-05-11 16:04:57 +02:00
Hector Palacios ab98e928f5 machines: move common recipes to all packagegroup-dey-core
- u-boot-fw-utils
- cryptodev-module

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
2020-05-06 17:02:28 +02:00