diff mbox series

[next] board/friendlyarm/nanopi-neo: fix uboot partition size

Message ID tencent_C2D6061483906AA710B3001B277F4EE62606@qq.com
State Accepted
Headers show
Series [next] board/friendlyarm/nanopi-neo: fix uboot partition size | expand

Commit Message

Dong Wang Aug. 15, 2024, 5:28 p.m. UTC
This patch fixes the wrongly calculated uboot partition size in
genimage.cfg. The size should be 1016K, which is
1MB (typical partition start) - 8K(offset dictated by the bootrom).

Signed-off-by: Dong Wang <wangdong115@foxmail.com>
---
 board/friendlyarm/nanopi-neo/genimage.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Yann E. MORIN Aug. 15, 2024, 5:50 p.m. UTC | #1
Dong Wang, All,

Thanks for your contribution.

On 2024-08-16 01:28 +0800, Dong Wang spake thusly:
> This patch fixes the wrongly calculated uboot partition size in
> genimage.cfg. The size should be 1016K, which is
> 1MB (typical partition start) - 8K(offset dictated by the bootrom).

It seems you are using an old version of Buildroot, as the defconfig
and board files for nanopi_neo were removed with commit c0a44ba0dfbf
(configs/friendlyarm_nanopi_neo: drop defconfig), in August 2022, two
years ago.

If you are still using nanopi_neo and have access to that board, then
you are welcome to submit it again, of course!

Regards,
Yann E. MORIN.

> Signed-off-by: Dong Wang <wangdong115@foxmail.com>
> ---
>  board/friendlyarm/nanopi-neo/genimage.cfg | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/board/friendlyarm/nanopi-neo/genimage.cfg b/board/friendlyarm/nanopi-neo/genimage.cfg
> index ec78fd0e56..8d6bdd3295 100644
> --- a/board/friendlyarm/nanopi-neo/genimage.cfg
> +++ b/board/friendlyarm/nanopi-neo/genimage.cfg
> @@ -7,7 +7,7 @@ image sdcard.img {
>  		in-partition-table = false
>  		image = "u-boot-sunxi-with-spl.bin"
>  		offset = 8K
> -		size = 1000K # 1MB - 8KB(offset) - 16KB(GPT)
> +		size = 1016K # 1MB - 8KB(offset)
>  	}
>  
>  	partition rootfs {
> -- 
> 2.25.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Dong Wang Aug. 15, 2024, 5:58 p.m. UTC | #2
Hi Yann,

On 2024/8/16 01:50, Yann E. MORIN wrote:
> Dong Wang, All,
> 
> Thanks for your contribution.
> 
> On 2024-08-16 01:28 +0800, Dong Wang spake thusly:
>> This patch fixes the wrongly calculated uboot partition size in
>> genimage.cfg. The size should be 1016K, which is
>> 1MB (typical partition start) - 8K(offset dictated by the bootrom).
> 
> It seems you are using an old version of Buildroot, as the defconfig
> and board files for nanopi_neo were removed with commit c0a44ba0dfbf
> (configs/friendlyarm_nanopi_neo: drop defconfig), in August 2022, two
> years ago. >
> If you are still using nanopi_neo and have access to that board, then
> you are welcome to submit it again, of course!

I already did! See 
https://git.buildroot.net/buildroot/commit/?id=4265790541e925708364e1e86038bd2884eec3a5 


This is an follow up on the above commit to resolve Thomas's comments!

> 
> Regards,
> Yann E. MORIN.
> 
>> Signed-off-by: Dong Wang <wangdong115@foxmail.com>
>> ---
>>   board/friendlyarm/nanopi-neo/genimage.cfg | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/board/friendlyarm/nanopi-neo/genimage.cfg b/board/friendlyarm/nanopi-neo/genimage.cfg
>> index ec78fd0e56..8d6bdd3295 100644
>> --- a/board/friendlyarm/nanopi-neo/genimage.cfg
>> +++ b/board/friendlyarm/nanopi-neo/genimage.cfg
>> @@ -7,7 +7,7 @@ image sdcard.img {
>>   		in-partition-table = false
>>   		image = "u-boot-sunxi-with-spl.bin"
>>   		offset = 8K
>> -		size = 1000K # 1MB - 8KB(offset) - 16KB(GPT)
>> +		size = 1016K # 1MB - 8KB(offset)
>>   	}
>>   
>>   	partition rootfs {
>> -- 
>> 2.25.1
>>
>> _______________________________________________
>> buildroot mailing list
>> buildroot@buildroot.org
>> https://lists.buildroot.org/mailman/listinfo/buildroot
> 

Thanks!
Dong Wang
Yann E. MORIN Aug. 15, 2024, 6:14 p.m. UTC | #3
Darren, All,

On 2024-08-16 01:58 +0800, Darren Wang spake thusly:
> On 2024/8/16 01:50, Yann E. MORIN wrote:
[--SNIP--]
> > If you are still using nanopi_neo and have access to that board, then
> > you are welcome to submit it again, of course!
> I already did! See https://git.buildroot.net/buildroot/commit/?id=4265790541e925708364e1e86038bd2884eec3a5

Damned, I missed that it was so recent, and forgot to look it up on the
next branch. Sorry for the confusion. Thanks!

Regards,
Yann E. MORIN.
Yann E. MORIN Aug. 15, 2024, 6:19 p.m. UTC | #4
Dong Wang, All,

On 2024-08-16 01:28 +0800, Dong Wang spake thusly:
> This patch fixes the wrongly calculated uboot partition size in
> genimage.cfg. The size should be 1016K, which is
> 1MB (typical partition start) - 8K(offset dictated by the bootrom).
> 
> Signed-off-by: Dong Wang <wangdong115@foxmail.com>

Applied to next, thanks!

Again, sorry for the confusion.

Regards,
Yann E. MORIN.

> ---
>  board/friendlyarm/nanopi-neo/genimage.cfg | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/board/friendlyarm/nanopi-neo/genimage.cfg b/board/friendlyarm/nanopi-neo/genimage.cfg
> index ec78fd0e56..8d6bdd3295 100644
> --- a/board/friendlyarm/nanopi-neo/genimage.cfg
> +++ b/board/friendlyarm/nanopi-neo/genimage.cfg
> @@ -7,7 +7,7 @@ image sdcard.img {
>  		in-partition-table = false
>  		image = "u-boot-sunxi-with-spl.bin"
>  		offset = 8K
> -		size = 1000K # 1MB - 8KB(offset) - 16KB(GPT)
> +		size = 1016K # 1MB - 8KB(offset)
>  	}
>  
>  	partition rootfs {
> -- 
> 2.25.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Dong Wang Aug. 15, 2024, 6:22 p.m. UTC | #5
Yann,


On 2024/8/16 02:19, Yann E. MORIN wrote:
> Dong Wang, All,
> 
> On 2024-08-16 01:28 +0800, Dong Wang spake thusly:
>> This patch fixes the wrongly calculated uboot partition size in
>> genimage.cfg. The size should be 1016K, which is
>> 1MB (typical partition start) - 8K(offset dictated by the bootrom).
>>
>> Signed-off-by: Dong Wang <wangdong115@foxmail.com>
> 
> Applied to next, thanks!

Thanks a lot!

> 
> Again, sorry for the confusion.

My bad! I should have let you know in the first patch!

> 
> Regards,
> Yann E. MORIN.
> 
>> ---
>>   board/friendlyarm/nanopi-neo/genimage.cfg | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/board/friendlyarm/nanopi-neo/genimage.cfg b/board/friendlyarm/nanopi-neo/genimage.cfg
>> index ec78fd0e56..8d6bdd3295 100644
>> --- a/board/friendlyarm/nanopi-neo/genimage.cfg
>> +++ b/board/friendlyarm/nanopi-neo/genimage.cfg
>> @@ -7,7 +7,7 @@ image sdcard.img {
>>   		in-partition-table = false
>>   		image = "u-boot-sunxi-with-spl.bin"
>>   		offset = 8K
>> -		size = 1000K # 1MB - 8KB(offset) - 16KB(GPT)
>> +		size = 1016K # 1MB - 8KB(offset)
>>   	}
>>   
>>   	partition rootfs {
>> -- 
>> 2.25.1
>>
>> _______________________________________________
>> buildroot mailing list
>> buildroot@buildroot.org
>> https://lists.buildroot.org/mailman/listinfo/buildroot
> 

Best,
Dong Wang
Thomas Petazzoni Aug. 15, 2024, 7:50 p.m. UTC | #6
Hello,

On Fri, 16 Aug 2024 01:28:26 +0800
Dong Wang <wangdong115@foxmail.com> wrote:

> This patch fixes the wrongly calculated uboot partition size in
> genimage.cfg. The size should be 1016K, which is
> 1MB (typical partition start) - 8K(offset dictated by the bootrom).
> 
> Signed-off-by: Dong Wang <wangdong115@foxmail.com>
> ---
>  board/friendlyarm/nanopi-neo/genimage.cfg | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/board/friendlyarm/nanopi-neo/genimage.cfg b/board/friendlyarm/nanopi-neo/genimage.cfg
> index ec78fd0e56..8d6bdd3295 100644
> --- a/board/friendlyarm/nanopi-neo/genimage.cfg
> +++ b/board/friendlyarm/nanopi-neo/genimage.cfg
> @@ -7,7 +7,7 @@ image sdcard.img {
>  		in-partition-table = false
>  		image = "u-boot-sunxi-with-spl.bin"
>  		offset = 8K
> -		size = 1000K # 1MB - 8KB(offset) - 16KB(GPT)
> +		size = 1016K # 1MB - 8KB(offset)

Actually, does this size argument really make sense? This space will
automatically take the size of the "u-boot-sunxi-with-spl.bin" file I
believe. Or is it needed to make sure that the next partition doesn't
start before 1 MB?

Why is it important that the size is 1MB - 8KB, and not 1MB or 2MB ?

Thomas
Yann E. MORIN Aug. 15, 2024, 8 p.m. UTC | #7
Thomas, All,

On 2024-08-15 21:50 +0200, Thomas Petazzoni via buildroot spake thusly:
> On Fri, 16 Aug 2024 01:28:26 +0800
> Dong Wang <wangdong115@foxmail.com> wrote:
> > This patch fixes the wrongly calculated uboot partition size in
> > genimage.cfg. The size should be 1016K, which is
> > 1MB (typical partition start) - 8K(offset dictated by the bootrom).
[--SNIP--]
> > -		size = 1000K # 1MB - 8KB(offset) - 16KB(GPT)
> > +		size = 1016K # 1MB - 8KB(offset)
> Actually, does this size argument really make sense? This space will
> automatically take the size of the "u-boot-sunxi-with-spl.bin" file I
> believe. Or is it needed to make sure that the next partition doesn't
> start before 1 MB?
> 
> Why is it important that the size is 1MB - 8KB, and not 1MB or 2MB ?

The above has two effects:
  - ensure the uboot image is not bigger than the allocated space,
  - the filesystem image (rootfs) is aligned to a 1MiB boundary.

The latter could be achieved by setting offset=1MiB (or 2MiB or
whatever). I'm not sure how genimage would handle the case where the
uboot image would be too big that the offset of the next partition could
not be honored...

Regards,
Yann E. MORIN.
Dong Wang Aug. 16, 2024, 4:15 p.m. UTC | #8
Yann, All,

On 2024/8/16 04:00, Yann E. MORIN wrote:
> Thomas, All,
> 
> On 2024-08-15 21:50 +0200, Thomas Petazzoni via buildroot spake thusly:
>> On Fri, 16 Aug 2024 01:28:26 +0800
>> Dong Wang <wangdong115@foxmail.com> wrote:
>>> This patch fixes the wrongly calculated uboot partition size in
>>> genimage.cfg. The size should be 1016K, which is
>>> 1MB (typical partition start) - 8K(offset dictated by the bootrom).
> [--SNIP--]
>>> -		size = 1000K # 1MB - 8KB(offset) - 16KB(GPT)
>>> +		size = 1016K # 1MB - 8KB(offset)
>> Actually, does this size argument really make sense? This space will
>> automatically take the size of the "u-boot-sunxi-with-spl.bin" file I
>> believe. Or is it needed to make sure that the next partition doesn't
>> start before 1 MB?
>>
>> Why is it important that the size is 1MB - 8KB, and not 1MB or 2MB ?
> 
> The above has two effects:
>    - ensure the uboot image is not bigger than the allocated space,
>    - the filesystem image (rootfs) is aligned to a 1MiB boundary.
> 
> The latter could be achieved by setting offset=1MiB (or 2MiB or
> whatever). I'm not sure how genimage would handle the case where the
> uboot image would be too big that the offset of the next partition could
> not be honored...

 From the doc of the genimage project, yes, sanity checks are done so 
that no partitions overlap.

https://github.com/pengutronix/genimage/blob/v18/README.rst#the-image-section

"The partition must not overlap any other partition, or the areas 
occupied by the partition table."

I also verified this behavior by changing the offset to a smaller one 
(rootfs offset=128K < uboot image size ~500K). genimage.sh would fail 
with the log:

ERROR: hdimage(sdcard.img): partition rootfs (offset 0x20000, size 
0x3c00000) overlaps previous partition u-boot (offset 0x2000, size 0x7cca8)

Maybe I can send another patch to use offset=1M for rootfs?

> 
> Regards,
> Yann E. MORIN.
> 

Thanks,
Dong
diff mbox series

Patch

diff --git a/board/friendlyarm/nanopi-neo/genimage.cfg b/board/friendlyarm/nanopi-neo/genimage.cfg
index ec78fd0e56..8d6bdd3295 100644
--- a/board/friendlyarm/nanopi-neo/genimage.cfg
+++ b/board/friendlyarm/nanopi-neo/genimage.cfg
@@ -7,7 +7,7 @@  image sdcard.img {
 		in-partition-table = false
 		image = "u-boot-sunxi-with-spl.bin"
 		offset = 8K
-		size = 1000K # 1MB - 8KB(offset) - 16KB(GPT)
+		size = 1016K # 1MB - 8KB(offset)
 	}
 
 	partition rootfs {