Skip to contentSkip to conversation

Add support for extlinux.conf

PATCH Applied Alexander Shiyan 2 participants 3 messages Jun 5 – Jun 15 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 Add support for extlinux.conf

This adds support for the extlinux.conf configuration format, commonly used by Syslinux and many Linux distributions. The configuration file is typically located at /boot/extlinux/extlinux.conf or /extlinux/extlinux.conf and defines boot entries with kernel, initrd, device tree, and command line options.

The implementation integrates with the existing boot entry framework:
- The extlinux scanner discovers entries on mounted filesystems.
- Only the DEFAULT label is turned into a boot entry (multiple
LABEL sections are ignored after the default is found).
- Bootm is used to load and start the kernel.
---
barebox@Diasom DS-RK3568-SOM-EVB:/ global.bootm.appendroot=true
barebox@Diasom DS-RK3568-SOM-EVB:/ global.boot.default=mmc1.2
barebox@Diasom DS-RK3568-SOM-EVB:/ boot
ext4 ext40: EXT2 rev 1, inode_size 256, descriptor size 64
Booting entry 'extlinux: linux'
extlinux: Booting extlinux label 'linux'
Adding "root=/dev/mmcblk1p3" to Kernel commandline
Loading ARM aarch64 Linux/EFI image '/mnt/mmc1.2/boot/extlinux/../vmlinuz'
commandline: root=/dev/mmcblk1p3 console=ttyS2,1500000n8 ro systemd.unit=setup.target quiet splash systemd.machine_id=181af2816b4c6b0aef77068e0ccc69ad Loaded kernel to 0x0a400000, devicetree at 0x000000000fb49000

---
 common/Kconfig    |  20 ++++
 common/Makefile   |   1 +
 common/extlinux.c | 247 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 268 insertions(+)
 create mode 100644 common/extlinux.c
common/Kconfig +20 -0
index f9985d8aa4..0708855b78 100644
@@ -773,6 +773,26 @@ config BLSPEC
 	  on a device and it allows the Operating System to install / update
 	  kernels.
 
+config EXTLINUX
+	bool
+	prompt "Support extlinux.conf"
+	depends on FLEXIBLE_BOOTARGS
+	depends on !SHELL_NONE
+	select BOOT
+	select BOOTM
+	select MMCBLKDEV_ROOTARG if MCI
+	help
+	  Enable this to let barebox parse extlinux.conf configuration files,
+	  commonly used by the Syslinux bootloader and many Linux distributions
+	  (e.g., on SD cards or USB drives).
+	  extlinux.conf is typically located at /boot/extlinux/extlinux.conf or
+	  /extlinux/extlinux.conf. It defines boot entries with kernel, initrd,
+	  device tree, and command line options.
+
+	  Note: barebox only uses the entry specified by the DEFAULT keyword.
+	  Additional LABEL sections are ignored. This allows a simple and
+	  portable way to define a single default boot option.
+
 config FLEXIBLE_BOOTARGS
 	bool
 	prompt "flexible Linux bootargs generation"
common/Makefile +1 -0
index 27c5dea168..cd929b2194 100644
@@ -9,6 +9,7 @@ obj-y				+= clock.o
 pbl-$(CONFIG_PBL_CLOCKSOURCE)	+= clock.o
 obj-y				+= console_common.o
 obj-$(CONFIG_OFDEVICE)		+= deep-probe.o
+obj-$(CONFIG_EXTLINUX)		+= extlinux.o
 obj-y				+= startup.o
 obj-y				+= misc.o
 obj-pbl-y			+= memsize.o
common/extlinux.c new file +247 -0

247 lines not on this page · raw message

Signature · 1 line
2.52.0
#1 lore raw

PATCH v4 2/2 Documentation: add extlinux.conf support description

---
 Documentation/user/booting-linux.rst | 41 ++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
Documentation/user/booting-linux.rst +41 -0
index 7bbb79ecdf..0f12256813 100644
@@ -304,6 +304,47 @@ Additional notes about keys in the bootloader spec entries:
    different devices without having to specify a different ``root=`` option each
    time.
 
+.. _extlinux_conf:
+
+extlinux.conf Support
+^^^^^^^^^^^^^^^^^^^^^
+
+In addition to the Boot Loader Specification, barebox also supports the
+extlinux configuration format, commonly used by the Syslinux bootloader and
+many Linux distributions. This format is often found on SD cards, USB drives,
+or disk partitions prepared with tools like ``extlinux --install``.
+
+The configuration file is named ``extlinux.conf`` and can be located at:
+* ``/boot/extlinux/extlinux.conf``
+* ``/extlinux/extlinux.conf``
+
+The file uses a simple key-value syntax with sections labeled by ``LABEL``.
+A typical example looks like:
+
+.. code-block:: none
+
+  DEFAULT linux
+  LABEL linux
+    KERNEL /boot/vmlinuz
+    INITRD /boot/initrd.img
+    FDT /boot/board.dtb
+    APPEND console=ttyS0,115200 root=PARTUUID=deadbeef-01
+
+.. note::
+   barebox only uses the entry marked as ``DEFAULT``. Additional ``LABEL``
+   sections are ignored. This provides a simple way to define a single boot
+   option.
+
+To use extlinux support, enable ``CONFIG_EXTLINUX`` in your barebox
+configuration. Entries are automatically discovered by the :ref:`command_boot`
+command when scanning a device or mount point. For example:
+
+.. code-block:: sh
+
+  global.bootm.appendroot=true
+  global.boot.default=mmc1.2
+  boot
+
 .. _booting_linux_net:
 
 Network boot
Signature · 1 line
2.52.0
Applied
#2 lore raw
In reply to Alexander Shiyan
Quoted 6 lines · Alexander Shiyan

This adds support for the extlinux.conf configuration format, commonly used by Syslinux and many Linux distributions. The configuration file is typically located at /boot/extlinux/extlinux.conf or /extlinux/extlinux.conf and defines boot entries with kernel, initrd, device tree, and command line options.

Quoted 7 lines

The implementation integrates with the existing boot entry framework:
- The extlinux scanner discovers entries on mounted filesystems.
- Only the DEFAULT label is turned into a boot entry (multiple LABEL sections are ignored after the default is found).
- Bootm is used to load and start the kernel.

[...]

Applied, thanks!

[1/2] Add support for extlinux.conf
https://git.pengutronix.de/cgit/barebox/commit/?id=b912fa9fc3ca (link may not be stable)
[2/2] Documentation: add extlinux.conf support description
https://git.pengutronix.de/cgit/barebox/commit/?id=3aebbc2b1686 (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>