raspberrypi, raspberrypi2: add a serial console
PATCH 1/1 raspberrypi, raspberrypi2: add a serial console
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 two changes:
1. have two 'console=' entries in the kernel command line;
2. add a new getty process to the generated inittab.
Step 2 requires a post-build script since the Buildroot makefiles can configure only one console. But instead of simply adding a new getty on ttyAMA0 (which would work) this patch actually changes BR2_TARGET_GENERIC_GETTY_PORT from tty1 to ttyAMA0, 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:
ttyAMA0::respawn:/sbin/getty -L ttyAMA0 0 vt100 # GENERIC_SERIAL tty1::respawn:/sbin/getty -L tty1 0 vt100 # HDMI console
---
Tested on both Raspberry Pi B and Raspberry Pi 2, each on serial and HDMI console.
--- board/raspberrypi/post-build.sh | 9 +++++++++ configs/raspberrypi2_defconfig | 3 ++- configs/raspberrypi_defconfig | 3 ++- package/rpi-firmware/cmdline.txt | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) create mode 100755 board/raspberrypi/post-build.sh
board/raspberrypi/post-build.sh new file +9 -0
@@ -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
configs/raspberrypi2_defconfig +2 -1
@@ -5,7 +5,7 @@ BR2_ARM_FPU_NEON_VFPV4=y BR2_TOOLCHAIN_BUILDROOT_CXX=y -BR2_TARGET_GENERIC_GETTY_PORT="tty1" +BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" # Linux headers same as kernel, a 4.1 series BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_1=y
@@ -33,4 +33,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"
configs/raspberrypi_defconfig +2 -1
@@ -2,7 +2,7 @@ BR2_arm=y BR2_arm1176jzf_s=y BR2_ARM_EABIHF=y -BR2_TARGET_GENERIC_GETTY_PORT="tty1" +BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" # Linux headers same as kernel, a 4.1 series BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_1=y
@@ -32,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/raspberrypi/post-build.sh" BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi/post-image.sh"
package/rpi-firmware/cmdline.txt +1 -1
@@ -1 +1 @@ -root=/dev/mmcblk0p2 rootwait +root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200
Signature · 1 line
1.9.1
PATCH 1/1 raspberrypi, raspberrypi2: add a serial console
Hei hei,
Am 2016-03-29 00:08, schrieb Luca Ceresoli:
Quoted 5 lines
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.
I ran in the very problem last week. So +1 for the idea.
Quoted 3 lines
This requires two changes:
1. have two 'console=' entries in the kernel command line;
2. add a new getty process to the generated inittab.
Then why not split up those two changes in two patches? ;-)
Review
Quoted 2 lines
(quoted diff) +1
-1-BR2_TARGET_GENERIC_GETTY_PORT="tty1" +BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+1
package/rpi-firmware/cmdline.txt line 1
Quoted 7 lines
package/rpi-firmware/cmdline.txt +1
-1@@ -1 +1 @@ -root=/dev/mmcblk0p2 rootwait +root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200
+1
Not sure about the post build script though, maybe someone with more experience in buildroot could comment on that.
Greets
Alex
Signature · 4 lines
?With the first link, the chain is forged. The first speech censured, the first thought forbidden, the first freedom denied, chains us all irrevocably.? (Jean-Luc Picard, quoting Judge Aaron Satie) *** GnuPG-FP: C28E E6B9 0263 95CF 8FAF 08FA 34AD CD00 7221 5CC6 ***
PATCH 1/1 raspberrypi, raspberrypi2: add a serial console
Hei hei Alexander,
thanks for your review! See below by replies.
However, when replying to a mail on the mailing list, please reply to all. This helps involved people to follow the discussion. Typically an e-mail sent directly is seen sooner that one on a mailing list only.
Quoted 9 lines · Alexander Dahl
Hei hei,
Am 2016-03-29 00:08, schrieb Luca Ceresoli:
Quoted 5 lines
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.
Quoted 7 lines
I ran in the very problem last week. So +1 for the idea.
Quoted 3 lines
This requires two changes:
1. have two 'console=' entries in the kernel command line;
2. add a new getty process to the generated inittab.Then why not split up those two changes in two patches? ;-)
Because change 1 alone is almost useless. It just outputs kernel booting and early init messages on UART, but no console. I see adding a UART console as a self-contained change, but of course that's only my opinion.
Quoted 16 lines
Review
Quoted 3 lines
(quoted diff) +1
-1-BR2_TARGET_GENERIC_GETTY_PORT="tty1" +BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"+1
package/rpi-firmware/cmdline.txt line 1
Quoted 7 lines
package/rpi-firmware/cmdline.txt +1
-1@@ -1 +1 @@ -root=/dev/mmcblk0p2 rootwait +root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200+1
Quoted 2 lines
Not sure about the post build script though, maybe someone with more experience in buildroot could comment on that.
That's OK if you don't feel confident enough to give your official Acked-by or Reviewed-by tag. Still, you can test the patch on a real board and report back the outcome. If it works, you can add your Tested-by tag. Otherwise, please report what went wrong. More details on:
http://nightly.buildroot.org/manual.html#_reviewing_and_testing_patches
Cheers,
Signature · 1 line
Luca
PATCH 1/1 raspberrypi, raspberrypi2: add a serial console
Hei hei,
Quoted 3 lines · Luca Ceresoli
However, when replying to a mail on the mailing list, please reply to all. This helps involved people to follow the discussion. Typically an e-mail sent directly is seen sooner that one on a mailing list only.
Well, I try to remember it, each community handles this different and I find it annoying to receive mails twice personally. Some mailing list filter this, others not. ;-)
Quoted 4 lines
That's OK if you don't feel confident enough to give your official Acked-by or Reviewed-by tag. Still, you can test the patch on a real board and report back the outcome. If it works, you can add your Tested-by tag. Otherwise, please report what went wrong. More details on:
Yeah I actually tried to this evening, but there was a showstopper I filed a bug for now: https://bugs.busybox.net/show_bug.cgi?id=8831
Maybe I try again later.
Greets
Alex
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20160329/0caacef1/attachment.asc>
PATCH 1/1 raspberrypi, raspberrypi2: add a serial console
Quoted 11 lines · Alexander Dahl
Hei hei,
Quoted 3 lines · Luca Ceresoli
However, when replying to a mail on the mailing list, please reply to all. This helps involved people to follow the discussion. Typically an e-mail sent directly is seen sooner that one on a mailing list only.
Well, I try to remember it, each community handles this different and I find it annoying to receive mails twice personally. Some mailing list filter this, others not. ;-)
Quoted 7 lines
Quoted 4 lines
That's OK if you don't feel confident enough to give your official Acked-by or Reviewed-by tag. Still, you can test the patch on a real board and report back the outcome. If it works, you can add your Tested-by tag. Otherwise, please report what went wrong. More details on:
Yeah I actually tried to this evening, but there was a showstopper I filed a bug for now: https://bugs.busybox.net/show_bug.cgi?id=8831
But that problem has nothing to do with this patch. I expect that if you
revert the patch, your build will still fail.
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 raspberrypi, raspberrypi2: add a serial console
In reply to Luca CeresoliQuoted 58 lines · Luca Ceresoli
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 two changes:
1. have two 'console=' entries in the kernel command line;
2. add a new getty process to the generated inittab.Step 2 requires a post-build script since the Buildroot makefiles can configure only one console. But instead of simply adding a new getty on ttyAMA0 (which would work) this patch actually changes
BR2_TARGET_GENERIC_GETTY_PORTfrom tty1 to ttyAMA0, then adds back tty1 viapost-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:
ttyAMA0::respawn:/sbin/getty -L ttyAMA0 0 vt100 #
GENERIC_SERIALtty1::respawn:/sbin/getty -L tty1 0 vt100 # HDMI consoleCc Yann E. MORIN <[email protected]>Signed-off-by Luca Ceresoli <[email protected]>---
Tested on both Raspberry Pi B and Raspberry Pi 2, each on serial and HDMI console.
--- board/raspberrypi/post-build.sh | 9 +++++++++ configs/raspberrypi2_defconfig | 3 ++- configs/raspberrypi_defconfig | 3 ++- package/rpi-firmware/cmdline.txt | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-)create mode 100755
board/raspberrypi/post-build.shboard/raspberrypi/post-build.sh new file +9
-0@@ -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/inittabconfigs/raspberrypi2_defconfig +0
-0
configs/raspberrypi2_defconfig BR2_ARM_FPU_NEON_VFPV4=y · line 8
Quoted 5 lines
configs/raspberrypi2_defconfig +1
-1@@ -5,7 +5,7 @@ BR2_ARM_FPU_NEON_VFPV4=y BR2_TOOLCHAIN_BUILDROOT_CXX=y -BR2_TARGET_GENERIC_GETTY_PORT="tty1" +BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
Why not keep the default "console"? That should work, no? Or doesn't that work
if there are two consoles?
Regards,
Arnout
Quoted 37 lines
configs/raspberrypi2_defconfig +1
-0# Linux headers same as kernel, a 4.1 series BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_1=y@@ -33,4 +33,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"configs/raspberrypi_defconfig +1
-1@@ -2,7 +2,7 @@ BR2_arm=y BR2_arm1176jzf_s=y BR2_ARM_EABIHF=y -BR2_TARGET_GENERIC_GETTY_PORT="tty1" +BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" # Linux headers same as kernel, a 4.1 seriesBR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_1=y
configs/raspberrypi_defconfig +1
-0@@ -32,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/raspberrypi/post-build.sh" BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi/post-image.sh"package/rpi-firmware/cmdline.txt +1
-1@@ -1 +1 @@ -root=/dev/mmcblk0p2 rootwait +root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 raspberrypi, raspberrypi2: add a serial console
Dear Arnout,
Quoted 63 lines · Arnout Vandecappelle
Quoted 62 lines · Luca Ceresoli
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 two changes:
1. have two 'console=' entries in the kernel command line;
2. add a new getty process to the generated inittab.Step 2 requires a post-build script since the Buildroot makefiles can configure only one console. But instead of simply adding a new getty on ttyAMA0 (which would work) this patch actually changes
BR2_TARGET_GENERIC_GETTY_PORTfrom tty1 to ttyAMA0, then adds back tty1 viapost-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:
ttyAMA0::respawn:/sbin/getty -L ttyAMA0 0 vt100 #
GENERIC_SERIALtty1::respawn:/sbin/getty -L tty1 0 vt100 # HDMI consoleCc Yann E. MORIN <[email protected]>Signed-off-by Luca Ceresoli <[email protected]>---
Tested on both Raspberry Pi B and Raspberry Pi 2, each on serial and HDMI console.
--- board/raspberrypi/post-build.sh | 9 +++++++++ configs/raspberrypi2_defconfig | 3 ++- configs/raspberrypi_defconfig | 3 ++- package/rpi-firmware/cmdline.txt | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-)create mode 100755
board/raspberrypi/post-build.shboard/raspberrypi/post-build.sh new file +9
-0@@ -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
configs/raspberrypi2_defconfig +0
-0@@ -5,7 +5,7 @@ BR2_ARM_FPU_NEON_VFPV4=y
Quoted 7 lines
configs/raspberrypi2_defconfig BR2_ARM_FPU_NEON_VFPV4=y · line 8
Quoted 4 lines
configs/raspberrypi2_defconfig +1
-1BR2_TOOLCHAIN_BUILDROOT_CXX=y -BR2_TARGET_GENERIC_GETTY_PORT="tty1" +BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"Why not keep the default "console"? That should work, no? Or doesn't
that work if there are two consoles?
What improvement you expect from using "console" instead of "ttyAMA0"?
OTOH I think ttyAMA0 or tty1 is explicit about the device to use. And as Yann pointed out on IRC, "console is not a controlling tty, so no Ctrl-C for example".
Signature · 1 line
Luca
PATCH 1/1 raspberrypi, raspberrypi2: add a serial console
Quoted 4 lines · Luca Ceresoli
Dear Arnout,
Quoted 1 line · Arnout Vandecappelle
On 03/29/16 00:08, Luca Ceresoli wrote:
[snip]
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
configs/raspberrypi2_defconfig +0
-0@@ -5,7 +5,7 @@ BR2_ARM_FPU_NEON_VFPV4=yQuoted 7 lines
configs/raspberrypi2_defconfig BR2_ARM_FPU_NEON_VFPV4=y · line 8
Quoted 4 lines
configs/raspberrypi2_defconfig +1
-1BR2_TOOLCHAIN_BUILDROOT_CXX=y -BR2_TARGET_GENERIC_GETTY_PORT="tty1" +BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"Why not keep the default "console"? That should work, no? Or doesn't
that work if there are two consoles?
Quoted 5 lines
What improvement you expect from using "console" instead of "ttyAMA0"?
OTOH I think ttyAMA0 or tty1 is explicit about the device to use. And as Yann pointed out on IRC, "console is not a controlling tty, so no Ctrl-C for example".
For the record, as concluded on IRC:
- "console" is still a controlling tty, it is init=/bin/sh that doesn't give a controlling tty;
- GETTY_PORT="console" will launch a getty on the last console= given on the kernel command line
- What I actually meant is that BR2_TARGET_GENERIC_GETTY_PORT can be removed completely from the defconfig (as is the case already in roughly half our defconfigs) because it anyway defaults to "console".
Regards,
Arnout
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 raspberrypi, raspberrypi2: add a serial console
Dear Arnout,
Quoted 32 lines · Arnout Vandecappelle
Quoted 4 lines · Luca Ceresoli
Dear Arnout,
Quoted 1 line · Arnout Vandecappelle
On 03/29/16 00:08, Luca Ceresoli wrote:
[snip]
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
configs/raspberrypi2_defconfig +0
-0@@ -5,7 +5,7 @@ BR2_ARM_FPU_NEON_VFPV4=yQuoted 7 lines
configs/raspberrypi2_defconfig BR2_ARM_FPU_NEON_VFPV4=y · line 8
Quoted 4 lines
configs/raspberrypi2_defconfig +1
-1BR2_TOOLCHAIN_BUILDROOT_CXX=y -BR2_TARGET_GENERIC_GETTY_PORT="tty1" +BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"Why not keep the default "console"? That should work, no? Or doesn't
that work if there are two consoles?Quoted 5 lines
What improvement you expect from using "console" instead of "ttyAMA0"?
OTOH I think ttyAMA0 or tty1 is explicit about the device to use. And as Yann pointed out on IRC, "console is not a controlling tty, so no Ctrl-C for example".
For the record, as concluded on IRC:
- "console" is still a controlling tty, it is init=/bin/sh that doesn't give a controlling tty;
Quoted 6 lines
- GETTY_PORT="console" will launch a getty on the last console= given on the kernel command line
- What I actually meant is that
BR2_TARGET_GENERIC_GETTY_PORTcan be removed completely from the defconfig (as is the case already in roughly half our defconfigs) because it anyway defaults to "console".
Thanks for the recap. Will do in v2.
Signature · 1 line
Luca