public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/2] sunxi: Fix boot of Cubietruk and al.
@ 2017-10-19 14:04 Maxime Ripard
  2017-10-19 14:04 ` [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check Maxime Ripard
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Maxime Ripard @ 2017-10-19 14:04 UTC (permalink / raw)
  To: u-boot

Hi

Most featureful boards, such as the Cubietruck, have been broken since
the release 2017.09 (the two variants of the Olinuxino-Lime2 and the
cubietruck at least, possibly more since then).

This is due to a size increase of the binary that will trip us across
the size we've been using in our default configuration since forever,
and widely distributed through the u-boot-sunxi-with-spl.bin file.

We would have several ways to work around it. The first one would be
to just increase the offset of the environment. However, since it
would break all the environments of our users and possibly the custom
partition scheme that they would have created, it doesn't really seem
like a smart move.

The second one would be to move the environment to a filesystem file,
which would also break all the existing users. This can be envisionned
as a long term fix though.

Another one would be to start trimming down a bit our enabled options
in order to reduce the size and to gain some extra space for users
customisations. However, this will always result in pointless and
endless discussions, so let's move away from that.

The final one that has been implemented would be to just build U-Boot
using thumb2 to push back the issue until hopefully I'm no longer
maintainer or the switch to the env filesystem would have been done.

I've also added a patch to make sure that the compilation breaks and
that we can notice.

Maxime


Maxime Ripard (2):
  sunxi: binman: Add U-Boot binary size check
  sunxi: Enable THUMB build for the U-Boot binary

 arch/arm/Kconfig               |  1 +
 arch/arm/dts/sunxi-u-boot.dtsi | 11 +++++++++++
 2 files changed, 12 insertions(+)

-- 
2.14.2

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check
  2017-10-19 14:04 [U-Boot] [PATCH v2 0/2] sunxi: Fix boot of Cubietruk and al Maxime Ripard
@ 2017-10-19 14:04 ` Maxime Ripard
  2017-10-19 14:36   ` Bin Meng
                     ` (2 more replies)
  2017-10-19 14:04 ` [U-Boot] [PATCH 2/2] sunxi: Enable THUMB build for the U-Boot binary Maxime Ripard
  2017-10-19 22:11 ` [U-Boot] [PATCH v2 0/2] sunxi: Fix boot of Cubietruk and al André Przywara
  2 siblings, 3 replies; 10+ messages in thread
From: Maxime Ripard @ 2017-10-19 14:04 UTC (permalink / raw)
  To: u-boot

The U-boot binary may trip over its actual allocated size in the storage.
In such a case, the environment will not be readable anymore (because
corrupted when the new image was flashed), and any attempt at using saveenv
to reconstruct the environment will result in a corrupted U-boot binary.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/dts/sunxi-u-boot.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
index 5adfd9bca2ec..b44660e8d37e 100644
--- a/arch/arm/dts/sunxi-u-boot.dtsi
+++ b/arch/arm/dts/sunxi-u-boot.dtsi
@@ -1,5 +1,13 @@
 #include <config.h>
 
+/*
+ * This is the maximum size the U-boot binary can be, which is
+ * basically the start of the environment, minus the (padded) size of
+ * the SPL), minus the offset at which the generated file is supposed
+ * to be flashed in the MMC.
+ */
+#define UBOOT_MAX_SIZE	(CONFIG_ENV_OFFSET - CONFIG_SPL_PAD_TO - (8 << 10))
+
 / {
 	binman {
 		filename = "u-boot-sunxi-with-spl.bin";
@@ -8,6 +16,9 @@
 			filename = "spl/sunxi-spl.bin";
 		};
 		u-boot-img {
+#ifdef CONFIG_MMC
+			size = <UBOOT_MAX_SIZE>;
+#endif
 			pos = <CONFIG_SPL_PAD_TO>;
 		};
 	};
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 2/2] sunxi: Enable THUMB build for the U-Boot binary
  2017-10-19 14:04 [U-Boot] [PATCH v2 0/2] sunxi: Fix boot of Cubietruk and al Maxime Ripard
  2017-10-19 14:04 ` [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check Maxime Ripard
@ 2017-10-19 14:04 ` Maxime Ripard
  2017-10-19 22:11 ` [U-Boot] [PATCH v2 0/2] sunxi: Fix boot of Cubietruk and al André Przywara
  2 siblings, 0 replies; 10+ messages in thread
From: Maxime Ripard @ 2017-10-19 14:04 UTC (permalink / raw)
  To: u-boot

We start to get to the limit of our main U-Boot binary size (with some
boards even crossing it). Enable its build using thumb2 to get some extra
room.

Suggested-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 64e0ee43f112..83b7aa51dc2c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -698,6 +698,7 @@ config ARCH_SUNXI
 	select SPL_SYS_MALLOC_SIMPLE if SPL
 	select SYS_NS16550
 	select SPL_SYS_THUMB_BUILD if !ARM64
+	select SYS_THUMB_BUILD if !ARM64
 	select USB if DISTRO_DEFAULTS
 	select USB_STORAGE if DISTRO_DEFAULTS
 	select USB_KEYBOARD if DISTRO_DEFAULTS
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check
  2017-10-19 14:04 ` [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check Maxime Ripard
@ 2017-10-19 14:36   ` Bin Meng
  2017-10-19 15:07   ` Andre Przywara
  2017-11-02 15:53   ` Frank Kunz
  2 siblings, 0 replies; 10+ messages in thread
From: Bin Meng @ 2017-10-19 14:36 UTC (permalink / raw)
  To: u-boot

On Thu, Oct 19, 2017 at 10:04 PM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> The U-boot binary may trip over its actual allocated size in the storage.
> In such a case, the environment will not be readable anymore (because
> corrupted when the new image was flashed), and any attempt at using saveenv
> to reconstruct the environment will result in a corrupted U-boot binary.
>

nits: U-boot -> U-Boot

Please fix this globally in this commit.

> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  arch/arm/dts/sunxi-u-boot.dtsi | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
> index 5adfd9bca2ec..b44660e8d37e 100644
> --- a/arch/arm/dts/sunxi-u-boot.dtsi
> +++ b/arch/arm/dts/sunxi-u-boot.dtsi
> @@ -1,5 +1,13 @@
>  #include <config.h>
>
> +/*
> + * This is the maximum size the U-boot binary can be, which is
> + * basically the start of the environment, minus the (padded) size of
> + * the SPL), minus the offset at which the generated file is supposed
> + * to be flashed in the MMC.
> + */
> +#define UBOOT_MAX_SIZE (CONFIG_ENV_OFFSET - CONFIG_SPL_PAD_TO - (8 << 10))
> +
>  / {
>         binman {
>                 filename = "u-boot-sunxi-with-spl.bin";
> @@ -8,6 +16,9 @@
>                         filename = "spl/sunxi-spl.bin";
>                 };
>                 u-boot-img {
> +#ifdef CONFIG_MMC
> +                       size = <UBOOT_MAX_SIZE>;
> +#endif
>                         pos = <CONFIG_SPL_PAD_TO>;
>                 };
>         };
> --


Regards,
Bin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check
  2017-10-19 14:04 ` [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check Maxime Ripard
  2017-10-19 14:36   ` Bin Meng
@ 2017-10-19 15:07   ` Andre Przywara
  2017-11-02 15:53   ` Frank Kunz
  2 siblings, 0 replies; 10+ messages in thread
From: Andre Przywara @ 2017-10-19 15:07 UTC (permalink / raw)
  To: u-boot

Hi,

On 19/10/17 15:04, Maxime Ripard wrote:
> The U-boot binary may trip over its actual allocated size in the storage.
> In such a case, the environment will not be readable anymore (because
> corrupted when the new image was flashed), and any attempt at using saveenv
> to reconstruct the environment will result in a corrupted U-boot binary.

Merci beaucoup for that v2 series!

> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  arch/arm/dts/sunxi-u-boot.dtsi | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
> index 5adfd9bca2ec..b44660e8d37e 100644
> --- a/arch/arm/dts/sunxi-u-boot.dtsi
> +++ b/arch/arm/dts/sunxi-u-boot.dtsi
> @@ -1,5 +1,13 @@
>  #include <config.h>
>  
> +/*
> + * This is the maximum size the U-boot binary can be, which is
> + * basically the start of the environment, minus the (padded) size of
> + * the SPL), minus the offset at which the generated file is supposed
> + * to be flashed in the MMC.
> + */
> +#define UBOOT_MAX_SIZE	(CONFIG_ENV_OFFSET - CONFIG_SPL_PAD_TO - (8 << 10))

Just bikeshedding: Can't we use:
	(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR << 9)
for the last two expressions?

But that's just a nit, so:

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre.

> +
>  / {
>  	binman {
>  		filename = "u-boot-sunxi-with-spl.bin";
> @@ -8,6 +16,9 @@
>  			filename = "spl/sunxi-spl.bin";
>  		};
>  		u-boot-img {
> +#ifdef CONFIG_MMC
> +			size = <UBOOT_MAX_SIZE>;
> +#endif
>  			pos = <CONFIG_SPL_PAD_TO>;
>  		};
>  	};
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH v2 0/2] sunxi: Fix boot of Cubietruk and al.
  2017-10-19 14:04 [U-Boot] [PATCH v2 0/2] sunxi: Fix boot of Cubietruk and al Maxime Ripard
  2017-10-19 14:04 ` [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check Maxime Ripard
  2017-10-19 14:04 ` [U-Boot] [PATCH 2/2] sunxi: Enable THUMB build for the U-Boot binary Maxime Ripard
@ 2017-10-19 22:11 ` André Przywara
  2 siblings, 0 replies; 10+ messages in thread
From: André Przywara @ 2017-10-19 22:11 UTC (permalink / raw)
  To: u-boot

Hi Maxime,

On 19/10/17 15:04, Maxime Ripard wrote:

....

> The final one that has been implemented would be to just build U-Boot
> using thumb2 to push back the issue until hopefully I'm no longer
> maintainer or the switch to the env filesystem would have been done.
> 
> I've also added a patch to make sure that the compilation breaks and
> that we can notice.

Can you please swap the patches? So that we get the fix before we break
the build? This looks better in bisecting and buildman.

Cheers,
Andre.

> 
> Maxime
> 
> 
> Maxime Ripard (2):
>   sunxi: binman: Add U-Boot binary size check
>   sunxi: Enable THUMB build for the U-Boot binary
> 
>  arch/arm/Kconfig               |  1 +
>  arch/arm/dts/sunxi-u-boot.dtsi | 11 +++++++++++
>  2 files changed, 12 insertions(+)
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check
  2017-10-19 14:04 ` [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check Maxime Ripard
  2017-10-19 14:36   ` Bin Meng
  2017-10-19 15:07   ` Andre Przywara
@ 2017-11-02 15:53   ` Frank Kunz
  2017-11-03  8:42     ` Maxime Ripard
  2 siblings, 1 reply; 10+ messages in thread
From: Frank Kunz @ 2017-11-02 15:53 UTC (permalink / raw)
  To: u-boot

Am Donnerstag, 19. Oktober 2017, 16:04:18 CET schrieb Maxime Ripard:
> The U-boot binary may trip over its actual allocated size in the storage.
> In such a case, the environment will not be readable anymore (because
> corrupted when the new image was flashed), and any attempt at using saveenv
> to reconstruct the environment will result in a corrupted U-boot binary.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  arch/arm/dts/sunxi-u-boot.dtsi | 11 +++++++++++
>  1 file changed, 11 insertions(+)

Hello,

I found that this patch causes the sunxi-fel tool to fail with:

sunxi-fel uboot u-boot-sunxi-with-spl.bin
U-Boot image data size mismatch: expected 516032, got 389212

Is there a patch for the sunxi tools missing?

Br,
Frank

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check
  2017-11-02 15:53   ` Frank Kunz
@ 2017-11-03  8:42     ` Maxime Ripard
  2017-11-03 17:01       ` Frank Kunz
  0 siblings, 1 reply; 10+ messages in thread
From: Maxime Ripard @ 2017-11-03  8:42 UTC (permalink / raw)
  To: u-boot

Hi Frank,

On Thu, Nov 02, 2017 at 04:53:54PM +0100, Frank Kunz wrote:
> Am Donnerstag, 19. Oktober 2017, 16:04:18 CET schrieb Maxime Ripard:
> > The U-boot binary may trip over its actual allocated size in the storage.
> > In such a case, the environment will not be readable anymore (because
> > corrupted when the new image was flashed), and any attempt at using saveenv
> > to reconstruct the environment will result in a corrupted U-boot binary.
> > 
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > ---
> >  arch/arm/dts/sunxi-u-boot.dtsi | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
>
> I found that this patch causes the sunxi-fel tool to fail with:
> 
> sunxi-fel uboot u-boot-sunxi-with-spl.bin
> U-Boot image data size mismatch: expected 516032, got 389212
> 
> Is there a patch for the sunxi tools missing?

No, because no one reported it so far.

Can you test with:
http://code.bulix.org/mb0ic7-221765?raw

You'll need the zlib development files installed.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171103/ecdda46c/attachment.sig>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check
  2017-11-03  8:42     ` Maxime Ripard
@ 2017-11-03 17:01       ` Frank Kunz
  2017-11-06 14:35         ` Maxime Ripard
  0 siblings, 1 reply; 10+ messages in thread
From: Frank Kunz @ 2017-11-03 17:01 UTC (permalink / raw)
  To: u-boot

Am Freitag, 3. November 2017, 09:42:44 CET schrieb Maxime Ripard:
> Hi Frank,
> 
> On Thu, Nov 02, 2017 at 04:53:54PM +0100, Frank Kunz wrote:
> > Am Donnerstag, 19. Oktober 2017, 16:04:18 CET schrieb Maxime Ripard:
> > > The U-boot binary may trip over its actual allocated size in the
> > > storage.
> > > In such a case, the environment will not be readable anymore (because
> > > corrupted when the new image was flashed), and any attempt at using
> > > saveenv
> > > to reconstruct the environment will result in a corrupted U-boot binary.
> > > 
> > > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > > ---
> > > 
> > >  arch/arm/dts/sunxi-u-boot.dtsi | 11 +++++++++++
> > >  1 file changed, 11 insertions(+)
> > 
> > I found that this patch causes the sunxi-fel tool to fail with:
> > 
> > sunxi-fel uboot u-boot-sunxi-with-spl.bin
> > U-Boot image data size mismatch: expected 516032, got 389212
> > 
> > Is there a patch for the sunxi tools missing?
> 
> No, because no one reported it so far.
> 
> Can you test with:
> http://code.bulix.org/mb0ic7-221765?raw
> 

That works.

Tested-by: Frank Kunz <mailinglists@kunz-im-inter.net>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check
  2017-11-03 17:01       ` Frank Kunz
@ 2017-11-06 14:35         ` Maxime Ripard
  0 siblings, 0 replies; 10+ messages in thread
From: Maxime Ripard @ 2017-11-06 14:35 UTC (permalink / raw)
  To: u-boot

On Fri, Nov 03, 2017 at 06:01:20PM +0100, Frank Kunz wrote:
> Am Freitag, 3. November 2017, 09:42:44 CET schrieb Maxime Ripard:
> > Hi Frank,
> > 
> > On Thu, Nov 02, 2017 at 04:53:54PM +0100, Frank Kunz wrote:
> > > Am Donnerstag, 19. Oktober 2017, 16:04:18 CET schrieb Maxime Ripard:
> > > > The U-boot binary may trip over its actual allocated size in the
> > > > storage.
> > > > In such a case, the environment will not be readable anymore (because
> > > > corrupted when the new image was flashed), and any attempt at using
> > > > saveenv
> > > > to reconstruct the environment will result in a corrupted U-boot binary.
> > > > 
> > > > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > > > ---
> > > > 
> > > >  arch/arm/dts/sunxi-u-boot.dtsi | 11 +++++++++++
> > > >  1 file changed, 11 insertions(+)
> > > 
> > > I found that this patch causes the sunxi-fel tool to fail with:
> > > 
> > > sunxi-fel uboot u-boot-sunxi-with-spl.bin
> > > U-Boot image data size mismatch: expected 516032, got 389212
> > > 
> > > Is there a patch for the sunxi tools missing?
> > 
> > No, because no one reported it so far.
> > 
> > Can you test with:
> > http://code.bulix.org/mb0ic7-221765?raw
> > 
> 
> That works.
> 
> Tested-by: Frank Kunz <mailinglists@kunz-im-inter.net>

I created a pull request for sunxi-tools to fix the issue. Thanks for
the test, and sorry for the bug.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171106/c7466c1b/attachment.sig>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-11-06 14:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-19 14:04 [U-Boot] [PATCH v2 0/2] sunxi: Fix boot of Cubietruk and al Maxime Ripard
2017-10-19 14:04 ` [U-Boot] [PATCH 1/2] sunxi: binman: Add U-Boot binary size check Maxime Ripard
2017-10-19 14:36   ` Bin Meng
2017-10-19 15:07   ` Andre Przywara
2017-11-02 15:53   ` Frank Kunz
2017-11-03  8:42     ` Maxime Ripard
2017-11-03 17:01       ` Frank Kunz
2017-11-06 14:35         ` Maxime Ripard
2017-10-19 14:04 ` [U-Boot] [PATCH 2/2] sunxi: Enable THUMB build for the U-Boot binary Maxime Ripard
2017-10-19 22:11 ` [U-Boot] [PATCH v2 0/2] sunxi: Fix boot of Cubietruk and al André Przywara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox