Bug 15456 - No more login on Raspberry Pi 3 since 2023.02
Summary: No more login on Raspberry Pi 3 since 2023.02
Status: RESOLVED MOVED
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: 2023.02
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-19 09:28 UTC by freemp
Modified: 2024-06-15 15:07 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments
Console output (25.71 KB, text/x-log)
2023-03-19 09:28 UTC, freemp
Details

Note You need to log in before you can comment on or make changes to this bug.
Description freemp 2023-03-19 09:28:39 UTC
Created attachment 9541 [details]
Console output

I was building raspberrypi4_defconfig with systemd as init system and bash as shell. Here's the config diff:

$ git diff
diff --git a/configs/raspberrypi3_defconfig b/configs/raspberrypi3_defconfig
index 0a59ab42a9..2940ee52fb 100644
--- a/configs/raspberrypi3_defconfig
+++ b/configs/raspberrypi3_defconfig
@@ -1,39 +1,31 @@
 BR2_arm=y
 BR2_cortex_a53=y
 BR2_ARM_FPU_NEON_VFPV4=y
-
+BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_10=y
 BR2_TOOLCHAIN_BUILDROOT_CXX=y
-
+BR2_DL_DIR="$(TOPDIR)/../buildroot_dl"
+BR2_CCACHE=y
+BR2_INIT_SYSTEMD=y
+BR2_SYSTEM_BIN_SH_BASH=y
 BR2_SYSTEM_DHCP="eth0"
-
-# Linux headers same as kernel, a 5.10 series
-BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_10=y
-
+BR2_SYSTEM_DEFAULT_PATH="/bin:/sbin:/usr/bin:/usr/sbin"
+BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi3/post-build.sh"
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi3/post-image.sh"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
 BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,raspberrypi,linux,0b54dbda3cca2beb51e236a25738784e90853b64)/linux-0b54dbda3cca2beb51e236a25738784e90853b64.tar.gz"
 BR2_LINUX_KERNEL_DEFCONFIG="bcm2709"
-
-# Build the DTB from the kernel sources
 BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b bcm2710-rpi-3-b-plus bcm2710-rpi-cm3"
-
 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
-
 BR2_PACKAGE_RPI_FIRMWARE=y
 BR2_PACKAGE_RPI_FIRMWARE_BOOTCODE_BIN=y
 BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI=y
 BR2_PACKAGE_RPI_FIRMWARE_CONFIG_FILE="board/raspberrypi3/config_3.txt"
-
-# Required tools to create the SD image
-BR2_PACKAGE_HOST_DOSFSTOOLS=y
-BR2_PACKAGE_HOST_GENIMAGE=y
-BR2_PACKAGE_HOST_MTOOLS=y
-
-# Filesystem / image
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_4=y
 BR2_TARGET_ROOTFS_EXT2_SIZE="120M"
 # BR2_TARGET_ROOTFS_TAR is not set
-BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi3/post-build.sh"
-BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi3/post-image.sh"
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y


The resulting system image does not allow to login (entire console log attached):

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.10.92-v7 (*******) (arm-buildroot-linux-gnueabihf-gcc.br_real (Buildroot 2023.02) 11.3.0, GNU ld (GNU Binutils) 2.38) #1 SMP Sun Mar 19 09:32:14 CET 2023
[    0.000000] CPU: ARMv7 Processor [410fd034] revision 4 (ARMv7), cr=10c5383d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi 3 Model B Rev 1.2
[    0.000000] random: fast init done
[    0.000000] Memory policy: Data cache writealloc
...
[  OK  ] Started D-Bus System Message Bus.
[   11.490042] random: dbus-daemon: uninitialized urandom read (12 bytes read)
[  OK  ] Started Serial Getty on ttyAMA0.
[  OK  ] Reached target Login Prompts.
[   11.591252] random: dbus-daemon: uninitialized urandom read (12 bytes read)
[  OK  ] Started Network Configuration.
[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Network.
[   12.040785] brcmfmac: brcmf_sdio_htclk: HT Avail timeout (1000000): clkctl 0x50

Welcome to Buildroot
buildroot login: root
[   16.761152] random: crng init done
[   16.826639] audit: type=1701 audit(1671560156.029:7): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=189 comm="bash" exe="/usr/bin/bash" sig=11 res=1

Welcome to Buildroot
buildroot login:
Comment 1 Peter Seiderer 2023-03-19 11:22:57 UTC
> [   16.826639] audit: type=1701 audit(1671560156.029:7): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=189 comm="bash" exe="/usr/bin/bash" sig=11 res=1

Disable 'BR2_SYSTEM_BIN_SH_BASH=y' in your configuration (make menuconfig and change 'System configuration' --> '/bin/sh' from 'bash' back to 'busybox default shell') and try to debug/fix the bash 'Segmentation fault' error separately...

Your mention 'raspberrypi4_defconfig' but the diff is from 'raspberrypi3_defconfig'..., did you test both?
Comment 2 freemp 2023-03-19 13:50:20 UTC
(In reply to Peter Seiderer from comment #1)
> Your mention 'raspberrypi4_defconfig' but the diff is from 'raspberrypi3_defconfig'..., did you test both?

No, this is just a typo. I was building for Raspi 3 only.
Comment 3 Peter Seiderer 2023-03-19 20:36:02 UTC
Tested on raspberrypi_4, bash crashes with:

    $ ./host/bin/arm-buildroot-linux-gnueabihf-gdb build/bash-5.2.15/bash core.199
    Core was generated by `bash'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  0xb6d74b5c in ?? ()
    (gdb) set sysroot ./staging
    Reading symbols from ./staging/lib/libreadline.so.8...
    Reading symbols from ./staging/lib/libhistory.so.8...
    Reading symbols from ./staging/lib/libncurses.so.6...
    Reading symbols from ./staging/lib/libc.so.6...
    Reading symbols from ./staging/lib/ld-linux-armhf.so.3...
    (gdb) where
    #0  0xb6d74b5c in kill () at ../sysdeps/unix/syscall-template.S:120
    #1  0x004d4f0c in kill_shell (sig=sig@entry=11) at sig.c:643
    #2  0x004d5110 in termsig_handler (sig=11) at sig.c:624
    #3  termsig_handler (sig=11) at sig.c:575
    #4  0x004d5248 in termsig_sighandler (sig=<optimized out>) at sig.c:558
    #5  <signal handler called>
    #6  strlen () at ../sysdeps/arm/strlen.S:32
    #7  0xb6f2fb20 in _rl_init_locale () at ../nls.c:150
    #8  0xb6f2fba0 in _rl_init_eightbit () at ../nls.c:227
    #9  0xb6f10f54 in readline_initialize_everything () at ../readline.c:1292
    #10 rl_initialize () at ../readline.c:1183
    #11 0x004e439c in initialize_readline () at bashline.c:522
    #12 0x0048e63c in yy_readline_get ()
        at /usr/local/src/chet/src/bash/src/parse.y:1514
    #13 0x00491190 in shell_getc (
        remove_quoted_newline=remove_quoted_newline@entry=1)
        at /usr/local/src/chet/src/bash/src/parse.y:2393
    #14 0x00493410 in read_token (command=0)
        at /usr/local/src/chet/src/bash/src/parse.y:3404
    #15 read_token (command=0) at /usr/local/src/chet/src/bash/src/parse.y:3355
    #16 0x00496a64 in yylex () at /usr/local/src/chet/src/bash/src/parse.y:2892
    #17 yyparse () at y.tab.c:1854
    #18 0x0048da38 in parse_command () at eval.c:348
    #19 0x0048db88 in read_command () at eval.c:392
    #20 0x0048dd10 in reader_loop () at eval.c:139
    #21 0x0048c7e8 in main (argc=5489868, argv=0x0, env=<optimized out>)
        at shell.c:833

But e.g. 'LANG=C bash' runs fine...
Comment 4 Peter Seiderer 2023-03-21 19:25:11 UTC
The systemd default locale is 'C.UTF-8' (since 252, see [1] and /etc/locale.conf  on the board):

    $ echo $LANG
    C.UTF-8
 
From build/readline-8.2/nls.c:

    126 char *
    127 _rl_init_locale (void)
    128 {
    129   char *ret, *lspec;
    130
    131   /* Set the LC_CTYPE locale category from environment variables. */
    132   lspec = _rl_get_locale_var ("LC_CTYPE");
    133   /* Since _rl_get_locale_var queries the right environment variables,
    134      we query the current locale settings with setlocale(), and, if
    135      that doesn't return anything, we set lspec to the empty string to
    136      force the subsequent call to setlocale() to define the `native'
    137      environment. */
    138 #if defined (HAVE_SETLOCALE)
    139   if (lspec == 0 || *lspec == 0)
    140     lspec = setlocale (LC_CTYPE, (char *)NULL);
    141   if (lspec == 0)
    142     lspec = "";
    143   ret = setlocale (LC_CTYPE, lspec);    /* ok, since it does not change locale */
    144 #else
    145   ret = (lspec == 0 || *lspec == 0) ? RL_DEFAULT_LOCALE : lspec;
    146 #endif
    147
    148   _rl_utf8locale = (ret && *ret) ? utf8locale (ret) : 0;
    149
    150   _rl_current_locale = savestring (ret);
    151   return ret;
    152 }

The call to '_rl_get_locale_var()' returns 'C.UTF-8' (line 132) but the
call to 'setlocale(LC_CTYPE, 'C.UTF-8')' returns 0 (line 143) which
leads to the segmentation fault in the call to 'savestring(0)' (line 150).

Setting the following in the buildroot config file fixes the problem for me:

    BR2_ENABLE_LOCALE_WHITELIST="C"
    BR2_GENERATE_LOCALE="C"

[1] https://github.com/systemd/systemd/blob/main/NEWS
Comment 5 Peter Seiderer 2023-03-22 15:44:18 UTC
Upstream bug/patch at [1].

[1] https://lists.gnu.org/archive/html/bug-readline/2022-10/msg00002.html
Comment 6 freemp 2023-03-24 16:32:58 UTC
Works for me too.

So, BR2_GENERATE_LOCALE="C" should be set in case BR2_PACKAGE_BASH is selected.
Comment 7 Yann E. MORIN 2024-06-15 15:07:28 UTC
Thank you for your report.

The issue tracker for the Buildroot project has been moved to
the Gitlab.com issue tracker:
    https://gitlab.com/buildroot.org/buildroot/-/issues

We are taking this opportunity to close old issues in this old
tracker. If you believe your issue is still relevant, please
open one in the new issue tracker.

Thank you!