Skip to contentSkip to conversation

board_f: explicitly disable console on early boot

PATCH In review Alexey Brodkin 3 participants 6 messages Nov 27, 2013 – Dec 16, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 board_f: explicitly disable console on early boot

If U-Boot build with DEBUG enabled/defined the first call of "debug" function (that dumps data to any available console) will happen before zeroing of initial "gd" in init call "zero_global_data" in "init_sequence_f".

And if stack was not filled with zeros chances are high that "gd->have_console" won't be 0. In its turn it will cause attempt to output things to non-initialized yet serial console.

So for safety and predictability we set "gd->have_console = 0".

Cc Mischa Jonker <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
---
 common/board_f.c | 1 +
 1 file changed, 1 insertion(+)
common/board_f.c +1 -0
index f0664bc..fcfd713 100644
@@ -1010,6 +1010,7 @@ void board_init_f(ulong boot_flags)
 #endif
 
 	gd->flags = boot_flags;
+	gd->have_console = 0;
 
 	if (initcall_run_list(init_sequence_f))
 		hang();
Signature · 1 line
1.8.4.2
#1 lore raw

PATCH 1/1 board_f: explicitly disable console on early boot

Quoted 5 lines · Alexey Brodkin

If U-Boot build with DEBUG enabled/defined the first call of "debug" function (that dumps data to any available console) will happen before zeroing of initial "gd" in init call "zero_global_data" in "init_sequence_f".

Quoted 8 lines

And if stack was not filled with zeros chances are high that "gd->have_console" won't be 0. In its turn it will cause attempt to output things to non-initialized yet serial console.

So for safety and predictability we set "gd->have_console = 0".

I have a similar patch locally, but it actually does memset() on the whole structure. Some archs handle this setup differently. For example both ARM and x86 now allocate it in low level code so there is no need for the board_f code to allocate a global data structure.

Regards,
Simon

Quoted 24 lines
Cc Mischa Jonker <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
---
 common/board_f.c | 1 +
 1 file changed, 1 insertion(+)
common/board_f.c +1 -1
index f0664bc..fcfd713 100644
@@ -1010,6 +1010,7 @@ void board_init_f(ulong boot_flags)
 #endif
 
        gd->flags = boot_flags;
+       gd->have_console = 0;
 
        if (initcall_run_list(init_sequence_f))
                hang();
--

1.8.4.2

#2 lore raw

PATCH 1/1 board_f: explicitly disable console on early boot

Quoted 5 lines · Simon Glass

I have a similar patch locally, but it actually does memset() on the whole structure. Some archs handle this setup differently. For example both ARM and x86 now allocate it in low level code so there is no need for the board_f code to allocate a global data structure.

Another approach would be to move "zero_global_data" from "init_sequence_f" to the very beginning of "board_init_f" right after global data allocation.

But IMHO it is a bit more significant modification so I decided to start from the simplest fix that resolves a particular issue I see.

-Alexey

#3 lore raw

PATCH 1/1 board_f: explicitly disable console on early boot

Quoted 9 lines · Alexey Brodkin
Quoted 5 lines · Simon Glass

I have a similar patch locally, but it actually does memset() on the whole structure. Some archs handle this setup differently. For example both ARM and x86 now allocate it in low level code so there is no need for the board_f code to allocate a global data structure.

Quoted 6 lines

Another approach would be to move "zero_global_data" from "init_sequence_f" to the very beginning of "board_init_f" right after global data allocation.

But IMHO it is a bit more significant modification so I decided to start from the simplest fix that resolves a particular issue I see.

Any chance for this patch to be applied or described problem has to be resolved/worked-around in any other way?

-Alexey

#4 lore raw

PATCH 1/1 board_f: explicitly disable console on early boot

Quoted 14 lines · Alexey Brodkin
Quoted 13 lines · Alexey Brodkin
Quoted 5 lines · Simon Glass

I have a similar patch locally, but it actually does memset() on the whole structure. Some archs handle this setup differently. For example both ARM and x86 now allocate it in low level code so there is no need for the board_f code to allocate a global data structure.

Another approach would be to move "zero_global_data" from "init_sequence_f" to the very beginning of "board_init_f" right after global data allocation.

Quoted 5 lines
Quoted 2 lines

But IMHO it is a bit more significant modification so I decided to start from the simplest fix that resolves a particular issue I see.

Any chance for this patch to be applied or described problem has to be resolved/worked-around in any other way?

I say apply it. Tom would you like me to do a pull request, or do you want to pick it up?

Regards,
Simon

#5 lore raw
In reply to Alexey Brodkin
Quoted 9 lines · Alexey Brodkin

If U-Boot build with DEBUG enabled/defined the first call of "debug" function (that dumps data to any available console) will happen before zeroing of initial "gd" in init call "zero_global_data" in "init_sequence_f".

And if stack was not filled with zeros chances are high that "gd->have_console" won't be 0. In its turn it will cause attempt to output things to non-initialized yet serial console.

Quoted 8 lines

So for safety and predictability we set "gd->have_console = 0".

Cc Mischa Jonker <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131216/2f3ee5b9/attachment.pgp>