raspberrypi, raspberrypi2: add a serial console
authorLuca Ceresoli <luca@lucaceresoli.net>
Sun, 17 Apr 2016 21:45:46 +0000 (23:45 +0200)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Mon, 18 Apr 2016 11:36:11 +0000 (13:36 +0200)
The current Buildroot defconfigs for Raspberry Pi and Raspberry Pi 2
instantiate a console on tty1, which appears on HDMI. Add a console on
the serial port (ttyAMA0) to be more consistent with other defconfigs
and provide a better out-of-the-box experience to users used to have a
serial console from Buildroot defconfigs.

This requires three changes:
 1. have two 'console=' entries in the kernel command line: tty1,
    then ttyAMA0;
 2. change BR2_TARGET_GENERIC_GETTY_PORT to "console", so it starts
    a getty on the last console= passed to the kernel, ttyAMA0;
 3. add a new getty on tty1 to the generated inittab.

Step 2 is actually obtained by removing BR2_TARGET_GENERIC_GETTY_PORT
entirely from the defconfigs, since "console" is the default value.

Step 3 requires a post-build script since the Buildroot makefiles can
configure only one console.

Note: instead of simply adding a new getty on ttyAMA0 (which would
work) this patch actually changes BR2_TARGET_GENERIC_GETTY_PORT to
instantiate a console on UART, then adds back tty1 via
post-build.sh. This is done only to avoid the "GENERIC_SERIAL" comment
where we instantiate an HDMI console, then instantiate a really-serial
console on another line.

The result is these two inittab lines:

  console::respawn:/sbin/getty -L  console 0 vt100 # GENERIC_SERIAL
  tty1::respawn:/sbin/getty -L  tty1 0 vt100 # HDMI console

Cc: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
board/raspberrypi/post-build.sh [new file with mode: 0755]
configs/raspberrypi2_defconfig
configs/raspberrypi_defconfig
package/rpi-firmware/cmdline.txt

diff --git a/board/raspberrypi/post-build.sh b/board/raspberrypi/post-build.sh
new file mode 100755 (executable)
index 0000000..7eae14a
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -u
+set -e
+
+# Add a console on tty1
+grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \
+sed -i '/GENERIC_SERIAL/a\
+tty1::respawn:/sbin/getty -L  tty1 0 vt100 # HDMI console' ${TARGET_DIR}/etc/inittab
index 506330cd078051a85f21b3b3b6e0083718a836c3..7fc39c234c32fb32d5fe32807b919bd13a3a12fd 100644 (file)
@@ -5,7 +5,6 @@ BR2_ARM_FPU_NEON_VFPV4=y
 
 BR2_TOOLCHAIN_BUILDROOT_CXX=y
 
-BR2_TARGET_GENERIC_GETTY_PORT="tty1"
 BR2_SYSTEM_DHCP="eth0"
 
 # Linux headers same as kernel, a 4.1 series
@@ -33,4 +32,5 @@ BR2_PACKAGE_HOST_MTOOLS=y
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
 # BR2_TARGET_ROOTFS_TAR is not set
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi2/post-build.sh"
 BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi2/post-image.sh"
index 1795b2c03d534a27d5d29f57fba9a4932bbf2271..8d13381105c1545a740106b76504f84233ec3c5e 100644 (file)
@@ -2,7 +2,6 @@ BR2_arm=y
 BR2_arm1176jzf_s=y
 BR2_ARM_EABIHF=y
 
-BR2_TARGET_GENERIC_GETTY_PORT="tty1"
 BR2_SYSTEM_DHCP="eth0"
 
 # Linux headers same as kernel, a 4.1 series
@@ -32,4 +31,5 @@ BR2_PACKAGE_HOST_MTOOLS=y
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
 # BR2_TARGET_ROOTFS_TAR is not set
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi/post-build.sh"
 BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi/post-image.sh"
index 38aa3782621bc067fb36d217c67625d0be0e1e51..155a54693bff3fac2e097b6f634b28544c21e56d 100644 (file)
@@ -1 +1 @@
-root=/dev/mmcblk0p2 rootwait
+root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200