Skip to content

Commit

Permalink
syslinux: Improve compatibility with u-boot extlinux.conf
Browse files Browse the repository at this point in the history
The NVidia Jetson NX comes with u-boot installed in syslinux compatible
mode.  It reads from `/boot/extlinux/extlinux.conf` to know what to boot.
It's quite picky about what format it will accept.  It crashes if
`MENU LABEL` is missing or `KERNEL` is present rather than `LINUX`.

This commit improves compatibility by conforming to what u-boot accepts.
In theory it shouldn't affect real syslinux systems because the
documentation says:

> ### LINUX
>
> You can use this, instead of using KERNEL file to boot a linux kernel
> image.

although I don't have a real syslinux system to test it on.
  • Loading branch information
wmanley committed Jan 7, 2021
1 parent aa4aae4 commit 2e3ba99
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/libostree/ostree-bootloader-syslinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ append_config_from_loader_entries (OstreeBootloaderSyslinux *self,
if (regenerate_default && i == 0)
g_ptr_array_add (new_lines, g_strdup_printf ("DEFAULT %s", val));

g_ptr_array_add (new_lines, g_strdup_printf ("LABEL %s", val));
g_ptr_array_add (new_lines, g_strdup_printf ("\nLABEL %s", val));
g_ptr_array_add (new_lines, g_strdup_printf ("\tMENU LABEL %s", val));

val = ostree_bootconfig_parser_get (config, "linux");
if (!val)
return glnx_throw (error, "No \"linux\" key in bootloader config");
g_ptr_array_add (new_lines, g_strdup_printf ("\tKERNEL /boot%s", val));
g_ptr_array_add (new_lines, g_strdup_printf ("\tLINUX /boot%s", val));

val = ostree_bootconfig_parser_get (config, "initrd");
if (val)
Expand Down Expand Up @@ -207,6 +208,11 @@ _ostree_bootloader_syslinux_write_config (OstreeBootloader *bootloader,
g_free (kernel_arg);
kernel_arg = g_strdup (line + strlen ("\tKERNEL "));
}
else if (parsing_label && g_str_has_prefix (line, "\tLINUX "))
{
g_free (kernel_arg);
kernel_arg = g_strdup (line + strlen ("\tLINUX "));
}
else if (!parsing_label &&
(g_str_has_prefix (line, "DEFAULT ")))
{
Expand Down
2 changes: 2 additions & 0 deletions tests/bootloader-entries-crosscheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def validate_syslinux(sysroot):
syslinux_entry['title'] = v
elif k == 'KERNEL':
syslinux_entry['linux'] = v
elif k == 'LINUX':
syslinux_entry['linux'] = v
elif k == 'INITRD':
syslinux_entry['initrd'] = v
elif k == 'APPEND':
Expand Down

0 comments on commit 2e3ba99

Please sign in to comment.