busybox shell doesn't come up or get stuck.. where should I look or how should I debug it?
Hi all, I'm trying to boot linux with minimal config on our FPGA board which is under development. After months of trying (but I tried this intermittently) I think I'm about to see the shell prompt. (there was a bug in interconnect driver that I found yesterday, this caused a long delay) Anyway, when I run linux kernel on a qemu machine, the boot process ends like this at the shell prompt. (The echo '### INIT SCRIPT ###' was put in /init script which is in the initramfs) Run /init as init process ### INIT SCRIPT ### mount: mounting none on /tmp failed: Invalid argument This boot took 2.12 seconds /bin/sh: can't access tty; job control turned off / # / # Now, when I run it on our FPGA board using u-boot, it ends like this. Run /init as init process ### INIT SCRIPT ### mount: mounting none on /tmp failed: Invalid argument This boot took 0.00 seconds /bin/sh: can't acce So it seems this init_kernel thread executes /init and /init excutes /bin/sh at the end. this is the /init script. #!/bin/sh echo "### INIT SCRIPT ###" mkdir /proc /sys /tmp mount -t proc none /proc mount -t sysfs none /sys mount -t tmpfs none /tmp echo -e "\nThis boot took $(cut -d' ' -f1 /proc/uptime) seconds\n" #ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up #route add default gw 10.0.2.2 exec /bin/sh Somehow the busybox applet /bin/sh is stuck somewhere. Can anybody tell me where I should look? Or how to debug this? Thanks in advance! Chan Kim
Hello, all, In the initramfs.cpio.gz file from the busybox, when I replace the /init script to an executable binary called 'init', (which prints Hello! Repeatedly), The output from the board looks like this. (...) ### point 106 ### point 106-1 Run /init as init process ### point 106-2, ret = -2 Failed to execute /init (error -2) ### point 107 ### point 107-1 Run /init as init process ### point 107-2, ret = -2 Kernel panic - not syncing: Requested init /init failed (error -2). CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.0-rc5 #197 Hardware name: ETRI ab21m (DT) Call trace: dump_backtrace+0x0/0x190 show_stack+0x14/0x30 dump_stack+0xcc/0x104 panic+0x16c/0x328 kernel_init+0x178/0x264 ret_from_fork+0x10/0x18 Kernel Offset: disabled CPU features: 0x0000007,78002c18 Memory Limit: none ---[ end Kernel panic - not syncing: Requested init /init failed (error -2). ]--- The related source code (init/main.c) looks like this (trying it first from the ramdisk. 'init=/init' was given from the bootargs in device tree) printk("### point 106\n"); if (ramdisk_execute_command) { printk("### point 106-1\n"); ret = run_init_process(ramdisk_execute_command); printk("### point 106-2, ret = %d\n", ret); if (!ret) return 0; pr_err("Failed to execute %s (error %d)\n", ramdisk_execute_command, ret); } /* * We try each of these until one succeeds. * * The Bourne shell can be used instead of init if we are * trying to recover a really broken machine. */ printk("### point 107\n"); if (execute_command) { printk("### point 107-1\n"); ret = run_init_process(execute_command); printk("### point 107-2, ret = %d\n", ret); if (!ret) return 0; panic("Requested init %s failed (error %d).", execute_command, ret); } I compiled the init program by the command "aarch64-none-linux-gcc -static -o init test.c". When 'init' was a script, some lines of it was processed ok, but when I replace 'init' to a binary program, it just failed with -2. I find error code 2 is 'No such file or directory' which is strange because my 'init' program was under / when I made the initramfs.cpio.gz. Can anyone give me any advice? Thank you! Chan Kim From: Chan Kim <ckim@etri.re.kr> Sent: Friday, August 12, 2022 5:32 PM To: kernelnewbies@kernelnewbies.org Subject: busybox shell doesn't come up or get stuck.. where should I look or how should I debug it? Hi all, I'm trying to boot linux with minimal config on our FPGA board which is under development. After months of trying (but I tried this intermittently) I think I'm about to see the shell prompt. (there was a bug in interconnect driver that I found yesterday, this caused a long delay) Anyway, when I run linux kernel on a qemu machine, the boot process ends like this at the shell prompt. (The echo '### INIT SCRIPT ###' was put in /init script which is in the initramfs) Run /init as init process ### INIT SCRIPT ### mount: mounting none on /tmp failed: Invalid argument This boot took 2.12 seconds /bin/sh: can't access tty; job control turned off / # / # Now, when I run it on our FPGA board using u-boot, it ends like this. Run /init as init process ### INIT SCRIPT ### mount: mounting none on /tmp failed: Invalid argument This boot took 0.00 seconds /bin/sh: can't acce So it seems this init_kernel thread executes /init and /init excutes /bin/sh at the end. this is the /init script. #!/bin/sh echo "### INIT SCRIPT ###" mkdir /proc /sys /tmp mount -t proc none /proc mount -t sysfs none /sys mount -t tmpfs none /tmp echo -e "\nThis boot took $(cut -d' ' -f1 /proc/uptime) seconds\n" #ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up #route add default gw 10.0.2.2 exec /bin/sh Somehow the busybox applet /bin/sh is stuck somewhere. Can anybody tell me where I should look? Or how to debug this? Thanks in advance! Chan Kim
I had mistakenly omitted '-static' option when making init program.(repeated Hello! Print). So now the board output looks like this. (...) ### point 106-1 Run /init as init process ### point 106-2, ret = 0 Hello! i=0 Hello! i=1 Hello! i=2 ... Hello! i=115 Hello! i=116 Hello! i=117 He <=== hangs. So the running the 'init' program (whether it's a script or a binary program) is ok. The binary 'init' program stops after printing Hello 117 times so there seems to be more basic problem in H/W or device tree. And when the init script ran 'exec /bin/sh', the shell didn't start so 'running exec inside a script' can have a problem. If anyone has a suggestion or advice, I welcome it. Thank you! Chan Kim
Hi, all, I set a variable to true just before calling the ramdisk_exeucte_cmd (which is /init in this case) in the kernel_init function, And added printk in schedule() function so that it prints something it is called and when the previous variable is true. And found the program stops after the schedule function is called. Like this. Hello! i=115 Hello! i=116 Helloschedule! schedule! I checked the timer interrupt number was given correctly in the device tree (that's why schedule was called by the timer..). I stopped the experiment to do something else but will resume it next week by adding some prints. If anyone has any idea about what might be wrong, please tell me. Thanks for reading. Chan Kim From: Chan Kim <ckim@etri.re.kr> Sent: Thursday, August 18, 2022 3:02 PM To: kernelnewbies@kernelnewbies.org Subject: RE: busybox shell doesn't come up or get stuck.. where should I look or how should I debug it? I had mistakenly omitted '-static' option when making init program.(repeated Hello! Print). So now the board output looks like this. (...) ### point 106-1 Run /init as init process ### point 106-2, ret = 0 Hello! i=0 Hello! i=1 Hello! i=2 ... Hello! i=115 Hello! i=116 Hello! i=117 He <=== hangs. So the running the 'init' program (whether it's a script or a binary program) is ok. The binary 'init' program stops after printing Hello 117 times so there seems to be more basic problem in H/W or device tree. And when the init script ran 'exec /bin/sh', the shell didn't start so 'running exec inside a script' can have a problem. If anyone has a suggestion or advice, I welcome it. Thank you! Chan Kim
participants (1)
-
Chan Kim