x86,armsr: interpolate GRUB_SERIAL into /etc/inittab
authorPhilip Prindeville <philipp@redfish-solutions.com>
Wed, 13 Sep 2023 16:09:43 +0000 (10:09 -0600)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 19 Nov 2023 16:33:37 +0000 (17:33 +0100)
Some platforms have their console on other ports than ttyS0, so
allow the developer to tailor this on bespoke platform images.

Fixes issue #13401.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
target/linux/armsr/base-files.mk [new file with mode: 0644]
target/linux/armsr/base-files/etc/inittab
target/linux/armsr/image/Makefile
target/linux/x86/base-files.mk [new file with mode: 0644]
target/linux/x86/base-files/etc/inittab
target/linux/x86/image/Makefile

diff --git a/target/linux/armsr/base-files.mk b/target/linux/armsr/base-files.mk
new file mode 100644 (file)
index 0000000..88ba97d
--- /dev/null
@@ -0,0 +1,8 @@
+GRUB_SERIAL:=$(call qstrip,$(CONFIG_GRUB_SERIAL))
+ifeq ($(GRUB_SERIAL),)
+$(error This platform requires CONFIG_GRUB_SERIAL be set!)
+endif
+
+define Package/base-files/install-target
+       $(SED) "s#@GRUB_SERIAL@#$(GRUB_SERIAL)#" $(1)/etc/inittab
+endef
index 51832eb77564f8b004b70189509cc408640f1e4d..87d5460d3233138052e1e77fe37fff0b9911becc 100644 (file)
@@ -1,7 +1,7 @@
 ::sysinit:/etc/init.d/rcS S boot
 ::shutdown:/etc/init.d/rcS K shutdown
 ttyAMA0::askfirst:/usr/libexec/login.sh
-ttyS0::askfirst:/usr/libexec/login.sh
+@GRUB_SERIAL@::askfirst:/usr/libexec/login.sh
 tty0::askfirst:/usr/libexec/login.sh
 hvc0::askfirst:/usr/libexec/login.sh
 ttymxc0::askfirst:/usr/libexec/login.sh
index 1df9657385dc624eb22a35c0233cdf1a61d59311..e5be3fbe38f426d16aa94a38f552586c6e835263 100644 (file)
@@ -17,14 +17,10 @@ endif
 
 GRUB_SERIAL:=$(call qstrip,$(CONFIG_GRUB_SERIAL))
 
-ifneq ($(GRUB_SERIAL),)
-  GRUB_SERIAL_CONFIG := serial --unit=0 --speed=$(CONFIG_GRUB_BAUDRATE) --word=8 --parity=no --stop=1 --rtscts=$(if $(CONFIG_GRUB_FLOWCONTROL),on,off)
-  GRUB_TERMINALS += serial
-endif
+GRUB_SERIAL_CONFIG := serial --unit=0 --speed=$(CONFIG_GRUB_BAUDRATE) --word=8 --parity=no --stop=1 --rtscts=$(if $(CONFIG_GRUB_FLOWCONTROL),on,off)
+GRUB_TERMINALS += serial
 
-ifneq ($(GRUB_TERMINALS),)
-  GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS)
-endif
+GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS)
 
 ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
 ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(IMG_PART_SIGNATURE)-02)
diff --git a/target/linux/x86/base-files.mk b/target/linux/x86/base-files.mk
new file mode 100644 (file)
index 0000000..88ba97d
--- /dev/null
@@ -0,0 +1,8 @@
+GRUB_SERIAL:=$(call qstrip,$(CONFIG_GRUB_SERIAL))
+ifeq ($(GRUB_SERIAL),)
+$(error This platform requires CONFIG_GRUB_SERIAL be set!)
+endif
+
+define Package/base-files/install-target
+       $(SED) "s#@GRUB_SERIAL@#$(GRUB_SERIAL)#" $(1)/etc/inittab
+endef
index f4747f200d0b248028492e7fc654e75452cb2a86..9daf2ce2f0f34de4b47a2a218b49cc923d5e3d84 100644 (file)
@@ -1,5 +1,5 @@
 ::sysinit:/etc/init.d/rcS S boot
 ::shutdown:/etc/init.d/rcS K shutdown
-ttyS0::askfirst:/usr/libexec/login.sh
+@GRUB_SERIAL@::askfirst:/usr/libexec/login.sh
 hvc0::askfirst:/usr/libexec/login.sh
 tty1::askfirst:/usr/libexec/login.sh
index 322131c2a4881560fa234b188982e21e62c20efa..d95fd15f00825c06a1233625046fe37448620e23 100644 (file)
@@ -18,15 +18,11 @@ endif
 
 GRUB_SERIAL:=$(call qstrip,$(CONFIG_GRUB_SERIAL))
 
-ifneq ($(GRUB_SERIAL),)
-  GRUB_CONSOLE_CMDLINE += console=$(GRUB_SERIAL),$(CONFIG_GRUB_BAUDRATE)n8$(if $(CONFIG_GRUB_FLOWCONTROL),r,)
-  GRUB_SERIAL_CONFIG := serial --unit=0 --speed=$(CONFIG_GRUB_BAUDRATE) --word=8 --parity=no --stop=1 --rtscts=$(if $(CONFIG_GRUB_FLOWCONTROL),on,off)
-  GRUB_TERMINALS += serial
-endif
+GRUB_CONSOLE_CMDLINE += console=$(GRUB_SERIAL),$(CONFIG_GRUB_BAUDRATE)n8$(if $(CONFIG_GRUB_FLOWCONTROL),r,)
+GRUB_SERIAL_CONFIG := serial --unit=0 --speed=$(CONFIG_GRUB_BAUDRATE) --word=8 --parity=no --stop=1 --rtscts=$(if $(CONFIG_GRUB_FLOWCONTROL),on,off)
+GRUB_TERMINALS += serial
 
-ifneq ($(GRUB_TERMINALS),)
-  GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS)
-endif
+GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS)
 
 ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME))
 ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(IMG_PART_SIGNATURE)-02)