
When both CONFIG_SYS_CONSOLE_IS_IN_ENV and CONFIG_NETCONSOLE are defined the user can have stdout set to nc (netconsole).
This causes problems because u-boot will try to write to nc as soon as GD_FLG_DEVINIT is set in gd->flags, which happens before the network devices are initialized in net/eth.c. This results in error messages being spewed out.
To prevent this problem set GD_FLG_DEVINIT in net/eth.c:eth_initialize(), after the network devices have been initialized, instead of in common/console.c:console_init_r().
Signed-off-by: Gary Jennejohn garyj@denx.de --- common/console.c | 11 +++++++++++ net/eth.c | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/common/console.c b/common/console.c index 6f0846f..e0d7541 100644 --- a/common/console.c +++ b/common/console.c @@ -447,7 +447,18 @@ int console_init_r (void) console_setfile (stdin, inputdev); }
+#ifdef CONFIG_NETCONSOLE + /* + * Must do this later in net/eth.c because a network device may + * be set as a console at boot. + * + * Note that the code is left here to make it clear that gd->flags + * would normally have been set at this point. + */ + gd->flags |= 0; +#else gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */ +#endif /* CONFIG_NETCONSOLE */
#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET /* Print information */ diff --git a/net/eth.c b/net/eth.c index ccd871a..6c00ff7 100644 --- a/net/eth.c +++ b/net/eth.c @@ -26,6 +26,10 @@ #include <net.h> #include <miiphy.h>
+#if defined(CONFIG_NETCONSOLE) && defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) +DECLARE_GLOBAL_DATA_PTR; +#endif + #if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI)
/* @@ -262,6 +266,15 @@ int eth_initialize(bd_t *bis) putc ('\n'); }
+#if defined(CONFIG_NETCONSOLE) && defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) + /* + * Must do this late because a network device may be set as a + * console at boot. gd->flags is normally set quite early in + * console_init_r. + */ + gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */ +#endif + return eth_number; }
@@ -538,6 +551,15 @@ int eth_initialize(bd_t *bis) #if defined(CONFIG_DRIVER_TI_EMAC) davinci_eth_miiphy_initialize(bis); #endif +#if defined(CONFIG_NETCONSOLE) && defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) + /* + * Must do this late because a network device may be set as a + * console at boot. gd->flags is normally set quite early in + * console_init_r. + */ + gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */ +#endif + return 0; } #endif