* How the kernel printk works before do console_setup. @ 2009-06-24 3:50 Johnny Hung 2009-06-24 5:03 ` Tim Bird 2009-06-29 19:36 ` Freeman 0 siblings, 2 replies; 6+ messages in thread From: Johnny Hung @ 2009-06-24 3:50 UTC (permalink / raw) To: linux-kernel, linuxppc-dev, linux-embedded Hi All: I have a powerpc arch platform. The default console is ttyS1 not ttyS0 in the platform. My question is how the kernel print debug message like DBG before parse kernel command line and do console_setup function. The command line passed to kernel about console info is console=ttyS1. So kernel can not print anything before parse cmd line and initial console but the result is against. Anyone point me or give me a clue is appreciate. BR, H. Johnny ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How the kernel printk works before do console_setup. 2009-06-24 3:50 How the kernel printk works before do console_setup Johnny Hung @ 2009-06-24 5:03 ` Tim Bird 2009-06-24 22:56 ` Benjamin Herrenschmidt 2009-06-29 19:36 ` Freeman 1 sibling, 1 reply; 6+ messages in thread From: Tim Bird @ 2009-06-24 5:03 UTC (permalink / raw) To: Johnny Hung; +Cc: linux-kernel, linuxppc-dev, linux-embedded Johnny Hung wrote: > Hi All: > I have a powerpc arch platform. The default console is ttyS1 not > ttyS0 in the platform. My question is how the kernel print debug > message > like DBG before parse kernel command line and do console_setup > function. The command line passed to kernel about console info is > console=ttyS1. > So kernel can not print anything before parse cmd line and initial > console but the result is against. Anyone point me or give me a clue > is appreciate. Before the console is set up, the printk data is formatted and put into the kernel log buffer, but not sent to any console. Any messages printk'ed before that are buffered but do not appear. When the console is initialized, then all buffered messages are sent to the console, and subsequent printks cause the message to go to the log buffer, but then immediately get sent from there to the console. Under certain conditions you can examine the log buffer of a kernel that failed to initialize it's console, after a warm reset of the machine, using the firmware memory dump command. See http://elinux.org/Kernel_Debugging_Tips#Accessing_the_printk_buffer_after_a_silent_hang_on_boot for some tips on accessing the log buffer of a previous boot. Note also, that if the serial console does not come up, but the kernel successfully boots, and you can get a network login on the machine, you can always print out the kernel log buffer messages using 'dmesg' at a user-space shell prompt. Hope this helps! -- Tim ============================= Tim Bird Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Corporation of America ============================= ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How the kernel printk works before do console_setup. 2009-06-24 5:03 ` Tim Bird @ 2009-06-24 22:56 ` Benjamin Herrenschmidt 2009-06-25 6:27 ` Johnny Hung 0 siblings, 1 reply; 6+ messages in thread From: Benjamin Herrenschmidt @ 2009-06-24 22:56 UTC (permalink / raw) To: Tim Bird; +Cc: Johnny Hung, linuxppc-dev, linux-kernel, linux-embedded > Before the console is set up, the printk data is formatted > and put into the kernel log buffer, but not sent to any console. > Any messages printk'ed before that are buffered but do not > appear. When the console is initialized, then all buffered > messages are sent to the console, and subsequent printks cause > the message to go to the log buffer, but then immediately > get sent from there to the console. > > Under certain conditions you can examine the log buffer of > a kernel that failed to initialize it's console, after a > warm reset of the machine, using the firmware memory dump > command. On ppc, we have tricks to display things earlier :-) We can initialize the serial ports way before console_setup() (and we do in most cases) and we use what we call the "udbg" console until the real one takes over. The "udbg" console is a very small layer which outputs via a provided "putc" routine. Platforms can provide their own here, we have a collection of standard ones for legacy UARTs (it should be automatically setup in that case by the code in legacy_serial), Apple ESCCs, etc... We even have compile time options that allow that stuff to be initialized before start_kernel... Cheers, Ben. > See http://elinux.org/Kernel_Debugging_Tips#Accessing_the_printk_buffer_after_a_silent_hang_on_boot > for some tips on accessing the log buffer of a previous boot. > > Note also, that if the serial console does not come up, > but the kernel successfully boots, and you can get a network > login on the machine, you can always print out the kernel log > buffer messages using 'dmesg' at a user-space shell prompt. > > Hope this helps! > -- Tim > > ============================= > Tim Bird > Architecture Group Chair, CE Linux Forum > Senior Staff Engineer, Sony Corporation of America > ============================= > > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How the kernel printk works before do console_setup. 2009-06-24 22:56 ` Benjamin Herrenschmidt @ 2009-06-25 6:27 ` Johnny Hung 2009-06-25 6:37 ` Michael Ellerman 0 siblings, 1 reply; 6+ messages in thread From: Johnny Hung @ 2009-06-25 6:27 UTC (permalink / raw) To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, linux-embedded, linux-kernel 2009/6/25 Benjamin Herrenschmidt <benh@kernel.crashing.org>: > >> Before the console is set up, the printk data is formatted >> and put into the kernel log buffer, but not sent to any console. >> Any messages printk'ed before that are buffered but do not >> appear. When the console is initialized, then all buffered >> messages are sent to the console, and subsequent printks cause >> the message to go to the log buffer, but then immediately >> get sent from there to the console. >> >> Under certain conditions you can examine the log buffer of >> a kernel that failed to initialize it's console, after a >> warm reset of the machine, using the firmware memory dump >> command. > > On ppc, we have tricks to display things earlier :-) > > We can initialize the serial ports way before console_setup() (and we do > in most cases) and we use what we call the "udbg" console until the real > one takes over. The "udbg" console is a very small layer which outputs > via a provided "putc" routine. Platforms can provide their own here, we > have a collection of standard ones for legacy UARTs (it should be > automatically setup in that case by the code in legacy_serial), Apple > ESCCs, etc... We even have compile time options that allow that stuff to > be initialized before start_kernel... Thank you. This is what I described and want to understand. The arch/powerpc/kernel/legacy_serial.c do find_legacy_serial_ports then take a default serial port by using open firmware device tree information. The find_legacy_serial_ports() called form setup_arch but I don't know who call setup_arch (setup_32.c)function. Can you give me a hint ? Thanks in advanced. BRs, H. Johnny ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How the kernel printk works before do console_setup. 2009-06-25 6:27 ` Johnny Hung @ 2009-06-25 6:37 ` Michael Ellerman 0 siblings, 0 replies; 6+ messages in thread From: Michael Ellerman @ 2009-06-25 6:37 UTC (permalink / raw) To: Johnny Hung Cc: Benjamin Herrenschmidt, linuxppc-dev, linux-embedded, linux-kernel [-- Attachment #1: Type: text/plain, Size: 1885 bytes --] On Thu, 2009-06-25 at 14:27 +0800, Johnny Hung wrote: > 2009/6/25 Benjamin Herrenschmidt <benh@kernel.crashing.org>: > > > >> Before the console is set up, the printk data is formatted > >> and put into the kernel log buffer, but not sent to any console. > >> Any messages printk'ed before that are buffered but do not > >> appear. When the console is initialized, then all buffered > >> messages are sent to the console, and subsequent printks cause > >> the message to go to the log buffer, but then immediately > >> get sent from there to the console. > >> > >> Under certain conditions you can examine the log buffer of > >> a kernel that failed to initialize it's console, after a > >> warm reset of the machine, using the firmware memory dump > >> command. > > > > On ppc, we have tricks to display things earlier :-) > > > > We can initialize the serial ports way before console_setup() (and we do > > in most cases) and we use what we call the "udbg" console until the real > > one takes over. The "udbg" console is a very small layer which outputs > > via a provided "putc" routine. Platforms can provide their own here, we > > have a collection of standard ones for legacy UARTs (it should be > > automatically setup in that case by the code in legacy_serial), Apple > > ESCCs, etc... We even have compile time options that allow that stuff to > > be initialized before start_kernel... > > Thank you. This is what I described and want to understand. The > arch/powerpc/kernel/legacy_serial.c > do find_legacy_serial_ports then take a default serial port by using > open firmware device tree > information. The find_legacy_serial_ports() called form setup_arch but > I don't know who call > setup_arch (setup_32.c)function. Can you give me a hint ? Thanks in advanced. setup_arch() is called from start_kernel() in init/main.c cheers [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: How the kernel printk works before do console_setup. 2009-06-24 3:50 How the kernel printk works before do console_setup Johnny Hung 2009-06-24 5:03 ` Tim Bird @ 2009-06-29 19:36 ` Freeman 1 sibling, 0 replies; 6+ messages in thread From: Freeman @ 2009-06-29 19:36 UTC (permalink / raw) To: linux-embedded Johnny Hung <johnny.hacking <at> gmail.com> writes: > > Hi All: > I have a powerpc arch platform. The default console is ttyS1 not > ttyS0 in the platform. My question is how the kernel print debug > message > like DBG before parse kernel command line and do console_setup > function. The command line passed to kernel about console info is > console=ttyS1. > So kernel can not print anything before parse cmd line and initial > console but the result is against. Anyone point me or give me a clue > is appreciate. > > BR, H. Johnny > Don't worry, printk uses a ring buffer so it allows the kernel to print some, hopefully enough, out before console is registered/initialized. This is from printk.c 197 /* 198 * The console driver calls this routine during kernel initialization 199 * to register the console printing procedure with printk() and to 200 * print any messages that were printed by the kernel before the 201 * console driver was initialized. 202 */ 203 void register_console(void (*proc)(const char *)) Freeman ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-06-29 19:36 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-06-24 3:50 How the kernel printk works before do console_setup Johnny Hung 2009-06-24 5:03 ` Tim Bird 2009-06-24 22:56 ` Benjamin Herrenschmidt 2009-06-25 6:27 ` Johnny Hung 2009-06-25 6:37 ` Michael Ellerman 2009-06-29 19:36 ` Freeman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).