OpenWrt Forum Archive

Topic: Verbose boot....how?

The content of this topic has been archived on 23 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Since I'm getting "Kernel panic - not syncing: Attempted to kill init!" from the serial console, I would like to know if there's a way to enable some sort of "much more verbose output". Until that message,everything is ok.
Is there something to enable in the "make menuconfig" that I've not seen?

Many thanks!

You may try to add the char device /dev/console (5,1) to your rootfs if it isn't already there. This helped me once in debugging a hanging init on a RB133. See ticket #3051.

jal2 wrote:

You may try to add the char device /dev/console (5,1) to your rootfs if it isn't already there. This helped me once in debugging a hanging init on a RB133. See ticket #3051.

Sorry smile but I've not understood smile
Please, can you be more specific? How can I add that "char device" ? (I'm currently seeing the output via the serial console,is it the same thing?)

michelinok76 wrote:
jal2 wrote:

You may try to add the char device /dev/console (5,1) to your rootfs if it isn't already there. This helped me once in debugging a hanging init on a RB133. See ticket #3051.

Sorry smile but I've not understood smile
Please, can you be more specific? How can I add that "char device" ? (I'm currently seeing the output via the serial console,is it the same thing?)

On the RB133 I changed wget2nand, the script running inside the netboot to write the "real" firmware to flash:

Index: target/linux/adm5120/router_le/base-files/sbin/wget2nand
===================================================================
--- target/linux/adm5120/router_le/base-files/sbin/wget2nand    (revision 11323)
+++ target/linux/adm5120/router_le/base-files/sbin/wget2nand    (working copy)
@@ -53,6 +53,13 @@
 
 echo "Copying filesystem..."
 ( wget -O - $url/openwrt-adm5120-2.6-rootfs.tgz) | ( cd /tmp/wget2nand-rootfs/; tar xvz )
+
+#jal: added to have an initial console
+F=/tmp/wget2nand-rootfs/dev/console
+if [ ! -e $F ]; then 
+    mknod $F c 5 1 
+fi
+
 # RouterBOOT is looking for a kernel named "kernel"
 wget -O /tmp/wget2nand-kernel/kernel $url/openwrt-adm5120-2.6-rb1xx-kernel

Most certainly this won't help you, as the netboot approach is RB1xx specific.
Adding the char device /dev/console requires to find the place where the rootfs is created in the build process and change the Makefile there.

Too much complex for me smile
Thanks a lot anyway!
I'll search for an alternative way to see what happens :\

If it can help,here's the output taken from the console:

Linux version 2.6.25.12 (michele@localhost.localdomain) (gcc version
4.2.4) #6 8
console [ttyS0] enabled
Setting up paging and the MMU.
Linux/CRIS port on ETRAX 100LX (c) 2001 Axis Communications AB Built 1
zonelists in Zone order, mobility grouping on. Total pages: 4080 Kernel
command line: root=/dev/mtdblock1 rootfstype=squashfs,jffs2 init=/etc/pr0
PID hash table entries: 128 (order: 7, 512 bytes)
ds1302: RTC found.
ds1302: SDA, SCL, RST on PB0, PB1, GENIO2
rtc_time : 11:19:03
rtc_date : 2008-08-02
Dentry cache hash table entries: 4096 (order: 1, 16384 bytes) Inode-cache
hash table entries: 2048 (order: 0, 8192 bytes)
Memory: 30312k/32768k available (1279k kernel code, 2456k reserved, 319k
data, ) Mount-cache hash table entries: 1024
net_namespace: 444 bytes
NET: Registered protocol family 16
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 2048 (order: 0, 8192 bytes) TCP
established hash table entries: 1024 (order: 0, 8192 bytes) TCP bind hash
table entries: 1024 (order: -1, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024) TCP reno registered
console [ttyS0] enabled
fast_timer_init()
squashfs: version 3.0 (2006/03/15) Phillip Lougher Registering mini_fo
version $Id$
JFFS2 version 2.2. (NAND) (SUMMARY) ?© 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler deadline registered (default) ETRAX 100LX serial-driver 1.25 $,
(c) 2000-2004 Axis Communications AB ttyS0 at 0xb0000060 is a builtin UART
with DMA
ttyS2 at 0xb0000070 is a builtin UART with DMA
ttyS3 at 0xb0000078 is a builtin UART with DMA ETRAX 100LX 10/100MBit
ethernet v2.0 (c) 1998-2007 Axis Communications AB
eth0: changed MAC to 00:40:8c:cd:00:00
ETRAX 100LX USB Host Controller (2.6.25-rc9 port) version 1.00 hinko.4 (c)
2005B
usb_devdrv: Etrax 100LX USB Revision 16 v1,2
usb_devdrv: Bulk timer interval, start:2 eot:6
usb_devdrv: Claimed interface for USB physical port 1
usb_devdrv: Claimed interface for USB physical port 2 crisv10_irq dbg:
ctr_status_irq, controller status: host_mode hc-crisv10 hc-crisv10.0: ETRAX
100LX USB Host Controller (2.6.25-rc9 port) hc-crisv10 hc-crisv10.0: new USB
bus registered, assigned bus number 1 hc-crisv10 hc-crisv10.0: reset
hc-crisv10 hc-crisv10.0: start usb usb1: configuration #1 chosen from 1
choice hub 1-0:1.0: USB hub found hub 1-0:1.0: 2 ports detected
cse0: Probing a 0x04000000 bytes large window at 0xe0000000.
cse0: Found 1 x16 devices at 0x0 in 16-bit bank Amd/Fujitsu Extended Query
Table at 0x0040
cse0: Swapping erase regions for broken CFI table.
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
cse1: Probing a 0x04000000 bytes large window at 0xe4000000.
cse0: 0x00800000 bytes of flash memory.
Scanning flash for end of kernel magic
Kernel ends at 0x000F0000
Using default partition table.
Creating 2 MTD partitions on "cse0":
0x00000000-0x000f0000 : "kernel"
0x000f0000-0x00800000 : "rootfs"
mtd: partition "rootfs" set to be root filesystem
mtd: partition "rootfs_data" created automatically, ofs=200000, len=600000
0x00200000-0x00800000 : "rootfs_data"
Adding RAM partition for romfs image:
/dev/flash1 at 0x00000000, size 0x00000000 I2C driver v2.2, (c) 1999-2004
Axis Communications AB GPIO port G: in_bits: 0x01FFFF3F out_bits: 0x3200003E
val: F1FFFFFF GPIO port G: dir: 00000000 changeable: 01FFFF01 ETRAX 100LX
GPIO driver v2.5, (c) 2001-2008 Axis Communications AB
ds1302: RTC found.
ds1302: SDA, SCL, RST on PB0, PB1, GENIO2
rtc_time : 11:19:04
rtc_date : 2008-08-02
nf_conntrack version 0.5.0 (2048 buckets, 8192 max)
ip_tables: (C) 2000-2006 Netfilter Core Team TCP vegas registered
NET: Registered protocol family 1
NET: Registered protocol family 17
ieee80211: 802.11 data/management/control stack, git-1.1.13
ieee80211: Copyright (C) 2004-2005 Intel Corporation
<jketreno@linux.intel.com>
VFS: Mounted root (squashfs filesystem) readonly.
Freeing unused kernel memory: 56k freed
Please be patient, while OpenWrt loads ...
Kernel panic - not syncing: Attempted to kill init!

OK, you run a 2.6.25.x kernel on etrax using squashfs for the rootfs.
I've checked out r12087 and built for etrax.
Couldn't find a way to create a char device with mksquashfs-lzma (to run mknod on the host you need to be root).

You may try to copy the patch below into the new file trunk/target/linux/generic-2.6/patches-2.6.25/841-try_to_create_initial_console.patch
and build the kernel from scratch:

--- linux-2.6.25.12/init/main.c.orig    2008-08-04 14:14:27.000000000 +0200
+++ linux-2.6.25.12/init/main.c 2008-08-04 14:39:49.000000000 +0200
@@ -774,9 +774,23 @@ static int noinline init_post(void)
        system_state = SYSTEM_RUNNING;
        numa_default_policy();
 
-       if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
-               printk(KERN_WARNING "Please be patient, while OpenWrt loads ...\n");
-
+       if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) {
+               /* jal: try to create /dev/console as char device 5,1 */
+               int rc;
+               if ((rc=sys_mknod((const char __user *) "/dev/console", 
+                               S_IFCHR|S_IRUSR|S_IWUSR, MKDEV(5,1))) < 0) {
+                       printk(KERN_WARNING "Failed to create /dev/console (%d)\n",rc);
+               } else {
+                       /* try again */
+                       if (sys_open((const char __user *) "/dev/console", 
+                                       O_RDWR, 0) < 0) {
+                               printk(KERN_WARNING 
+                                       "Please be patient, while OpenWrt loads ...\n");
+                       } else
+                               printk(KERN_WARNING 
+                                       "opened intial console on char dev 5,1\n");
+               }
+       }
        (void) sys_dup(0);
        (void) sys_dup(0);

It compiles fine but I currently lack the resources to test it.
This patch tries to create /dev/console as a char device with major 5 and minor 1.
If it suceeds, it will print

opened intial console on char dev 5,1

No idea if the initial console will help in debugging your problem ...

(Last edited by jal2 on 4 Aug 2008, 15:01)

jal2 wrote:

OK, you run a 2.6.25.x kernel on etrax using squashfs for the rootfs.
I've checked out r12087 and built for etrax.
Couldn't find a way to create a char device with mksquashfs-lzma (to run mknod on the host you need to be root).

You may try to copy the patch below into the new file trunk/target/linux/generic-2.6/patches-2.6.25/841-try_to_create_initial_console.patch
and build the kernel from scratch:

--- linux-2.6.25.12/init/main.c.orig    2008-08-04 14:14:27.000000000 +0200
+++ linux-2.6.25.12/init/main.c 2008-08-04 14:39:49.000000000 +0200
@@ -774,9 +774,23 @@ static int noinline init_post(void)
        system_state = SYSTEM_RUNNING;
        numa_default_policy();
 
-       if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
-               printk(KERN_WARNING "Please be patient, while OpenWrt loads ...\n");
-
+       if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) {
+               /* jal: try to create /dev/console as char device 5,1 */
+               int rc;
+               if ((rc=sys_mknod((const char __user *) "/dev/console", 
+                               S_IFCHR|S_IRUSR|S_IWUSR, MKDEV(5,1))) < 0) {
+                       printk(KERN_WARNING "Failed to create /dev/console (%d)\n",rc);
+               } else {
+                       /* try again */
+                       if (sys_open((const char __user *) "/dev/console", 
+                                       O_RDWR, 0) < 0) {
+                               printk(KERN_WARNING 
+                                       "Please be patient, while OpenWrt loads ...\n");
+                       } else
+                               printk(KERN_WARNING 
+                                       "opened intial console on char dev 5,1\n");
+               }
+       }
        (void) sys_dup(0);
        (void) sys_dup(0);

It compiles fine but I currently lack the resources to test it.
This patch tries to create /dev/console as a char device with major 5 and minor 1.
If it suceeds, it will print

opened intial console on char dev 5,1

No idea if the initial console will help in debugging your problem ...

In what way it should help me?
Sorry for my stupid question sad
As I've understood, the patch create a char device...but what it should do? (another stupid question...I'm a "linux-approacher",but i learn very quick!)

Thanks!

michelinok76 wrote:

In what way it should help me?
Sorry for my stupid question sad
As I've understood, the patch create a char device...but what it should do? (another stupid question...I'm a "linux-approacher",but i learn very quick!)

It connects stdin, stdout and stderr of the init process to the system console (char device, major 5, minor 1), i.e. the last device given on kernel cmdline with console=.
See Documentation/serial-console.txt  in the kernel source for some details.

jal2 wrote:
michelinok76 wrote:

In what way it should help me?
Sorry for my stupid question sad
As I've understood, the patch create a char device...but what it should do? (another stupid question...I'm a "linux-approacher",but i learn very quick!)

It connects stdin, stdout and stderr of the init process to the system console (char device, major 5, minor 1), i.e. the last device given on kernel cmdline with console=.
See Documentation/serial-console.txt  in the kernel source for some details.

I'll try it asap.
Many thanks!
I'll let you know the results ASAP!

To be precise, the patch causes the init process to create "/dev/console" as char device (5,1) if it failed to
open it in the first place. Afterwards the open is tried again.
(stdout and sterr are opened by the two strdup() afterwards)

Without the patch init won't try to create "/dev/console" if it failed in the first try and leave stdin, stdout and stderr
unconnected.

The discussion might have continued from here.