mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Compressed barebox image support
@ 2012-07-19  8:12 Sascha Hauer
  2012-07-19  8:12 ` [PATCH 1/9] lzo: Allow for static inlining Sascha Hauer
                   ` (10 more replies)
  0 siblings, 11 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19  8:12 UTC (permalink / raw)
  To: barebox

The following series allows to create a self extracting barebox image.
This is done by linking barebox twice, once for the actual binary, but
without lowlevel initstuff and once for the lowlevel init stuff, the
decompressor and the compressed image.

Using lzo compression the pcm038 image shrinks from 252k to 155k. The
series has been tested on the pcm038 second stage, first stage NAND and
first stage NOR and also on an i.MX53 LOCO board (also in thumb2 mode)

Using compressed images currently adds to the boot time, at least on
my slower arm9 systems. Using the MMU during decompression would help,
but this currently isn't implemented.

I think the preparation patches should be ready for merging. The last
patch in this series adding compression support I am not that confident
with. Currently I am not very happy with the Makefile changes which
somehow look like bypassing the kbuild mechanism and handcrufting
something that looks like kbuild. If someone has ideas how to improve
this, let me know. Nevertheless I would be happy about Tested-by
(and does-not-work-for) tags.

Sascha

----------------------------------------------------------------
Sascha Hauer (9):
      lzo: Allow for static inlining
      ARM lds: remove unused got
      ARM: remove board linker script option
      ARM: remove exception vectors from boards
      ARM startup: calculate offset instead of runtime address
      ARM ep93xx: Get rid of special handling in linker file
      ARM boards: Use _text rather than TEXT_BASE
      ARM: Separate assembler functions into their own section
      Add compressed image support

 Makefile                                           |   31 ++++++-
 arch/arm/Kconfig                                   |   13 +--
 arch/arm/Makefile                                  |    4 +-
 arch/arm/boards/a9m2410/a9m2410.c                  |    3 +-
 arch/arm/boards/a9m2440/a9m2440.c                  |    3 +-
 arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c  |    7 +-
 arch/arm/boards/eukrea_cpuimx25/lowlevel.c         |    4 +-
 arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c  |    4 +-
 arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S    |   11 +--
 arch/arm/boards/eukrea_cpuimx35/flash_header.c     |    2 -
 arch/arm/boards/eukrea_cpuimx35/lowlevel.c         |    4 +-
 arch/arm/boards/freescale-mx25-3-stack/3stack.c    |    8 +-
 .../boards/freescale-mx25-3-stack/lowlevel_init.S  |   11 +--
 arch/arm/boards/freescale-mx35-3-stack/3stack.c    |    4 +-
 .../boards/freescale-mx35-3-stack/flash_header.c   |    4 +-
 .../boards/freescale-mx35-3-stack/lowlevel_init.S  |   11 +--
 arch/arm/boards/freescale-mx53-loco/flash_header.c |    2 +-
 arch/arm/boards/freescale-mx53-smd/flash_header.c  |    2 +-
 arch/arm/boards/freescale-mx6-arm2/flash_header.c  |    5 +-
 arch/arm/boards/guf-cupid/lowlevel.c               |    4 +-
 arch/arm/boards/guf-neso/lowlevel.c                |    4 +-
 arch/arm/boards/imx21ads/imx21ads.c                |    4 +-
 arch/arm/boards/imx21ads/lowlevel_init.S           |   10 +--
 arch/arm/boards/karo-tx25/board.c                  |    3 +-
 arch/arm/boards/karo-tx25/lowlevel.c               |    4 +-
 arch/arm/boards/karo-tx51/flash_header.c           |    2 +-
 arch/arm/boards/mini2440/mini2440.c                |    3 +-
 arch/arm/boards/pcm037/lowlevel_init.S             |    7 +-
 arch/arm/boards/pcm037/pcm037.c                    |    4 +-
 arch/arm/boards/pcm038/lowlevel.c                  |    4 +-
 arch/arm/boards/pcm043/lowlevel.c                  |    4 +-
 arch/arm/boards/phycard-i.MX27/lowlevel_init.S     |    8 +-
 arch/arm/boards/phycard-i.MX27/pca100.c            |    2 +-
 arch/arm/boards/tqma53/flash_header.c              |    5 +-
 arch/arm/cpu/cache-armv4.S                         |    7 +-
 arch/arm/cpu/cache-armv5.S                         |    7 +-
 arch/arm/cpu/cache-armv6.S                         |   11 ++-
 arch/arm/cpu/cache-armv7.S                         |    8 +-
 arch/arm/cpu/start.c                               |   85 +++++++++++++++++---
 arch/arm/lib/Makefile                              |    4 +-
 arch/arm/lib/ashldi3.S                             |    1 +
 arch/arm/lib/ashrdi3.S                             |    1 +
 arch/arm/lib/barebox-compressed.lds.S              |   71 ++++++++++++++++
 arch/arm/lib/barebox.lds.S                         |   11 +--
 arch/arm/lib/findbit.S                             |    9 +++
 arch/arm/lib/io-writesw-armv4.S                    |    2 +
 arch/arm/lib/lib1funcs.S                           |    7 ++
 arch/arm/lib/lshrdi3.S                             |    1 +
 arch/arm/mach-ep93xx/Makefile                      |    2 +-
 arch/arm/mach-ep93xx/header.c                      |    8 ++
 arch/arm/mach-ep93xx/include/mach/barebox.lds.h    |    9 +++
 common/Kconfig                                     |   12 +++
 include/asm-generic/barebox.lds.h                  |    3 +-
 include/asm-generic/memory_layout.h                |    2 +
 include/lzo.h                                      |    8 +-
 lib/decompress_unlzo.c                             |    9 ++-
 lib/lzo/lzo1x_decompress.c                         |    2 +-
 lib/vsprintf.c                                     |   25 +++++-
 piggy.lzo.S                                        |    6 ++
 59 files changed, 382 insertions(+), 130 deletions(-)
 create mode 100644 arch/arm/lib/barebox-compressed.lds.S
 create mode 100644 arch/arm/mach-ep93xx/header.c
 create mode 100644 arch/arm/mach-ep93xx/include/mach/barebox.lds.h
 create mode 100644 piggy.lzo.S


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

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

* [PATCH 1/9] lzo: Allow for static inlining
  2012-07-19  8:12 Compressed barebox image support Sascha Hauer
@ 2012-07-19  8:12 ` Sascha Hauer
  2012-07-19  8:12 ` [PATCH 2/9] ARM lds: remove unused got Sascha Hauer
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19  8:12 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/lzo.h              |    8 ++++++--
 lib/decompress_unlzo.c     |    9 +++++++--
 lib/lzo/lzo1x_decompress.c |    2 +-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/include/lzo.h b/include/lzo.h
index 0530a68..ceacfba 100644
--- a/include/lzo.h
+++ b/include/lzo.h
@@ -19,12 +19,16 @@
 
 #define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
 
+#ifndef STATIC
+#define STATIC
+#endif
+
 /* This requires 'workmem' of size LZO1X_1_MEM_COMPRESS */
 int lzo1x_1_compress(const unsigned char *src, size_t src_len,
 			unsigned char *dst, size_t *dst_len, void *wrkmem);
 
 /* safe decompression with overrun testing */
-int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
+STATIC int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
 			unsigned char *dst, size_t *dst_len);
 
 /*
@@ -41,7 +45,7 @@ int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
 #define LZO_E_INPUT_NOT_CONSUMED	(-8)
 #define LZO_E_NOT_YET_IMPLEMENTED	(-9)
 
-int decompress_unlzo(u8 *input, int in_len,
+STATIC int decompress_unlzo(u8 *input, int in_len,
 		int (*fill) (void *, unsigned int),
 		int (*flush) (void *, unsigned int),
 		u8 *output, int *posp,
diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c
index 000bd70..0e6a7ad 100644
--- a/lib/decompress_unlzo.c
+++ b/lib/decompress_unlzo.c
@@ -33,11 +33,16 @@
 #include <common.h>
 #include <malloc.h>
 #include <linux/types.h>
-#include <lzo.h>
 #include <errno.h>
 #include <fs.h>
 #include <xfuncs.h>
 
+#ifdef STATIC
+#include "lzo/lzo1x_decompress.c"
+#endif
+
+#include <lzo.h>
+
 #include <linux/compiler.h>
 #include <asm/unaligned.h>
 
@@ -106,7 +111,7 @@ static inline int parse_header(u8 *input, int *skip, int in_len)
 	return 1;
 }
 
-int decompress_unlzo(u8 *input, int in_len,
+STATIC int decompress_unlzo(u8 *input, int in_len,
 				int (*fill) (void *, unsigned int),
 				int (*flush) (void *, unsigned int),
 				u8 *output, int *posp,
diff --git a/lib/lzo/lzo1x_decompress.c b/lib/lzo/lzo1x_decompress.c
index af94382..7f1451f 100644
--- a/lib/lzo/lzo1x_decompress.c
+++ b/lib/lzo/lzo1x_decompress.c
@@ -23,7 +23,7 @@
 #define COPY4(dst, src)	\
 		put_unaligned(get_unaligned((const u32 *)(src)), (u32 *)(dst))
 
-int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
+STATIC int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
 			unsigned char *out, size_t *out_len)
 {
 	const unsigned char * const ip_end = in + in_len;
-- 
1.7.10.4


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

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

* [PATCH 2/9] ARM lds: remove unused got
  2012-07-19  8:12 Compressed barebox image support Sascha Hauer
  2012-07-19  8:12 ` [PATCH 1/9] lzo: Allow for static inlining Sascha Hauer
@ 2012-07-19  8:12 ` Sascha Hauer
  2012-07-19  8:12 ` [PATCH 3/9] ARM: remove board linker script option Sascha Hauer
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19  8:12 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/lib/barebox.lds.S |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
index 3fd271b..736e5f0 100644
--- a/arch/arm/lib/barebox.lds.S
+++ b/arch/arm/lib/barebox.lds.S
@@ -80,9 +80,6 @@ SECTIONS
 	. = ALIGN(4);
 	.data : { *(.data*) }
 
-	. = ALIGN(4);
-	.got : { *(.got*) }
-
 	. = .;
 	__barebox_cmd_start = .;
 	.barebox_cmd : { BAREBOX_CMDS }
-- 
1.7.10.4


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

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

* [PATCH 3/9] ARM: remove board linker script option
  2012-07-19  8:12 Compressed barebox image support Sascha Hauer
  2012-07-19  8:12 ` [PATCH 1/9] lzo: Allow for static inlining Sascha Hauer
  2012-07-19  8:12 ` [PATCH 2/9] ARM lds: remove unused got Sascha Hauer
@ 2012-07-19  8:12 ` Sascha Hauer
  2012-07-19  8:12 ` [PATCH 4/9] ARM: remove exception vectors from boards Sascha Hauer
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19  8:12 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/Kconfig      |   12 ------------
 arch/arm/Makefile     |    3 +--
 arch/arm/lib/Makefile |    3 +--
 3 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index af4cb59..d988455 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1,15 +1,3 @@
-#
-#
-#
-config BOARD_LINKER_SCRIPT
-	bool
-	default n
-
-config GENERIC_LINKER_SCRIPT
-	bool
-	default y
-	depends on !BOARD_LINKER_SCRIPT
-
 config ARM
 	bool
 	select HAS_KALLSYMS
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 1225df7..cbbc0a0 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -207,7 +207,6 @@ endif
 common-y += $(BOARD) $(MACH)
 common-y += arch/arm/lib/ arch/arm/cpu/
 
-lds-$(CONFIG_GENERIC_LINKER_SCRIPT)	:= arch/arm/lib/barebox.lds
-lds-$(CONFIG_BOARD_LINKER_SCRIPT)	:= $(BOARD)/barebox.lds
+lds-y	:= arch/arm/lib/barebox.lds
 
 CLEAN_FILES += include/generated/mach-types.h arch/arm/lib/barebox.lds
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 27a4b88..1eaf474 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -20,5 +20,4 @@ obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= memcpy.o
 obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= memset.o
 obj-$(CONFIG_ARM_UNWIND) += unwind.o
 obj-$(CONFIG_MODULES) += module.o
-extra-$(CONFIG_GENERIC_LINKER_SCRIPT) += barebox.lds
-
+extra-y += barebox.lds
-- 
1.7.10.4


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

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

* [PATCH 4/9] ARM: remove exception vectors from boards
  2012-07-19  8:12 Compressed barebox image support Sascha Hauer
                   ` (2 preceding siblings ...)
  2012-07-19  8:12 ` [PATCH 3/9] ARM: remove board linker script option Sascha Hauer
@ 2012-07-19  8:12 ` Sascha Hauer
  2012-07-19  8:12 ` [PATCH 5/9] ARM startup: calculate offset instead of runtime address Sascha Hauer
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19  8:12 UTC (permalink / raw)
  To: barebox

The exception vector table will become part of the uncompressed image,
so we can't reference them from the lowlevel init stuff anymore.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c     |    4 +---
 arch/arm/boards/eukrea_cpuimx35/flash_header.c        |    2 --
 arch/arm/boards/freescale-mx25-3-stack/3stack.c       |    4 +---
 arch/arm/boards/freescale-mx35-3-stack/flash_header.c |    4 +---
 arch/arm/boards/freescale-mx6-arm2/flash_header.c     |    3 ++-
 arch/arm/boards/tqma53/flash_header.c                 |    3 ++-
 6 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
index 1b8f618..b3b0838 100644
--- a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
+++ b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
@@ -49,8 +49,6 @@
 #include <mach/devices-imx25.h>
 #include <asm/barebox-arm-head.h>
 
-extern void exception_vectors(void);
-
 void __naked __flash_header_start go(void)
 {
 	barebox_arm_head();
@@ -72,7 +70,7 @@ struct imx_dcd_entry __dcd_entry_section dcd_entry[] = {
 };
 
 struct imx_flash_header __flash_header_section flash_header = {
-	.app_code_jump_vector	= DEST_BASE + ((unsigned int)&exception_vectors - TEXT_BASE),
+	.app_code_jump_vector	= DEST_BASE + 0x1000,
 	.app_code_barker	= APP_CODE_BARKER,
 	.app_code_csf		= 0,
 	.dcd_ptr_ptr		= FLASH_HEADER_BASE + offsetof(struct imx_flash_header, dcd),
diff --git a/arch/arm/boards/eukrea_cpuimx35/flash_header.c b/arch/arm/boards/eukrea_cpuimx35/flash_header.c
index a745442..26752d1 100644
--- a/arch/arm/boards/eukrea_cpuimx35/flash_header.c
+++ b/arch/arm/boards/eukrea_cpuimx35/flash_header.c
@@ -3,8 +3,6 @@
 #include <mach/imx-regs.h>
 #include <asm/barebox-arm-head.h>
 
-extern void exception_vectors(void);
-
 void __naked __flash_header_start go(void)
 {
 	barebox_arm_head();
diff --git a/arch/arm/boards/freescale-mx25-3-stack/3stack.c b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
index 323cd11..6b6146d 100644
--- a/arch/arm/boards/freescale-mx25-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
@@ -45,8 +45,6 @@
 #include <mach/devices-imx25.h>
 #include <asm/barebox-arm-head.h>
 
-extern void exception_vectors(void);
-
 void __naked __flash_header_start go(void)
 {
 	barebox_arm_head();
@@ -95,7 +93,7 @@ struct imx_dcd_entry __dcd_entry_section dcd_entry[] = {
 };
 
 struct imx_flash_header __flash_header_section flash_header = {
-	.app_code_jump_vector	= DEST_BASE + ((unsigned int)&exception_vectors - TEXT_BASE),
+	.app_code_jump_vector	= DEST_BASE + 0x1000,
 	.app_code_barker	= APP_CODE_BARKER,
 	.app_code_csf		= 0,
 	.dcd_ptr_ptr		= FLASH_HEADER_BASE + offsetof(struct imx_flash_header, dcd),
diff --git a/arch/arm/boards/freescale-mx35-3-stack/flash_header.c b/arch/arm/boards/freescale-mx35-3-stack/flash_header.c
index 0786836..66763db 100644
--- a/arch/arm/boards/freescale-mx35-3-stack/flash_header.c
+++ b/arch/arm/boards/freescale-mx35-3-stack/flash_header.c
@@ -3,8 +3,6 @@
 #include <mach/imx-regs.h>
 #include <asm/barebox-arm-head.h>
 
-extern void exception_vectors(void);
-
 void __naked __flash_header_start go(void)
 {
 	barebox_arm_head();
@@ -59,7 +57,7 @@ struct imx_dcd_entry __dcd_entry_section dcd_entry[] = {
 
 
 struct imx_flash_header __flash_header_section flash_header = {
-	.app_code_jump_vector	= DEST_BASE + ((unsigned int)&exception_vectors - TEXT_BASE),
+	.app_code_jump_vector	= DEST_BASE + 0x1000,
 	.app_code_barker	= APP_CODE_BARKER,
 	.app_code_csf		= 0,
 	.dcd_ptr_ptr		= FLASH_HEADER_BASE + offsetof(struct imx_flash_header, dcd),
diff --git a/arch/arm/boards/freescale-mx6-arm2/flash_header.c b/arch/arm/boards/freescale-mx6-arm2/flash_header.c
index 79f3113..69d9cfa 100644
--- a/arch/arm/boards/freescale-mx6-arm2/flash_header.c
+++ b/arch/arm/boards/freescale-mx6-arm2/flash_header.c
@@ -15,12 +15,13 @@
 
 #include <common.h>
 #include <asm/byteorder.h>
+#include <asm/barebox-arm-head.h>
 #include <mach/imx-flash-header.h>
 #include <mach/imx6-regs.h>
 
 void __naked __flash_header_start go(void)
 {
-	__asm__ __volatile__("b exception_vectors\n");
+	barebox_arm_head();
 }
 
 #define DCD(a, v) { .addr = cpu_to_be32(a), .val = cpu_to_be32(v), }
diff --git a/arch/arm/boards/tqma53/flash_header.c b/arch/arm/boards/tqma53/flash_header.c
index f5e817c..d912b38 100644
--- a/arch/arm/boards/tqma53/flash_header.c
+++ b/arch/arm/boards/tqma53/flash_header.c
@@ -15,11 +15,12 @@
 
 #include <common.h>
 #include <asm/byteorder.h>
+#include <asm/barebox-arm-head.h>
 #include <mach/imx-flash-header.h>
 
 void __naked __flash_header_start go(void)
 {
-	__asm__ __volatile__("b exception_vectors\n");
+	barebox_arm_head();
 }
 
 struct imx_dcd_v2_entry __dcd_entry_section dcd_entry[] = {
-- 
1.7.10.4


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

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

* [PATCH 5/9] ARM startup: calculate offset instead of runtime address
  2012-07-19  8:12 Compressed barebox image support Sascha Hauer
                   ` (3 preceding siblings ...)
  2012-07-19  8:12 ` [PATCH 4/9] ARM: remove exception vectors from boards Sascha Hauer
@ 2012-07-19  8:12 ` Sascha Hauer
  2012-07-19  8:12 ` [PATCH 6/9] ARM ep93xx: Get rid of special handling in linker file Sascha Hauer
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19  8:12 UTC (permalink / raw)
  To: barebox

Calculating the offset between runtime and linked address makes the
intention of the binary copy function a bit more clear.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/start.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 523179d..cabe4d2 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -104,7 +104,7 @@ void __naked __bare_init reset(void)
  */
 void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
 {
-	uint32_t r, addr;
+	uint32_t r, addr, offset;
 
 	/*
 	 * Get runtime address of this function. Do not
@@ -116,13 +116,13 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
 	r = STACK_BASE + STACK_SIZE - 16;
 	__asm__ __volatile__("mov sp, %0" : : "r"(r));
 
-	/* Get start of binary image */
-	addr -= (uint32_t)&__ll_return - TEXT_BASE;
+	/* Get offset between linked address and runtime address */
+	offset = (uint32_t)__ll_return - addr;
 
 	/* relocate to link address if necessary */
-	if (addr != TEXT_BASE)
-		memcpy((void *)TEXT_BASE, (void *)addr,
-				(unsigned int)&__bss_start - TEXT_BASE);
+	if (offset)
+		memcpy((void *)_text, (void *)(_text - offset),
+				__bss_start - _text);
 
 	/* clear bss */
 	memset(__bss_start, 0, __bss_stop - __bss_start);
-- 
1.7.10.4


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

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

* [PATCH 6/9] ARM ep93xx: Get rid of special handling in linker file
  2012-07-19  8:12 Compressed barebox image support Sascha Hauer
                   ` (4 preceding siblings ...)
  2012-07-19  8:12 ` [PATCH 5/9] ARM startup: calculate offset instead of runtime address Sascha Hauer
@ 2012-07-19  8:12 ` Sascha Hauer
  2012-07-19  8:13 ` [PATCH 7/9] ARM boards: Use _text rather than TEXT_BASE Sascha Hauer
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19  8:12 UTC (permalink / raw)
  To: barebox

The ep93xx needs a special value at offset 0x1000. Rather than
do special handling in the linker file add aa header section
as done on i.MX.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/lib/barebox.lds.S                      |    5 -----
 arch/arm/mach-ep93xx/Makefile                   |    2 +-
 arch/arm/mach-ep93xx/header.c                   |    8 ++++++++
 arch/arm/mach-ep93xx/include/mach/barebox.lds.h |    9 +++++++++
 include/asm-generic/barebox.lds.h               |    3 ++-
 5 files changed, 20 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/mach-ep93xx/header.c
 create mode 100644 arch/arm/mach-ep93xx/include/mach/barebox.lds.h

diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
index 736e5f0..e0bae70 100644
--- a/arch/arm/lib/barebox.lds.S
+++ b/arch/arm/lib/barebox.lds.S
@@ -41,11 +41,6 @@ SECTIONS
 		*(.text_entry*)
 		__ll_return = .;
 		*(.text_ll_return*)
-#ifdef CONFIG_ARCH_EP93XX
-		/* the EP93xx expects to find the pattern 'CRUS' at 0x1000 */
-	  . = 0x1000;
-	  LONG(0x53555243) /* 'CRUS' */
-#endif
 		__bare_init_start = .;
 		*(.text_bare_init*)
 		__bare_init_end = .;
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
index dac6571..d401164 100644
--- a/arch/arm/mach-ep93xx/Makefile
+++ b/arch/arm/mach-ep93xx/Makefile
@@ -1,3 +1,3 @@
-obj-y += clocksource.o gpio.o led.o
+obj-y += clocksource.o gpio.o led.o header.o
 
 obj-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += lowlevel_init.o
diff --git a/arch/arm/mach-ep93xx/header.c b/arch/arm/mach-ep93xx/header.c
new file mode 100644
index 0000000..4e6a2e5
--- /dev/null
+++ b/arch/arm/mach-ep93xx/header.c
@@ -0,0 +1,8 @@
+#include <common.h>
+#include <linux/compiler.h>
+#include <asm/barebox-arm-head.h>
+
+void __naked __section(.flash_header_start) go(void)
+{
+        barebox_arm_head();
+}
diff --git a/arch/arm/mach-ep93xx/include/mach/barebox.lds.h b/arch/arm/mach-ep93xx/include/mach/barebox.lds.h
new file mode 100644
index 0000000..74c4662
--- /dev/null
+++ b/arch/arm/mach-ep93xx/include/mach/barebox.lds.h
@@ -0,0 +1,9 @@
+
+/* the EP93xx expects to find the pattern 'CRUS' at 0x1000 */
+
+#define PRE_IMAGE				\
+	.pre_image : {				\
+		KEEP(*(.flash_header_start*))	\
+		. = 0x1000;			\
+		LONG(0x53555243) /* 'CRUS' */	\
+	}
diff --git a/include/asm-generic/barebox.lds.h b/include/asm-generic/barebox.lds.h
index e853ca1..b2bd19e 100644
--- a/include/asm-generic/barebox.lds.h
+++ b/include/asm-generic/barebox.lds.h
@@ -4,7 +4,8 @@
 	defined CONFIG_ARCH_IMX51 || \
 	defined CONFIG_ARCH_IMX53 || \
 	defined CONFIG_ARCH_IMX6 || \
-	defined CONFIG_X86
+	defined CONFIG_X86 || \
+	defined CONFIG_ARCH_EP93XX
 #include <mach/barebox.lds.h>
 #endif
 
-- 
1.7.10.4


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

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

* [PATCH 7/9] ARM boards: Use _text rather than TEXT_BASE
  2012-07-19  8:12 Compressed barebox image support Sascha Hauer
                   ` (5 preceding siblings ...)
  2012-07-19  8:12 ` [PATCH 6/9] ARM ep93xx: Get rid of special handling in linker file Sascha Hauer
@ 2012-07-19  8:13 ` Sascha Hauer
  2012-07-19  8:13 ` [PATCH 8/9] ARM: Separate assembler functions into their own section Sascha Hauer
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19  8:13 UTC (permalink / raw)
  To: barebox

With compressed image support TEXT_BASE will become the base
address of the uncompressed image. What the boards want instead
is the base address of the decompressor code or, if not compressed,
the base address of the uncompressed image. Use _text which is
the correct one for both cases.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/a9m2410/a9m2410.c                      |    3 ++-
 arch/arm/boards/a9m2440/a9m2440.c                      |    3 ++-
 arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c      |    3 ++-
 arch/arm/boards/eukrea_cpuimx25/lowlevel.c             |    4 ++--
 arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c      |    4 +++-
 arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S        |   11 ++++-------
 arch/arm/boards/eukrea_cpuimx35/lowlevel.c             |    4 ++--
 arch/arm/boards/freescale-mx25-3-stack/3stack.c        |    4 +++-
 arch/arm/boards/freescale-mx25-3-stack/lowlevel_init.S |   11 ++++-------
 arch/arm/boards/freescale-mx35-3-stack/3stack.c        |    4 +++-
 arch/arm/boards/freescale-mx35-3-stack/lowlevel_init.S |   11 ++++-------
 arch/arm/boards/freescale-mx53-loco/flash_header.c     |    2 +-
 arch/arm/boards/freescale-mx53-smd/flash_header.c      |    2 +-
 arch/arm/boards/freescale-mx6-arm2/flash_header.c      |    2 +-
 arch/arm/boards/guf-cupid/lowlevel.c                   |    4 ++--
 arch/arm/boards/guf-neso/lowlevel.c                    |    4 ++--
 arch/arm/boards/imx21ads/imx21ads.c                    |    4 +++-
 arch/arm/boards/imx21ads/lowlevel_init.S               |   10 ++++------
 arch/arm/boards/karo-tx25/board.c                      |    3 ++-
 arch/arm/boards/karo-tx25/lowlevel.c                   |    4 ++--
 arch/arm/boards/karo-tx51/flash_header.c               |    2 +-
 arch/arm/boards/mini2440/mini2440.c                    |    3 ++-
 arch/arm/boards/pcm037/lowlevel_init.S                 |    7 ++-----
 arch/arm/boards/pcm037/pcm037.c                        |    4 +++-
 arch/arm/boards/pcm038/lowlevel.c                      |    4 ++--
 arch/arm/boards/pcm043/lowlevel.c                      |    4 ++--
 arch/arm/boards/phycard-i.MX27/lowlevel_init.S         |    8 ++------
 arch/arm/boards/phycard-i.MX27/pca100.c                |    2 +-
 arch/arm/boards/tqma53/flash_header.c                  |    2 +-
 29 files changed, 65 insertions(+), 68 deletions(-)

diff --git a/arch/arm/boards/a9m2410/a9m2410.c b/arch/arm/boards/a9m2410/a9m2410.c
index eaafdbd..3e4572f 100644
--- a/arch/arm/boards/a9m2410/a9m2410.c
+++ b/arch/arm/boards/a9m2410/a9m2410.c
@@ -29,6 +29,7 @@
 #include <init.h>
 #include <asm/armlinux.h>
 #include <generated/mach-types.h>
+#include <asm-generic/sections.h>
 #include <partition.h>
 #include <nand.h>
 #include <io.h>
@@ -139,7 +140,7 @@ device_initcall(a9m2410_devices_init);
 #ifdef CONFIG_S3C_NAND_BOOT
 void __bare_init nand_boot(void)
 {
-	s3c24x0_nand_load_image((void *)TEXT_BASE, 256 * 1024, 0);
+	s3c24x0_nand_load_image(_text, 256 * 1024, 0);
 }
 #endif
 
diff --git a/arch/arm/boards/a9m2440/a9m2440.c b/arch/arm/boards/a9m2440/a9m2440.c
index 1d20248..6d71aef 100644
--- a/arch/arm/boards/a9m2440/a9m2440.c
+++ b/arch/arm/boards/a9m2440/a9m2440.c
@@ -28,6 +28,7 @@
 #include <driver.h>
 #include <init.h>
 #include <asm/armlinux.h>
+#include <asm-generic/sections.h>
 #include <generated/mach-types.h>
 #include <partition.h>
 #include <nand.h>
@@ -158,7 +159,7 @@ device_initcall(a9m2440_devices_init);
 #ifdef CONFIG_S3C_NAND_BOOT
 void __bare_init nand_boot(void)
 {
-	s3c24x0_nand_load_image((void *)TEXT_BASE, 256 * 1024, 0);
+	s3c24x0_nand_load_image(_text, 256 * 1024, 0);
 }
 #endif
 
diff --git a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
index b3b0838..0aac13c 100644
--- a/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
+++ b/arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c
@@ -28,6 +28,7 @@
 #include <environment.h>
 #include <mach/imx-regs.h>
 #include <asm/armlinux.h>
+#include <asm/barebox-arm.h>
 #include <asm-generic/sections.h>
 #include <mach/gpio.h>
 #include <io.h>
@@ -284,7 +285,7 @@ console_initcall(eukrea_cpuimx25_console_init);
 #ifdef CONFIG_NAND_IMX_BOOT
 void __bare_init nand_boot(void)
 {
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
 }
 #endif
 
diff --git a/arch/arm/boards/eukrea_cpuimx25/lowlevel.c b/arch/arm/boards/eukrea_cpuimx25/lowlevel.c
index ff66e92..89066e9 100644
--- a/arch/arm/boards/eukrea_cpuimx25/lowlevel.c
+++ b/arch/arm/boards/eukrea_cpuimx25/lowlevel.c
@@ -42,7 +42,7 @@ static void __bare_init __naked insdram(void)
 	r = STACK_BASE + STACK_SIZE - 12;
 	__asm__ __volatile__("mov sp, %0" : : "r"(r));
 
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
 
 	board_init_lowlevel_return();
 }
@@ -154,7 +154,7 @@ void __bare_init __naked board_init_lowlevel(void)
 		board_init_lowlevel_return();
 
 	src = (unsigned int *)IMX_NFC_BASE;
-	trg = (unsigned int *)TEXT_BASE;
+	trg = (unsigned int *)_text;
 
 	/* Move ourselves out of NFC SRAM */
 	for (i = 0; i < 0x800 / sizeof(int); i++)
diff --git a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
index 63e87c9..193c277 100644
--- a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
+++ b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
@@ -31,6 +31,7 @@
 #include <mach/gpio.h>
 #include <asm/armlinux.h>
 #include <asm-generic/sections.h>
+#include <asm/barebox-arm.h>
 #include <generated/mach-types.h>
 #include <partition.h>
 #include <fs.h>
@@ -264,7 +265,8 @@ late_initcall(eukrea_cpuimx27_late_init);
 #ifdef CONFIG_NAND_IMX_BOOT
 void __bare_init nand_boot(void)
 {
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
+	board_init_lowlevel_return();
 }
 #endif
 
diff --git a/arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S b/arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S
index e318546..0dae3ec 100644
--- a/arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S
+++ b/arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S
@@ -1,4 +1,5 @@
 #include <config.h>
+#include <asm-generic/memory_layout.h>
 #include <mach/imx-regs.h>
 
 #define writel(val, reg) \
@@ -107,7 +108,7 @@ board_init_lowlevel:
 	sdram_init
 
 #ifdef CONFIG_NAND_IMX_BOOT
-	ldr	sp, =0xa0f00000		/* Setup a temporary stack in SDRAM */
+	ldr	sp, =STACK_BASE + STACK_SIZE - 12	/* Setup a temporary stack in SDRAM */
 
 	ldr	r0, =IMX_NFC_BASE		/* start of NFC SRAM                */
 	ldr	r2, =IMX_NFC_BASE + 0x1000	/* end of NFC SRAM                  */
@@ -119,7 +120,7 @@ board_init_lowlevel:
 	bhi	ret
 
 	/* Move ourselves out of NFC SRAM */
-	ldr	r1, =TEXT_BASE
+	ldr	r1, =_text
 
 copy_loop:
 	ldmia	r0!, {r3-r9}		/* copy from source address [r0]    */
@@ -129,12 +130,8 @@ copy_loop:
 
 	ldr	pc, =1f			/* Jump to SDRAM                    */
 1:
-	bl	nand_boot		/* Load barebox from NAND Flash      */
-
-	ldr	r1, =IMX_NFC_BASE - TEXT_BASE
-	sub	r10, r10, r1		/* adjust return address from NFC SRAM */
+	b	nand_boot		/* Load barebox from NAND Flash      */
 					/* to SDRAM                            */
-
 #endif /* CONFIG_NAND_IMX_BOOT */
 
 ret:
diff --git a/arch/arm/boards/eukrea_cpuimx35/lowlevel.c b/arch/arm/boards/eukrea_cpuimx35/lowlevel.c
index 552b0cf..57867dc 100644
--- a/arch/arm/boards/eukrea_cpuimx35/lowlevel.c
+++ b/arch/arm/boards/eukrea_cpuimx35/lowlevel.c
@@ -53,7 +53,7 @@ static void __bare_init __naked insdram(void)
 	r = STACK_BASE + STACK_SIZE - 12;
 	__asm__ __volatile__("mov sp, %0" : : "r"(r));
 
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
 
 	board_init_lowlevel_return();
 }
@@ -163,7 +163,7 @@ void __bare_init __naked board_init_lowlevel(void)
 		board_init_lowlevel_return();
 
 	src = (unsigned int *)IMX_NFC_BASE;
-	trg = (unsigned int *)TEXT_BASE;
+	trg = (unsigned int *)_text;
 
 	/* Move ourselves out of NFC SRAM */
 	for (i = 0; i < 0x800 / sizeof(int); i++)
diff --git a/arch/arm/boards/freescale-mx25-3-stack/3stack.c b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
index 6b6146d..97c1fd9 100644
--- a/arch/arm/boards/freescale-mx25-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx25-3-stack/3stack.c
@@ -28,6 +28,7 @@
 #include <mach/imx-regs.h>
 #include <asm/armlinux.h>
 #include <asm-generic/sections.h>
+#include <asm/barebox-arm.h>
 #include <mach/gpio.h>
 #include <io.h>
 #include <partition.h>
@@ -294,7 +295,8 @@ console_initcall(imx25_console_init);
 #ifdef CONFIG_NAND_IMX_BOOT
 void __bare_init nand_boot(void)
 {
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
+	board_init_lowlevel_return();
 }
 #endif
 
diff --git a/arch/arm/boards/freescale-mx25-3-stack/lowlevel_init.S b/arch/arm/boards/freescale-mx25-3-stack/lowlevel_init.S
index 7b75233..fa0f957 100644
--- a/arch/arm/boards/freescale-mx25-3-stack/lowlevel_init.S
+++ b/arch/arm/boards/freescale-mx25-3-stack/lowlevel_init.S
@@ -21,6 +21,7 @@
  * MA 02111-1307 USA
  */
 
+#include <asm-generic/memory_layout.h>
 #include <mach/imx-regs.h>
 #include <mach/imx-pll.h>
 #include <mach/esdctl.h>
@@ -100,7 +101,7 @@ board_init_lowlevel:
 	str r3, [r0, #0x30]
 
 #ifdef CONFIG_NAND_IMX_BOOT
-	ldr	sp, =0xa0f00000		/* Setup a temporary stack in SDRAM */
+	ldr	sp, =STACK_BASE + STACK_SIZE - 12 /* Setup a temporary stack in SDRAM */
 
 	ldr	r0, =IMX_NFC_BASE		/* start of NFC SRAM                */
 	ldr	r2, =IMX_NFC_BASE + 0x1000	/* end of NFC SRAM                  */
@@ -112,7 +113,7 @@ board_init_lowlevel:
 	bhi	ret
 
 	/* Move ourselves out of NFC SRAM */
-	ldr	r1, =TEXT_BASE
+	ldr	r1, =_text
 
 copy_loop:
 	ldmia	r0!, {r3-r9}		/* copy from source address [r0]    */
@@ -122,11 +123,7 @@ copy_loop:
 
 	ldr	pc, =1f			/* Jump to SDRAM                    */
 1:
-	bl	nand_boot		/* Load barebox from NAND Flash      */
-
-	ldr	r1, =IMX_NFC_BASE - TEXT_BASE
-	sub	r10, r10, r1		/* adjust return address from NFC SRAM */
-					/* to SDRAM                            */
+	b	nand_boot		/* Load barebox from NAND Flash      */
 
 #endif /* CONFIG_NAND_IMX_BOOT */
 
diff --git a/arch/arm/boards/freescale-mx35-3-stack/3stack.c b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
index cb1280d..9b255a5 100644
--- a/arch/arm/boards/freescale-mx35-3-stack/3stack.c
+++ b/arch/arm/boards/freescale-mx35-3-stack/3stack.c
@@ -38,6 +38,7 @@
 
 #include <asm/armlinux.h>
 #include <asm-generic/sections.h>
+#include <asm/barebox-arm.h>
 #include <io.h>
 #include <generated/mach-types.h>
 
@@ -450,6 +451,7 @@ void __bare_init nand_boot(void)
 	 * The driver is able to detect NAND's pagesize by CPU internal
 	 * fuses or external pull ups. But not the blocksize...
 	 */
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
+	board_init_lowlevel_return();
 }
 #endif
diff --git a/arch/arm/boards/freescale-mx35-3-stack/lowlevel_init.S b/arch/arm/boards/freescale-mx35-3-stack/lowlevel_init.S
index 30dbcc0..837d2ff 100644
--- a/arch/arm/boards/freescale-mx35-3-stack/lowlevel_init.S
+++ b/arch/arm/boards/freescale-mx35-3-stack/lowlevel_init.S
@@ -25,6 +25,7 @@
 #include <mach/imx-pll.h>
 #include <mach/esdctl.h>
 #include <asm/cache-l2x0.h>
+#include <asm-generic/memory_layout.h>
 #include "board-mx35_3stack.h"
 
 #define CSD0_BASE_ADDR		0x80000000
@@ -156,7 +157,7 @@ board_init_lowlevel:
 	str	r3, [r0, #0x30]
 
 #ifdef CONFIG_NAND_IMX_BOOT
-	ldr	sp, =TEXT_BASE - 4		/* Setup a temporary stack in SDRAM */
+	ldr	sp, =STACK_BASE + STACK_SIZE - 12		/* Setup a temporary stack in SDRAM */
 
 	ldr	r0, =IMX_NFC_BASE		/* start of NFC SRAM */
 	ldr	r2, =IMX_NFC_BASE + 0x800	/* end of NFC SRAM */
@@ -168,7 +169,7 @@ board_init_lowlevel:
 	bhs	ret
 
 	/* Move ourselves out of NFC SRAM */
-	ldr r1, =TEXT_BASE
+	ldr r1, =_text
 
 copy_loop:
 	ldmia	r0!, {r3-r9}			/* copy from source address [r0] */
@@ -178,11 +179,7 @@ copy_loop:
 
 	ldr	pc, =1f				/* Jump to SDRAM */
 1:
-	bl	nand_boot			/* Load barebox from NAND Flash */
-
-	/* rebase the return address */
-	ldr	r1, =IMX_NFC_BASE - TEXT_BASE
-	sub	r10, r10, r1			/* adjust return address from NFC SRAM */
+	b	nand_boot			/* Load barebox from NAND Flash */
 ret:
 #endif /* CONFIG_NAND_IMX_BOOT */
 
diff --git a/arch/arm/boards/freescale-mx53-loco/flash_header.c b/arch/arm/boards/freescale-mx53-loco/flash_header.c
index 52e6eee..c2ab255 100644
--- a/arch/arm/boards/freescale-mx53-loco/flash_header.c
+++ b/arch/arm/boards/freescale-mx53-loco/flash_header.c
@@ -77,7 +77,7 @@ struct imx_dcd_v2_entry __dcd_entry_section dcd_entry[] = {
 	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x00000000), },
 };
 
-#define APP_DEST	CONFIG_TEXT_BASE
+#define APP_DEST	0x70000000
 
 struct imx_flash_header_v2 __flash_header_section flash_header = {
 	.header.tag		= IVT_HEADER_TAG,
diff --git a/arch/arm/boards/freescale-mx53-smd/flash_header.c b/arch/arm/boards/freescale-mx53-smd/flash_header.c
index 52e6eee..c2ab255 100644
--- a/arch/arm/boards/freescale-mx53-smd/flash_header.c
+++ b/arch/arm/boards/freescale-mx53-smd/flash_header.c
@@ -77,7 +77,7 @@ struct imx_dcd_v2_entry __dcd_entry_section dcd_entry[] = {
 	{ .addr = cpu_to_be32(0x63fd901c), .val = cpu_to_be32(0x00000000), },
 };
 
-#define APP_DEST	CONFIG_TEXT_BASE
+#define APP_DEST	0x70000000
 
 struct imx_flash_header_v2 __flash_header_section flash_header = {
 	.header.tag		= IVT_HEADER_TAG,
diff --git a/arch/arm/boards/freescale-mx6-arm2/flash_header.c b/arch/arm/boards/freescale-mx6-arm2/flash_header.c
index 69d9cfa..60cf9cd 100644
--- a/arch/arm/boards/freescale-mx6-arm2/flash_header.c
+++ b/arch/arm/boards/freescale-mx6-arm2/flash_header.c
@@ -146,7 +146,7 @@ struct imx_dcd_v2_entry __dcd_entry_section dcd_entry[] = {
 	DCD(MX6_IOMUXC_BASE_ADDR + 0x01c, 0x007f007f),
 };
 
-#define APP_DEST	CONFIG_TEXT_BASE
+#define APP_DEST	0x10000000
 
 struct imx_flash_header_v2 __flash_header_section flash_header = {
 	.header.tag		= IVT_HEADER_TAG,
diff --git a/arch/arm/boards/guf-cupid/lowlevel.c b/arch/arm/boards/guf-cupid/lowlevel.c
index bcaa199..8fa9152 100644
--- a/arch/arm/boards/guf-cupid/lowlevel.c
+++ b/arch/arm/boards/guf-cupid/lowlevel.c
@@ -60,7 +60,7 @@ static void __bare_init __naked insdram(void)
 	r = STACK_BASE + STACK_SIZE - 12;
 	__asm__ __volatile__("mov sp, %0" : : "r"(r));
 
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
 
 	board_init_lowlevel_return();
 }
@@ -334,7 +334,7 @@ void __bare_init __naked board_init_lowlevel(void)
 		board_init_lowlevel_return();
 
 	src = (unsigned int *)IMX_NFC_BASE;
-	trg = (unsigned int *)TEXT_BASE;
+	trg = (unsigned int *)_text;
 
 	/* Move ourselves out of NFC SRAM */
 	for (i = 0; i < 0x800 / sizeof(int); i++)
diff --git a/arch/arm/boards/guf-neso/lowlevel.c b/arch/arm/boards/guf-neso/lowlevel.c
index a8718e7..9b206be 100644
--- a/arch/arm/boards/guf-neso/lowlevel.c
+++ b/arch/arm/boards/guf-neso/lowlevel.c
@@ -44,7 +44,7 @@ static void __bare_init __naked insdram(void)
 	r = STACK_BASE + STACK_SIZE - 12;
 	__asm__ __volatile__("mov sp, %0" : : "r"(r));
 
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
 
 	board_init_lowlevel_return();
 }
@@ -105,7 +105,7 @@ void __bare_init __naked board_init_lowlevel(void)
 		board_init_lowlevel_return();
 
 	src = (unsigned int *)IMX_NFC_BASE;
-	trg = (unsigned int *)TEXT_BASE;
+	trg = (unsigned int *)_text;
 
 	/* Move ourselves out of NFC SRAM */
 	for (i = 0; i < 0x800 / sizeof(int); i++)
diff --git a/arch/arm/boards/imx21ads/imx21ads.c b/arch/arm/boards/imx21ads/imx21ads.c
index e394417..2bbd5ed 100644
--- a/arch/arm/boards/imx21ads/imx21ads.c
+++ b/arch/arm/boards/imx21ads/imx21ads.c
@@ -28,6 +28,7 @@
 #include <mach/imx-regs.h>
 #include <asm/armlinux.h>
 #include <asm-generic/sections.h>
+#include <asm/barebox-arm.h>
 #include <io.h>
 #include <mach/gpio.h>
 #include <partition.h>
@@ -204,7 +205,8 @@ console_initcall(mx21ads_console_init);
 void __bare_init nand_boot(void)
 {
 	PCCR0 |= PCCR0_NFC_EN;
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
+	board_init_lowlevel_return();
 }
 #endif
 
diff --git a/arch/arm/boards/imx21ads/lowlevel_init.S b/arch/arm/boards/imx21ads/lowlevel_init.S
index 7926e28..1aeea57 100644
--- a/arch/arm/boards/imx21ads/lowlevel_init.S
+++ b/arch/arm/boards/imx21ads/lowlevel_init.S
@@ -18,6 +18,7 @@
  */
 
 #include <config.h>
+#include <asm-generic/memory_layout.h>
 #include <mach/imx-regs.h>
 
 	.section ".text_bare_init","ax"
@@ -121,7 +122,7 @@ board_init_lowlevel:
 	str	r1, [r0]
 
 #ifdef CONFIG_NAND_IMX_BOOT
-	ldr	sp, =TEXT_BASE - 4	/* Setup a temporary stack in SDRAM */
+	ldr	sp, =STACK_BASE + STACK_SIZE - 12	/* Setup a temporary stack in SDRAM */
 
 	ldr	r0, =IMX_NFC_BASE		/* start of NFC SRAM        */
 	ldr	r2, =IMX_NFC_BASE + 0x800	/* end of NFC SRAM          */
@@ -133,7 +134,7 @@ board_init_lowlevel:
 	bhi	ret
 
 	/* Move ourselves out of NFC SRAM */
-	ldr	r1, =TEXT_BASE
+	ldr	r1, =_text
 
 copy_loop:
 	ldmia	r0!, {r3-r9}		/* copy from source address [r0]    */
@@ -143,10 +144,7 @@ copy_loop:
 
 	ldr	pc, =1f			/* Jump to SDRAM                    */
 1:
-	bl	nand_boot		/* Load barebox from NAND Flash     */
-
-	ldr	r1, =IMX_NFC_BASE - TEXT_BASE
-	sub	r10, r10, r1		/* adjust return address from NFC   */
+	b	nand_boot		/* Load barebox from NAND Flash     */
 					/* SRAM to SDRAM                    */
 #endif /* CONFIG_NAND_IMX_BOOT */
 
diff --git a/arch/arm/boards/karo-tx25/board.c b/arch/arm/boards/karo-tx25/board.c
index 040c75b..c089935 100644
--- a/arch/arm/boards/karo-tx25/board.c
+++ b/arch/arm/boards/karo-tx25/board.c
@@ -28,6 +28,7 @@
 #include <mach/imx-regs.h>
 #include <asm/armlinux.h>
 #include <asm-generic/sections.h>
+#include <asm/barebox-arm.h>
 #include <mach/gpio.h>
 #include <io.h>
 #include <partition.h>
@@ -168,7 +169,7 @@ console_initcall(tx25_console_init);
 #ifdef CONFIG_NAND_IMX_BOOT
 void __bare_init nand_boot(void)
 {
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
 }
 #endif
 
diff --git a/arch/arm/boards/karo-tx25/lowlevel.c b/arch/arm/boards/karo-tx25/lowlevel.c
index 35dfe9f..9f1c5d6 100644
--- a/arch/arm/boards/karo-tx25/lowlevel.c
+++ b/arch/arm/boards/karo-tx25/lowlevel.c
@@ -40,7 +40,7 @@ static void __bare_init __naked insdram(void)
 	r = STACK_BASE + STACK_SIZE - 12;
 	__asm__ __volatile__("mov sp, %0" : : "r"(r));
 
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
 
 	board_init_lowlevel_return();
 }
@@ -158,7 +158,7 @@ void __bare_init __naked board_init_lowlevel(void)
 		board_init_lowlevel_return();
 
 	src = (unsigned int *)IMX_NFC_BASE;
-	trg = (unsigned int *)TEXT_BASE;
+	trg = (unsigned int *)_text;
 
 	/* Move ourselves out of NFC SRAM */
 	for (i = 0; i < 0x800 / sizeof(int); i++)
diff --git a/arch/arm/boards/karo-tx51/flash_header.c b/arch/arm/boards/karo-tx51/flash_header.c
index 7d2f97e..f570348 100644
--- a/arch/arm/boards/karo-tx51/flash_header.c
+++ b/arch/arm/boards/karo-tx51/flash_header.c
@@ -39,7 +39,7 @@ struct imx_dcd_entry __dcd_entry_section dcd_entry[] = {
     { .ptr_type = 4, .addr = 0x83fd9014, .val = 0x00000000, },
 };
 
-#define APP_DEST	CONFIG_ARCH_TEXT_BASE
+#define APP_DEST	0x90000000
 
 struct imx_flash_header __flash_header_section flash_header = {
 	.app_code_jump_vector	= APP_DEST + 0x1000,
diff --git a/arch/arm/boards/mini2440/mini2440.c b/arch/arm/boards/mini2440/mini2440.c
index 3d3b820..6408bc8 100644
--- a/arch/arm/boards/mini2440/mini2440.c
+++ b/arch/arm/boards/mini2440/mini2440.c
@@ -36,6 +36,7 @@
 #include <mci.h>
 #include <fb.h>
 #include <asm/armlinux.h>
+#include <asm-generic/sections.h>
 #include <io.h>
 #include <mach/gpio.h>
 #include <mach/s3c-iomap.h>
@@ -329,7 +330,7 @@ device_initcall(mini2440_devices_init);
 #ifdef CONFIG_S3C_NAND_BOOT
 void __bare_init nand_boot(void)
 {
-	s3c24x0_nand_load_image((void *)TEXT_BASE, 256 * 1024, 0);
+	s3c24x0_nand_load_image(_text, 256 * 1024, 0);
 }
 #endif
 
diff --git a/arch/arm/boards/pcm037/lowlevel_init.S b/arch/arm/boards/pcm037/lowlevel_init.S
index cc4674d..1f8d38f 100644
--- a/arch/arm/boards/pcm037/lowlevel_init.S
+++ b/arch/arm/boards/pcm037/lowlevel_init.S
@@ -146,7 +146,7 @@ clear_iomux:
 	bhs	ret
 
 	/* Move ourselves out of NFC SRAM */
-	ldr	r1, =TEXT_BASE
+	ldr	r1, =_text
 
 copy_loop:
 	ldmia	r0!, {r3-r9}		/* copy from source address [r0]    */
@@ -156,10 +156,7 @@ copy_loop:
 
 	ldr	pc, =1f			/* Jump to SDRAM                    */
 1:
-	bl	nand_boot		/* Load barebox from NAND Flash      */
-
-	ldr	r1, =IMX_NFC_BASE - TEXT_BASE
-	sub	r10, r10, r1		/* adjust return address from NFC SRAM */
+	b	nand_boot		/* Load barebox from NAND Flash      */
 ret:
 #endif /* CONFIG_NAND_IMX_BOOT */
 
diff --git a/arch/arm/boards/pcm037/pcm037.c b/arch/arm/boards/pcm037/pcm037.c
index d789b28..9cb082b 100644
--- a/arch/arm/boards/pcm037/pcm037.c
+++ b/arch/arm/boards/pcm037/pcm037.c
@@ -37,6 +37,7 @@
 #include <asm/mmu.h>
 #include <partition.h>
 #include <generated/mach-types.h>
+#include <asm/barebox-arm.h>
 #include <mach/imx-nand.h>
 #include <mach/devices-imx31.h>
 
@@ -246,6 +247,7 @@ console_initcall(imx31_console_init);
 #ifdef CONFIG_NAND_IMX_BOOT
 void __bare_init nand_boot(void)
 {
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
+	board_init_lowlevel_return();
 }
 #endif
diff --git a/arch/arm/boards/pcm038/lowlevel.c b/arch/arm/boards/pcm038/lowlevel.c
index 2bc89a0..3f29a83 100644
--- a/arch/arm/boards/pcm038/lowlevel.c
+++ b/arch/arm/boards/pcm038/lowlevel.c
@@ -45,7 +45,7 @@ static void __bare_init __naked insdram(void)
 	r = STACK_BASE + STACK_SIZE - 12;
 	__asm__ __volatile__("mov sp, %0" : : "r"(r));
 
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
 
 	board_init_lowlevel_return();
 }
@@ -111,7 +111,7 @@ void __bare_init __naked board_init_lowlevel(void)
 		board_init_lowlevel_return();
 
 	src = (unsigned int *)IMX_NFC_BASE;
-	trg = (unsigned int *)TEXT_BASE;
+	trg = (unsigned int *)_text;
 
 	/* Move ourselves out of NFC SRAM */
 	for (i = 0; i < 0x800 / sizeof(int); i++)
diff --git a/arch/arm/boards/pcm043/lowlevel.c b/arch/arm/boards/pcm043/lowlevel.c
index 69cc4f1..fd6787f 100644
--- a/arch/arm/boards/pcm043/lowlevel.c
+++ b/arch/arm/boards/pcm043/lowlevel.c
@@ -58,7 +58,7 @@ static void __bare_init __naked insdram(void)
 	r = STACK_BASE + STACK_SIZE - 12;
 	__asm__ __volatile__("mov sp, %0" : : "r"(r));
 
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
 
 	board_init_lowlevel_return();
 }
@@ -213,7 +213,7 @@ void __bare_init __naked board_init_lowlevel(void)
 		board_init_lowlevel_return();
 
 	src = (unsigned int *)IMX_NFC_BASE;
-	trg = (unsigned int *)TEXT_BASE;
+	trg = (unsigned int *)_text;
 
 	/* Move ourselves out of NFC SRAM */
 	for (i = 0; i < 0x800 / sizeof(int); i++)
diff --git a/arch/arm/boards/phycard-i.MX27/lowlevel_init.S b/arch/arm/boards/phycard-i.MX27/lowlevel_init.S
index 3ef2c54..c24edd4 100644
--- a/arch/arm/boards/phycard-i.MX27/lowlevel_init.S
+++ b/arch/arm/boards/phycard-i.MX27/lowlevel_init.S
@@ -106,7 +106,7 @@ board_init_lowlevel:
 	bhi	ret
 
 	/* Move ourselves out of NFC SRAM */
-	ldr	r1, =TEXT_BASE
+	ldr	r1, =_text
 
 copy_loop:
 	ldmia	r0!, {r3-r9}		/* copy from source address [r0]    */
@@ -116,11 +116,7 @@ copy_loop:
 
 	ldr	pc, =1f			/* Jump to SDRAM                    */
 1:
-	bl	nand_boot		/* Load barebox from NAND Flash      */
-
-	ldr	r1, =IMX_NFC_BASE - TEXT_BASE
-	sub	r10, r10, r1		/* adjust return address from NFC SRAM */
-					/* to SDRAM                            */
+	b	nand_boot		/* Load barebox from NAND Flash      */
 
 #endif /* CONFIG_NAND_IMX_BOOT */
 
diff --git a/arch/arm/boards/phycard-i.MX27/pca100.c b/arch/arm/boards/phycard-i.MX27/pca100.c
index 6fdcf6e..126f9ef 100644
--- a/arch/arm/boards/phycard-i.MX27/pca100.c
+++ b/arch/arm/boards/phycard-i.MX27/pca100.c
@@ -328,7 +328,7 @@ console_initcall(pca100_console_init);
 #ifdef CONFIG_NAND_IMX_BOOT
 void __bare_init nand_boot(void)
 {
-	imx_nand_load_image((void *)TEXT_BASE, barebox_image_size);
+	imx_nand_load_image(_text, barebox_image_size);
 }
 #endif
 
diff --git a/arch/arm/boards/tqma53/flash_header.c b/arch/arm/boards/tqma53/flash_header.c
index d912b38..a6bcdad 100644
--- a/arch/arm/boards/tqma53/flash_header.c
+++ b/arch/arm/boards/tqma53/flash_header.c
@@ -85,7 +85,7 @@ struct imx_dcd_v2_entry __dcd_entry_section dcd_entry[] = {
 	{ .addr = cpu_to_be32(0x63fd901C), .val = cpu_to_be32(0x00000000), },
 };
 
-#define APP_DEST	CONFIG_TEXT_BASE
+#define APP_DEST	0x70000000
 
 struct imx_flash_header_v2 __flash_header_section flash_header = {
 	.header.tag		= IVT_HEADER_TAG,
-- 
1.7.10.4


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

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

* [PATCH 8/9] ARM: Separate assembler functions into their own section
  2012-07-19  8:12 Compressed barebox image support Sascha Hauer
                   ` (6 preceding siblings ...)
  2012-07-19  8:13 ` [PATCH 7/9] ARM boards: Use _text rather than TEXT_BASE Sascha Hauer
@ 2012-07-19  8:13 ` Sascha Hauer
  2012-07-19 10:38   ` Marc Kleine-Budde
  2012-07-23 19:59   ` Sascha Hauer
  2012-07-19  8:13 ` [PATCH 9/9] Add compressed image support Sascha Hauer
                   ` (2 subsequent siblings)
  10 siblings, 2 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19  8:13 UTC (permalink / raw)
  To: barebox

To let the linker remove unused functions.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/cache-armv4.S      |    7 ++++++-
 arch/arm/cpu/cache-armv5.S      |    7 ++++++-
 arch/arm/cpu/cache-armv6.S      |   11 +++++++++--
 arch/arm/cpu/cache-armv7.S      |    8 ++++++--
 arch/arm/lib/ashldi3.S          |    1 +
 arch/arm/lib/ashrdi3.S          |    1 +
 arch/arm/lib/findbit.S          |    9 +++++++++
 arch/arm/lib/io-writesw-armv4.S |    2 ++
 arch/arm/lib/lib1funcs.S        |    7 +++++++
 arch/arm/lib/lshrdi3.S          |    1 +
 10 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/cache-armv4.S b/arch/arm/cpu/cache-armv4.S
index 6d03565..2231eee 100644
--- a/arch/arm/cpu/cache-armv4.S
+++ b/arch/arm/cpu/cache-armv4.S
@@ -3,6 +3,7 @@
 
 #define CACHE_DLINESIZE 32
 
+.section .text.__mmu_cache_on
 ENTRY(__mmu_cache_on)
 		mov	r12, lr
 #ifdef CONFIG_MMU
@@ -30,6 +31,7 @@ __common_mmu_cache_on:
 		mrc	p15, 0, r0, c1, c0, 0	@ and read it back to
 		sub	pc, lr, r0, lsr #32	@ properly flush pipeline
 
+.section .text.__mmu_cache_off
 ENTRY(__mmu_cache_off)
 #ifdef CONFIG_MMU
 		mrc	p15, 0, r0, c1, c0
@@ -42,6 +44,7 @@ ENTRY(__mmu_cache_off)
 		mov	pc, lr
 ENDPROC(__mmu_cache_off)
 
+.section .text.__mmu_cache_flush
 ENTRY(__mmu_cache_flush)
 		mrc	p15, 0, r6, c0, c0	@ get processor ID
 		mov	r2, #64*1024		@ default: 32K dcache size (*2)
@@ -74,7 +77,6 @@ no_cache_id:
 		mov	pc, lr
 ENDPROC(__mmu_cache_flush)
 
-.section ".text.text"
 /*
  *	dma_inv_range(start, end)
  *
@@ -88,6 +90,7 @@ ENDPROC(__mmu_cache_flush)
  *
  * (same as v4wb)
  */
+.section .text.__dma_inv_range
 ENTRY(__dma_inv_range)
 	tst	r0, #CACHE_DLINESIZE - 1
 	bic	r0, r0, #CACHE_DLINESIZE - 1
@@ -111,6 +114,7 @@ ENTRY(__dma_inv_range)
  *
  * (same as v4wb)
  */
+.section .text.__dma_clean_range
 ENTRY(__dma_clean_range)
 	bic	r0, r0, #CACHE_DLINESIZE - 1
 1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
@@ -128,6 +132,7 @@ ENTRY(__dma_clean_range)
  *	- start	- virtual start address
  *	- end	- virtual end address
  */
+.section .text.__dma_flush_range
 ENTRY(__dma_flush_range)
 	bic	r0, r0, #CACHE_DLINESIZE - 1
 1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
diff --git a/arch/arm/cpu/cache-armv5.S b/arch/arm/cpu/cache-armv5.S
index a1193a6..d6ffaf1 100644
--- a/arch/arm/cpu/cache-armv5.S
+++ b/arch/arm/cpu/cache-armv5.S
@@ -3,6 +3,7 @@
 
 #define CACHE_DLINESIZE 32
 
+.section .text.__mmu_cache_on
 ENTRY(__mmu_cache_on)
 		mov	r12, lr
 #ifdef CONFIG_MMU
@@ -30,6 +31,7 @@ __common_mmu_cache_on:
 		mrc	p15, 0, r0, c1, c0, 0	@ and read it back to
 		sub	pc, lr, r0, lsr #32	@ properly flush pipeline
 
+.section .text.__mmu_cache_off
 ENTRY(__mmu_cache_off)
 #ifdef CONFIG_MMU
 		mrc	p15, 0, r0, c1, c0
@@ -42,6 +44,7 @@ ENTRY(__mmu_cache_off)
 		mov	pc, lr
 ENDPROC(__mmu_cache_off)
 
+.section .text.__mmu_cache_flush
 ENTRY(__mmu_cache_flush)
 1:		mrc	p15, 0, r15, c7, c14, 3	@ test,clean,invalidate D cache
 		bne	1b
@@ -49,7 +52,6 @@ ENTRY(__mmu_cache_flush)
 		mcr	p15, 0, r0, c7, c10, 4	@ drain WB
 		mov	pc, lr
 ENDPROC(__mmu_cache_flush)
-.section ".text.text"
 
 /*
  *	dma_inv_range(start, end)
@@ -64,6 +66,7 @@ ENDPROC(__mmu_cache_flush)
  *
  * (same as v4wb)
  */
+.section .text.__dma_inv_range
 ENTRY(__dma_inv_range)
 	tst	r0, #CACHE_DLINESIZE - 1
 	bic	r0, r0, #CACHE_DLINESIZE - 1
@@ -87,6 +90,7 @@ ENTRY(__dma_inv_range)
  *
  * (same as v4wb)
  */
+.section .text.__dma_clean_range
 ENTRY(__dma_clean_range)
 	bic	r0, r0, #CACHE_DLINESIZE - 1
 1:	mcr	p15, 0, r0, c7, c10, 1		@ clean D entry
@@ -104,6 +108,7 @@ ENTRY(__dma_clean_range)
  *	- start	- virtual start address
  *	- end	- virtual end address
  */
+.section .text.__dma_flush_range
 ENTRY(__dma_flush_range)
 	bic	r0, r0, #CACHE_DLINESIZE - 1
 1:	mcr	p15, 0, r0, c7, c14, 1		@ clean+invalidate D entry
diff --git a/arch/arm/cpu/cache-armv6.S b/arch/arm/cpu/cache-armv6.S
index 335bac2..02b1d3e 100644
--- a/arch/arm/cpu/cache-armv6.S
+++ b/arch/arm/cpu/cache-armv6.S
@@ -5,6 +5,7 @@
 #define CACHE_LINE_SIZE		32
 #define D_CACHE_LINE_SIZE	32
 
+.section .text.__mmu_cache_on
 ENTRY(__mmu_cache_on)
 		mov	r12, lr
 #ifdef CONFIG_MMU
@@ -33,6 +34,7 @@ __common_mmu_cache_on:
 		sub	pc, lr, r0, lsr #32	@ properly flush pipeline
 
 
+.section .text.__mmu_cache_off
 ENTRY(__mmu_cache_off)
 #ifdef CONFIG_MMU
 		mrc	p15, 0, r0, c1, c0
@@ -44,6 +46,7 @@ ENTRY(__mmu_cache_off)
 #endif
 		mov	pc, lr
 
+.section .text.__mmu_cache_flush
 ENTRY(__mmu_cache_flush)
 		mov	r1, #0
 		mcr	p15, 0, r1, c7, c14, 0	@ clean+invalidate D
@@ -52,7 +55,6 @@ ENTRY(__mmu_cache_flush)
 		mcr	p15, 0, r1, c7, c10, 4	@ drain WB
 		mov	pc, lr
 ENDPROC(__mmu_cache_flush)
-.section ".text.text"
 
 /*
  *	v6_dma_inv_range(start,end)
@@ -64,6 +66,7 @@ ENDPROC(__mmu_cache_flush)
  *	- start   - virtual start address of region
  *	- end     - virtual end address of region
  */
+.section .text.__dma_inv_range
 ENTRY(__dma_inv_range)
 	tst	r0, #D_CACHE_LINE_SIZE - 1
 	bic	r0, r0, #D_CACHE_LINE_SIZE - 1
@@ -91,12 +94,14 @@ ENTRY(__dma_inv_range)
 	mov	r0, #0
 	mcr	p15, 0, r0, c7, c10, 4		@ drain write buffer
 	mov	pc, lr
+ENDPROC(__dma_inv_range)
 
 /*
  *	v6_dma_clean_range(start,end)
  *	- start   - virtual start address of region
  *	- end     - virtual end address of region
  */
+.section .text.__dma_clean_range
 ENTRY(__dma_clean_range)
 	bic	r0, r0, #D_CACHE_LINE_SIZE - 1
 1:
@@ -111,12 +116,14 @@ ENTRY(__dma_clean_range)
 	mov	r0, #0
 	mcr	p15, 0, r0, c7, c10, 4		@ drain write buffer
 	mov	pc, lr
+ENDPROC(__dma_clean_range)
 
 /*
  *	v6_dma_flush_range(start,end)
  *	- start   - virtual start address of region
  *	- end     - virtual end address of region
  */
+.section .text.__dma_flush_range
 ENTRY(__dma_flush_range)
 	bic	r0, r0, #D_CACHE_LINE_SIZE - 1
 1:
@@ -131,4 +138,4 @@ ENTRY(__dma_flush_range)
 	mov	r0, #0
 	mcr	p15, 0, r0, c7, c10, 4		@ drain write buffer
 	mov	pc, lr
-
+ENDPROC(__dma_flush_range)
diff --git a/arch/arm/cpu/cache-armv7.S b/arch/arm/cpu/cache-armv7.S
index 28a6315..9bd7425 100644
--- a/arch/arm/cpu/cache-armv7.S
+++ b/arch/arm/cpu/cache-armv7.S
@@ -1,6 +1,7 @@
 #include <linux/linkage.h>
 #include <init.h>
 
+.section .text.__mmu_cache_on
 ENTRY(__mmu_cache_on)
 		mov	r12, lr
 #ifdef CONFIG_MMU
@@ -30,6 +31,7 @@ ENTRY(__mmu_cache_on)
 		mov	pc, r12
 ENDPROC(__mmu_cache_on)
 
+.section .text.__mmu_cache_off
 ENTRY(__mmu_cache_off)
 		mrc	p15, 0, r0, c1, c0
 #ifdef CONFIG_MMU
@@ -50,6 +52,7 @@ ENTRY(__mmu_cache_off)
 		mov	pc, r12
 ENDPROC(__mmu_cache_off)
 
+.section .text.__mmu_cache_flush
 ENTRY(__mmu_cache_flush)
 		mrc	p15, 0, r10, c0, c1, 5	@ read ID_MMFR1
 		tst	r10, #0xf << 16		@ hierarchical cache (ARMv7)
@@ -110,7 +113,6 @@ iflush:
 		mcr	p15, 0, r10, c7, c5, 4	@ ISB
 		mov	pc, lr
 ENDPROC(__mmu_cache_flush)
-.section ".text.text"
 
 /*
  * cache_line_size - get the cache line size from the CSIDR register
@@ -134,6 +136,7 @@ ENDPROC(__mmu_cache_flush)
  *	- start   - virtual start address of region
  *	- end     - virtual end address of region
  */
+.section .text.__dma_inv_range
 ENTRY(__dma_inv_range)
 	dcache_line_size r2, r3
 	sub	r3, r2, #1
@@ -158,6 +161,7 @@ ENDPROC(__dma_inv_range)
  *	- start   - virtual start address of region
  *	- end     - virtual end address of region
  */
+.section .text.__dma_clean_range
 ENTRY(__dma_clean_range)
 	dcache_line_size r2, r3
 	sub	r3, r2, #1
@@ -176,6 +180,7 @@ ENDPROC(__dma_clean_range)
  *	- start   - virtual start address of region
  *	- end     - virtual end address of region
  */
+.section .text.__dma_flush_range
 ENTRY(__dma_flush_range)
 	dcache_line_size r2, r3
 	sub	r3, r2, #1
@@ -188,4 +193,3 @@ ENTRY(__dma_flush_range)
 	dsb
 	mov	pc, lr
 ENDPROC(__dma_flush_range)
-
diff --git a/arch/arm/lib/ashldi3.S b/arch/arm/lib/ashldi3.S
index 638deb1..6588846 100644
--- a/arch/arm/lib/ashldi3.S
+++ b/arch/arm/lib/ashldi3.S
@@ -36,6 +36,7 @@ Boston, MA 02110-1301, USA.  */
 #define ah r1
 #endif
 
+.section .text.__ashldi3
 ENTRY(__ashldi3)
 ENTRY(__aeabi_llsl)
 
diff --git a/arch/arm/lib/ashrdi3.S b/arch/arm/lib/ashrdi3.S
index 015e8aa..a8a32f6 100644
--- a/arch/arm/lib/ashrdi3.S
+++ b/arch/arm/lib/ashrdi3.S
@@ -36,6 +36,7 @@ Boston, MA 02110-1301, USA.  */
 #define ah r1
 #endif
 
+.section .text.__ashrdi3
 ENTRY(__ashrdi3)
 ENTRY(__aeabi_lasr)
 
diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S
index ef4caff..422455d 100644
--- a/arch/arm/lib/findbit.S
+++ b/arch/arm/lib/findbit.S
@@ -22,6 +22,7 @@
  * Purpose  : Find a 'zero' bit
  * Prototype: int find_first_zero_bit(void *addr, unsigned int maxbit);
  */
+.section .text._find_first_zero_bit_le
 ENTRY(_find_first_zero_bit_le)
 		teq	r1, #0
 		beq	3f
@@ -43,6 +44,7 @@ ENDPROC(_find_first_zero_bit_le)
  * Purpose  : Find next 'zero' bit
  * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset)
  */
+.section .text._find_next_zero_bit_le
 ENTRY(_find_next_zero_bit_le)
 		teq	r1, #0
 		beq	3b
@@ -63,6 +65,7 @@ ENDPROC(_find_next_zero_bit_le)
  * Purpose  : Find a 'one' bit
  * Prototype: int find_first_bit(const unsigned long *addr, unsigned int maxbit);
  */
+.section .text._find_first_bit_le
 ENTRY(_find_first_bit_le)
 		teq	r1, #0
 		beq	3f
@@ -84,6 +87,7 @@ ENDPROC(_find_first_bit_le)
  * Purpose  : Find next 'one' bit
  * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset)
  */
+.section .text._find_next_bit_le
 ENTRY(_find_next_bit_le)
 		teq	r1, #0
 		beq	3b
@@ -101,6 +105,7 @@ ENDPROC(_find_next_bit_le)
 
 #ifdef __ARMEB__
 
+.section .text._find_first_zero_bit_be
 ENTRY(_find_first_zero_bit_be)
 		teq	r1, #0
 		beq	3f
@@ -118,6 +123,7 @@ ENTRY(_find_first_zero_bit_be)
 		mov	pc, lr
 ENDPROC(_find_first_zero_bit_be)
 
+.section .text._find_next_zero_bit_be
 ENTRY(_find_next_zero_bit_be)
 		teq	r1, #0
 		beq	3b
@@ -135,6 +141,7 @@ ENTRY(_find_next_zero_bit_be)
 		b	2b			@ loop for next bit
 ENDPROC(_find_next_zero_bit_be)
 
+.section .text._find_first_bit_be
 ENTRY(_find_first_bit_be)
 		teq	r1, #0
 		beq	3f
@@ -152,6 +159,7 @@ ENTRY(_find_first_bit_be)
 		mov	pc, lr
 ENDPROC(_find_first_bit_be)
 
+.section .text._find_next_bit_be
 ENTRY(_find_next_bit_be)
 		teq	r1, #0
 		beq	3b
@@ -173,6 +181,7 @@ ENDPROC(_find_next_bit_be)
 /*
  * One or more bits in the LSB of r3 are assumed to be set.
  */
+.section .text.L_found
 .L_found:
 #if __LINUX_ARM_ARCH__ >= 5
 		rsb	r0, r3, #0
diff --git a/arch/arm/lib/io-writesw-armv4.S b/arch/arm/lib/io-writesw-armv4.S
index ff4f71b..9e8308d 100644
--- a/arch/arm/lib/io-writesw-armv4.S
+++ b/arch/arm/lib/io-writesw-armv4.S
@@ -22,6 +22,8 @@
 #endif
 		.endm
 
+.section .text.__raw_writesw
+
 .Loutsw_align:	movs	ip, r1, lsl #31
 		bne	.Loutsw_noalign
 
diff --git a/arch/arm/lib/lib1funcs.S b/arch/arm/lib/lib1funcs.S
index 5143e90..7d6f708 100644
--- a/arch/arm/lib/lib1funcs.S
+++ b/arch/arm/lib/lib1funcs.S
@@ -205,6 +205,7 @@ Boston, MA 02111-1307, USA.  */
 .endm
 
 
+.section .text.__udivsi3
 ENTRY(__udivsi3)
 ENTRY(__aeabi_uidiv)
 
@@ -233,6 +234,7 @@ ENTRY(__aeabi_uidiv)
 ENDPROC(__udivsi3)
 ENDPROC(__aeabi_uidiv)
 
+.section .text.__umodsi3
 ENTRY(__umodsi3)
 
 	subs	r2, r1, #1			@ compare divisor with 1
@@ -249,6 +251,7 @@ ENTRY(__umodsi3)
 
 ENDPROC(__umodsi3)
 
+.section .text.__divsi3
 ENTRY(__divsi3)
 ENTRY(__aeabi_idiv)
 
@@ -290,6 +293,7 @@ ENTRY(__aeabi_idiv)
 ENDPROC(__divsi3)
 ENDPROC(__aeabi_idiv)
 
+.section .text.__modsi3
 ENTRY(__modsi3)
 
 	cmp	r1, #0
@@ -314,6 +318,7 @@ ENDPROC(__modsi3)
 
 #ifdef CONFIG_AEABI
 
+.section .text.__aeabi_uidivmod
 ENTRY(__aeabi_uidivmod)
 
 	stmfd	sp!, {r0, r1, ip, lr}
@@ -325,6 +330,7 @@ ENTRY(__aeabi_uidivmod)
 
 ENDPROC(__aeabi_uidivmod)
 
+.section .text.__aeabi_idivmod
 ENTRY(__aeabi_idivmod)
 
 	stmfd	sp!, {r0, r1, ip, lr}
@@ -338,6 +344,7 @@ ENDPROC(__aeabi_idivmod)
 
 #endif
 
+.section .text.Ldiv0
 Ldiv0:
 
 	str	lr, [sp, #-8]!
diff --git a/arch/arm/lib/lshrdi3.S b/arch/arm/lib/lshrdi3.S
index f83d449..3c7df3b 100644
--- a/arch/arm/lib/lshrdi3.S
+++ b/arch/arm/lib/lshrdi3.S
@@ -36,6 +36,7 @@ Boston, MA 02110-1301, USA.  */
 #define ah r1
 #endif
 
+.section .text.__lshrdi3
 ENTRY(__lshrdi3)
 ENTRY(__aeabi_llsr)
 
-- 
1.7.10.4


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

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

* [PATCH 9/9] Add compressed image support
  2012-07-19  8:12 Compressed barebox image support Sascha Hauer
                   ` (7 preceding siblings ...)
  2012-07-19  8:13 ` [PATCH 8/9] ARM: Separate assembler functions into their own section Sascha Hauer
@ 2012-07-19  8:13 ` Sascha Hauer
  2012-07-19 14:10   ` Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 more replies)
  2012-07-19 15:08 ` Compressed barebox " Jean-Christophe PLAGNIOL-VILLARD
  2012-07-19 20:11 ` Robert Jarzmik
  10 siblings, 3 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19  8:13 UTC (permalink / raw)
  To: barebox

This allows for creating a lzo compressed binary. This is done by
linking barebox twice using two linker scripts. One is the regular
uncompressed binary but without the lowlevel init stuff. The
other contains the lowlevel init stuff, the decompressor and the
compressed binary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Makefile                              |   31 +++++++++++++-
 arch/arm/Kconfig                      |    1 +
 arch/arm/Makefile                     |    1 +
 arch/arm/cpu/start.c                  |   73 +++++++++++++++++++++++++++++++--
 arch/arm/lib/Makefile                 |    1 +
 arch/arm/lib/barebox-compressed.lds.S |   71 ++++++++++++++++++++++++++++++++
 arch/arm/lib/barebox.lds.S            |    3 +-
 common/Kconfig                        |   12 ++++++
 include/asm-generic/memory_layout.h   |    2 +
 lib/vsprintf.c                        |   25 ++++++++++-
 piggy.lzo.S                           |    6 +++
 11 files changed, 220 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm/lib/barebox-compressed.lds.S
 create mode 100644 piggy.lzo.S

diff --git a/Makefile b/Makefile
index ebcf9bf..3ade6cc 100644
--- a/Makefile
+++ b/Makefile
@@ -512,6 +512,7 @@ common-y	:= $(patsubst %/, %/built-in.o, $(common-y))
 barebox-common := $(common-y)
 barebox-all    := $(barebox-common)
 barebox-lds    := $(lds-y)
+barebox-compressed-lds    := $(lds-compressed-y)
 
 # Rule to link barebox
 # May be overridden by arch/$(ARCH)/Makefile
@@ -667,6 +668,7 @@ quiet_cmd_objcopy = OBJCOPY $@
       cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
 
 OBJCOPYFLAGS_barebox.bin = -O binary
+OBJCOPYFLAGS_barebox-uncompressed.bin = -O binary
 
 barebox.bin: barebox FORCE
 	$(call if_changed,objcopy)
@@ -700,13 +702,39 @@ quiet_cmd_disasm = DISASM  $@
 
 barebox.S: barebox FORCE
 	$(call if_changed,disasm)
+barebox-uncompressed.S: barebox-uncompressed FORCE
+	$(call if_changed,disasm)
 endif
 
 # barebox image
+barebox-uncompressed: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o)
+	$(call barebox-modpost)
+	$(call if_changed_rule,barebox__)
+	$(Q)rm -f .old_version
+
+barebox-uncompressed.bin: barebox-uncompressed
+	$(call if_changed,objcopy)
+
+barebox-uncompressed.bin.lzo: barebox-uncompressed.bin
+	@echo "  LZO    " $@
+	$(Q)lzop -f -9 -o $@ barebox-uncompressed.bin
+
+piggy.lzo.o: barebox-uncompressed.bin.lzo piggy.lzo.S
+	@echo "  CC     " $@
+	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c piggy.lzo.S -o $@
+
+ifdef CONFIG_IMAGE_COMPRESSION_LZO
+barebox: piggy.lzo.o
+	@echo "  LD     " $@
+	$(Q)$(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
+		-T $(barebox-compressed-lds) $(barebox-compressed) \
+		--start-group $(barebox-common) piggy.lzo.o --end-group
+else
 barebox: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o) FORCE
 	$(call barebox-modpost)
 	$(call if_changed_rule,barebox__)
 	$(Q)rm -f .old_version
+endif
 
 barebox.srec: barebox
 	$(OBJCOPY) -O srec $< $@
@@ -1004,7 +1032,8 @@ CLEAN_FILES +=	barebox System.map include/generated/barebox_default_env.h \
                 .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \
 		.tmp_kallsyms* barebox_default_env* barebox.ldr \
 		scripts/bareboxenv-target \
-		Doxyfile.version barebox.srec barebox.s5p
+		Doxyfile.version barebox.srec barebox.s5p \
+		barebox-uncompressed barebox-uncompressed.bin barebox-uncompressed.bin.lzo
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_DIRS  += include/config include2 usr/include
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index d988455..2396bae 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -4,6 +4,7 @@ config ARM
 	select HAS_MODULES
 	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
 	select HAVE_CONFIGURABLE_TEXT_BASE
+	select HAVE_IMAGE_COMPRESSION
 	default y
 
 config ARM_AMBA
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index cbbc0a0..a93c4d5 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -208,5 +208,6 @@ common-y += $(BOARD) $(MACH)
 common-y += arch/arm/lib/ arch/arm/cpu/
 
 lds-y	:= arch/arm/lib/barebox.lds
+lds-compressed-y := arch/arm/lib/barebox-compressed.lds
 
 CLEAN_FILES += include/generated/mach-types.h arch/arm/lib/barebox.lds
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index cabe4d2..f4aeefe 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -28,16 +28,36 @@
 #include <asm-generic/memory_layout.h>
 #include <asm/sections.h>
 
+#ifdef CONFIG_IMAGE_COMPRESSION_LZO
+void __naked __section(.text_head_entry) compressed_start(void)
+{
+	barebox_arm_head();
+}
+
+void __naked __section(.text_entry) start(void)
+{
+	u32 r;
+
+	/* Setup the stack */
+	r = STACK_BASE + STACK_SIZE - 16;
+	__asm__ __volatile__("mov sp, %0" : : "r"(r));
+	/* clear bss */
+	memset(__bss_start, 0, __bss_stop - __bss_start);
+
+	start_barebox();
+}
+#else
 void __naked __section(.text_entry) start(void)
 {
 	barebox_arm_head();
 }
+#endif
 
 void __naked __section(.text_exceptions) exception_vectors(void)
 {
 	__asm__ __volatile__ (
 		".arm\n"
-		"b reset\n"				/* reset */
+		"1: b 1b\n"					/* reset */
 #ifdef CONFIG_ARM_EXCEPTIONS
 		"ldr pc, =undefined_instruction\n"	/* undefined instruction */
 		"ldr pc, =software_interrupt\n"		/* software interrupt (SWI) */
@@ -98,6 +118,34 @@ void __naked __bare_init reset(void)
 	board_init_lowlevel_return();
 }
 
+extern void *input_data;
+extern void *input_data_end;
+
+#define STATIC static
+#include "../../../lib/decompress_unlzo.c"
+
+void barebox_uncompress(void *compressed_start, unsigned int len)
+{
+	void (*barebox)(void);
+
+#ifdef CONFIG_THUMB2_BAREBOX
+	barebox = (void *)(TEXT_BASE + 1);
+#else
+	barebox = (void *)TEXT_BASE;
+#endif
+
+	decompress_unlzo((void *)compressed_start,
+			len,
+			NULL, NULL,
+			(void *)TEXT_BASE, NULL, NULL);
+
+	/* flush I-cache before jumping to the uncompressed binary */
+	__asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
+
+	barebox();
+}
+
+
 /*
  * Board code can jump here by either returning from board_init_lowlevel
  * or by calling this function directly.
@@ -105,7 +153,10 @@ void __naked __bare_init reset(void)
 void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
 {
 	uint32_t r, addr, offset;
-
+#ifdef CONFIG_IMAGE_COMPRESSION_LZO
+	uint32_t compressed_start, compressed_end, len;
+	void (*uncompress)(void *compressed_start, unsigned int len);
+#endif
 	/*
 	 * Get runtime address of this function. Do not
 	 * put any code above this.
@@ -130,8 +181,24 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
 	/* flush I-cache before jumping to the copied binary */
 	__asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
 
+#ifdef CONFIG_IMAGE_COMPRESSION_LZO
+	compressed_start = (uint32_t)&input_data - offset;
+	compressed_end = (uint32_t)&input_data_end - offset;
+	len = compressed_end - compressed_start;
+
+	uncompress = barebox_uncompress;
+
+	/* call start_barebox with its absolute address */
+	__asm__ __volatile__(
+			"mov r0, %1\n"
+			"mov r1, %2\n"
+			"mov pc, %0\n"
+			:
+			: "r"(uncompress), "r"(compressed_start), "r"(len)
+			: "r0", "r1");
+#else
 	/* call start_barebox with its absolute address */
 	r = (unsigned int)&start_barebox;
 	__asm__ __volatile__("mov pc, %0" : : "r"(r));
+#endif
 }
-
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 1eaf474..044d3e6 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -21,3 +21,4 @@ obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= memset.o
 obj-$(CONFIG_ARM_UNWIND) += unwind.o
 obj-$(CONFIG_MODULES) += module.o
 extra-y += barebox.lds
+extra-$(CONFIG_IMAGE_COMPRESSION_LZO) += barebox-compressed.lds
diff --git a/arch/arm/lib/barebox-compressed.lds.S b/arch/arm/lib/barebox-compressed.lds.S
new file mode 100644
index 0000000..f267da9
--- /dev/null
+++ b/arch/arm/lib/barebox-compressed.lds.S
@@ -0,0 +1,71 @@
+/*
+ * (C) Copyright 2000-2004
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#include <asm-generic/barebox.lds.h>
+#include <asm-generic/memory_layout.h>
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(compressed_start)
+SECTIONS
+{
+	. = HEAD_TEXT_BASE;
+
+	PRE_IMAGE
+
+	. = ALIGN(4);
+	.text      :
+	{
+		_stext = .;
+		_text = .;
+		*(.text_head_entry*)
+		__ll_return = .;
+		*(.text_ll_return*)
+		__bare_init_start = .;
+		*(.text_bare_init*)
+		__bare_init_end = .;
+		*(.text*)
+	}
+	BAREBOX_BARE_INIT_SIZE
+
+	. = ALIGN(4);
+	.rodata : { *(.rodata*) }
+
+	_etext = .;			/* End of text and rodata section */
+
+	. = ALIGN(4);
+	.piggydata : {
+		*(.piggydata)
+	}
+
+	. = ALIGN(4);
+	.data : { *(.data*) }
+
+	. = ALIGN(4);
+	__bss_start = .;
+	.bss : { *(.bss*) }
+	__bss_stop = .;
+	_end = .;
+	_barebox_image_size = __bss_start - HEAD_TEXT_BASE;
+}
diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
index e0bae70..b415830 100644
--- a/arch/arm/lib/barebox.lds.S
+++ b/arch/arm/lib/barebox.lds.S
@@ -31,8 +31,9 @@ SECTIONS
 {
 	. = TEXT_BASE;
 
+#ifndef CONFIG_IMAGE_COMPRESSION_LZO
 	PRE_IMAGE
-
+#endif
 	. = ALIGN(4);
 	.text      :
 	{
diff --git a/common/Kconfig b/common/Kconfig
index b776031..0e81b57 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -93,6 +93,13 @@ config ENVIRONMENT_VARIABLES
 
 menu "memory layout                 "
 
+config HAVE_IMAGE_COMPRESSION
+	bool
+
+config IMAGE_COMPRESSION_LZO
+	depends on HAVE_IMAGE_COMPRESSION
+	bool "lzo compressed image"
+
 config MMU
 	bool "Enable MMU"
 	help
@@ -173,6 +180,11 @@ config MALLOC_SIZE
 	hex
 	default 0x400000
 	prompt "malloc area size"
+
+config HEAD_TEXT_BASE
+	depends on MEMORY_LAYOUT_FIXED && IMAGE_COMPRESSION_LZO
+	hex
+	prompt "HEAD_TEXT_BASE"
 endmenu
 
 config BROKEN
diff --git a/include/asm-generic/memory_layout.h b/include/asm-generic/memory_layout.h
index 941cd42..a5efaf0 100644
--- a/include/asm-generic/memory_layout.h
+++ b/include/asm-generic/memory_layout.h
@@ -5,11 +5,13 @@
 
 #define MALLOC_BASE (TEXT_BASE - CONFIG_MALLOC_SIZE)
 #define STACK_BASE (TEXT_BASE - CONFIG_MALLOC_SIZE - CONFIG_STACK_SIZE)
+#define HEAD_TEXT_BASE (TEXT_BASE - 0x100000)
 
 #else
 
 #define STACK_BASE CONFIG_STACK_BASE
 #define MALLOC_BASE CONFIG_MALLOC_BASE
+#define HEAD_TEXT_BASE CONFIG_HEAD_TEXT_BASE
 
 #endif
 
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 17c1973..3f23bf1 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -18,6 +18,7 @@
 #include <kallsyms.h>
 
 #include <common.h>
+#include <init.h>
 #include <led.h>
 
 unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
@@ -618,7 +619,7 @@ char *asprintf(const char *fmt, ...)
 }
 EXPORT_SYMBOL(asprintf);
 
-void __noreturn panic(const char *fmt, ...)
+static void __noreturn __panic(const char *fmt, ...)
 {
 	va_list	args;
 	va_start(args, fmt);
@@ -637,4 +638,26 @@ void __noreturn panic(const char *fmt, ...)
 	reset_cpu(0);
 #endif
 }
+
+static void (*panic_fn)(const char *fmt, ...);
+
+static int panic_init(void)
+{
+	panic_fn = __panic;
+
+	return 0;
+}
+core_initcall(panic_init);
+
+void __noreturn panic(const char *fmt, ...)
+{
+	if (panic_fn) {
+		va_list	args;
+		va_start(args, fmt);
+		panic_fn(fmt, args);
+		va_end(args);
+	}
+
+	while(1);
+}
 EXPORT_SYMBOL(panic);
diff --git a/piggy.lzo.S b/piggy.lzo.S
new file mode 100644
index 0000000..6cc618d
--- /dev/null
+++ b/piggy.lzo.S
@@ -0,0 +1,6 @@
+	.section .piggydata,#alloc
+	.globl  input_data
+input_data:
+	.incbin "barebox-uncompressed.bin.lzo"
+	.globl  input_data_end
+input_data_end:
-- 
1.7.10.4


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

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

* Re: [PATCH 8/9] ARM: Separate assembler functions into their own section
  2012-07-19  8:13 ` [PATCH 8/9] ARM: Separate assembler functions into their own section Sascha Hauer
@ 2012-07-19 10:38   ` Marc Kleine-Budde
  2012-07-19 14:04     ` Jean-Christophe PLAGNIOL-VILLARD
  2012-07-19 14:08     ` Sascha Hauer
  2012-07-23 19:59   ` Sascha Hauer
  1 sibling, 2 replies; 28+ messages in thread
From: Marc Kleine-Budde @ 2012-07-19 10:38 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 1350 bytes --]

On 07/19/2012 10:13 AM, Sascha Hauer wrote:
> To let the linker remove unused functions.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  arch/arm/cpu/cache-armv4.S      |    7 ++++++-
>  arch/arm/cpu/cache-armv5.S      |    7 ++++++-
>  arch/arm/cpu/cache-armv6.S      |   11 +++++++++--
>  arch/arm/cpu/cache-armv7.S      |    8 ++++++--
>  arch/arm/lib/ashldi3.S          |    1 +
>  arch/arm/lib/ashrdi3.S          |    1 +
>  arch/arm/lib/findbit.S          |    9 +++++++++
>  arch/arm/lib/io-writesw-armv4.S |    2 ++
>  arch/arm/lib/lib1funcs.S        |    7 +++++++
>  arch/arm/lib/lshrdi3.S          |    1 +
>  10 files changed, 48 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/cpu/cache-armv4.S b/arch/arm/cpu/cache-armv4.S
> index 6d03565..2231eee 100644
> --- a/arch/arm/cpu/cache-armv4.S
> +++ b/arch/arm/cpu/cache-armv4.S
> @@ -3,6 +3,7 @@
>  
>  #define CACHE_DLINESIZE 32
>  
> +.section .text.__mmu_cache_on
>  ENTRY(__mmu_cache_on)

Is it possible to add the section to the ENTRY macro?

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

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

* Re: [PATCH 8/9] ARM: Separate assembler functions into their own section
  2012-07-19 10:38   ` Marc Kleine-Budde
@ 2012-07-19 14:04     ` Jean-Christophe PLAGNIOL-VILLARD
  2012-07-19 14:08     ` Sascha Hauer
  1 sibling, 0 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-19 14:04 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

On 12:38 Thu 19 Jul     , Marc Kleine-Budde wrote:
> On 07/19/2012 10:13 AM, Sascha Hauer wrote:
> > To let the linker remove unused functions.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  arch/arm/cpu/cache-armv4.S      |    7 ++++++-
> >  arch/arm/cpu/cache-armv5.S      |    7 ++++++-
> >  arch/arm/cpu/cache-armv6.S      |   11 +++++++++--
> >  arch/arm/cpu/cache-armv7.S      |    8 ++++++--
> >  arch/arm/lib/ashldi3.S          |    1 +
> >  arch/arm/lib/ashrdi3.S          |    1 +
> >  arch/arm/lib/findbit.S          |    9 +++++++++
> >  arch/arm/lib/io-writesw-armv4.S |    2 ++
> >  arch/arm/lib/lib1funcs.S        |    7 +++++++
> >  arch/arm/lib/lshrdi3.S          |    1 +
> >  10 files changed, 48 insertions(+), 6 deletions(-)
> > 
> > diff --git a/arch/arm/cpu/cache-armv4.S b/arch/arm/cpu/cache-armv4.S
> > index 6d03565..2231eee 100644
> > --- a/arch/arm/cpu/cache-armv4.S
> > +++ b/arch/arm/cpu/cache-armv4.S
> > @@ -3,6 +3,7 @@
> >  
> >  #define CACHE_DLINESIZE 32
> >  
> > +.section .text.__mmu_cache_on
> >  ENTRY(__mmu_cache_on)
> 
> Is it possible to add the section to the ENTRY macro?
Agreed

Best Regards,
J.

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

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

* Re: [PATCH 8/9] ARM: Separate assembler functions into their own section
  2012-07-19 10:38   ` Marc Kleine-Budde
  2012-07-19 14:04     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-07-19 14:08     ` Sascha Hauer
  2012-07-19 20:45       ` Sascha Hauer
  1 sibling, 1 reply; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19 14:08 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

On Thu, Jul 19, 2012 at 12:38:03PM +0200, Marc Kleine-Budde wrote:
> On 07/19/2012 10:13 AM, Sascha Hauer wrote:
> > To let the linker remove unused functions.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  arch/arm/cpu/cache-armv4.S      |    7 ++++++-
> >  arch/arm/cpu/cache-armv5.S      |    7 ++++++-
> >  arch/arm/cpu/cache-armv6.S      |   11 +++++++++--
> >  arch/arm/cpu/cache-armv7.S      |    8 ++++++--
> >  arch/arm/lib/ashldi3.S          |    1 +
> >  arch/arm/lib/ashrdi3.S          |    1 +
> >  arch/arm/lib/findbit.S          |    9 +++++++++
> >  arch/arm/lib/io-writesw-armv4.S |    2 ++
> >  arch/arm/lib/lib1funcs.S        |    7 +++++++
> >  arch/arm/lib/lshrdi3.S          |    1 +
> >  10 files changed, 48 insertions(+), 6 deletions(-)
> > 
> > diff --git a/arch/arm/cpu/cache-armv4.S b/arch/arm/cpu/cache-armv4.S
> > index 6d03565..2231eee 100644
> > --- a/arch/arm/cpu/cache-armv4.S
> > +++ b/arch/arm/cpu/cache-armv4.S
> > @@ -3,6 +3,7 @@
> >  
> >  #define CACHE_DLINESIZE 32
> >  
> > +.section .text.__mmu_cache_on
> >  ENTRY(__mmu_cache_on)
> 
> Is it possible to add the section to the ENTRY macro?

I'm not sure. I was pretty sure that some assembly functions fall
through to the next function. I cannot find any examples though.

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] 28+ messages in thread

* Re: [PATCH 9/9] Add compressed image support
  2012-07-19  8:13 ` [PATCH 9/9] Add compressed image support Sascha Hauer
@ 2012-07-19 14:10   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-07-19 17:08   ` Johannes Stezenbach
  2012-07-20 15:24   ` Jean-Christophe PLAGNIOL-VILLARD
  2 siblings, 0 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-19 14:10 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 10:13 Thu 19 Jul     , Sascha Hauer wrote:
> This allows for creating a lzo compressed binary. This is done by
> linking barebox twice using two linker scripts. One is the regular
> uncompressed binary but without the lowlevel init stuff. The
> other contains the lowlevel init stuff, the decompressor and the
> compressed binary.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  Makefile                              |   31 +++++++++++++-
>  arch/arm/Kconfig                      |    1 +
>  arch/arm/Makefile                     |    1 +
>  arch/arm/cpu/start.c                  |   73 +++++++++++++++++++++++++++++++--
>  arch/arm/lib/Makefile                 |    1 +
>  arch/arm/lib/barebox-compressed.lds.S |   71 ++++++++++++++++++++++++++++++++
>  arch/arm/lib/barebox.lds.S            |    3 +-
>  common/Kconfig                        |   12 ++++++
>  include/asm-generic/memory_layout.h   |    2 +
>  lib/vsprintf.c                        |   25 ++++++++++-
>  piggy.lzo.S                           |    6 +++
>  11 files changed, 220 insertions(+), 6 deletions(-)
>  create mode 100644 arch/arm/lib/barebox-compressed.lds.S
>  create mode 100644 piggy.lzo.S
> 
> diff --git a/Makefile b/Makefile
> index ebcf9bf..3ade6cc 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -512,6 +512,7 @@ common-y	:= $(patsubst %/, %/built-in.o, $(common-y))
>  barebox-common := $(common-y)
>  barebox-all    := $(barebox-common)
>  barebox-lds    := $(lds-y)
> +barebox-compressed-lds    := $(lds-compressed-y)
>  
>  # Rule to link barebox
>  # May be overridden by arch/$(ARCH)/Makefile
> @@ -667,6 +668,7 @@ quiet_cmd_objcopy = OBJCOPY $@
>        cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
>  
>  OBJCOPYFLAGS_barebox.bin = -O binary
> +OBJCOPYFLAGS_barebox-uncompressed.bin = -O binary
>  
>  barebox.bin: barebox FORCE
>  	$(call if_changed,objcopy)
> @@ -700,13 +702,39 @@ quiet_cmd_disasm = DISASM  $@
>  
>  barebox.S: barebox FORCE
>  	$(call if_changed,disasm)
> +barebox-uncompressed.S: barebox-uncompressed FORCE
> +	$(call if_changed,disasm)
>  endif
>  
>  # barebox image
> +barebox-uncompressed: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o)
> +	$(call barebox-modpost)
> +	$(call if_changed_rule,barebox__)
> +	$(Q)rm -f .old_version
> +
> +barebox-uncompressed.bin: barebox-uncompressed
> +	$(call if_changed,objcopy)
> +
> +barebox-uncompressed.bin.lzo: barebox-uncompressed.bin
> +	@echo "  LZO    " $@
> +	$(Q)lzop -f -9 -o $@ barebox-uncompressed.bin
> +
> +piggy.lzo.o: barebox-uncompressed.bin.lzo piggy.lzo.S
> +	@echo "  CC     " $@
> +	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c piggy.lzo.S -o $@
> +
> +ifdef CONFIG_IMAGE_COMPRESSION_LZO
> +barebox: piggy.lzo.o
> +	@echo "  LD     " $@
> +	$(Q)$(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
> +		-T $(barebox-compressed-lds) $(barebox-compressed) \
> +		--start-group $(barebox-common) piggy.lzo.o --end-group
> +else
>  barebox: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o) FORCE
>  	$(call barebox-modpost)
>  	$(call if_changed_rule,barebox__)
>  	$(Q)rm -f .old_version
> +endif
>  
>  barebox.srec: barebox
>  	$(OBJCOPY) -O srec $< $@
> @@ -1004,7 +1032,8 @@ CLEAN_FILES +=	barebox System.map include/generated/barebox_default_env.h \
>                  .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \
>  		.tmp_kallsyms* barebox_default_env* barebox.ldr \
>  		scripts/bareboxenv-target \
> -		Doxyfile.version barebox.srec barebox.s5p
> +		Doxyfile.version barebox.srec barebox.s5p \
> +		barebox-uncompressed barebox-uncompressed.bin barebox-uncompressed.bin.lzo
>  
>  # Directories & files removed with 'make mrproper'
>  MRPROPER_DIRS  += include/config include2 usr/include
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index d988455..2396bae 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -4,6 +4,7 @@ config ARM
>  	select HAS_MODULES
>  	select HAVE_CONFIGURABLE_MEMORY_LAYOUT
>  	select HAVE_CONFIGURABLE_TEXT_BASE
> +	select HAVE_IMAGE_COMPRESSION
>  	default y
>  
>  config ARM_AMBA
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index cbbc0a0..a93c4d5 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -208,5 +208,6 @@ common-y += $(BOARD) $(MACH)
>  common-y += arch/arm/lib/ arch/arm/cpu/
>  
>  lds-y	:= arch/arm/lib/barebox.lds
> +lds-compressed-y := arch/arm/lib/barebox-compressed.lds
>  
>  CLEAN_FILES += include/generated/mach-types.h arch/arm/lib/barebox.lds
> diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
> index cabe4d2..f4aeefe 100644
> --- a/arch/arm/cpu/start.c
> +++ b/arch/arm/cpu/start.c
> @@ -28,16 +28,36 @@
>  #include <asm-generic/memory_layout.h>
>  #include <asm/sections.h>
>  
> +#ifdef CONFIG_IMAGE_COMPRESSION_LZO
> +void __naked __section(.text_head_entry) compressed_start(void)
> +{
> +	barebox_arm_head();
> +}
> +
> +void __naked __section(.text_entry) start(void)
can we have a have for all of the __section stuff
> +{
> +	u32 r;
> +
> +	/* Setup the stack */
> +	r = STACK_BASE + STACK_SIZE - 16;
> +	__asm__ __volatile__("mov sp, %0" : : "r"(r));
> +	/* clear bss */
> +	memset(__bss_start, 0, __bss_stop - __bss_start);
> +
> +	start_barebox();
> +}
> +#else
>  void __naked __section(.text_entry) start(void)
>  {
>  	barebox_arm_head();
>  }
> +#endif
>  
>  void __naked __section(.text_exceptions) exception_vectors(void)
>  {
>  	__asm__ __volatile__ (
>  		".arm\n"
> -		"b reset\n"				/* reset */
> +		"1: b 1b\n"					/* reset */
>  #ifdef CONFIG_ARM_EXCEPTIONS
>  		"ldr pc, =undefined_instruction\n"	/* undefined instruction */
>  		"ldr pc, =software_interrupt\n"		/* software interrupt (SWI) */
> @@ -98,6 +118,34 @@ void __naked __bare_init reset(void)
>  	board_init_lowlevel_return();
>  }
>  
> +extern void *input_data;
> +extern void *input_data_end;
> +
> +#define STATIC static
> +#include "../../../lib/decompress_unlzo.c"
> +
> +void barebox_uncompress(void *compressed_start, unsigned int len)
> +{
> +	void (*barebox)(void);
> +
> +#ifdef CONFIG_THUMB2_BAREBOX
> +	barebox = (void *)(TEXT_BASE + 1);
> +#else
> +	barebox = (void *)TEXT_BASE;
> +#endif
I hate the ifdef please use if (IS_ENABLED(x))
> +
> +	decompress_unlzo((void *)compressed_start,
> +			len,
> +			NULL, NULL,
> +			(void *)TEXT_BASE, NULL, NULL);
> +
> +	/* flush I-cache before jumping to the uncompressed binary */
> +	__asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
macro or inline?
> +
> +	barebox();
> +}
> +
> +
>  /*
>   * Board code can jump here by either returning from board_init_lowlevel
>   * or by calling this function directly.
> @@ -105,7 +153,10 @@ void __naked __bare_init reset(void)
>  void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
>  {
>  	uint32_t r, addr, offset;
> -
> +#ifdef CONFIG_IMAGE_COMPRESSION_LZO
> +	uint32_t compressed_start, compressed_end, len;
> +	void (*uncompress)(void *compressed_start, unsigned int len);
> +#endif
>  	/*
>  	 * Get runtime address of this function. Do not
>  	 * put any code above this.
> @@ -130,8 +181,24 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
>  	/* flush I-cache before jumping to the copied binary */
>  	__asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
>  
> +#ifdef CONFIG_IMAGE_COMPRESSION_LZO
> +	compressed_start = (uint32_t)&input_data - offset;
> +	compressed_end = (uint32_t)&input_data_end - offset;
> +	len = compressed_end - compressed_start;
> +
> +	uncompress = barebox_uncompress;
> +
> +	/* call start_barebox with its absolute address */
> +	__asm__ __volatile__(
> +			"mov r0, %1\n"
> +			"mov r1, %2\n"
> +			"mov pc, %0\n"
> +			:
> +			: "r"(uncompress), "r"(compressed_start), "r"(len)
> +			: "r0", "r1");
> +#else
>  	/* call start_barebox with its absolute address */
>  	r = (unsigned int)&start_barebox;
>  	__asm__ __volatile__("mov pc, %0" : : "r"(r));
> +#endif
ifdef rrrr :(
>  }
> -
> diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
> index 1eaf474..044d3e6 100644
> --- a/arch/arm/lib/Makefile
> +++ b/arch/arm/lib/Makefile
> @@ -21,3 +21,4 @@ obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= memset.o
>  obj-$(CONFIG_ARM_UNWIND) += unwind.o
>  obj-$(CONFIG_MODULES) += module.o
>  extra-y += barebox.lds
> +extra-$(CONFIG_IMAGE_COMPRESSION_LZO) += barebox-compressed.lds
> diff --git a/arch/arm/lib/barebox-compressed.lds.S b/arch/arm/lib/barebox-compressed.lds.S
> new file mode 100644
> index 0000000..f267da9
> --- /dev/null
> +++ b/arch/arm/lib/barebox-compressed.lds.S
> @@ -0,0 +1,71 @@
> +/*
> + * (C) Copyright 2000-2004
> + * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
you can put you onw copyright
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + *
> + */
> +
> +#include <asm-generic/barebox.lds.h>
> +#include <asm-generic/memory_layout.h>
> +
> +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
> +OUTPUT_ARCH(arm)
> +ENTRY(compressed_start)
> +SECTIONS
> +{
> +	. = HEAD_TEXT_BASE;
> +
> +	PRE_IMAGE
> +
> +	. = ALIGN(4);
> +	.text      :
> +	{
> +		_stext = .;
> +		_text = .;
> +		*(.text_head_entry*)
> +		__ll_return = .;
> +		*(.text_ll_return*)
> +		__bare_init_start = .;
> +		*(.text_bare_init*)
> +		__bare_init_end = .;
> +		*(.text*)
> +	}
macro?
> +	BAREBOX_BARE_INIT_SIZE
> +
> +	. = ALIGN(4);
> +	.rodata : { *(.rodata*) }
> +
> +	_etext = .;			/* End of text and rodata section */
> +
> +	. = ALIGN(4);
> +	.piggydata : {
> +		*(.piggydata)
> +	}
> +
> +	. = ALIGN(4);
> +	.data : { *(.data*) }

ditto
> +
> +	. = ALIGN(4);
> +	__bss_start = .;
> +	.bss : { *(.bss*) }
> +	__bss_stop = .;
ditto
> +	_end = .;
> +	_barebox_image_size = __bss_start - HEAD_TEXT_BASE;
ditto
> +}
> diff --git a/arch/arm/lib/barebox.lds.S b/arch/arm/lib/barebox.lds.S
> index e0bae70..b415830 100644
> --- a/arch/arm/lib/barebox.lds.S
> +++ b/arch/arm/lib/barebox.lds.S
> @@ -31,8 +31,9 @@ SECTIONS
>  {
>  	. = TEXT_BASE;
>  
> +#ifndef CONFIG_IMAGE_COMPRESSION_LZO
>  	PRE_IMAGE
> -
> +#endif
>  	. = ALIGN(4);
>  	.text      :
>  	{
> diff --git a/common/Kconfig b/common/Kconfig
> index b776031..0e81b57 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -93,6 +93,13 @@ config ENVIRONMENT_VARIABLES
>  
>  menu "memory layout                 "
>  
> +config HAVE_IMAGE_COMPRESSION
> +	bool
> +
> +config IMAGE_COMPRESSION_LZO
> +	depends on HAVE_IMAGE_COMPRESSION
> +	bool "lzo compressed image"
> +
>  config MMU
>  	bool "Enable MMU"
>  	help
> @@ -173,6 +180,11 @@ config MALLOC_SIZE
>  	hex
>  	default 0x400000
>  	prompt "malloc area size"
> +
> +config HEAD_TEXT_BASE
> +	depends on MEMORY_LAYOUT_FIXED && IMAGE_COMPRESSION_LZO
> +	hex
> +	prompt "HEAD_TEXT_BASE"
>  endmenu
>  
>  config BROKEN
> diff --git a/include/asm-generic/memory_layout.h b/include/asm-generic/memory_layout.h
> index 941cd42..a5efaf0 100644
> --- a/include/asm-generic/memory_layout.h
> +++ b/include/asm-generic/memory_layout.h
> @@ -5,11 +5,13 @@
>  
>  #define MALLOC_BASE (TEXT_BASE - CONFIG_MALLOC_SIZE)
>  #define STACK_BASE (TEXT_BASE - CONFIG_MALLOC_SIZE - CONFIG_STACK_SIZE)
> +#define HEAD_TEXT_BASE (TEXT_BASE - 0x100000)
>  
>  #else
>  
>  #define STACK_BASE CONFIG_STACK_BASE
>  #define MALLOC_BASE CONFIG_MALLOC_BASE
> +#define HEAD_TEXT_BASE CONFIG_HEAD_TEXT_BASE
>  
>  #endif
>  
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 17c1973..3f23bf1 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -18,6 +18,7 @@
>  #include <kallsyms.h>
>  
>  #include <common.h>
> +#include <init.h>
>  #include <led.h>
>  
>  unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
> @@ -618,7 +619,7 @@ char *asprintf(const char *fmt, ...)
>  }
>  EXPORT_SYMBOL(asprintf);
>  
> -void __noreturn panic(const char *fmt, ...)
> +static void __noreturn __panic(const char *fmt, ...)
>  {
>  	va_list	args;
>  	va_start(args, fmt);
> @@ -637,4 +638,26 @@ void __noreturn panic(const char *fmt, ...)
>  	reset_cpu(0);
>  #endif
>  }
> +
> +static void (*panic_fn)(const char *fmt, ...);
how about have a default empty panic
> +
> +static int panic_init(void)
> +{
> +	panic_fn = __panic;
> +
> +	return 0;
> +}
> +core_initcall(panic_init);
> +
> +void __noreturn panic(const char *fmt, ...)
> +{
> +	if (panic_fn) {
so we can drop the test
> +		va_list	args;
> +		va_start(args, fmt);
> +		panic_fn(fmt, args);
> +		va_end(args);
> +	}
> +
> +	while(1);
> +}

Best Regrds,
J.

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

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

* Re: Compressed barebox image support
  2012-07-19  8:12 Compressed barebox image support Sascha Hauer
                   ` (8 preceding siblings ...)
  2012-07-19  8:13 ` [PATCH 9/9] Add compressed image support Sascha Hauer
@ 2012-07-19 15:08 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-07-19 16:05   ` Sascha Hauer
  2012-07-19 20:11 ` Robert Jarzmik
  10 siblings, 1 reply; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-19 15:08 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 10:12 Thu 19 Jul     , Sascha Hauer wrote:
> The following series allows to create a self extracting barebox image.
> This is done by linking barebox twice, once for the actual binary, but
> without lowlevel initstuff and once for the lowlevel init stuff, the
> decompressor and the compressed image.
> 
> Using lzo compression the pcm038 image shrinks from 252k to 155k. The
> series has been tested on the pcm038 second stage, first stage NAND and
> first stage NOR and also on an i.MX53 LOCO board (also in thumb2 mode)
> 
> Using compressed images currently adds to the boot time, at least on
> my slower arm9 systems. Using the MMU during decompression would help,
> but this currently isn't implemented.
> 
> I think the preparation patches should be ready for merging. The last
> patch in this series adding compression support I am not that confident
> with. Currently I am not very happy with the Makefile changes which
> somehow look like bypassing the kbuild mechanism and handcrufting
> something that looks like kbuild. If someone has ideas how to improve
> this, let me know. Nevertheless I would be happy about Tested-by
> (and does-not-work-for) tags.
> 
> Sascha
> 
> ----------------------------------------------------------------
> Sascha Hauer (9):
>       lzo: Allow for static inlining
>       ARM lds: remove unused got
>       ARM: remove board linker script option
>       ARM: remove exception vectors from boards
>       ARM startup: calculate offset instead of runtime address
>       ARM ep93xx: Get rid of special handling in linker file
>       ARM boards: Use _text rather than TEXT_BASE
>       ARM: Separate assembler functions into their own section
>       Add compressed image support

can you push it on a git?

Best Regards,
J.

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

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

* Re: Compressed barebox image support
  2012-07-19 15:08 ` Compressed barebox " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-07-19 16:05   ` Sascha Hauer
  0 siblings, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19 16:05 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Thu, Jul 19, 2012 at 05:08:32PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:12 Thu 19 Jul     , Sascha Hauer wrote:
> > The following series allows to create a self extracting barebox image.
> > This is done by linking barebox twice, once for the actual binary, but
> > without lowlevel initstuff and once for the lowlevel init stuff, the
> > decompressor and the compressed image.
> > 
> > Using lzo compression the pcm038 image shrinks from 252k to 155k. The
> > series has been tested on the pcm038 second stage, first stage NAND and
> > first stage NOR and also on an i.MX53 LOCO board (also in thumb2 mode)
> > 
> > Using compressed images currently adds to the boot time, at least on
> > my slower arm9 systems. Using the MMU during decompression would help,
> > but this currently isn't implemented.
> > 
> > I think the preparation patches should be ready for merging. The last
> > patch in this series adding compression support I am not that confident
> > with. Currently I am not very happy with the Makefile changes which
> > somehow look like bypassing the kbuild mechanism and handcrufting
> > something that looks like kbuild. If someone has ideas how to improve
> > this, let me know. Nevertheless I would be happy about Tested-by
> > (and does-not-work-for) tags.
> > 
> > Sascha
> > 
> > ----------------------------------------------------------------
> > Sascha Hauer (9):
> >       lzo: Allow for static inlining
> >       ARM lds: remove unused got
> >       ARM: remove board linker script option
> >       ARM: remove exception vectors from boards
> >       ARM startup: calculate offset instead of runtime address
> >       ARM ep93xx: Get rid of special handling in linker file
> >       ARM boards: Use _text rather than TEXT_BASE
> >       ARM: Separate assembler functions into their own section
> >       Add compressed image support
> 
> can you push it on a git?

Here you are. I partly integrated your comments already.

Sascha

The following changes since commit 2f6b1f7690640f571f8e72fc2f2564acb2e13778:

  ARM/MXS: the GPIO bitkeeper enable logic is inverse to the pullup enable logic (2012-07-16 23:30:14 +0200)

are available in the git repository at:

  git://git.pengutronix.de/git/barebox.git work/compressed-image

for you to fetch changes up to af1de0f86036ab8cb8f4a434708a31db21b33de2:

  Add compressed image support (2012-07-19 18:02:02 +0200)

----------------------------------------------------------------
Sascha Hauer (9):
      lzo: Allow for static inlining
      ARM lds: remove unused got
      ARM: remove board linker script option
      ARM: remove exception vectors from boards
      ARM startup: calculate offset instead of runtime address
      ARM ep93xx: Get rid of special handling in linker file
      ARM boards: Use _text rather than TEXT_BASE
      ARM: Separate assembler functions into their own section
      Add compressed image support

 Makefile                                           |   31 ++++++-
 arch/arm/Kconfig                                   |   13 +--
 arch/arm/Makefile                                  |    4 +-
 arch/arm/boards/a9m2410/a9m2410.c                  |    3 +-
 arch/arm/boards/a9m2440/a9m2440.c                  |    3 +-
 arch/arm/boards/eukrea_cpuimx25/eukrea_cpuimx25.c  |    7 +-
 arch/arm/boards/eukrea_cpuimx25/lowlevel.c         |    4 +-
 arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c  |    4 +-
 arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S    |   11 +--
 arch/arm/boards/eukrea_cpuimx35/flash_header.c     |    2 -
 arch/arm/boards/eukrea_cpuimx35/lowlevel.c         |    4 +-
 arch/arm/boards/freescale-mx25-3-stack/3stack.c    |    8 +-
 .../boards/freescale-mx25-3-stack/lowlevel_init.S  |   11 +--
 arch/arm/boards/freescale-mx35-3-stack/3stack.c    |    4 +-
 .../boards/freescale-mx35-3-stack/flash_header.c   |    4 +-
 .../boards/freescale-mx35-3-stack/lowlevel_init.S  |   11 +--
 arch/arm/boards/freescale-mx53-loco/flash_header.c |    2 +-
 arch/arm/boards/freescale-mx53-smd/flash_header.c  |    2 +-
 arch/arm/boards/freescale-mx6-arm2/flash_header.c  |    5 +-
 arch/arm/boards/guf-cupid/lowlevel.c               |    4 +-
 arch/arm/boards/guf-neso/lowlevel.c                |    4 +-
 arch/arm/boards/imx21ads/imx21ads.c                |    4 +-
 arch/arm/boards/imx21ads/lowlevel_init.S           |   10 +--
 arch/arm/boards/karo-tx25/board.c                  |    3 +-
 arch/arm/boards/karo-tx25/lowlevel.c               |    4 +-
 arch/arm/boards/karo-tx51/flash_header.c           |    2 +-
 arch/arm/boards/mini2440/mini2440.c                |    3 +-
 arch/arm/boards/pcm037/lowlevel_init.S             |    7 +-
 arch/arm/boards/pcm037/pcm037.c                    |    4 +-
 arch/arm/boards/pcm038/lowlevel.c                  |    4 +-
 arch/arm/boards/pcm043/lowlevel.c                  |    4 +-
 arch/arm/boards/phycard-i.MX27/lowlevel_init.S     |    8 +-
 arch/arm/boards/phycard-i.MX27/pca100.c            |    2 +-
 arch/arm/boards/tqma53/flash_header.c              |    5 +-
 arch/arm/cpu/cache-armv4.S                         |    7 +-
 arch/arm/cpu/cache-armv5.S                         |    7 +-
 arch/arm/cpu/cache-armv6.S                         |   11 ++-
 arch/arm/cpu/cache-armv7.S                         |    8 +-
 arch/arm/cpu/start.c                               |   87 +++++++++++++++++---
 arch/arm/lib/Makefile                              |    4 +-
 arch/arm/lib/ashldi3.S                             |    1 +
 arch/arm/lib/ashrdi3.S                             |    1 +
 arch/arm/lib/barebox-compressed.lds.S              |   70 ++++++++++++++++
 arch/arm/lib/barebox.lds.S                         |   11 +--
 arch/arm/lib/findbit.S                             |    9 ++
 arch/arm/lib/io-writesw-armv4.S                    |    2 +
 arch/arm/lib/lib1funcs.S                           |    7 ++
 arch/arm/lib/lshrdi3.S                             |    1 +
 arch/arm/mach-ep93xx/Makefile                      |    2 +-
 arch/arm/mach-ep93xx/header.c                      |    8 ++
 arch/arm/mach-ep93xx/include/mach/barebox.lds.h    |    9 ++
 common/Kconfig                                     |   12 +++
 include/asm-generic/barebox.lds.h                  |    3 +-
 include/asm-generic/memory_layout.h                |    2 +
 include/lzo.h                                      |    8 +-
 lib/decompress_unlzo.c                             |    9 +-
 lib/lzo/lzo1x_decompress.c                         |    2 +-
 lib/vsprintf.c                                     |    2 +-
 piggy.lzo.S                                        |    6 ++
 59 files changed, 358 insertions(+), 132 deletions(-)
 create mode 100644 arch/arm/lib/barebox-compressed.lds.S
 create mode 100644 arch/arm/mach-ep93xx/header.c
 create mode 100644 arch/arm/mach-ep93xx/include/mach/barebox.lds.h
 create mode 100644 piggy.lzo.S
-- 
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] 28+ messages in thread

* Re: [PATCH 9/9] Add compressed image support
  2012-07-19  8:13 ` [PATCH 9/9] Add compressed image support Sascha Hauer
  2012-07-19 14:10   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-07-19 17:08   ` Johannes Stezenbach
  2012-07-19 17:41     ` Sascha Hauer
  2012-07-20 15:24   ` Jean-Christophe PLAGNIOL-VILLARD
  2 siblings, 1 reply; 28+ messages in thread
From: Johannes Stezenbach @ 2012-07-19 17:08 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi,

On Thu, Jul 19, 2012 at 10:13:02AM +0200, Sascha Hauer wrote:
> --- a/Makefile
> +++ b/Makefile
...
> +ifdef CONFIG_IMAGE_COMPRESSION_LZO
> +barebox: piggy.lzo.o
> +	@echo "  LD     " $@
> +	$(Q)$(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
> +		-T $(barebox-compressed-lds) $(barebox-compressed) \
> +		--start-group $(barebox-common) piggy.lzo.o --end-group
> +else

Where is barebox-compressed set?

I tried it and it fails to link:

  LD      arch/arm/lib/built-in.o
  LD      barebox-uncompressed
  SYSMAP  System.map
  OBJCOPY barebox-uncompressed.bin
  LZO     barebox-uncompressed.bin.lzo
  CC      piggy.lzo.o
  LD      barebox
common/built-in.o: In function `start_barebox':
.../barebox/common/startup.c:154: undefined reference to `__barebox_initcalls_start'
.../barebox/common/startup.c:154: undefined reference to `__barebox_initcalls_end'

$ make V=1
...
  LD      barebox
arm-linux-ld -EL  -Map barebox.map -static --gc-sections -o barebox \
                -T arch/arm/lib/barebox-compressed.lds  \
                --start-group  common/built-in.o  drivers/built-in.o  commands/built-in.o  lib/built-in.o  crypto/built-in.o  net/built-in.o  fs/built-in.o  arch/arm/boards/foo/built-in.o  arch/arm/mach-foo/built-in.o  arch/arm/lib/built-in.o  arch/arm/cpu/built-in.o piggy.lzo.o --end-group


It shouldn't link all the -built-in.o into the uncompressor, should it?
Or is it supposed to work via --gc-sections trick?


Thanks,
Johannes

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

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

* Re: [PATCH 9/9] Add compressed image support
  2012-07-19 17:08   ` Johannes Stezenbach
@ 2012-07-19 17:41     ` Sascha Hauer
  2012-07-19 18:32       ` Johannes Stezenbach
  0 siblings, 1 reply; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19 17:41 UTC (permalink / raw)
  To: Johannes Stezenbach; +Cc: barebox

On Thu, Jul 19, 2012 at 07:08:45PM +0200, Johannes Stezenbach wrote:
> Hi,
> 
> On Thu, Jul 19, 2012 at 10:13:02AM +0200, Sascha Hauer wrote:
> > --- a/Makefile
> > +++ b/Makefile
> ...
> > +ifdef CONFIG_IMAGE_COMPRESSION_LZO
> > +barebox: piggy.lzo.o
> > +	@echo "  LD     " $@
> > +	$(Q)$(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
> > +		-T $(barebox-compressed-lds) $(barebox-compressed) \
> > +		--start-group $(barebox-common) piggy.lzo.o --end-group
> > +else
> 
> Where is barebox-compressed set?
> 
> I tried it and it fails to link:
> 
>   LD      arch/arm/lib/built-in.o
>   LD      barebox-uncompressed
>   SYSMAP  System.map
>   OBJCOPY barebox-uncompressed.bin
>   LZO     barebox-uncompressed.bin.lzo
>   CC      piggy.lzo.o
>   LD      barebox
> common/built-in.o: In function `start_barebox':
> .../barebox/common/startup.c:154: undefined reference to `__barebox_initcalls_start'
> .../barebox/common/startup.c:154: undefined reference to `__barebox_initcalls_end'
> 
> $ make V=1
> ...
>   LD      barebox
> arm-linux-ld -EL  -Map barebox.map -static --gc-sections -o barebox \
>                 -T arch/arm/lib/barebox-compressed.lds  \
>                 --start-group  common/built-in.o  drivers/built-in.o  commands/built-in.o  lib/built-in.o  crypto/built-in.o  net/built-in.o  fs/built-in.o  arch/arm/boards/foo/built-in.o  arch/arm/mach-foo/built-in.o  arch/arm/lib/built-in.o  arch/arm/cpu/built-in.o piggy.lzo.o --end-group
> 
> 
> It shouldn't link all the -built-in.o into the uncompressor, should it?
> Or is it supposed to work via --gc-sections trick?

Yes, it works using --gc-sections. Are you building a defconfig or a
custom one? If the error above is correct start_barebox is referenced
from the decompressor code. This should not happen.

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] 28+ messages in thread

* Re: [PATCH 9/9] Add compressed image support
  2012-07-19 17:41     ` Sascha Hauer
@ 2012-07-19 18:32       ` Johannes Stezenbach
  2012-07-19 20:42         ` Sascha Hauer
  0 siblings, 1 reply; 28+ messages in thread
From: Johannes Stezenbach @ 2012-07-19 18:32 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Thu, Jul 19, 2012 at 07:41:25PM +0200, Sascha Hauer wrote:
> On Thu, Jul 19, 2012 at 07:08:45PM +0200, Johannes Stezenbach wrote:
> > On Thu, Jul 19, 2012 at 10:13:02AM +0200, Sascha Hauer wrote:
> > > --- a/Makefile
> > > +++ b/Makefile
> > ...
> > > +ifdef CONFIG_IMAGE_COMPRESSION_LZO
> > > +barebox: piggy.lzo.o
> > > +	@echo "  LD     " $@
> > > +	$(Q)$(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
> > > +		-T $(barebox-compressed-lds) $(barebox-compressed) \
> > > +		--start-group $(barebox-common) piggy.lzo.o --end-group
> > > +else
> > 
> > Where is barebox-compressed set?
> > 
> > I tried it and it fails to link:
> > 
> >   LD      arch/arm/lib/built-in.o
> >   LD      barebox-uncompressed
> >   SYSMAP  System.map
> >   OBJCOPY barebox-uncompressed.bin
> >   LZO     barebox-uncompressed.bin.lzo
> >   CC      piggy.lzo.o
> >   LD      barebox
> > common/built-in.o: In function `start_barebox':
> > .../barebox/common/startup.c:154: undefined reference to `__barebox_initcalls_start'
> > .../barebox/common/startup.c:154: undefined reference to `__barebox_initcalls_end'
> > 
> > $ make V=1
> > ...
> >   LD      barebox
> > arm-linux-ld -EL  -Map barebox.map -static --gc-sections -o barebox \
> >                 -T arch/arm/lib/barebox-compressed.lds  \
> >                 --start-group  common/built-in.o  drivers/built-in.o  commands/built-in.o  lib/built-in.o  crypto/built-in.o  net/built-in.o  fs/built-in.o  arch/arm/boards/foo/built-in.o  arch/arm/mach-foo/built-in.o  arch/arm/lib/built-in.o  arch/arm/cpu/built-in.o piggy.lzo.o --end-group
> > 
> > 
> > It shouldn't link all the -built-in.o into the uncompressor, should it?
> > Or is it supposed to work via --gc-sections trick?
> 
> Yes, it works using --gc-sections. Are you building a defconfig or a
> custom one? If the error above is correct start_barebox is referenced
> from the decompressor code. This should not happen.

I'm building a custom one (unpublished code).  It has some SPI flash
boot assembly code, I guess that might cause the issue wrt the new section
annotations.  I'll look at it tomorrow.  However, I still wonder
about the empty $(barebox-compressed)?


Thanks
Johannes

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

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

* Re: Compressed barebox image support
  2012-07-19  8:12 Compressed barebox image support Sascha Hauer
                   ` (9 preceding siblings ...)
  2012-07-19 15:08 ` Compressed barebox " Jean-Christophe PLAGNIOL-VILLARD
@ 2012-07-19 20:11 ` Robert Jarzmik
  2012-07-20  7:59   ` Sascha Hauer
  10 siblings, 1 reply; 28+ messages in thread
From: Robert Jarzmik @ 2012-07-19 20:11 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Sascha Hauer <s.hauer@pengutronix.de> writes:
> Nevertheless I would be happy about Tested-by (and does-not-work-for) tags.
>
> Sascha

I tried on Xscale PXA (mioa701 board, armv5te).
It works like a charm.

Therefore, feel free to add my :
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>

-- 
Robert

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

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

* Re: [PATCH 9/9] Add compressed image support
  2012-07-19 18:32       ` Johannes Stezenbach
@ 2012-07-19 20:42         ` Sascha Hauer
  2012-07-20 15:01           ` Johannes Stezenbach
  0 siblings, 1 reply; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19 20:42 UTC (permalink / raw)
  To: Johannes Stezenbach; +Cc: barebox

On Thu, Jul 19, 2012 at 08:32:38PM +0200, Johannes Stezenbach wrote:
> > > ...
> > >   LD      barebox
> > > arm-linux-ld -EL  -Map barebox.map -static --gc-sections -o barebox \
> > >                 -T arch/arm/lib/barebox-compressed.lds  \
> > >                 --start-group  common/built-in.o  drivers/built-in.o  commands/built-in.o  lib/built-in.o  crypto/built-in.o  net/built-in.o  fs/built-in.o  arch/arm/boards/foo/built-in.o  arch/arm/mach-foo/built-in.o  arch/arm/lib/built-in.o  arch/arm/cpu/built-in.o piggy.lzo.o --end-group
> > > 
> > > 
> > > It shouldn't link all the -built-in.o into the uncompressor, should it?
> > > Or is it supposed to work via --gc-sections trick?
> > 
> > Yes, it works using --gc-sections. Are you building a defconfig or a
> > custom one? If the error above is correct start_barebox is referenced
> > from the decompressor code. This should not happen.
> 
> I'm building a custom one (unpublished code).  It has some SPI flash
> boot assembly code, I guess that might cause the issue wrt the new section
> annotations.  I'll look at it tomorrow.  However, I still wonder
> about the empty $(barebox-compressed)?

It's empty here aswell, so this shouldn't be a problem. Though I should
probably simpy remove it.

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] 28+ messages in thread

* Re: [PATCH 8/9] ARM: Separate assembler functions into their own section
  2012-07-19 14:08     ` Sascha Hauer
@ 2012-07-19 20:45       ` Sascha Hauer
  2012-07-20 16:20         ` Johannes Stezenbach
  0 siblings, 1 reply; 28+ messages in thread
From: Sascha Hauer @ 2012-07-19 20:45 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

On Thu, Jul 19, 2012 at 04:08:34PM +0200, Sascha Hauer wrote:
> On Thu, Jul 19, 2012 at 12:38:03PM +0200, Marc Kleine-Budde wrote:
> > On 07/19/2012 10:13 AM, Sascha Hauer wrote:
> > > To let the linker remove unused functions.
> > > 
> > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > ---
> > >  arch/arm/cpu/cache-armv4.S      |    7 ++++++-
> > >  arch/arm/cpu/cache-armv5.S      |    7 ++++++-
> > >  arch/arm/cpu/cache-armv6.S      |   11 +++++++++--
> > >  arch/arm/cpu/cache-armv7.S      |    8 ++++++--
> > >  arch/arm/lib/ashldi3.S          |    1 +
> > >  arch/arm/lib/ashrdi3.S          |    1 +
> > >  arch/arm/lib/findbit.S          |    9 +++++++++
> > >  arch/arm/lib/io-writesw-armv4.S |    2 ++
> > >  arch/arm/lib/lib1funcs.S        |    7 +++++++
> > >  arch/arm/lib/lshrdi3.S          |    1 +
> > >  10 files changed, 48 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/arch/arm/cpu/cache-armv4.S b/arch/arm/cpu/cache-armv4.S
> > > index 6d03565..2231eee 100644
> > > --- a/arch/arm/cpu/cache-armv4.S
> > > +++ b/arch/arm/cpu/cache-armv4.S
> > > @@ -3,6 +3,7 @@
> > >  
> > >  #define CACHE_DLINESIZE 32
> > >  
> > > +.section .text.__mmu_cache_on
> > >  ENTRY(__mmu_cache_on)
> > 
> > Is it possible to add the section to the ENTRY macro?
> 
> I'm not sure. I was pretty sure that some assembly functions fall
> through to the next function. I cannot find any examples though.

For example we have this:

.section .text.__divsi3
ENTRY(__divsi3)
ENTRY(__aeabi_idiv)
	...

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] 28+ messages in thread

* Re: Compressed barebox image support
  2012-07-19 20:11 ` Robert Jarzmik
@ 2012-07-20  7:59   ` Sascha Hauer
  0 siblings, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-20  7:59 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: barebox

Hi Robert,

On Thu, Jul 19, 2012 at 10:11:06PM +0200, Robert Jarzmik wrote:
> Sascha Hauer <s.hauer@pengutronix.de> writes:
> > Nevertheless I would be happy about Tested-by (and does-not-work-for) tags.
> >
> > Sascha
> 
> I tried on Xscale PXA (mioa701 board, armv5te).
> It works like a charm.
> 
> Therefore, feel free to add my :
> Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>

Thanks for testing.

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] 28+ messages in thread

* Re: [PATCH 9/9] Add compressed image support
  2012-07-19 20:42         ` Sascha Hauer
@ 2012-07-20 15:01           ` Johannes Stezenbach
  0 siblings, 0 replies; 28+ messages in thread
From: Johannes Stezenbach @ 2012-07-20 15:01 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Thu, Jul 19, 2012 at 10:42:12PM +0200, Sascha Hauer wrote:
> On Thu, Jul 19, 2012 at 08:32:38PM +0200, Johannes Stezenbach wrote:
> > > > ...
> > > >   LD      barebox
> > > > arm-linux-ld -EL  -Map barebox.map -static --gc-sections -o barebox \
> > > >                 -T arch/arm/lib/barebox-compressed.lds  \
> > > >                 --start-group  common/built-in.o  drivers/built-in.o  commands/built-in.o  lib/built-in.o  crypto/built-in.o  net/built-in.o  fs/built-in.o  arch/arm/boards/foo/built-in.o  arch/arm/mach-foo/built-in.o  arch/arm/lib/built-in.o  arch/arm/cpu/built-in.o piggy.lzo.o --end-group
> > > > 
> > > > 
> > > > It shouldn't link all the -built-in.o into the uncompressor, should it?
> > > > Or is it supposed to work via --gc-sections trick?
> > > 
> > > Yes, it works using --gc-sections. Are you building a defconfig or a
> > > custom one? If the error above is correct start_barebox is referenced
> > > from the decompressor code. This should not happen.
> > 
> > I'm building a custom one (unpublished code).  It has some SPI flash
> > boot assembly code, I guess that might cause the issue wrt the new section
> > annotations.  I'll look at it tomorrow.  However, I still wonder
> > about the empty $(barebox-compressed)?
> 
> It's empty here aswell, so this shouldn't be a problem. Though I should
> probably simpy remove it.

OK, got it to work now.  I had a "b start" in my SPI flash boot code
to skip low level init when it was loaded into RAM via JTAG.
That needed to be changed to "b compressed_start".  It seems
there is no real support in ld to debug this, I added --cref
to LDFLAGS_barebox but I still couldn't see why stuff from
common/built-in.o gets pulled into the uncompressor.

BTW, I briefly tried the lzo update from
http://lkml.org/lkml/2012/7/16/355
(don't have much time to do real benchmarks, just tried
"time uncompress somefile.lzo somefile"),
but it seems to be slower on ARM926 than the old version
(504ms vs 362ms).


Thanks,
Johannes

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

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

* Re: [PATCH 9/9] Add compressed image support
  2012-07-19  8:13 ` [PATCH 9/9] Add compressed image support Sascha Hauer
  2012-07-19 14:10   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-07-19 17:08   ` Johannes Stezenbach
@ 2012-07-20 15:24   ` Jean-Christophe PLAGNIOL-VILLARD
  2 siblings, 0 replies; 28+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-07-20 15:24 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

> +{
> +	u32 r;
> +
> +	/* Setup the stack */
> +	r = STACK_BASE + STACK_SIZE - 16;
> +	__asm__ __volatile__("mov sp, %0" : : "r"(r));
> +	/* clear bss */
> +	memset(__bss_start, 0, __bss_stop - __bss_start);
> +
> +	start_barebox();
> +}
> +#else
>  void __naked __section(.text_entry) start(void)
>  {
>  	barebox_arm_head();
>  }
> +#endif
>  
>  void __naked __section(.text_exceptions) exception_vectors(void)
>  {
>  	__asm__ __volatile__ (
>  		".arm\n"
> -		"b reset\n"				/* reset */
> +		"1: b 1b\n"					/* reset */
>  #ifdef CONFIG_ARM_EXCEPTIONS
>  		"ldr pc, =undefined_instruction\n"	/* undefined instruction */
>  		"ldr pc, =software_interrupt\n"		/* software interrupt (SWI) */
> @@ -98,6 +118,34 @@ void __naked __bare_init reset(void)
>  	board_init_lowlevel_return();
>  }
>  
> +extern void *input_data;
> +extern void *input_data_end;
> +
> +#define STATIC static
> +#include "../../../lib/decompress_unlzo.c"
> +
> +void barebox_uncompress(void *compressed_start, unsigned int len)
> +{
> +	void (*barebox)(void);
need to check here if we are at TEXT_BASE (I mean if the code run where we are
supposed to uncompress

otherwise on at91 it will not work as the bootstrap put use at TEXT_BASE

so we have need to link at an other address

but the decompressor need work anyway by copying itself with the data before
of after the TEXT_BASE
and we should take the uncompress size about 4 times the compressed one.
There is nearly no change to compress more than 75%


otherwise Tested by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Best Regards,
J.

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

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

* Re: [PATCH 8/9] ARM: Separate assembler functions into their own section
  2012-07-19 20:45       ` Sascha Hauer
@ 2012-07-20 16:20         ` Johannes Stezenbach
  2012-07-23 20:00           ` Sascha Hauer
  0 siblings, 1 reply; 28+ messages in thread
From: Johannes Stezenbach @ 2012-07-20 16:20 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Thu, Jul 19, 2012 at 10:45:48PM +0200, Sascha Hauer wrote:
> On Thu, Jul 19, 2012 at 04:08:34PM +0200, Sascha Hauer wrote:
> > On Thu, Jul 19, 2012 at 12:38:03PM +0200, Marc Kleine-Budde wrote:
> > > On 07/19/2012 10:13 AM, Sascha Hauer wrote:
> > > >  
> > > > +.section .text.__mmu_cache_on
> > > >  ENTRY(__mmu_cache_on)
> > > 
> > > Is it possible to add the section to the ENTRY macro?
> > 
> > I'm not sure. I was pretty sure that some assembly functions fall
> > through to the next function. I cannot find any examples though.
> 
> For example we have this:
> 
> .section .text.__divsi3
> ENTRY(__divsi3)
> ENTRY(__aeabi_idiv)
> 	...

and also:
ENTRY(__lshrdi3)
ENTRY(__aeabi_llsr)

However, this is the rare exception.  How about
adding __ENTRY for these cases?


Johannes

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

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

* Re: [PATCH 8/9] ARM: Separate assembler functions into their own section
  2012-07-19  8:13 ` [PATCH 8/9] ARM: Separate assembler functions into their own section Sascha Hauer
  2012-07-19 10:38   ` Marc Kleine-Budde
@ 2012-07-23 19:59   ` Sascha Hauer
  1 sibling, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-23 19:59 UTC (permalink / raw)
  To: barebox

On Thu, Jul 19, 2012 at 10:13:01AM +0200, Sascha Hauer wrote:
 diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S
> index ef4caff..422455d 100644
> --- a/arch/arm/lib/findbit.S
> +++ b/arch/arm/lib/findbit.S
> @@ -22,6 +22,7 @@
>   * Purpose  : Find a 'zero' bit
>   * Prototype: int find_first_zero_bit(void *addr, unsigned int maxbit);
>   */
> +.section .text._find_first_zero_bit_le
>  ENTRY(_find_first_zero_bit_le)
>  		teq	r1, #0
>  		beq	3f
> @@ -43,6 +44,7 @@ ENDPROC(_find_first_zero_bit_le)
>   * Purpose  : Find next 'zero' bit
>   * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset)
>   */
> +.section .text._find_next_zero_bit_le
>  ENTRY(_find_next_zero_bit_le)
>  		teq	r1, #0
>  		beq	3b
> @@ -63,6 +65,7 @@ ENDPROC(_find_next_zero_bit_le)
>   * Purpose  : Find a 'one' bit
>   * Prototype: int find_first_bit(const unsigned long *addr, unsigned int maxbit);
>   */
> +.section .text._find_first_bit_le
>  ENTRY(_find_first_bit_le)
>  		teq	r1, #0
>  		beq	3f

The changes in this file are completely wrong. These functions use
different jump labels (1b, 1f,...) to jump over function borders.
The bad thing is that the compiler does not issue any warning, it only
generates broken code.
Will fix.

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] 28+ messages in thread

* Re: [PATCH 8/9] ARM: Separate assembler functions into their own section
  2012-07-20 16:20         ` Johannes Stezenbach
@ 2012-07-23 20:00           ` Sascha Hauer
  0 siblings, 0 replies; 28+ messages in thread
From: Sascha Hauer @ 2012-07-23 20:00 UTC (permalink / raw)
  To: Johannes Stezenbach; +Cc: barebox

On Fri, Jul 20, 2012 at 06:20:07PM +0200, Johannes Stezenbach wrote:
> > For example we have this:
> > 
> > .section .text.__divsi3
> > ENTRY(__divsi3)
> > ENTRY(__aeabi_idiv)
> > 	...
> 
> and also:
> ENTRY(__lshrdi3)
> ENTRY(__aeabi_llsr)
> 
> However, this is the rare exception.  How about
> adding __ENTRY for these cases?

I think it's better to keep the ENTRY semantics (which is derived from
the Linux Kernel) and just live with it that we have to add the .section
at the beginning of each function.

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] 28+ messages in thread

end of thread, other threads:[~2012-07-23 20:00 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-19  8:12 Compressed barebox image support Sascha Hauer
2012-07-19  8:12 ` [PATCH 1/9] lzo: Allow for static inlining Sascha Hauer
2012-07-19  8:12 ` [PATCH 2/9] ARM lds: remove unused got Sascha Hauer
2012-07-19  8:12 ` [PATCH 3/9] ARM: remove board linker script option Sascha Hauer
2012-07-19  8:12 ` [PATCH 4/9] ARM: remove exception vectors from boards Sascha Hauer
2012-07-19  8:12 ` [PATCH 5/9] ARM startup: calculate offset instead of runtime address Sascha Hauer
2012-07-19  8:12 ` [PATCH 6/9] ARM ep93xx: Get rid of special handling in linker file Sascha Hauer
2012-07-19  8:13 ` [PATCH 7/9] ARM boards: Use _text rather than TEXT_BASE Sascha Hauer
2012-07-19  8:13 ` [PATCH 8/9] ARM: Separate assembler functions into their own section Sascha Hauer
2012-07-19 10:38   ` Marc Kleine-Budde
2012-07-19 14:04     ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-19 14:08     ` Sascha Hauer
2012-07-19 20:45       ` Sascha Hauer
2012-07-20 16:20         ` Johannes Stezenbach
2012-07-23 20:00           ` Sascha Hauer
2012-07-23 19:59   ` Sascha Hauer
2012-07-19  8:13 ` [PATCH 9/9] Add compressed image support Sascha Hauer
2012-07-19 14:10   ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-19 17:08   ` Johannes Stezenbach
2012-07-19 17:41     ` Sascha Hauer
2012-07-19 18:32       ` Johannes Stezenbach
2012-07-19 20:42         ` Sascha Hauer
2012-07-20 15:01           ` Johannes Stezenbach
2012-07-20 15:24   ` Jean-Christophe PLAGNIOL-VILLARD
2012-07-19 15:08 ` Compressed barebox " Jean-Christophe PLAGNIOL-VILLARD
2012-07-19 16:05   ` Sascha Hauer
2012-07-19 20:11 ` Robert Jarzmik
2012-07-20  7:59   ` Sascha Hauer

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