File renaming problem with systemd-boot after u-boot

Hugo LAFFONT hugo.laffont at smile.fr
Mon Jun 24 09:49:25 CEST 2024


Hello,

I am creating an update system using systemd (repart + sysupdate) and
systemd-boot on an embedded target (beaglebone black).

Everything seems to work except the bootcounting of systemd-boot. "Failed
to rename '\loader\entries\entry+3-0.conf' to 'entry+2-1.conf', ignoring:
Access denied". This happens when the function handle->SetInfo(handle,
MAKE_GUID_PTR(EFI_FILE_INFO), file_info_size, file_info) is called
(src/boot/efi/boot.c line 1385). Then the system is able to boot but I need
to get this bootcouting system working to be able to do fallback if the
update goes wrong.

According to the UEFI Specification we get Access denied after the call of
this function in these cases:
- An attempt is made to change the name of a file to a file that is already
present.
- An attempt is being made to change the EFI_FILE_DIRECTORY Attribute.
- An attempt is being made to change the size of a directory.
- InformationType is EFI_FILE_INFO_ID and the file was opened read-only and
an attempt is being made to modify a field other than Attribute.
However, none of these cases seem to happen because only the field FileName
is modified, the file is opened read/write before and the new name of the
file is not taken by another file.

I tried first to find the implementation of the SetInfo function to see in
more detail what is going wrong, but I didn't find it. Then, I tried to
identify the problem by printing the Attributes field of the EFI_FILE
\loader\entries\entry+3-0.conf. I found that this field is set to 0 and it
correspond to nothing :
- #define EFI_FILE_READ_ONLY  0x01U
- #define EFI_FILE_HIDDEN     0x02U
- #define EFI_FILE_SYSTEM     0x04U
- #define EFI_FILE_RESERVED   0x08U
- #define EFI_FILE_DIRECTORY  0x10U
- #define EFI_FILE_ARCHIVE    0x20U
- #define EFI_FILE_VALID_ATTR 0x37U

I built the image with Yocto and here are the different partitions in the
image :
# u-boot partition
part --source uboot-part --ondisk mmcblk0 --fstype=vfat --label uboot
--active --align 1024 --fixed-size 32 --mbr
# esp partition
part --source esp-part --ondisk mmcblk0 --fstype=vfat --label esp --align
1024 --part-type C12A7328-F81F-11D2-BA4B-00A0C93EC93B
# recovery partition
part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --label recovery
--align 1024
# create gpt layout with mbr
bootloader --ptable=gpt-hybrid

systemd-boot was started by u-boot using the bootefi command :
fatload mmc 0:2 ${loadaddr} EFI/BOOT/bootarm.efi ; bootefi ${loadaddr}

So, my question is why do I get Access denied when I activate the
systemd-boot bootcounting ? Is it because the Attributes of the file
entry+3-0.conf is not set by u-boot ? If yes, how can I set it correctly ?


More information about the U-Boot mailing list