Skip to content

Commit

Permalink
u-boot: add 'bootdir' to the generated uEnv.txt
Browse files Browse the repository at this point in the history
When doing a full copy of:

$deployment/usr/lib/ostree-boot -> /boot/ostree/$os-$bootcsum/

U-Boot bootscript can use the 'bootdir' to find, for example,
the Device Tree (dtb) file, as in:

load ${dtype} ${disk}:${bootpart} ${a_fdt} ${bootdir}${dtbname}

Or u-boot external bootscript:

load ${dtype} ${disk}:${bootpart} ${a_scr} ${bootdir}${scriptname}

It could also be possible to point 'bootdir' directly to the
$deployment/usr/lib/ostree-boot, but this would add unnecessary
restrictions on what file system can be used for rootfs as u-boot,
for example, can not read from BTRFS. So having
bootdir=/boot/ostree/$os-$bootcsum/ is a better approach here, as
/boot can be on a separate partition with its own file system type.

Signed-off-by: Gatis Paeglis <[email protected]>
Signed-off-by: Hongxu Jia <[email protected]>
Signed-off-by: Chen Qi <[email protected]>
  • Loading branch information
hongxu-jia authored and ChenQi1989 committed Jun 25, 2024
1 parent 0ea7d2e commit fe269e7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libostree/ostree-bootloader-uboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, int bootver
g_autoptr (GPtrArray) boot_loader_configs = NULL;
OstreeBootconfigParser *config;
const char *val;
g_autofree char *bootdir = NULL;

if (!_ostree_sysroot_read_boot_loader_configs (self->sysroot, bootversion, &boot_loader_configs,
cancellable, error))
Expand All @@ -129,6 +130,9 @@ create_config_from_boot_loader_entries (OstreeBootloaderUboot *self, int bootver
}
g_ptr_array_add (new_lines, g_strdup_printf ("kernel_image%s=/boot%s", index_suffix, val));

bootdir = strndup (val, strrchr(val, '/') - val);
g_ptr_array_add (new_lines, g_strdup_printf ("bootdir%s=%s/", index_suffix, bootdir));

val = ostree_bootconfig_parser_get (config, "initrd");
if (val)
g_ptr_array_add (new_lines, g_strdup_printf ("ramdisk_image%s=/boot%s", index_suffix, val));
Expand Down

0 comments on commit fe269e7

Please sign in to comment.