mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] Load PBL into SRAM
@ 2014-01-30 15:43 David Vincent
  2014-01-31  6:51 ` Sascha Hauer
  0 siblings, 1 reply; 14+ messages in thread
From: David Vincent @ 2014-01-30 15:43 UTC (permalink / raw)
  To: barebox; +Cc: David Vincent

This allows to load all the lowlevel init code, including the
uncompressor, inside SRAM and not just the bare init part. This is
useful when pbl is used as a first-stage bootloader but is loaded by an
external ROM code.

Signed-off-by: David Vincent <freesilicon@gmail.com>
---
 arch/arm/lib/pbl.lds.S            |    2 +-
 common/Kconfig                    |   13 ++++++++++++-
 include/asm-generic/barebox.lds.h |    3 +--
 include/asm-generic/pbl.lds.h     |   15 +++++++++++++++
 pbl/Kconfig                       |    7 +++++++
 5 files changed, 36 insertions(+), 4 deletions(-)
 create mode 100644 include/asm-generic/pbl.lds.h

diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
index 0954c89..78b39a6 100644
--- a/arch/arm/lib/pbl.lds.S
+++ b/arch/arm/lib/pbl.lds.S
@@ -21,7 +21,7 @@
  *
  */
 #include <sizes.h>
-#include <asm-generic/barebox.lds.h>
+#include <asm-generic/pbl.lds.h>
 #include <asm-generic/memory_layout.h>
 
 #ifdef CONFIG_PBL_RELOCATABLE
diff --git a/common/Kconfig b/common/Kconfig
index 8af7ec1..38ed619 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -146,14 +146,25 @@ config BAREBOX_MAX_IMAGE_SIZE
 	  Define the maximum size of barebox
 
 config BAREBOX_MAX_BARE_INIT_SIZE
+	depends on !LOAD_PBL_SRAM
 	prompt "Maximum bare_init size"
 	hex
 	default 0xffffffff
 	help
 	  Define the maximum size of bare_init
-	  this will allow your bare_init will fit in SRAM as example
+	  this will allow your bare_init to fit in SRAM as example
 	  ARCH can overwrite it via ARCH_BAREBOX_MAX_BARE_INIT_SIZE
 
+config BAREBOX_MAX_PBL_SIZE
+	depends on PBL_IMAGE && LOAD_PBL_SRAM
+	prompt "Maximum pre-bootloader size"
+	hex
+	default 0xffffffff
+	help
+	  Define the maximum size of pbl
+	  this will allow your pbl to fit in SRAM as example
+	  ARCH can overwrite it via ARCH_BAREBOX_MAX_PBL_SIZE
+
 config HAVE_CONFIGURABLE_MEMORY_LAYOUT
 	bool
 
diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
index 6d3a69e..18f3cd5 100644
--- a/include/asm-generic/barebox.lds.h
+++ b/include/asm-generic/barebox.lds.h
@@ -65,5 +65,4 @@ CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE < CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
 #define BAREBOX_BARE_INIT_SIZE					\
 	_barebox_bare_init_size = __bare_init_end - _text;	\
 	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
-	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \
-
+	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE))
diff --git a/include/asm-generic/pbl.lds.h b/include/asm-generic/pbl.lds.h
new file mode 100644
index 0000000..43149b7
--- /dev/null
+++ b/include/asm-generic/pbl.lds.h
@@ -0,0 +1,15 @@
+#include <asm-generic/barebox.lds.h>
+
+#if defined(CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE) && \
+CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE < CONFIG_BAREBOX_MAX_PBL_SIZE
+#define MAX_PBL_SIZE CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE
+#else
+#define MAX_PBL_SIZE CONFIG_BAREBOX_MAX_PBL_SIZE
+#endif
+
+#include <linux/stringify.h>
+#define BAREBOX_PBL_SIZE					\
+	_barebox_pbl_size = __bss_start - _text;	\
+	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, "Barebox pbl size > ") \
+	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, __stringify(MAX_PBL_SIZE))
+
diff --git a/pbl/Kconfig b/pbl/Kconfig
index dc31357..1edc2d1 100644
--- a/pbl/Kconfig
+++ b/pbl/Kconfig
@@ -34,6 +34,13 @@ config PBL_FORCE_PIGGYDATA_COPY
 
 if PBL_IMAGE
 
+config LOAD_PBL_SRAM
+	bool "Load pbl in SRAM"
+	help
+	  Load the whole content of the pbl binary into SRAM. This is useful if you
+	  use the pbl as a first stage bootloader but cannot load the whole binary
+	  at the same time.
+
 config PBL_RELOCATABLE
 	depends on ARM
 	bool "relocatable pbl image"
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Load PBL into SRAM
  2014-01-30 15:43 [PATCH] Load PBL into SRAM David Vincent
@ 2014-01-31  6:51 ` Sascha Hauer
  0 siblings, 0 replies; 14+ messages in thread
From: Sascha Hauer @ 2014-01-31  6:51 UTC (permalink / raw)
  To: David Vincent; +Cc: barebox

Hi David,

On Thu, Jan 30, 2014 at 04:43:46PM +0100, David Vincent wrote:
> This allows to load all the lowlevel init code, including the
> uncompressor, inside SRAM and not just the bare init part. This is
> useful when pbl is used as a first-stage bootloader but is loaded by an
> external ROM code.

I do not understand this patch. Is there something missing in it?

> +#include <linux/stringify.h>
> +#define BAREBOX_PBL_SIZE					\
> +	_barebox_pbl_size = __bss_start - _text;	\
> +	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, "Barebox pbl size > ") \
> +	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, __stringify(MAX_PBL_SIZE))

BAREBOX_PBL_SIZE is defined but unused.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Load PBL into SRAM
  2014-02-05 15:45           ` Sascha Hauer
@ 2014-02-20 16:32             ` David Vincent
  0 siblings, 0 replies; 14+ messages in thread
From: David Vincent @ 2014-02-20 16:32 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Sorry to come back on this subject, but I just synced with the
mainline and I noticed that the patch was not fully applied. It was
missing the part

diff --git a/pbl/Kconfig b/pbl/Kconfig
index dc31357..1edc2d1 100644
--- a/pbl/Kconfig
+++ b/pbl/Kconfig
@@ -34,6 +34,13 @@ config PBL_FORCE_PIGGYDATA_COPY

 if PBL_IMAGE

+config LOAD_PBL_SRAM
+       bool "Load pbl in SRAM"
+       help
+         Load the whole content of the pbl binary into SRAM. This is
useful if you
+         use the pbl as a first stage bootloader but cannot load the
whole binary
+         at the same time.
+
 config PBL_RELOCATABLE
        depends on ARM
        bool "relocatable pbl image"

which is needed to make everything work. So should I provide a new
patch containing only this correction on the mainline ?

Best regards,
David

2014-02-05 16:45 GMT+01:00 Sascha Hauer <s.hauer@pengutronix.de>:
> On Wed, Feb 05, 2014 at 01:48:45PM +0100, David Vincent wrote:
>> Due to the flow of answers, I'm a little lost... What is the status of
>> this submission, should I resend it, put more work into it or lose it
>> ?
>
> The latest version looks fine. I applied it now.
>
> Sascha
>
> --
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Load PBL into SRAM
  2014-02-05 12:48         ` David Vincent
@ 2014-02-05 15:45           ` Sascha Hauer
  2014-02-20 16:32             ` David Vincent
  0 siblings, 1 reply; 14+ messages in thread
From: Sascha Hauer @ 2014-02-05 15:45 UTC (permalink / raw)
  To: David Vincent; +Cc: barebox

On Wed, Feb 05, 2014 at 01:48:45PM +0100, David Vincent wrote:
> Due to the flow of answers, I'm a little lost... What is the status of
> this submission, should I resend it, put more work into it or lose it
> ?

The latest version looks fine. I applied it now.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Load PBL into SRAM
  2014-02-05  8:00       ` Sascha Hauer
@ 2014-02-05 12:48         ` David Vincent
  2014-02-05 15:45           ` Sascha Hauer
  0 siblings, 1 reply; 14+ messages in thread
From: David Vincent @ 2014-02-05 12:48 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Due to the flow of answers, I'm a little lost... What is the status of
this submission, should I resend it, put more work into it or lose it
?

Thanks in advance,
David

2014-02-05 Sascha Hauer <s.hauer@pengutronix.de>:
> On Tue, Feb 04, 2014 at 08:49:55AM +0100, David Vincent wrote:
>> 2014-02-04 Sascha Hauer <s.hauer@pengutronix.de>:
>> > On Tue, Feb 04, 2014 at 04:56:25AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
>> >> On 10:06 Fri 31 Jan     , David Vincent wrote:
>> >> > This allows to load all the lowlevel init code, including the
>> >> > uncompressor, inside SRAM and not just the bare init part. This is
>> >> > useful when pbl is used as a first-stage bootloader but is loaded by an
>> >> > external firmware.
>> >> >
>> >> > Signed-off-by: David Vincent <freesilicon@gmail.com>
>> >> > ---
>> >> >  arch/arm/lib/pbl.lds.S            |    4 ++--
>> >> >  common/Kconfig                    |   16 ++++++++++++++--
>> >> >  include/asm-generic/barebox.lds.h |   14 +++++++++++++-
>> >> >  pbl/Kconfig                       |    7 +++++++
>> >> >  4 files changed, 36 insertions(+), 5 deletions(-)
>> >> >
>> >> > diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
>> >> > index 0954c89..34c0cb3 100644
>> >> > --- a/arch/arm/lib/pbl.lds.S
>> >> > +++ b/arch/arm/lib/pbl.lds.S
>> >> > @@ -50,11 +50,11 @@ SECTIONS
>> >> >             *(.text*)
>> >> >     }
>> >> >
>> >> > +   BAREBOX_PBL_SIZE
>> >> > +
>> >> >     /* Discard unwind if enable in barebox */
>> >> >     /DISCARD/ : { *(.ARM.ex*) }
>> >> >
>> >> > -   BAREBOX_BARE_INIT_SIZE
>> >> > -
>> >>
>> >> nack you change the binary format you can add an information but can not
>> >> change the format
>> >
>> > I don't think the format is changed here. It shouldn't matter where the
>> > /DISCARD/ is, right? Nevertheless the patch looks more obvious if just
>> > the line is changed, not its position.
>> >
>> >> >  #include <linux/stringify.h>
>> >> >  /* use 2 ASSERT because ld can not accept '"size" "10"' format */
>> >> >  #define BAREBOX_BARE_INIT_SIZE                                     \
>> >> >     _barebox_bare_init_size = __bare_init_end - _text;      \
>> >> >     ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
>> >> > -   ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \
>> >> > +   ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE))
>> >> different patch
>> >
>> > This just removes the trailing '\' which is necessary here.
>>
>> It isn't obvious for me why the trailing '\' is necessary but you know
>> better than me so I will put it back and add one on the next
>> definition.
>
> I wasn't clear. What I meant is that it's necessary to remove the
> whitespace. But as said, I misread the patch anyway.
>
> Sascha
>
> --
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Load PBL into SRAM
  2014-02-04  7:49     ` David Vincent
@ 2014-02-05  8:00       ` Sascha Hauer
  2014-02-05 12:48         ` David Vincent
  0 siblings, 1 reply; 14+ messages in thread
From: Sascha Hauer @ 2014-02-05  8:00 UTC (permalink / raw)
  To: David Vincent; +Cc: barebox

On Tue, Feb 04, 2014 at 08:49:55AM +0100, David Vincent wrote:
> 2014-02-04 Sascha Hauer <s.hauer@pengutronix.de>:
> > On Tue, Feb 04, 2014 at 04:56:25AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> >> On 10:06 Fri 31 Jan     , David Vincent wrote:
> >> > This allows to load all the lowlevel init code, including the
> >> > uncompressor, inside SRAM and not just the bare init part. This is
> >> > useful when pbl is used as a first-stage bootloader but is loaded by an
> >> > external firmware.
> >> >
> >> > Signed-off-by: David Vincent <freesilicon@gmail.com>
> >> > ---
> >> >  arch/arm/lib/pbl.lds.S            |    4 ++--
> >> >  common/Kconfig                    |   16 ++++++++++++++--
> >> >  include/asm-generic/barebox.lds.h |   14 +++++++++++++-
> >> >  pbl/Kconfig                       |    7 +++++++
> >> >  4 files changed, 36 insertions(+), 5 deletions(-)
> >> >
> >> > diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
> >> > index 0954c89..34c0cb3 100644
> >> > --- a/arch/arm/lib/pbl.lds.S
> >> > +++ b/arch/arm/lib/pbl.lds.S
> >> > @@ -50,11 +50,11 @@ SECTIONS
> >> >             *(.text*)
> >> >     }
> >> >
> >> > +   BAREBOX_PBL_SIZE
> >> > +
> >> >     /* Discard unwind if enable in barebox */
> >> >     /DISCARD/ : { *(.ARM.ex*) }
> >> >
> >> > -   BAREBOX_BARE_INIT_SIZE
> >> > -
> >>
> >> nack you change the binary format you can add an information but can not
> >> change the format
> >
> > I don't think the format is changed here. It shouldn't matter where the
> > /DISCARD/ is, right? Nevertheless the patch looks more obvious if just
> > the line is changed, not its position.
> >
> >> >  #include <linux/stringify.h>
> >> >  /* use 2 ASSERT because ld can not accept '"size" "10"' format */
> >> >  #define BAREBOX_BARE_INIT_SIZE                                     \
> >> >     _barebox_bare_init_size = __bare_init_end - _text;      \
> >> >     ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
> >> > -   ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \
> >> > +   ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE))
> >> different patch
> >
> > This just removes the trailing '\' which is necessary here.
> 
> It isn't obvious for me why the trailing '\' is necessary but you know
> better than me so I will put it back and add one on the next
> definition.

I wasn't clear. What I meant is that it's necessary to remove the
whitespace. But as said, I misread the patch anyway.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH] Load PBL into SRAM
@ 2014-02-04  7:53 David Vincent
  0 siblings, 0 replies; 14+ messages in thread
From: David Vincent @ 2014-02-04  7:53 UTC (permalink / raw)
  To: barebox; +Cc: David Vincent

This allows to load all the lowlevel init code, including the
uncompressor, inside SRAM and not just the bare init part. This is
useful when pbl is used as a first-stage bootloader but is loaded by an
external firmware.

Signed-off-by: David Vincent <freesilicon@gmail.com>
---
 arch/arm/lib/pbl.lds.S            |    1 +
 common/Kconfig                    |   13 ++++++++++++-
 include/asm-generic/barebox.lds.h |   13 +++++++++++++
 pbl/Kconfig                       |    7 +++++++
 4 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
index 0954c89..d7a3cc5 100644
--- a/arch/arm/lib/pbl.lds.S
+++ b/arch/arm/lib/pbl.lds.S
@@ -54,6 +54,7 @@ SECTIONS
 	/DISCARD/ : { *(.ARM.ex*) }
 
 	BAREBOX_BARE_INIT_SIZE
+	BAREBOX_PBL_SIZE
 
 	. = ALIGN(4);
 	.rodata : { *(.rodata*) }
diff --git a/common/Kconfig b/common/Kconfig
index 8af7ec1..2eaa3b5 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -145,13 +145,24 @@ config BAREBOX_MAX_IMAGE_SIZE
 	help
 	  Define the maximum size of barebox
 
+config BAREBOX_MAX_PBL_SIZE
+	depends on PBL_IMAGE && LOAD_PBL_SRAM
+	prompt "Maximum pre-bootloader size"
+	hex
+	default 0xffffffff
+	help
+	  On some hardware the ROM code can load the pbl into SRAM, but not
+	  the whole image. This option specifies how big the pbl may get.
+
 config BAREBOX_MAX_BARE_INIT_SIZE
 	prompt "Maximum bare_init size"
 	hex
+	range 0x0 BAREBOX_MAX_PBL_SIZE if LOAD_PBL_SRAM
+	default BAREBOX_MAX_PBL_SIZE if LOAD_PBL_SRAM
 	default 0xffffffff
 	help
 	  Define the maximum size of bare_init
-	  this will allow your bare_init will fit in SRAM as example
+	  this will allow your bare_init to fit in SRAM as example
 	  ARCH can overwrite it via ARCH_BAREBOX_MAX_BARE_INIT_SIZE
 
 config HAVE_CONFIGURABLE_MEMORY_LAYOUT
diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
index 6d3a69e..5dabda3 100644
--- a/include/asm-generic/barebox.lds.h
+++ b/include/asm-generic/barebox.lds.h
@@ -60,6 +60,13 @@ CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE < CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
 #define MAX_BARE_INIT_SIZE CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
 #endif
 
+#if defined(CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE) && \
+CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE < CONFIG_BAREBOX_MAX_PBL_SIZE
+#define MAX_PBL_SIZE CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE
+#else
+#define MAX_PBL_SIZE CONFIG_BAREBOX_MAX_PBL_SIZE
+#endif
+
 #include <linux/stringify.h>
 /* use 2 ASSERT because ld can not accept '"size" "10"' format */
 #define BAREBOX_BARE_INIT_SIZE					\
@@ -67,3 +74,9 @@ CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE < CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
 	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
 	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \
 
+#define BAREBOX_PBL_SIZE					\
+	_barebox_pbl_size = __bss_start - _text;		\
+	ASSERT(MAX_BARE_INIT_SIZE <= MAX_PBL_SIZE, "bare_init cannot be bigger than pbl") \
+	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, "Barebox pbl size > ") \
+	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, __stringify(MAX_PBL_SIZE)) \
+
diff --git a/pbl/Kconfig b/pbl/Kconfig
index dc31357..1edc2d1 100644
--- a/pbl/Kconfig
+++ b/pbl/Kconfig
@@ -34,6 +34,13 @@ config PBL_FORCE_PIGGYDATA_COPY
 
 if PBL_IMAGE
 
+config LOAD_PBL_SRAM
+	bool "Load pbl in SRAM"
+	help
+	  Load the whole content of the pbl binary into SRAM. This is useful if you
+	  use the pbl as a first stage bootloader but cannot load the whole binary
+	  at the same time.
+
 config PBL_RELOCATABLE
 	depends on ARM
 	bool "relocatable pbl image"
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Load PBL into SRAM
  2014-02-04  3:56 ` Jean-Christophe PLAGNIOL-VILLARD
  2014-02-04  6:57   ` Sascha Hauer
@ 2014-02-04  7:51   ` David Vincent
  1 sibling, 0 replies; 14+ messages in thread
From: David Vincent @ 2014-02-04  7:51 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

2014-02-04 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>:
> On 10:06 Fri 31 Jan     , David Vincent wrote:
>> This allows to load all the lowlevel init code, including the
>> uncompressor, inside SRAM and not just the bare init part. This is
>> useful when pbl is used as a first-stage bootloader but is loaded by an
>> external firmware.
>>
>> Signed-off-by: David Vincent <freesilicon@gmail.com>
>> ---
>>  arch/arm/lib/pbl.lds.S            |    4 ++--
>>  common/Kconfig                    |   16 ++++++++++++++--
>>  include/asm-generic/barebox.lds.h |   14 +++++++++++++-
>>  pbl/Kconfig                       |    7 +++++++
>>  4 files changed, 36 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
>> index 0954c89..34c0cb3 100644
>> --- a/arch/arm/lib/pbl.lds.S
>> +++ b/arch/arm/lib/pbl.lds.S
>> @@ -50,11 +50,11 @@ SECTIONS
>>               *(.text*)
>>       }
>>
>> +     BAREBOX_PBL_SIZE
>> +
>>       /* Discard unwind if enable in barebox */
>>       /DISCARD/ : { *(.ARM.ex*) }
>>
>> -     BAREBOX_BARE_INIT_SIZE
>> -
>
> nack you change the binary format you can add an information but can not
> change the format

My mistake for the /DISCARD/, I will change it in the next submit and
put back the information about BARE_INIT_SIZE

>>       . = ALIGN(4);
>>       .rodata : { *(.rodata*) }
>>
>> diff --git a/common/Kconfig b/common/Kconfig
>> index 8af7ec1..e067127 100644
>> --- a/common/Kconfig
>> +++ b/common/Kconfig
>> @@ -145,13 +145,25 @@ config BAREBOX_MAX_IMAGE_SIZE
>>       help
>>         Define the maximum size of barebox
>>
>> +config BAREBOX_MAX_PBL_SIZE
>> +     depends on PBL_IMAGE && LOAD_PBL_SRAM
>> +     prompt "Maximum pre-bootloader size"
>> +     hex
>> +     default 0xffffffff
>> +     help
>> +       Define the maximum size of pbl
>> +       this will allow your pbl to fit in SRAM as example
>> +       ARCH can overwrite it via ARCH_BAREBOX_MAX_PBL_SIZE
>> +
>>  config BAREBOX_MAX_BARE_INIT_SIZE
>> -     prompt "Maximum bare_init size"
>> +     prompt "Maximum bare_init size" if !LOAD_PBL_SRAM
> you can set it in all case

BARE_INIT is included in PBL, but, alright, removing the condition doesn't hurt.

>>       hex
>> +     range 0x0 BAREBOX_MAX_PBL_SIZE if LOAD_PBL_SRAM
>> +     default BAREBOX_MAX_PBL_SIZE if LOAD_PBL_SRAM
>>       default 0xffffffff
>>       help
>>         Define the maximum size of bare_init
>> -       this will allow your bare_init will fit in SRAM as example
>> +       this will allow your bare_init to fit in SRAM as example
> different patch

Yes, my first submission was wrong.

>>         ARCH can overwrite it via ARCH_BAREBOX_MAX_BARE_INIT_SIZE
>>
>>  config HAVE_CONFIGURABLE_MEMORY_LAYOUT
>> diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
>> index 6d3a69e..10b0885 100644
>> --- a/include/asm-generic/barebox.lds.h
>> +++ b/include/asm-generic/barebox.lds.h
>> @@ -60,10 +60,22 @@ CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE < CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
>>  #define MAX_BARE_INIT_SIZE CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
>>  #endif
>>
>> +#if defined(CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE) && \
>> +CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE < CONFIG_BAREBOX_MAX_PBL_SIZE
>> +#define MAX_PBL_SIZE CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE
>> +#else
>> +#define MAX_PBL_SIZE CONFIG_BAREBOX_MAX_PBL_SIZE
>> +#endif
>> +
>>  #include <linux/stringify.h>
>>  /* use 2 ASSERT because ld can not accept '"size" "10"' format */
>>  #define BAREBOX_BARE_INIT_SIZE                                       \
>>       _barebox_bare_init_size = __bare_init_end - _text;      \
>>       ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
>> -     ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \
>> +     ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE))
> different patch
>>
>> +#define BAREBOX_PBL_SIZE                                     \
>> +     _barebox_pbl_size = __bss_start - _text;                \
>> +     ASSERT(MAX_BARE_INIT_SIZE <= MAX_PBL_SIZE, "bare_init cannot be bigger than pbl") \
>> +     ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, "Barebox pbl size > ") \
>> +     ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, __stringify(MAX_PBL_SIZE))
>> diff --git a/pbl/Kconfig b/pbl/Kconfig
>> index dc31357..1edc2d1 100644
>> --- a/pbl/Kconfig
>> +++ b/pbl/Kconfig
>> @@ -34,6 +34,13 @@ config PBL_FORCE_PIGGYDATA_COPY
>>
>>  if PBL_IMAGE
>>
>> +config LOAD_PBL_SRAM
>> +     bool "Load pbl in SRAM"
>> +     help
>> +       Load the whole content of the pbl binary into SRAM. This is useful if you
>> +       use the pbl as a first stage bootloader but cannot load the whole binary
>> +       at the same time.
>> +
>>  config PBL_RELOCATABLE
>>       depends on ARM
>>       bool "relocatable pbl image"
>> --
>> 1.7.10.4
>>
>>
>> _______________________________________________
>> barebox mailing list
>> barebox@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Load PBL into SRAM
  2014-02-04  6:57   ` Sascha Hauer
  2014-02-04  7:04     ` Sascha Hauer
@ 2014-02-04  7:49     ` David Vincent
  2014-02-05  8:00       ` Sascha Hauer
  1 sibling, 1 reply; 14+ messages in thread
From: David Vincent @ 2014-02-04  7:49 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

2014-02-04 Sascha Hauer <s.hauer@pengutronix.de>:
> On Tue, Feb 04, 2014 at 04:56:25AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
>> On 10:06 Fri 31 Jan     , David Vincent wrote:
>> > This allows to load all the lowlevel init code, including the
>> > uncompressor, inside SRAM and not just the bare init part. This is
>> > useful when pbl is used as a first-stage bootloader but is loaded by an
>> > external firmware.
>> >
>> > Signed-off-by: David Vincent <freesilicon@gmail.com>
>> > ---
>> >  arch/arm/lib/pbl.lds.S            |    4 ++--
>> >  common/Kconfig                    |   16 ++++++++++++++--
>> >  include/asm-generic/barebox.lds.h |   14 +++++++++++++-
>> >  pbl/Kconfig                       |    7 +++++++
>> >  4 files changed, 36 insertions(+), 5 deletions(-)
>> >
>> > diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
>> > index 0954c89..34c0cb3 100644
>> > --- a/arch/arm/lib/pbl.lds.S
>> > +++ b/arch/arm/lib/pbl.lds.S
>> > @@ -50,11 +50,11 @@ SECTIONS
>> >             *(.text*)
>> >     }
>> >
>> > +   BAREBOX_PBL_SIZE
>> > +
>> >     /* Discard unwind if enable in barebox */
>> >     /DISCARD/ : { *(.ARM.ex*) }
>> >
>> > -   BAREBOX_BARE_INIT_SIZE
>> > -
>>
>> nack you change the binary format you can add an information but can not
>> change the format
>
> I don't think the format is changed here. It shouldn't matter where the
> /DISCARD/ is, right? Nevertheless the patch looks more obvious if just
> the line is changed, not its position.
>
>> >  #include <linux/stringify.h>
>> >  /* use 2 ASSERT because ld can not accept '"size" "10"' format */
>> >  #define BAREBOX_BARE_INIT_SIZE                                     \
>> >     _barebox_bare_init_size = __bare_init_end - _text;      \
>> >     ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
>> > -   ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \
>> > +   ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE))
>> different patch
>
> This just removes the trailing '\' which is necessary here.

It isn't obvious for me why the trailing '\' is necessary but you know
better than me so I will put it back and add one on the next
definition.

>
> --
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Load PBL into SRAM
  2014-02-04  6:57   ` Sascha Hauer
@ 2014-02-04  7:04     ` Sascha Hauer
  2014-02-04  7:49     ` David Vincent
  1 sibling, 0 replies; 14+ messages in thread
From: Sascha Hauer @ 2014-02-04  7:04 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox, David Vincent

On Tue, Feb 04, 2014 at 07:57:46AM +0100, Sascha Hauer wrote:
> On Tue, Feb 04, 2014 at 04:56:25AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 10:06 Fri 31 Jan     , David Vincent wrote:
> > > This allows to load all the lowlevel init code, including the
> > > uncompressor, inside SRAM and not just the bare init part. This is
> > > useful when pbl is used as a first-stage bootloader but is loaded by an
> > > external firmware.
> > > 
> > > Signed-off-by: David Vincent <freesilicon@gmail.com>
> > > ---
> > >  arch/arm/lib/pbl.lds.S            |    4 ++--
> > >  common/Kconfig                    |   16 ++++++++++++++--
> > >  include/asm-generic/barebox.lds.h |   14 +++++++++++++-
> > >  pbl/Kconfig                       |    7 +++++++
> > >  4 files changed, 36 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
> > > index 0954c89..34c0cb3 100644
> > > --- a/arch/arm/lib/pbl.lds.S
> > > +++ b/arch/arm/lib/pbl.lds.S
> > > @@ -50,11 +50,11 @@ SECTIONS
> > >  		*(.text*)
> > >  	}
> > >  
> > > +	BAREBOX_PBL_SIZE
> > > +
> > >  	/* Discard unwind if enable in barebox */
> > >  	/DISCARD/ : { *(.ARM.ex*) }
> > >  
> > > -	BAREBOX_BARE_INIT_SIZE
> > > -
> > 
> > nack you change the binary format you can add an information but can not
> > change the format
> 
> I don't think the format is changed here. It shouldn't matter where the
> /DISCARD/ is, right? Nevertheless the patch looks more obvious if just
> the line is changed, not its position.

Sorry, I misread the patch. My thought was that BAREBOX_PBL_SIZE
replaces (and includes) BAREBOX_BARE_INIT_SIZE, but this is not the
case. So you are right, BAREBOX_BARE_INIT_SIZE should not be removed
here.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Load PBL into SRAM
  2014-02-04  3:56 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2014-02-04  6:57   ` Sascha Hauer
  2014-02-04  7:04     ` Sascha Hauer
  2014-02-04  7:49     ` David Vincent
  2014-02-04  7:51   ` David Vincent
  1 sibling, 2 replies; 14+ messages in thread
From: Sascha Hauer @ 2014-02-04  6:57 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox, David Vincent

On Tue, Feb 04, 2014 at 04:56:25AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:06 Fri 31 Jan     , David Vincent wrote:
> > This allows to load all the lowlevel init code, including the
> > uncompressor, inside SRAM and not just the bare init part. This is
> > useful when pbl is used as a first-stage bootloader but is loaded by an
> > external firmware.
> > 
> > Signed-off-by: David Vincent <freesilicon@gmail.com>
> > ---
> >  arch/arm/lib/pbl.lds.S            |    4 ++--
> >  common/Kconfig                    |   16 ++++++++++++++--
> >  include/asm-generic/barebox.lds.h |   14 +++++++++++++-
> >  pbl/Kconfig                       |    7 +++++++
> >  4 files changed, 36 insertions(+), 5 deletions(-)
> > 
> > diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
> > index 0954c89..34c0cb3 100644
> > --- a/arch/arm/lib/pbl.lds.S
> > +++ b/arch/arm/lib/pbl.lds.S
> > @@ -50,11 +50,11 @@ SECTIONS
> >  		*(.text*)
> >  	}
> >  
> > +	BAREBOX_PBL_SIZE
> > +
> >  	/* Discard unwind if enable in barebox */
> >  	/DISCARD/ : { *(.ARM.ex*) }
> >  
> > -	BAREBOX_BARE_INIT_SIZE
> > -
> 
> nack you change the binary format you can add an information but can not
> change the format

I don't think the format is changed here. It shouldn't matter where the
/DISCARD/ is, right? Nevertheless the patch looks more obvious if just
the line is changed, not its position.

> >  #include <linux/stringify.h>
> >  /* use 2 ASSERT because ld can not accept '"size" "10"' format */
> >  #define BAREBOX_BARE_INIT_SIZE					\
> >  	_barebox_bare_init_size = __bare_init_end - _text;	\
> >  	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
> > -	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \
> > +	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE))
> different patch

This just removes the trailing '\' which is necessary here.

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Load PBL into SRAM
  2014-01-31  9:06 David Vincent
  2014-02-03  8:12 ` Sascha Hauer
@ 2014-02-04  3:56 ` Jean-Christophe PLAGNIOL-VILLARD
  2014-02-04  6:57   ` Sascha Hauer
  2014-02-04  7:51   ` David Vincent
  1 sibling, 2 replies; 14+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2014-02-04  3:56 UTC (permalink / raw)
  To: David Vincent; +Cc: barebox

On 10:06 Fri 31 Jan     , David Vincent wrote:
> This allows to load all the lowlevel init code, including the
> uncompressor, inside SRAM and not just the bare init part. This is
> useful when pbl is used as a first-stage bootloader but is loaded by an
> external firmware.
> 
> Signed-off-by: David Vincent <freesilicon@gmail.com>
> ---
>  arch/arm/lib/pbl.lds.S            |    4 ++--
>  common/Kconfig                    |   16 ++++++++++++++--
>  include/asm-generic/barebox.lds.h |   14 +++++++++++++-
>  pbl/Kconfig                       |    7 +++++++
>  4 files changed, 36 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
> index 0954c89..34c0cb3 100644
> --- a/arch/arm/lib/pbl.lds.S
> +++ b/arch/arm/lib/pbl.lds.S
> @@ -50,11 +50,11 @@ SECTIONS
>  		*(.text*)
>  	}
>  
> +	BAREBOX_PBL_SIZE
> +
>  	/* Discard unwind if enable in barebox */
>  	/DISCARD/ : { *(.ARM.ex*) }
>  
> -	BAREBOX_BARE_INIT_SIZE
> -

nack you change the binary format you can add an information but can not
change the format
>  	. = ALIGN(4);
>  	.rodata : { *(.rodata*) }
>  
> diff --git a/common/Kconfig b/common/Kconfig
> index 8af7ec1..e067127 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -145,13 +145,25 @@ config BAREBOX_MAX_IMAGE_SIZE
>  	help
>  	  Define the maximum size of barebox
>  
> +config BAREBOX_MAX_PBL_SIZE
> +	depends on PBL_IMAGE && LOAD_PBL_SRAM
> +	prompt "Maximum pre-bootloader size"
> +	hex
> +	default 0xffffffff
> +	help
> +	  Define the maximum size of pbl
> +	  this will allow your pbl to fit in SRAM as example
> +	  ARCH can overwrite it via ARCH_BAREBOX_MAX_PBL_SIZE
> +
>  config BAREBOX_MAX_BARE_INIT_SIZE
> -	prompt "Maximum bare_init size"
> +	prompt "Maximum bare_init size" if !LOAD_PBL_SRAM
you can set it in all case
>  	hex
> +	range 0x0 BAREBOX_MAX_PBL_SIZE if LOAD_PBL_SRAM
> +	default BAREBOX_MAX_PBL_SIZE if LOAD_PBL_SRAM
>  	default 0xffffffff
>  	help
>  	  Define the maximum size of bare_init
> -	  this will allow your bare_init will fit in SRAM as example
> +	  this will allow your bare_init to fit in SRAM as example
different patch
>  	  ARCH can overwrite it via ARCH_BAREBOX_MAX_BARE_INIT_SIZE
>  
>  config HAVE_CONFIGURABLE_MEMORY_LAYOUT
> diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
> index 6d3a69e..10b0885 100644
> --- a/include/asm-generic/barebox.lds.h
> +++ b/include/asm-generic/barebox.lds.h
> @@ -60,10 +60,22 @@ CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE < CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
>  #define MAX_BARE_INIT_SIZE CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
>  #endif
>  
> +#if defined(CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE) && \
> +CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE < CONFIG_BAREBOX_MAX_PBL_SIZE
> +#define MAX_PBL_SIZE CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE
> +#else
> +#define MAX_PBL_SIZE CONFIG_BAREBOX_MAX_PBL_SIZE
> +#endif
> +
>  #include <linux/stringify.h>
>  /* use 2 ASSERT because ld can not accept '"size" "10"' format */
>  #define BAREBOX_BARE_INIT_SIZE					\
>  	_barebox_bare_init_size = __bare_init_end - _text;	\
>  	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
> -	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \
> +	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE))
different patch
>  
> +#define BAREBOX_PBL_SIZE					\
> +	_barebox_pbl_size = __bss_start - _text;		\
> +	ASSERT(MAX_BARE_INIT_SIZE <= MAX_PBL_SIZE, "bare_init cannot be bigger than pbl") \
> +	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, "Barebox pbl size > ") \
> +	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, __stringify(MAX_PBL_SIZE))
> diff --git a/pbl/Kconfig b/pbl/Kconfig
> index dc31357..1edc2d1 100644
> --- a/pbl/Kconfig
> +++ b/pbl/Kconfig
> @@ -34,6 +34,13 @@ config PBL_FORCE_PIGGYDATA_COPY
>  
>  if PBL_IMAGE
>  
> +config LOAD_PBL_SRAM
> +	bool "Load pbl in SRAM"
> +	help
> +	  Load the whole content of the pbl binary into SRAM. This is useful if you
> +	  use the pbl as a first stage bootloader but cannot load the whole binary
> +	  at the same time.
> +
>  config PBL_RELOCATABLE
>  	depends on ARM
>  	bool "relocatable pbl image"
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] Load PBL into SRAM
  2014-01-31  9:06 David Vincent
@ 2014-02-03  8:12 ` Sascha Hauer
  2014-02-04  3:56 ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 14+ messages in thread
From: Sascha Hauer @ 2014-02-03  8:12 UTC (permalink / raw)
  To: David Vincent; +Cc: barebox

On Fri, Jan 31, 2014 at 10:06:10AM +0100, David Vincent wrote:
> This allows to load all the lowlevel init code, including the
> uncompressor, inside SRAM and not just the bare init part. This is
> useful when pbl is used as a first-stage bootloader but is loaded by an
> external firmware.

Just to make sure I understand this correctly: The patch does not make a
code change, all it does is to check that the binary does not get too
big, right?

> +config BAREBOX_MAX_PBL_SIZE
> +	depends on PBL_IMAGE && LOAD_PBL_SRAM
> +	prompt "Maximum pre-bootloader size"
> +	hex
> +	default 0xffffffff
> +	help
> +	  Define the maximum size of pbl
> +	  this will allow your pbl to fit in SRAM as example
> +	  ARCH can overwrite it via ARCH_BAREBOX_MAX_PBL_SIZE

I stumble upon this 'allow', maybe better something like:

On some hardware the ROM code can load the pbl into SRAM, but not the
whole image. This option specifies how big the pbl may get.

What do you think?

Sascha

> +
> +
>  config BAREBOX_MAX_BARE_INIT_SIZE
> -	prompt "Maximum bare_init size"
> +	prompt "Maximum bare_init size" if !LOAD_PBL_SRAM
>  	hex
> +	range 0x0 BAREBOX_MAX_PBL_SIZE if LOAD_PBL_SRAM
> +	default BAREBOX_MAX_PBL_SIZE if LOAD_PBL_SRAM
>  	default 0xffffffff
>  	help
>  	  Define the maximum size of bare_init
> -	  this will allow your bare_init will fit in SRAM as example
> +	  this will allow your bare_init to fit in SRAM as example
>  	  ARCH can overwrite it via ARCH_BAREBOX_MAX_BARE_INIT_SIZE
>  
>  config HAVE_CONFIGURABLE_MEMORY_LAYOUT
> diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
> index 6d3a69e..10b0885 100644
> --- a/include/asm-generic/barebox.lds.h
> +++ b/include/asm-generic/barebox.lds.h
> @@ -60,10 +60,22 @@ CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE < CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
>  #define MAX_BARE_INIT_SIZE CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
>  #endif
>  
> +#if defined(CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE) && \
> +CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE < CONFIG_BAREBOX_MAX_PBL_SIZE
> +#define MAX_PBL_SIZE CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE
> +#else
> +#define MAX_PBL_SIZE CONFIG_BAREBOX_MAX_PBL_SIZE
> +#endif
> +
>  #include <linux/stringify.h>
>  /* use 2 ASSERT because ld can not accept '"size" "10"' format */
>  #define BAREBOX_BARE_INIT_SIZE					\
>  	_barebox_bare_init_size = __bare_init_end - _text;	\
>  	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
> -	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \
> +	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE))
>  
> +#define BAREBOX_PBL_SIZE					\
> +	_barebox_pbl_size = __bss_start - _text;		\
> +	ASSERT(MAX_BARE_INIT_SIZE <= MAX_PBL_SIZE, "bare_init cannot be bigger than pbl") \
> +	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, "Barebox pbl size > ") \
> +	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, __stringify(MAX_PBL_SIZE))
> diff --git a/pbl/Kconfig b/pbl/Kconfig
> index dc31357..1edc2d1 100644
> --- a/pbl/Kconfig
> +++ b/pbl/Kconfig
> @@ -34,6 +34,13 @@ config PBL_FORCE_PIGGYDATA_COPY
>  
>  if PBL_IMAGE
>  
> +config LOAD_PBL_SRAM
> +	bool "Load pbl in SRAM"
> +	help
> +	  Load the whole content of the pbl binary into SRAM. This is useful if you
> +	  use the pbl as a first stage bootloader but cannot load the whole binary
> +	  at the same time.
> +
>  config PBL_RELOCATABLE
>  	depends on ARM
>  	bool "relocatable pbl image"
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH] Load PBL into SRAM
@ 2014-01-31  9:06 David Vincent
  2014-02-03  8:12 ` Sascha Hauer
  2014-02-04  3:56 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 2 replies; 14+ messages in thread
From: David Vincent @ 2014-01-31  9:06 UTC (permalink / raw)
  To: barebox; +Cc: David Vincent

This allows to load all the lowlevel init code, including the
uncompressor, inside SRAM and not just the bare init part. This is
useful when pbl is used as a first-stage bootloader but is loaded by an
external firmware.

Signed-off-by: David Vincent <freesilicon@gmail.com>
---
 arch/arm/lib/pbl.lds.S            |    4 ++--
 common/Kconfig                    |   16 ++++++++++++++--
 include/asm-generic/barebox.lds.h |   14 +++++++++++++-
 pbl/Kconfig                       |    7 +++++++
 4 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/arch/arm/lib/pbl.lds.S b/arch/arm/lib/pbl.lds.S
index 0954c89..34c0cb3 100644
--- a/arch/arm/lib/pbl.lds.S
+++ b/arch/arm/lib/pbl.lds.S
@@ -50,11 +50,11 @@ SECTIONS
 		*(.text*)
 	}
 
+	BAREBOX_PBL_SIZE
+
 	/* Discard unwind if enable in barebox */
 	/DISCARD/ : { *(.ARM.ex*) }
 
-	BAREBOX_BARE_INIT_SIZE
-
 	. = ALIGN(4);
 	.rodata : { *(.rodata*) }
 
diff --git a/common/Kconfig b/common/Kconfig
index 8af7ec1..e067127 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -145,13 +145,25 @@ config BAREBOX_MAX_IMAGE_SIZE
 	help
 	  Define the maximum size of barebox
 
+config BAREBOX_MAX_PBL_SIZE
+	depends on PBL_IMAGE && LOAD_PBL_SRAM
+	prompt "Maximum pre-bootloader size"
+	hex
+	default 0xffffffff
+	help
+	  Define the maximum size of pbl
+	  this will allow your pbl to fit in SRAM as example
+	  ARCH can overwrite it via ARCH_BAREBOX_MAX_PBL_SIZE
+
 config BAREBOX_MAX_BARE_INIT_SIZE
-	prompt "Maximum bare_init size"
+	prompt "Maximum bare_init size" if !LOAD_PBL_SRAM
 	hex
+	range 0x0 BAREBOX_MAX_PBL_SIZE if LOAD_PBL_SRAM
+	default BAREBOX_MAX_PBL_SIZE if LOAD_PBL_SRAM
 	default 0xffffffff
 	help
 	  Define the maximum size of bare_init
-	  this will allow your bare_init will fit in SRAM as example
+	  this will allow your bare_init to fit in SRAM as example
 	  ARCH can overwrite it via ARCH_BAREBOX_MAX_BARE_INIT_SIZE
 
 config HAVE_CONFIGURABLE_MEMORY_LAYOUT
diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
index 6d3a69e..10b0885 100644
--- a/include/asm-generic/barebox.lds.h
+++ b/include/asm-generic/barebox.lds.h
@@ -60,10 +60,22 @@ CONFIG_ARCH_BAREBOX_MAX_BARE_INIT_SIZE < CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
 #define MAX_BARE_INIT_SIZE CONFIG_BAREBOX_MAX_BARE_INIT_SIZE
 #endif
 
+#if defined(CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE) && \
+CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE < CONFIG_BAREBOX_MAX_PBL_SIZE
+#define MAX_PBL_SIZE CONFIG_ARCH_BAREBOX_MAX_PBL_SIZE
+#else
+#define MAX_PBL_SIZE CONFIG_BAREBOX_MAX_PBL_SIZE
+#endif
+
 #include <linux/stringify.h>
 /* use 2 ASSERT because ld can not accept '"size" "10"' format */
 #define BAREBOX_BARE_INIT_SIZE					\
 	_barebox_bare_init_size = __bare_init_end - _text;	\
 	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, "Barebox bare_init size > ") \
-	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE)) \
+	ASSERT(_barebox_bare_init_size < MAX_BARE_INIT_SIZE, __stringify(MAX_BARE_INIT_SIZE))
 
+#define BAREBOX_PBL_SIZE					\
+	_barebox_pbl_size = __bss_start - _text;		\
+	ASSERT(MAX_BARE_INIT_SIZE <= MAX_PBL_SIZE, "bare_init cannot be bigger than pbl") \
+	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, "Barebox pbl size > ") \
+	ASSERT(_barebox_pbl_size < MAX_PBL_SIZE, __stringify(MAX_PBL_SIZE))
diff --git a/pbl/Kconfig b/pbl/Kconfig
index dc31357..1edc2d1 100644
--- a/pbl/Kconfig
+++ b/pbl/Kconfig
@@ -34,6 +34,13 @@ config PBL_FORCE_PIGGYDATA_COPY
 
 if PBL_IMAGE
 
+config LOAD_PBL_SRAM
+	bool "Load pbl in SRAM"
+	help
+	  Load the whole content of the pbl binary into SRAM. This is useful if you
+	  use the pbl as a first stage bootloader but cannot load the whole binary
+	  at the same time.
+
 config PBL_RELOCATABLE
 	depends on ARM
 	bool "relocatable pbl image"
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2014-02-20 16:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-30 15:43 [PATCH] Load PBL into SRAM David Vincent
2014-01-31  6:51 ` Sascha Hauer
2014-01-31  9:06 David Vincent
2014-02-03  8:12 ` Sascha Hauer
2014-02-04  3:56 ` Jean-Christophe PLAGNIOL-VILLARD
2014-02-04  6:57   ` Sascha Hauer
2014-02-04  7:04     ` Sascha Hauer
2014-02-04  7:49     ` David Vincent
2014-02-05  8:00       ` Sascha Hauer
2014-02-05 12:48         ` David Vincent
2014-02-05 15:45           ` Sascha Hauer
2014-02-20 16:32             ` David Vincent
2014-02-04  7:51   ` David Vincent
2014-02-04  7:53 David Vincent

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