Add board_pre_console_putc to deal with early console output
PATCH v3 1/1 Add board_pre_console_putc to deal with early console output
This patch adds support for console output before the console is inited. The main purpose of this is to deal with a very early panic() which would otherwise cause a silent hang.
A new board_pre_console_putc() function is added to the board API. If provided by the board it will be called in the event of console output before the console is ready. This function should turn on all UARTs and spray the character out if it possibly can.
The feature is controlled by a new CONFIG_PRE_CONSOLE_PUTC option.
---
Changes in v2:
- Made this feature conditional on CONFIG_PRE_CONSOLE_PANIC
Changes in v3:
- Rewrite this to be independent of panic()
- Rename feature to CONFIG_PRE_CONSOLE_PUTC
README | 17 +++++++++++++++++ common/console.c | 21 ++++++++++++++++++++- include/common.h | 7 +++++++ 3 files changed, 44 insertions(+), 1 deletions(-)
README +17 -0
@@ -634,6 +634,23 @@ The following options need to be configured: 'Sane' compilers will generate smaller code if CONFIG_PRE_CON_BUF_SZ is a power of 2 +- Pre-console putc(): + Prior to the console being initialised, console output is + normally silently discarded. This can be annoying if a + panic() happens in this time. + + If the CONFIG_PRE_CONSOLE_PUTC option is defined, then + U-Boot will call board_pre_console_putc() for each output + character in this case, This function should try to output + the character if possible, perhaps on all available UARTs + (it will need to do this directly, since the console code + is not functional yet). Note that if the panic happens + early enough, then it is possible that board_init_f() + (or even arch_cpu_init() on ARM) has not been called yet. + You should init all clocks, GPIOs, etc. that are needed + to get the character out. Baud rates will need to default + to something sensible. + - Boot Delay: CONFIG_BOOTDELAY - in seconds Delay before automatically booting the default image; set to -1 to disable autoboot.
common/console.c +20 -1
@@ -329,14 +329,30 @@ int tstc(void)return serial_tstc (); } -#ifdef CONFIG_PRE_CONSOLE_BUFFER +#ifdef CONFIG_PRE_CONSOLE_PUTC +/* Provide a default function for when no console is available */ +static void __board_pre_console_putc (int ch) +{ +/* Just return since we can't access the console */ +} + +void board_pre_console_putc (const char *msg) __attribute__((weak, +alias ("__board_pre_console_putc" ))); +#endif + +#if defined(CONFIG_PRE_CONSOLE_BUFFER ) || defined(CONFIG_PRE_CONSOLE_PUTC )#define CIRC_BUF_IDX (idx) ((idx) % (unsigned long)CONFIG_PRE_CON_BUF_SZ)static void pre_console_putc (const char c) { +#ifdef CONFIG_PRE_CONSOLE_BUFFER char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR ; buffer[CIRC_BUF_IDX (gd->precon_buf_idx++)] = c; +#endif +#ifdef CONFIG_PRE_CONSOLE_PUTC +board_pre_console_putc (c); +#endif }static void pre_console_puts (const char *s)
@@ -347,6 +363,7 @@ static void pre_console_puts(const char *s)static void print_pre_console_buffer (void ) { +#ifdef CONFIG_PRE_CONSOLE_BUFFER unsigned long i =0 ;char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR ;
@@ -355,7 +372,9 @@ static void print_pre_console_buffer(void)while (i < gd->precon_buf_idx)putc (buffer[CIRC_BUF_IDX (i++)]); +#endif } +#else static inline void pre_console_putc (const char c) {}static inline void pre_console_puts (const char *s) {}
include/common.h +7 -0
@@ -277,6 +277,13 @@ int last_stage_init(void);extern ulong monitor_flash_len;int mac_read_from_eeprom (void ); +/* +* Called when console output is requested before the console is available. +* The board should do its best to get the character out to the user any way +* it can. +*/ +void board_pre_console_putc (int ch); +/* common/flash.c */ void flash_perror (int );
Signature · 1 line
1.7.3.1
PATCH v3 1/1 Add board_pre_console_putc to deal with early console output
Hi Simon,
Quoted 13 lines · Simon Glass
This patch adds support for console output before the console is inited. The main purpose of this is to deal with a very early
panic()which would otherwise cause a silent hang.A new
board_pre_console_putc()function is added to the board API. If provided by the board it will be called in the event of console output before the console is ready. This function should turn on all UARTs and spray the character out if it possibly can.The feature is controlled by a new
CONFIG_PRE_CONSOLE_PUTCoption.Signed-off-by Simon Glass <[email protected]>---
[snip]
Quoted 11 lines
common/console.c +2
-1@@ -329,14 +329,30 @@ int tstc(void)return serial_tstc (); } -#ifdef CONFIG_PRE_CONSOLE_BUFFER +#ifdef CONFIG_PRE_CONSOLE_PUTC +/* Provide a default function for when no console is available */
common/console.c int tstc(void) · line 343
Quoted 10 lines
common/console.c +10
-0+static void __board_pre_console_putc (int ch) +{ +/* Just return since we can't access the console */ +} + +void board_pre_console_putc (const char *msg) __attribute__((weak, +alias ("__board_pre_console_putc" ))); +#endif + +#if defined(CONFIG_PRE_CONSOLE_BUFFER ) || defined(CONFIG_PRE_CONSOLE_PUTC )
I don't think we need this - If CONFIG_PRE_CONSOLE_PUTC then board_pre_console_putc() must also be defined - I would prefer a compilation due to undefined function that head-scratching as to why th output I expected did not occur
[snip]
Regards,
Graeme
PATCH v3 1/1 Add board_pre_console_putc to deal with early console output
Hi Graeme,
Quoted 37 lines · Graeme Russ
Hi Simon,
Quoted 13 lines · Simon Glass
This patch adds support for console output before the console is inited. The main purpose of this is to deal with a very early
panic()which would otherwise cause a silent hang.A new
board_pre_console_putc()function is added to the board API. If provided by the board it will be called in the event of console output before the console is ready. This function should turn on all UARTs and spray the character out if it possibly can.The feature is controlled by a new
CONFIG_PRE_CONSOLE_PUTCoption.Signed-off-by Simon Glass <[email protected]>---
[snip]
Quoted 18 lines
common/console.c +9
-1@@ -329,14 +329,30 @@ int tstc(void) ? ? ? ?return serial_tstc(); ?} -#ifdef CONFIG_PRE_CONSOLE_BUFFER +#ifdef CONFIG_PRE_CONSOLE_PUTC +/* Provide a default function for when no console is available */ +static void __board_pre_console_putc (int ch) +{ + ? ? ? /* Just return since we can't access the console */ +} + +void board_pre_console_putc(const char *msg) __attribute__((weak, + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? alias("__board_pre_console_putc")));
Quoted 8 lines
common/console.c int tstc(void) · line 343
Quoted 3 lines
common/console.c +3
-0+#endif + +#if defined(CONFIG_PRE_CONSOLE_BUFFER ) || defined(CONFIG_PRE_CONSOLE_PUTC )I don't think we need this - If
CONFIG_PRE_CONSOLE_PUTCthenboard_pre_console_putc()must also be defined - I would prefer a compilation due to undefined function that head-scratching as to why th output I expected did not occur
Yes definitely, will adjust.
Regards,
Simon
Quoted 7 lines
[snip]
Regards,
Graeme
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
In reply to Simon GlassThis patch adds support for console output before the console is inited. The main purpose of this is to deal with a very early panic() which would otherwise cause a silent hang.
A new board_pre_console_putc() function is added to the board API. If provided by the board it will be called in the event of console output before the console is ready. This function should turn on all UARTs and spray the character out if it possibly can.
The feature is controlled by a new CONFIG_PRE_CONSOLE_PUTC option.
---
Changes in v2:
- Made this feature conditional on CONFIG_PRE_CONSOLE_PANIC
Changes in v3:
- Rewrite this to be independent of panic()
- Rename feature to CONFIG_PRE_CONSOLE_PUTC
Changes in v4:
- Remove weak function, so we get a link error if it is undefined by the board
README | 17 +++++++++++++++++ common/console.c | 10 +++++++++- include/common.h | 7 +++++++ 3 files changed, 33 insertions(+), 1 deletions(-)
README +17 -0
@@ -634,6 +634,23 @@ The following options need to be configured: 'Sane' compilers will generate smaller code if CONFIG_PRE_CON_BUF_SZ is a power of 2 +- Pre-console putc(): + Prior to the console being initialised, console output is + normally silently discarded. This can be annoying if a + panic() happens in this time. + + If the CONFIG_PRE_CONSOLE_PUTC option is defined, then + U-Boot will call board_pre_console_putc() for each output + character in this case, This function should try to output + the character if possible, perhaps on all available UARTs + (it will need to do this directly, since the console code + is not functional yet). Note that if the panic happens + early enough, then it is possible that board_init_f() + (or even arch_cpu_init() on ARM) has not been called yet. + You should init all clocks, GPIOs, etc. that are needed + to get the character out. Baud rates will need to default + to something sensible. + - Boot Delay: CONFIG_BOOTDELAY - in seconds Delay before automatically booting the default image; set to -1 to disable autoboot.
common/console.c +9 -1
@@ -329,14 +329,19 @@ int tstc(void)return serial_tstc (); } -#ifdef CONFIG_PRE_CONSOLE_BUFFER +#if defined(CONFIG_PRE_CONSOLE_BUFFER ) || defined(CONFIG_PRE_CONSOLE_PUTC )#define CIRC_BUF_IDX (idx) ((idx) % (unsigned long)CONFIG_PRE_CON_BUF_SZ)static void pre_console_putc (const char c) { +#ifdef CONFIG_PRE_CONSOLE_BUFFER char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR ; buffer[CIRC_BUF_IDX (gd->precon_buf_idx++)] = c; +#endif +#ifdef CONFIG_PRE_CONSOLE_PUTC +board_pre_console_putc (c); +#endif }static void pre_console_puts (const char *s)
@@ -347,6 +352,7 @@ static void pre_console_puts(const char *s)static void print_pre_console_buffer (void ) { +#ifdef CONFIG_PRE_CONSOLE_BUFFER unsigned long i =0 ;char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR ;
@@ -355,7 +361,9 @@ static void print_pre_console_buffer(void)while (i < gd->precon_buf_idx)putc (buffer[CIRC_BUF_IDX (i++)]); +#endif } +#else static inline void pre_console_putc (const char c) {}static inline void pre_console_puts (const char *s) {}
include/common.h +7 -0
@@ -277,6 +277,13 @@ int last_stage_init(void);extern ulong monitor_flash_len;int mac_read_from_eeprom (void ); +/* +* Called when console output is requested before the console is available. +* The board should do its best to get the character out to the user any way +* it can. +*/ +void board_pre_console_putc (int ch); +/* common/flash.c */ void flash_perror (int );
Signature · 1 line
1.7.3.1
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
Hi Simon,
Quoted 4 lines · Simon Glass
This patch adds support for console output before the console is inited. The main purpose of this is to deal with a very early
panic()which would otherwise cause a silent hang.
Quoted 8 lines
A new
board_pre_console_putc()function is added to the board API. If provided by the board it will be called in the event of console output before the console is ready. This function should turn on all UARTs and spray the character out if it possibly can.The feature is controlled by a new
CONFIG_PRE_CONSOLE_PUTCoption.Signed-off-by Simon Glass <[email protected]>
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
Hi,
Quoted 12 lines · Graeme Russ
Hi Simon,
Quoted 9 lines · Simon Glass
This patch adds support for console output before the console is inited. The main purpose of this is to deal with a very early
panic()which would otherwise cause a silent hang.A new
board_pre_console_putc()function is added to the board API. If provided by the board it will be called in the event of console output before the console is ready. This function should turn on all UARTs and spray the character out if it possibly can.
Quoted 6 lines
Quoted 3 lines
The feature is controlled by a new
CONFIG_PRE_CONSOLE_PUTCoption.Signed-off-by Simon Glass <[email protected]>Acked-by Graeme Russ <[email protected]>
Just going through my backlog. Any interest in merging this?
Regards,
Simon
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
Quoted 5 lines · Simon Glass
Hi,
Quoted 2 lines · Graeme Russ
Hi Simon,
Hi Simon,
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
A new
board_pre_console_putc()function is added to the board API. If provided by the board it will be called in the event of console output before the console is ready. This function should turn on all UARTs and spray the character out if it possibly can.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
The feature is controlled by a new
CONFIG_PRE_CONSOLE_PUTCoption.Signed-off-by Simon Glass <[email protected]>Acked-by Graeme Russ <[email protected]>Just going through my backlog. Any interest in merging this?
I have frankly missed the patch - I will read the related thread, and I will take a look. For now I will put this patch in my TODO list in patchwork.
Best regards,
Stefano
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
Quoted 18 lines · Stefano Babic
Quoted 5 lines · Simon Glass
Hi,
Quoted 2 lines · Graeme Russ
Hi Simon,
Hi Simon,
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
A new
board_pre_console_putc()function is added to the board API. If provided by the board it will be called in the event of console output before the console is ready. This function should turn on all UARTs and spray the character out if it possibly can.The feature is controlled by a new
CONFIG_PRE_CONSOLE_PUTCoption.Signed-off-by Simon Glass <[email protected]>
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
Acked-by Graeme Russ <[email protected]>Just going through my backlog. Any interest in merging this?
I have frankly missed the patch - I will read the related thread, and I will take a look. For now I will put this patch in my TODO list in patchwork.
Hi Stefano,
Thank you - no particular reason for you to notice it, but I thought I would cc you. The original purpose was to get some sort of message out of a board that fails very early (before console_init_f()). It is useful when using an fdt, since if the fdt cannot be found it is nice to print a friendly message somehow.
Regards,
Simon
Quoted 11 lines
Best regards,
Stefano--
=====================================================================
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 ?Email: office at denx.de
=====================================================================
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
In reply to Simon GlassQuoted 9 lines · Simon Glass
This patch adds support for console output before the console is inited. The main purpose of this is to deal with a very early
panic()which would otherwise cause a silent hang.A new
board_pre_console_putc()function is added to the board API. If provided by the board it will be called in the event of console output before the console is ready. This function should turn on all UARTs and spray the character out if it possibly can.
Quoted 4 lines
The feature is controlled by a new
CONFIG_PRE_CONSOLE_PUTCoption.Signed-off-by Simon Glass <[email protected]>---
Hi Simon,
Quoted 9 lines
Changes in v2:
- Made this feature conditional onCONFIG_PRE_CONSOLE_PANICChanges in v3:
- Rewrite this to be independent ofpanic()
- Rename feature toCONFIG_PRE_CONSOLE_PUTCChanges in v4:
- Remove weak function, so we get a link error if it is undefined by the board
maybe I have not understood the real goal of this patch. We have already a CONFIG_PRE_CONSOLE_BUFFER, that tries to store the output when the console is not avalable - and can be retrieved with a JTAG debugger.
Your patch adds a way to call some serial setup in board code, but it is not said that works or can work for all / most boards. Compared to the usage of the circular buffer, it is not so general - am I missing something ?
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
Hi Stefan,
Quoted 28 lines · Stefano Babic
Quoted 9 lines · Simon Glass
This patch adds support for console output before the console is inited. The main purpose of this is to deal with a very early
panic()which would otherwise cause a silent hang.A new
board_pre_console_putc()function is added to the board API. If provided by the board it will be called in the event of console output before the console is ready. This function should turn on all UARTs and spray the character out if it possibly can.Quoted 4 lines
The feature is controlled by a new
CONFIG_PRE_CONSOLE_PUTCoption.Signed-off-by Simon Glass <[email protected]>---
Hi Simon,
Quoted 9 lines
Changes in v2:
- Made this feature conditional onCONFIG_PRE_CONSOLE_PANICChanges in v3:
- Rewrite this to be independent ofpanic()
- Rename feature toCONFIG_PRE_CONSOLE_PUTCChanges in v4:
- Remove weak function, so we get a link error if it is undefined by the board
Quoted 8 lines
maybe I have not understood the real goal of this patch. We have already a
CONFIG_PRE_CONSOLE_BUFFER, that tries to store the output when the console is not avalable - and can be retrieved with a JTAG debugger.Your patch adds a way to call some serial setup in board code, but it is not said that works or can work for all / most boards. Compared to the usage of the circular buffer, it is not so general - am I missing something ?
It actually started as a last-ditch panic message printer. It morphed into the general pre-console putc after discussions on the list (with Graeme).
It can happen that your early board code does not know what clocks to use, or can't find a console, or some other critical error. It then calls panic() which silently dies or maybe reboots if you are lucky. This problem mostly comes about with device trees, where we must have certain info in the device tree before we can even get to relocation.
The idea is that boards provide a way of outputting characters which tries to work on all types of boards with that SOC. For example, they output the characters on all UARTs with various clock options, etc.
We use it on Tegra to print a friendly panic message when something is horribly wrong. In this case we will never make it to relocation so the pre-console buffer will not be displayed. So we can't rely on that.
Regards,
Simon
Quoted 11 lines
Best regards,
Stefano Babic--
=====================================================================
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 ?Email: office at denx.de
=====================================================================
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
Quoted 10 lines · Simon Glass
It actually started as a last-ditch panic message printer. It morphed into the general pre-console putc after discussions on the list (with Graeme).
It can happen that your early board code does not know what clocks to use, or can't find a console, or some other critical error. It then calls
panic()which silently dies or maybe reboots if you are lucky. This problem mostly comes about with device trees, where we must have certain info in the device tree before we can even get to relocation.
Quoted 8 lines
The idea is that boards provide a way of outputting characters which tries to work on all types of boards with that SOC. For example, they output the characters on all UARTs with various clock options, etc.
We use it on Tegra to print a friendly panic message when something is horribly wrong. In this case we will never make it to relocation so the pre-console buffer will not be displayed. So we can't rely on that.
I do not know if this mechanism can be used on other SOCs, but IMHO it does not hurt and it helps at least on Tegra, as you explained me.
Applied to u-boot-staging, sbabic at denx.de branch
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de =====================================================================
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
Hi Stefan,
Quoted 21 lines · Stefano Babic
Quoted 10 lines · Simon Glass
It actually started as a last-ditch panic message printer. It morphed into the general pre-console putc after discussions on the list (with Graeme).
It can happen that your early board code does not know what clocks to use, or can't find a console, or some other critical error. It then calls
panic()which silently dies or maybe reboots if you are lucky. This problem mostly comes about with device trees, where we must have certain info in the device tree before we can even get to relocation.Quoted 8 lines
The idea is that boards provide a way of outputting characters which tries to work on all types of boards with that SOC. For example, they output the characters on all UARTs with various clock options, etc.
We use it on Tegra to print a friendly panic message when something is horribly wrong. In this case we will never make it to relocation so the pre-console buffer will not be displayed. So we can't rely on that.
Quoted 4 lines
I do not know if this mechanism can be used on other SOCs, but IMHO it does not hurt and it helps at least on Tegra, as you explained me.
Applied to u-boot-staging, sbabic at denx.de branch
Thanks. I think it can be used on any SOC with internal UARTs and a reasonably small list of permitted clock speeds. I suspect I will be trying it out on a few before long.
Regards,
Simon
Quoted 11 lines
Best regards,
Stefano Babic--
=====================================================================
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 ?Email: office at denx.de
=====================================================================
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
Hi Simon,
Quoted 24 lines · Simon Glass
Hi Stefan,
Quoted 21 lines · Stefano Babic
Quoted 18 lines · Simon Glass
It actually started as a last-ditch panic message printer. It morphed into the general pre-console putc after discussions on the list (with Graeme).
It can happen that your early board code does not know what clocks to use, or can't find a console, or some other critical error. It then calls
panic()which silently dies or maybe reboots if you are lucky. This problem mostly comes about with device trees, where we must have certain info in the device tree before we can even get to relocation.The idea is that boards provide a way of outputting characters which tries to work on all types of boards with that SOC. For example, they output the characters on all UARTs with various clock options, etc.
We use it on Tegra to print a friendly panic message when something is horribly wrong. In this case we will never make it to relocation so the pre-console buffer will not be displayed. So we can't rely on that.
Quoted 8 lines
Quoted 4 lines
I do not know if this mechanism can be used on other SOCs, but IMHO it does not hurt and it helps at least on Tegra, as you explained me.
Applied to u-boot-staging, sbabic at denx.de branch
Thanks. I think it can be used on any SOC with internal UARTs and a reasonably small list of permitted clock speeds. I suspect I will be trying it out on a few before long.
Can it be used in conjuction with PRE_CONSOLE_BUFFER? i.e. panic() prints the contents of the PRE_CONSOLE_BUFFER before the panic message? I think that would be invaluable in determining what was happening leading up to the panic
Regards,
Graeme
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
Hi Graeme,
Quoted 32 lines · Graeme Russ
Hi Simon,
Quoted 29 lines · Simon Glass
Hi Stefan,
Quoted 25 lines · Stefano Babic
Quoted 10 lines · Simon Glass
It actually started as a last-ditch panic message printer. It morphed into the general pre-console putc after discussions on the list (with Graeme).
It can happen that your early board code does not know what clocks to use, or can't find a console, or some other critical error. It then calls
panic()which silently dies or maybe reboots if you are lucky. This problem mostly comes about with device trees, where we must have certain info in the device tree before we can even get to relocation.Quoted 8 lines
The idea is that boards provide a way of outputting characters which tries to work on all types of boards with that SOC. For example, they output the characters on all UARTs with various clock options, etc.
We use it on Tegra to print a friendly panic message when something is horribly wrong. In this case we will never make it to relocation so the pre-console buffer will not be displayed. So we can't rely on that.
I do not know if this mechanism can be used on other SOCs, but IMHO it does not hurt and it helps at least on Tegra, as you explained me.
Applied to u-boot-staging, sbabic at denx.de branch
Quoted 8 lines
Quoted 3 lines
Thanks. I think it can be used on any SOC with internal UARTs and a reasonably small list of permitted clock speeds. I suspect I will be trying it out on a few before long.
Can it be used in conjuction with
PRE_CONSOLE_BUFFER? i.e.panic()prints the contents of thePRE_CONSOLE_BUFFERbefore the panic message? I think that would be invaluable in determining what was happening leading up to the panic
It could have been when it was still a pre-console panic. But now that it has morphed into a general putc(), I suppose the only option is to somehow detect the first call and send the pre-console text first?
Regards,
Simon
Quoted 5 lines
Regards,
Graeme
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
Hi Simon,
Quoted 39 lines · Simon Glass
Hi Graeme,
Quoted 36 lines · Graeme Russ
Hi Simon,
Quoted 32 lines · Simon Glass
Hi Stefan,
Quoted 21 lines · Stefano Babic
Quoted 10 lines · Simon Glass
It actually started as a last-ditch panic message printer. It morphed into the general pre-console putc after discussions on the list (with Graeme).
It can happen that your early board code does not know what clocks to use, or can't find a console, or some other critical error. It then calls
panic()which silently dies or maybe reboots if you are lucky. This problem mostly comes about with device trees, where we must have certain info in the device tree before we can even get to relocation.Quoted 8 lines
The idea is that boards provide a way of outputting characters which tries to work on all types of boards with that SOC. For example, they output the characters on all UARTs with various clock options, etc.
We use it on Tegra to print a friendly panic message when something is horribly wrong. In this case we will never make it to relocation so the pre-console buffer will not be displayed. So we can't rely on that.
Quoted 4 lines
I do not know if this mechanism can be used on other SOCs, but IMHO it does not hurt and it helps at least on Tegra, as you explained me.
Applied to u-boot-staging, sbabic at denx.de branch
Thanks. I think it can be used on any SOC with internal UARTs and a reasonably small list of permitted clock speeds. I suspect I will be trying it out on a few before long.
Quoted 8 lines
Quoted 4 lines
Can it be used in conjuction with
PRE_CONSOLE_BUFFER? i.e.panic()prints the contents of thePRE_CONSOLE_BUFFERbefore the panic message? I think that would be invaluable in determining what was happening leading up to the panicIt could have been when it was still a pre-console panic. But now that it has morphed into a general
putc(), I suppose the only option is to somehow detect the first call and send the pre-console text first?
Couldn't the panic() function detect that the pre console buffer is not empty and dump it before the panic message? Maybe even a generic panic_dump_pre_console_buffer() which checks if console has been initialised (in which case the buffer has already been dumped) and if the buffer is not empty, use pre_console_putc() to dump the buffer. This would be the first call in panic() followed by printing the panic message
Regards,
Graeme
PATCH v4 1/1 Add board_pre_console_putc to deal with early console output
Hi Graeme,
Quoted 51 lines · Graeme Russ
Hi Simon,
Quoted 39 lines · Simon Glass
Hi Graeme,
Quoted 36 lines · Graeme Russ
Hi Simon,
Quoted 32 lines · Simon Glass
Hi Stefan,
Quoted 21 lines · Stefano Babic
Quoted 10 lines · Simon Glass
It actually started as a last-ditch panic message printer. It morphed into the general pre-console putc after discussions on the list (with Graeme).
It can happen that your early board code does not know what clocks to use, or can't find a console, or some other critical error. It then calls
panic()which silently dies or maybe reboots if you are lucky. This problem mostly comes about with device trees, where we must have certain info in the device tree before we can even get to relocation.Quoted 8 lines
The idea is that boards provide a way of outputting characters which tries to work on all types of boards with that SOC. For example, they output the characters on all UARTs with various clock options, etc.
We use it on Tegra to print a friendly panic message when something is horribly wrong. In this case we will never make it to relocation so the pre-console buffer will not be displayed. So we can't rely on that.
Quoted 4 lines
I do not know if this mechanism can be used on other SOCs, but IMHO it does not hurt and it helps at least on Tegra, as you explained me.
Applied to u-boot-staging, sbabic at denx.de branch
Thanks. I think it can be used on any SOC with internal UARTs and a reasonably small list of permitted clock speeds. I suspect I will be trying it out on a few before long.
Quoted 8 lines
Quoted 4 lines
Can it be used in conjuction with
PRE_CONSOLE_BUFFER? i.e.panic()prints the contents of thePRE_CONSOLE_BUFFERbefore the panic message? I think that would be invaluable in determining what was happening leading up to the panicIt could have been when it was still a pre-console panic. But now that it has morphed into a general
putc(), I suppose the only option is to somehow detect the first call and send the pre-console text first?
Quoted 7 lines
Couldn't the
panic()function detect that the pre console buffer is not empty and dump it before the panic message? Maybe even a genericpanic_dump_pre_console_buffer()which checks if console has been initialised (in which case the buffer has already been dumped) and if the buffer is not empty, usepre_console_putc()to dump the buffer. This would be the first call inpanic()followed by printing the panic message
Yes it could - sounds like a great idea. Patches welcome :-)
Regards,
Simon
Quoted 4 lines
Regards,
Graeme