* [PATCH v1] Fix unbootable ARMv7 devices @ 2026-01-30 3:12 Brian Sune 2026-01-30 14:55 ` Tom Rini 0 siblings, 1 reply; 5+ messages in thread From: Brian Sune @ 2026-01-30 3:12 UTC (permalink / raw) To: u-boot, Tom Rini; +Cc: Brian Sune The linker script u-boot-spl.lds now is no longer aligned and -nodtb.bin ending shows the zeros are not 8 byte aligned. This result in the Makefile.xpl simply think the previous file is aligned and do not zero pad. simply fix the data align to 8 can ensure the -nodtb.bin is aligned, hence, the formation of u-boot-spl.bin properly align. Signed-off-by: Brian Sune <briansune@gmail.com> --- arch/arm/cpu/u-boot-spl.lds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds index c578c3ebf82..18b0f1e7284 100644 --- a/arch/arm/cpu/u-boot-spl.lds +++ b/arch/arm/cpu/u-boot-spl.lds @@ -26,7 +26,7 @@ SECTIONS . = ALIGN(4); .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) } - . = ALIGN(4); + . = ALIGN(8); .data : { *(.data*) } -- 2.34.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1] Fix unbootable ARMv7 devices 2026-01-30 3:12 [PATCH v1] Fix unbootable ARMv7 devices Brian Sune @ 2026-01-30 14:55 ` Tom Rini 2026-01-30 16:50 ` Sune Brian 2026-01-30 17:02 ` Sune Brian 0 siblings, 2 replies; 5+ messages in thread From: Tom Rini @ 2026-01-30 14:55 UTC (permalink / raw) To: Brian Sune; +Cc: u-boot [-- Attachment #1: Type: text/plain, Size: 1829 bytes --] On Fri, Jan 30, 2026 at 11:12:17AM +0800, Brian Sune wrote: > The linker script u-boot-spl.lds now > is no longer aligned and -nodtb.bin ending shows > the zeros are not 8 byte aligned. This result in > the Makefile.xpl simply think the previous file > is aligned and do not zero pad. simply fix the > data align to 8 can ensure the -nodtb.bin is aligned, > hence, the formation of u-boot-spl.bin properly align. > > Signed-off-by: Brian Sune <briansune@gmail.com> > --- > arch/arm/cpu/u-boot-spl.lds | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) This fixes your problem in that it results in the device tree being aligned still, but doesn't solve the underlying problem of why there were 4 extra bytes. Can you please try: diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds index c578c3ebf821..5f807323f856 100644 --- a/arch/arm/cpu/u-boot-spl.lds +++ b/arch/arm/cpu/u-boot-spl.lds @@ -31,16 +31,16 @@ SECTIONS *(.data*) } - . = ALIGN(4); - __u_boot_list : { - KEEP(*(SORT(__u_boot_list*))); - } - . = ALIGN(4); .binman_sym_table : { __binman_sym_start = .; KEEP(*(SORT(.binman_sym*))); __binman_sym_end = .; + } + + . = ALIGN(4); + __u_boot_list : { + KEEP(*(SORT(__u_boot_list*))); . = ALIGN(8); } As the problem ends up being that when both of these are true: - .binman_sym_table is empty of actual .binman_sym* symbols - The inner '. = ALIGN(8);' increments the linker counter from the previous '. = ALIGN(4);' (in other words we were not already 8b aligned). The linker sets the type for this section to "NOBITS" which in turn means that when we later call objcopy to create u-boot-spl-nodtb.bin we get a mismatch between our expected size and actual size for creating the -pad.bin file. -- Tom [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1] Fix unbootable ARMv7 devices 2026-01-30 14:55 ` Tom Rini @ 2026-01-30 16:50 ` Sune Brian 2026-01-30 18:10 ` Tom Rini 2026-01-30 17:02 ` Sune Brian 1 sibling, 1 reply; 5+ messages in thread From: Sune Brian @ 2026-01-30 16:50 UTC (permalink / raw) To: Tom Rini; +Cc: u-boot On Fri, Jan 30, 2026 at 10:55 PM Tom Rini <trini@konsulko.com> wrote: > > On Fri, Jan 30, 2026 at 11:12:17AM +0800, Brian Sune wrote: > > > The linker script u-boot-spl.lds now > > is no longer aligned and -nodtb.bin ending shows > > the zeros are not 8 byte aligned. This result in > > the Makefile.xpl simply think the previous file > > is aligned and do not zero pad. simply fix the > > data align to 8 can ensure the -nodtb.bin is aligned, > > hence, the formation of u-boot-spl.bin properly align. > > > > Signed-off-by: Brian Sune <briansune@gmail.com> > > --- > > arch/arm/cpu/u-boot-spl.lds | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > This fixes your problem in that it results in the device tree being > aligned still, but doesn't solve the underlying problem of why there No it is not 4 extra bytes but 4 bytes short on the latest master commits. > were 4 extra bytes. Can you please try: > > diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds > index c578c3ebf821..5f807323f856 100644 > --- a/arch/arm/cpu/u-boot-spl.lds > +++ b/arch/arm/cpu/u-boot-spl.lds > @@ -31,16 +31,16 @@ SECTIONS > *(.data*) > } > > - . = ALIGN(4); > - __u_boot_list : { > - KEEP(*(SORT(__u_boot_list*))); > - } > - > . = ALIGN(4); > .binman_sym_table : { > __binman_sym_start = .; > KEEP(*(SORT(.binman_sym*))); > __binman_sym_end = .; > + } > + > + . = ALIGN(4); > + __u_boot_list : { > + KEEP(*(SORT(__u_boot_list*))); > . = ALIGN(8); > } > This patch will create the same result but the actual problem never caused by the -pad.bin. The bss size is 8 byte aligned hence it will not be the issue from first place at Makefile.xpl as it will not create any zero pad. The issue here is that the nodtb size itself size is never 8 byte aligned at the end result in short or long cases while the Makefile.xpl only creates extra zero based on the bss size rather than the nodtb size. Then they simply join nodtb + pad + bss but from first place nodtb is not sized correctly at the end aka 8 byte sized. Any method that can make the end back to 8 byte size of the nodtb should do the job. > As the problem ends up being that when both of these are true: > - .binman_sym_table is empty of actual .binman_sym* symbols > - The inner '. = ALIGN(8);' increments the linker counter from the > previous '. = ALIGN(4);' (in other words we were not already 8b > aligned). So what you are suggesting is that the section of binman_sym_table is empty so the ALIGN(8) just simply cannot do its 8 byte alignment job. And reversing the order makes sure it will always ALIGN end with 8. But does "__u_boot_list" result in an empty case? If not then this indeed do what I also wanted to. I intended not to change any ordering to fix the issue. Brian > > The linker sets the type for this section to "NOBITS" which in turn > means that when we later call objcopy to create u-boot-spl-nodtb.bin we > get a mismatch between our expected size and actual size for creating > the -pad.bin file. > > -- > Tom ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] Fix unbootable ARMv7 devices 2026-01-30 16:50 ` Sune Brian @ 2026-01-30 18:10 ` Tom Rini 0 siblings, 0 replies; 5+ messages in thread From: Tom Rini @ 2026-01-30 18:10 UTC (permalink / raw) To: Sune Brian; +Cc: u-boot [-- Attachment #1: Type: text/plain, Size: 4434 bytes --] On Sat, Jan 31, 2026 at 12:50:17AM +0800, Sune Brian wrote: > On Fri, Jan 30, 2026 at 10:55 PM Tom Rini <trini@konsulko.com> wrote: > > > > On Fri, Jan 30, 2026 at 11:12:17AM +0800, Brian Sune wrote: > > > > > The linker script u-boot-spl.lds now > > > is no longer aligned and -nodtb.bin ending shows > > > the zeros are not 8 byte aligned. This result in > > > the Makefile.xpl simply think the previous file > > > is aligned and do not zero pad. simply fix the > > > data align to 8 can ensure the -nodtb.bin is aligned, > > > hence, the formation of u-boot-spl.bin properly align. > > > > > > Signed-off-by: Brian Sune <briansune@gmail.com> > > > --- > > > arch/arm/cpu/u-boot-spl.lds | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > This fixes your problem in that it results in the device tree being > > aligned still, but doesn't solve the underlying problem of why there > > No it is not 4 extra bytes but 4 bytes short on the latest master commits. > > > were 4 extra bytes. Can you please try: Yes, we're off by 4 bytes. Sometimes in one direction, sometimes in the other. I believe in either case it's because of not accounting for a non-empty section correctly. > > diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds > > index c578c3ebf821..5f807323f856 100644 > > --- a/arch/arm/cpu/u-boot-spl.lds > > +++ b/arch/arm/cpu/u-boot-spl.lds > > @@ -31,16 +31,16 @@ SECTIONS > > *(.data*) > > } > > > > - . = ALIGN(4); > > - __u_boot_list : { > > - KEEP(*(SORT(__u_boot_list*))); > > - } > > - > > . = ALIGN(4); > > .binman_sym_table : { > > __binman_sym_start = .; > > KEEP(*(SORT(.binman_sym*))); > > __binman_sym_end = .; > > + } > > + > > + . = ALIGN(4); > > + __u_boot_list : { > > + KEEP(*(SORT(__u_boot_list*))); > > . = ALIGN(8); > > } > > > > This patch will create the same result but the actual problem > never caused by the -pad.bin. > > The bss size is 8 byte aligned hence it will not be the issue from > first place at Makefile.xpl as it will not create any zero pad. Right, the pad file is created the correct size. > The issue here is that the nodtb size itself size is never 8 byte > aligned at the end result in short or long cases while the > Makefile.xpl only creates extra zero based on the bss size rather than > the nodtb size. Yes, the nodtb isn't aligned, but it's supposed to be. The ASSERT statements we have mean that the ELF object is correct, but when we transform it, we're breaking it. > Then they simply join nodtb + pad + bss but from first place nodtb > is not sized correctly at the end aka 8 byte sized. > > Any method that can make the end back to 8 byte size of the nodtb > should do the job. It's a two-part problem. The file has to be aligned, and we have to place the dtb at where __bss_end (in the case of SPL_SEPARATE_BSS=n) is at run-time. > > As the problem ends up being that when both of these are true: > > - .binman_sym_table is empty of actual .binman_sym* symbols > > - The inner '. = ALIGN(8);' increments the linker counter from the > > previous '. = ALIGN(4);' (in other words we were not already 8b > > aligned). > > So what you are suggesting is that the section of binman_sym_table > is empty so the ALIGN(8) just simply cannot do its 8 byte alignment job. Not quite. When we say "ALIGN(8)" we advance the linkers program counter but that's not the same as saying "add bytes of 0x0 until we reach the counter". > And reversing the order makes sure it will always ALIGN end with 8. > But does "__u_boot_list" result in an empty case? If not then this > indeed do what I also wanted to. > > I intended not to change any ordering to fix the issue. > > Brian > > > > > The linker sets the type for this section to "NOBITS" which in turn > > means that when we later call objcopy to create u-boot-spl-nodtb.bin we > > get a mismatch between our expected size and actual size for creating > > the -pad.bin file. Which is what I'm explaining here. We have to make sure the last section before the BSS is something that will never be empty. That's what makes sure that the final ALIGN does what we expect. -- Tom [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] Fix unbootable ARMv7 devices 2026-01-30 14:55 ` Tom Rini 2026-01-30 16:50 ` Sune Brian @ 2026-01-30 17:02 ` Sune Brian 1 sibling, 0 replies; 5+ messages in thread From: Sune Brian @ 2026-01-30 17:02 UTC (permalink / raw) To: Tom Rini; +Cc: u-boot On Fri, Jan 30, 2026 at 10:55 PM Tom Rini <trini@konsulko.com> wrote: > > On Fri, Jan 30, 2026 at 11:12:17AM +0800, Brian Sune wrote: > > > The linker script u-boot-spl.lds now > > is no longer aligned and -nodtb.bin ending shows > > the zeros are not 8 byte aligned. This result in > > the Makefile.xpl simply think the previous file > > is aligned and do not zero pad. simply fix the > > data align to 8 can ensure the -nodtb.bin is aligned, > > hence, the formation of u-boot-spl.bin properly align. > > > > Signed-off-by: Brian Sune <briansune@gmail.com> > > --- > > arch/arm/cpu/u-boot-spl.lds | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > This fixes your problem in that it results in the device tree being > aligned still, but doesn't solve the underlying problem of why there Hi Tom, Another follow up question here is even making the data node to 8 byte aligned will this create any harm or even fail case from first place? As for testing on a real platform it makes no difference at all. If "binman_sym_table" is empty then the previous node data is 8 byte aligned. Where "__u_boot_list" is also gated by 8 byte end aligned unless it could be empty while "binman_sym_table" does not. Just wondering and not really too good at these linker scripts. brian > were 4 extra bytes. Can you please try: > > diff --git a/arch/arm/cpu/u-boot-spl.lds b/arch/arm/cpu/u-boot-spl.lds > index c578c3ebf821..5f807323f856 100644 > --- a/arch/arm/cpu/u-boot-spl.lds > +++ b/arch/arm/cpu/u-boot-spl.lds > @@ -31,16 +31,16 @@ SECTIONS > *(.data*) > } > > - . = ALIGN(4); > - __u_boot_list : { > - KEEP(*(SORT(__u_boot_list*))); > - } > - > . = ALIGN(4); > .binman_sym_table : { > __binman_sym_start = .; > KEEP(*(SORT(.binman_sym*))); > __binman_sym_end = .; > + } > + > + . = ALIGN(4); > + __u_boot_list : { > + KEEP(*(SORT(__u_boot_list*))); > . = ALIGN(8); > } > > As the problem ends up being that when both of these are true: > - .binman_sym_table is empty of actual .binman_sym* symbols > - The inner '. = ALIGN(8);' increments the linker counter from the > previous '. = ALIGN(4);' (in other words we were not already 8b > aligned). > > The linker sets the type for this section to "NOBITS" which in turn > means that when we later call objcopy to create u-boot-spl-nodtb.bin we > get a mismatch between our expected size and actual size for creating > the -pad.bin file. > > -- > Tom ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-01-30 18:11 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-01-30 3:12 [PATCH v1] Fix unbootable ARMv7 devices Brian Sune 2026-01-30 14:55 ` Tom Rini 2026-01-30 16:50 ` Sune Brian 2026-01-30 18:10 ` Tom Rini 2026-01-30 17:02 ` Sune Brian
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.