[SRU] Add FK_FORCE_EFI environment variable to skip EFI check
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
flash-kernel |
Fix Released
|
Unknown
|
|||
flash-kernel (Ubuntu) |
New
|
Undecided
|
Unassigned | ||
Jammy |
Incomplete
|
Undecided
|
Unassigned |
Bug Description
[ Impact ]
Flash-kernel currently checks to see if the machine is running in an EFI environment by checking the existence of /sys/firmware/efi, and exits if this is the case. This is undesirable in some cases, such as in virtual, container, or chroot environments where the host is running in an EFI environment, but the target device that the system will actually run on is not and needs flash-kernel to be run.
This debdiff adds the ability to skip this check by setting the FK_FORCE_EFI environment variable to "yes" (which follows the usage of the FK_FORCE environment variable). This way, flash-kernel can be run even though the host system is running in an EFI environment.
[ Test Plan ]
As this change should not impact the current usage of the tool, a test should be carried out that the normal default usage (i.e. on target platforms) is not affected and retains the current behaviour.
We should also test that the current behaviour of exiting when the /sys/firmware/efi directory is detected is retained when FK_FORCE_EFI is not set to "yes".
Finally, the new ability to skip the EFI detection check when FK_FORCE_EFI is set to "yes" must be tested.
[ Where problems could occur ]
Some users may be relying on the current behaviour of flash-kernel to exit when the EFI environment is detected. The current default behaviour is being retained so as to avoid this issue, meaning a user should only see the effect of this change when setting FK_FORCE_EFI to "yes".
[ Other Info ]
N/A
Changed in flash-kernel: | |
status: | Unknown → New |
Changed in flash-kernel: | |
status: | New → Fix Released |
Test results on Ubuntu 22.04:
# Normal flash-kernel process.
ubuntu@ubuntu:~$ sudo flash-kernel 5.15.0- 1007-s32/ device- tree/freescale/ s32g274a- rdb2.dtb into /boot/dtbs/ 5.15.0- 1007-s32/ ./s32g274a- rdb2.dtb
Using DTB: s32g274a-rdb2.dtb
Installing /lib/firmware/
Taking backup of s32g274a-rdb2.dtb.
Installing new s32g274a-rdb2.dtb.
flash-kernel: installing version 5.15.0-1007-s32
Generating u-boot image... done.
Taking backup of fitImage.
Installing new fitImage.
# Mount a tmpfs over /sys/firmware so that we can add an efi directory.
ubuntu@ubuntu:~$ sudo mount -t tmpfs test /sys/firmware
ubuntu@ubuntu:~$ sudo mkdir /sys/firmware/efi
# Test the existing EFI detection is still working.
# flash-kernel should exit without doing anything.
ubuntu@ubuntu:~$ sudo flash-kernel
System running in EFI mode, skipping.
# Set the environment variable FK_FORCE_EFI="yes" to skip the EFI check
# Note we have to set the FK_MACHINE variable here as it can no longer
# read the device tree due to the tmpfs mount.
# This should succeed.
ubuntu@ubuntu:~$ sudo FK_FORCE_EFI="yes" FK_MACHINE="NXP S32G274A-RDB2" flash-kernel 5.15.0- 1007-s32/ device- tree/freescale/ s32g274a- rdb2.dtb into /boot/dtbs/ 5.15.0- 1007-s32/ ./s32g274a- rdb2.dtb
Using DTB: s32g274a-rdb2.dtb
Installing /lib/firmware/
Taking backup of s32g274a-rdb2.dtb.
Installing new s32g274a-rdb2.dtb.
flash-kernel: installing version 5.15.0-1007-s32
Generating u-boot image... done.
Taking backup of fitImage.
Installing new fitImage.