Skip to contentSkip to conversation

Load PBL into SRAM

PATCH In review David Vincent 2 participants 2 messages Jan 30, 2014 – Jan 31, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Load PBL into SRAM

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.

---
 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
arch/arm/lib/pbl.lds.S +1 -1
index 0954c89..78b39a6 100644
@@ -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
common/Kconfig +12 -1
index 8af7ec1..38ed619 100644
@@ -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
 
include/asm-generic/barebox.lds.h +1 -2
index 6d3a69e..18f3cd5 100644
@@ -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))
include/asm-generic/pbl.lds.h new file +15 -0
new file mode 100644
index 0000000..43149b7
@@ -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))
+
pbl/Kconfig +7 -0
index dc31357..1edc2d1 100644
@@ -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"
Signature · 7 lines
1.7.10.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

Hi David,

Quoted 4 lines · 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.

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

include/asm-generic/pbl.lds.h line 14

Quoted 5 lines
include/asm-generic/pbl.lds.h new file +5 -0
+#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

Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox