Skip to contentSkip to conversation

compressed image update

PATCH Superseded Jean-Christophe PLAGNIOL-VILLARD 2 participants 17 messages Jul 23, 2012

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover compressed image update

Hi,

v2:
fix modules support
move compressed barebox to arch/<arch?compressed rename target to zbarebox*

The following changes since commit 63ac9c743b1304b0b4b792643e4704394f6f8aeb:

only compress default env in uncompressed images (2012-07-20 14:20:15 +0200)

are available in the git repository at:

git://git.jcrosoft.org/barebox.git tags/compressed-gzip2

for you to fetch changes up to 225bc30b768479030889a0995acc446ddcfd949d:

compressed image: add gzip support (2012-07-23 12:13:38 +0800)

----------------------------------------------------------------
compressed: gzip support and cleanup

The follwing patch series add the support of GZIP

And allow now to link only what is need in the decompressor

This is needed if you want to compile a barebox with modules support

as we current rely on gcc and it's garbage colector to clean the non needed object.

With modules support gcc will not do this.

This will allow to have a version of barebox shrink to the first 128KiB so it can fit in the first page of nand which is garanty badblock free and then if we need more feature we will use modules store in an other partitions.

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (7):
stddev: make it selectable via Kconfig
decompress_unlzo: define decompress_unlzo as decompress compressed image: factorise compressor type
decompressor: import malloc/free implementation for linux 3.4
ARM: add early malloc support needed by the decompressor
compressed: rename barebox target to zbarebox and zbarebox.bin compressed image: add gzip support

 Makefile                                        |   35 +++-----------------------
 arch/arm/Makefile                               |    9 ++++++-
 arch/arm/compressed/Makefile                    |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/compressed/barebox.lds.S               |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 piggy.lzo.S => arch/arm/compressed/piggy.gzip.S |    2 +-
 arch/arm/compressed/piggy.lzo.S                 |    6 +++++
 arch/arm/cpu/start.c                            |   61 +++++++++++++++++++++++++++++++---------------
 arch/arm/lib/Makefile                           |    2 +-
 arch/arm/lib/barebox.lds.S                      |    2 +-
 commands/Makefile                               |    2 +-
 common/Kconfig                                  |   25 ++++++++++++++++---
 compressed/misc.c                               |   14 +++++++++++
 compressed/string.c                             |  127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/decompress/mm.h                   |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/decompress_inflate.c                        |    1 +
 lib/decompress_unlzo.c                          |    1 +
 16 files changed, 437 insertions(+), 58 deletions(-)
 create mode 100644 arch/arm/compressed/Makefile
 create mode 100644 arch/arm/compressed/barebox.lds.S
 rename piggy.lzo.S => arch/arm/compressed/piggy.gzip.S (70%)
 create mode 100644 arch/arm/compressed/piggy.lzo.S
 create mode 100644 compressed/misc.c
 create mode 100644 compressed/string.c
 create mode 100644 include/linux/decompress/mm.h

Best Regards,
J.

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

#1 lore raw

PATCH v2 1/7 stddev: make it selectable via Kconfig

enable is by default for simple and hush
we do not need to NO_SHELL

this allow to save 1KiB

---
 commands/Makefile |    2 +-
 common/Kconfig    |    5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
commands/Makefile +1 -1
index 54191b4..e9157bf 100644
@@ -1,4 +1,4 @@
-obj-y				+= stddev.o
+obj-$(CONFIG_STDDEV)		+= stddev.o
 obj-$(CONFIG_CMD_BOOTM)		+= bootm.o
 obj-$(CONFIG_CMD_UIMAGE)	+= uimage.o
 obj-$(CONFIG_CMD_LINUX16)	+= linux16.o
common/Kconfig +5 -0
index 1c996aa..c6f1afa 100644
@@ -50,6 +50,9 @@ config BINFMT
 config GLOBALVAR
 	bool
 
+config STDDEV
+	bool
+
 menu "General Settings              "
 
 config LOCALVERSION
@@ -295,6 +298,7 @@ choice
 		select COMMAND_SUPPORT
 		select PARAMETER
 		select BINFMT
+		select STDDEV
 		help
 		  Enable hush support. This is the most advanced shell available
 		  for barebox.
@@ -304,6 +308,7 @@ choice
 		select ENVIRONMENT_VARIABLES
 		select COMMAND_SUPPORT
 		select PARAMETER
+		select STDDEV
 		help
 		  simple shell. No if/then, no return values from commands, no loops
 
Signature · 7 lines
1.7.10


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

PATCH v2 2/7 decompress_unlzo: define decompress_unlzo as decompress

so we can use decompress in the decompressor
this will simplify multi decompress support

---
 lib/decompress_unlzo.c |    1 +
 1 file changed, 1 insertion(+)
lib/decompress_unlzo.c +1 -0
index 0e6a7ad..56abfc6 100644
@@ -289,3 +289,4 @@ exit_1:
 exit:
 	return ret;
 }
+#define decompress decompress_unlzo
Signature · 7 lines
1.7.10


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

PATCH v2 3/7 compressed image: factorise compressor type

In reply to Jean-Christophe PLAGNIOL-VILLARD

This will simplify to support of multi compressor support such as gzip, lzma, xz.

---
 Makefile                   |   12 +++++++-----
 arch/arm/cpu/start.c       |    9 ++++++---
 arch/arm/lib/Makefile      |    2 +-
 arch/arm/lib/barebox.lds.S |    2 +-
 common/Kconfig             |   17 ++++++++++++++---
 5 files changed, 29 insertions(+), 13 deletions(-)
Makefile +7 -5
index e0a3c07..0b3da03 100644
@@ -715,20 +715,22 @@ barebox-uncompressed: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsym
 barebox-uncompressed.bin: barebox-uncompressed
 	$(call if_changed,objcopy)
 
+suffix_$(CONFIG_IMAGE_COMPRESSION_LZO)	= lzo
+
 barebox-uncompressed.bin.lzo: barebox-uncompressed.bin
 	@echo "  LZO    " $@
 	$(Q)lzop -f -9 -o $@ barebox-uncompressed.bin
 
-piggy.lzo.o: barebox-uncompressed.bin.lzo $(src)/piggy.lzo.S
+piggy.$(suffix_y).o: barebox-uncompressed.bin.$(suffix_y) $(src)/piggy.$(suffix_y).S
 	@echo "  CC     " $@
-	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c $(src)/piggy.lzo.S -o $@
+	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c $(src)/piggy.$(suffix_y).S -o $@
 
-ifdef CONFIG_IMAGE_COMPRESSION_LZO
-barebox: piggy.lzo.o
+ifdef CONFIG_IMAGE_COMPRESSION
+barebox: piggy.$(suffix_y).o
 	@echo "  LD     " $@
 	$(Q)$(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
 		-T $(barebox-compressed-lds) \
-		--start-group $(barebox-common) piggy.lzo.o --end-group
+		--start-group $(barebox-common) piggy.$(suffix_y).o --end-group
 else
 barebox: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o) FORCE
 	$(call barebox-modpost)
arch/arm/cpu/start.c +6 -3
index 6743804..18c5c83 100644
@@ -28,7 +28,7 @@
 #include <asm-generic/memory_layout.h>
 #include <asm/sections.h>
 
-#ifdef CONFIG_IMAGE_COMPRESSION_LZO
+#ifdef CONFIG_IMAGE_COMPRESSION
 void __naked __section(.text_head_entry) compressed_start(void)
 {
 	barebox_arm_head();
@@ -101,7 +101,10 @@ extern void *input_data;
 extern void *input_data_end;
 
 #define STATIC static
+
+#ifdef CONFIG_IMAGE_COMPRESSION_LZO
 #include "../../../lib/decompress_unlzo.c"
+#endif
 
 void barebox_uncompress(void *compressed_start, unsigned int len)
 {
@@ -112,7 +115,7 @@ void barebox_uncompress(void *compressed_start, unsigned int len)
 	else
 		barebox = (void *)TEXT_BASE;
 
-	decompress_unlzo((void *)compressed_start,
+	decompress((void *)compressed_start,
 			len,
 			NULL, NULL,
 			(void *)TEXT_BASE, NULL, NULL);
@@ -158,7 +161,7 @@ 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));
 
-	if (IS_ENABLED(CONFIG_IMAGE_COMPRESSION_LZO)) {
+	if (IS_ENABLED(CONFIG_IMAGE_COMPRESSION)) {
 		compressed_start = (uint32_t)&input_data - offset;
 		compressed_end = (uint32_t)&input_data_end - offset;
 		len = compressed_end - compressed_start;
arch/arm/lib/Makefile +1 -1
index 044d3e6..1b6f7f4 100644
@@ -21,4 +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
+extra-$(CONFIG_IMAGE_COMPRESSION) += barebox-compressed.lds
arch/arm/lib/barebox.lds.S +1 -1
index b415830..b22cf98 100644
@@ -31,7 +31,7 @@ SECTIONS
 {
 	. = TEXT_BASE;
 
-#ifndef CONFIG_IMAGE_COMPRESSION_LZO
+#ifndef CONFIG_IMAGE_COMPRESSION
 	PRE_IMAGE
 #endif
 	. = ALIGN(4);
common/Kconfig +14 -3
index c6f1afa..8437e1c 100644
@@ -99,9 +99,20 @@ menu "memory layout                 "
 config HAVE_IMAGE_COMPRESSION
 	bool
 
+config IMAGE_COMPRESSION
+	bool "Compressed image"
+
+if IMAGE_COMPRESSION
+
+choice
+	prompt "Compression"
+
 config IMAGE_COMPRESSION_LZO
-	depends on HAVE_IMAGE_COMPRESSION
-	bool "lzo compressed image"
+	bool "lzo"
+
+endchoice
+
+endif
 
 config MMU
 	bool "Enable MMU"
@@ -185,7 +196,7 @@ config MALLOC_SIZE
 	prompt "malloc area size"
 
 config HEAD_TEXT_BASE
-	depends on MEMORY_LAYOUT_FIXED && IMAGE_COMPRESSION_LZO
+	depends on MEMORY_LAYOUT_FIXED && IMAGE_COMPRESSION
 	hex
 	prompt "HEAD_TEXT_BASE"
 endmenu
Signature · 7 lines
1.7.10


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

PATCH v2 4/7 decompressor: import malloc/free implementation for linux 3.4

In reply to Jean-Christophe PLAGNIOL-VILLARD

This is need for gunzip support

---
 include/linux/decompress/mm.h |   68 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 include/linux/decompress/mm.h
include/linux/decompress/mm.h new file +68 -0
new file mode 100644
index 0000000..0c35411
@@ -0,0 +1,68 @@
+/*
+ * linux/compr_mm.h
+ *
+ * Memory management for pre-boot and ramdisk uncompressors
+ *
+ * Authors: Alain Knaff <[email protected]>
+ *
+ */
+
+#ifndef DECOMPR_MM_H
+#define DECOMPR_MM_H
+
+#ifdef STATIC
+
+/* Code active when included from pre-boot environment: */
+
+/*
+ * Some architectures want to ensure there is no local data in their
+ * pre-boot environment, so that data can arbitrarily relocated (via
+ * GOT references).  This is achieved by defining STATIC_RW_DATA to
+ * be null.
+ */
+#ifndef STATIC_RW_DATA
+#define STATIC_RW_DATA static
+#endif
+
+/* A trivial malloc implementation, adapted from
+ *  malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
+ */
+STATIC_RW_DATA unsigned long malloc_ptr;
+STATIC_RW_DATA int malloc_count;
+
+static void *malloc(int size)
+{
+	void *p;
+
+	if (size < 0)
+		return NULL;
+	if (!malloc_ptr)
+		malloc_ptr = free_mem_ptr;
+
+	malloc_ptr = (malloc_ptr + 3) & ~3;     /* Align */
+
+	p = (void *)malloc_ptr;
+	malloc_ptr += size;
+
+	if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
+		return NULL;
+
+	malloc_count++;
+	return p;
+}
+
+static void free(void *where)
+{
+	malloc_count--;
+	if (!malloc_count)
+		malloc_ptr = free_mem_ptr;
+}
+
+#define large_malloc(a) malloc(a)
+#define large_free(a) free(a)
+
+#define INIT
+
+#endif /* STATIC */
+
+#endif /* DECOMPR_MM_H */
Signature · 7 lines
1.7.10


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

PATCH v2 5/7 ARM: add early malloc support needed by the decompressor

In reply to Jean-Christophe PLAGNIOL-VILLARD

This is not needed by lzo but by gunzip, xz and others.

---
 arch/arm/cpu/start.c |    7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/cpu/start.c +7 -0
index 18c5c83..8ab6fdc 100644
@@ -28,6 +28,9 @@
 #include <asm-generic/memory_layout.h>
 #include <asm/sections.h>
 
+unsigned long free_mem_ptr;
+unsigned long free_mem_end_ptr;
+
 #ifdef CONFIG_IMAGE_COMPRESSION
 void __naked __section(.text_head_entry) compressed_start(void)
 {
@@ -158,6 +161,10 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
 	/* clear bss */
 	memset(__bss_start, 0, __bss_stop - __bss_start);
 
+	/* set 128 KiB before the STACK_BASE - 16 address for early malloc */
+	free_mem_ptr = STACK_BASE - 0x20000 - 16;
+	free_mem_end_ptr = STACK_BASE - 16;
+
 	/* flush I-cache before jumping to the copied binary */
 	__asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
 
Signature · 7 lines
1.7.10


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

PATCH v2 6/7 compressed: rename barebox target to zbarebox and zbarebox.bin

In reply to Jean-Christophe PLAGNIOL-VILLARD

Today we link to whole barebox and rely on gcc to cleanup via it's garbage collector.
Now we specify only what is needed and introduce a new directory with source only related to the compressed target.

Build it in arch/<arm>/compressed
Rebuild all the needed object.

Keep the previous target untouched.
This fix the modules support and allow custom flags for each file.

Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic.

---
 Makefile                          |   37 ++---------
 arch/arm/Makefile                 |    9 ++-
 arch/arm/compressed/Makefile      |   69 ++++++++++++++++++++
 arch/arm/compressed/barebox.lds.S |   70 ++++++++++++++++++++
 arch/arm/compressed/piggy.lzo.S   |    6 ++
 arch/arm/cpu/start.c              |   41 +++++++-----
 compressed/misc.c                 |   14 ++++
 compressed/string.c               |  127 +++++++++++++++++++++++++++++++++++++
 piggy.lzo.S                       |    6 --
 9 files changed, 323 insertions(+), 56 deletions(-)
 create mode 100644 arch/arm/compressed/Makefile
 create mode 100644 arch/arm/compressed/barebox.lds.S
 create mode 100644 arch/arm/compressed/piggy.lzo.S
 create mode 100644 compressed/misc.c
 create mode 100644 compressed/string.c
 delete mode 100644 piggy.lzo.S
Makefile +4 -33
index 0b3da03..46c9491 100644
@@ -512,7 +512,6 @@ 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
@@ -668,11 +667,12 @@ 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)
+ifndef CONFIG_IMAGE_COMPRESSION
 	$(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
+endif
 
 ifdef CONFIG_X86
 barebox.S: barebox
@@ -702,41 +702,13 @@ 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)
-
-suffix_$(CONFIG_IMAGE_COMPRESSION_LZO)	= lzo
-
-barebox-uncompressed.bin.lzo: barebox-uncompressed.bin
-	@echo "  LZO    " $@
-	$(Q)lzop -f -9 -o $@ barebox-uncompressed.bin
-
-piggy.$(suffix_y).o: barebox-uncompressed.bin.$(suffix_y) $(src)/piggy.$(suffix_y).S
-	@echo "  CC     " $@
-	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c $(src)/piggy.$(suffix_y).S -o $@
-
-ifdef CONFIG_IMAGE_COMPRESSION
-barebox: piggy.$(suffix_y).o
-	@echo "  LD     " $@
-	$(Q)$(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
-		-T $(barebox-compressed-lds) \
-		--start-group $(barebox-common) piggy.$(suffix_y).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 $< $@
@@ -1031,11 +1003,10 @@ endif # CONFIG_MODULES
 # Directories & files removed with 'make clean'
 CLEAN_DIRS  += $(MODVERDIR)
 CLEAN_FILES +=	barebox System.map include/generated/barebox_default_env.h \
-                .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \
+                .tmp_version .tmp_barebox* barebox.* \
 		.tmp_kallsyms* barebox_default_env* barebox.ldr \
 		scripts/bareboxenv-target \
-		Doxyfile.version barebox.srec barebox.s5p \
-		barebox-uncompressed barebox-uncompressed.bin barebox-uncompressed.bin.lzo
+		Doxyfile.version barebox.srec barebox.s5p
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_DIRS  += include/config include2 usr/include
arch/arm/Makefile +8 -1
index a93c4d5..647c536 100644
@@ -184,6 +184,14 @@ ifeq ($(CONFIG_OMAP_BUILD_IFT),y)
 KBUILD_IMAGE := MLO
 endif
 
+ifdef CONFIG_IMAGE_COMPRESSION
+KBUILD_IMAGE := zbarebox.bin
+endif
+
+comp := arch/arm/compressed
+zbarebox.S zbarebox.bin zbarebox: barebox.bin
+	$(Q)$(MAKE) $(build)=$(comp) $(comp)/$@
+
 all: $(KBUILD_IMAGE)
 
 archprepare: maketools
@@ -208,6 +216,5 @@ 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
arch/arm/compressed/Makefile new file +69 -0

69 lines not on this page · raw message

arch/arm/compressed/barebox.lds.S new file +70 -0

70 lines not on this page · raw message

arch/arm/compressed/piggy.lzo.S new file +6 -0
new file mode 100644
index 0000000..0c0d216
@@ -0,0 +1,6 @@
+	.section .piggydata,#alloc
+	.globl	input_data
+input_data:
+	.incbin	"arch/arm/compressed/piggy.lzo"
+	.globl	input_data_end
+input_data_end:
arch/arm/cpu/start.c +25 -16

65 lines not on this page · raw message

compressed/misc.c new file +14 -0
new file mode 100644
index 0000000..47e9cea
@@ -0,0 +1,14 @@
+#include <common.h>
+#include <init.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+
+void __noreturn panic(const char *fmt, ...)
+{
+	while(1);
+}
+
+void start_barebox(void)
+{
+}
compressed/string.c new file +127 -0

127 lines not on this page · raw message

piggy.lzo.S deleted +0 -6
deleted file mode 100644
index 6cc618d..0000000
@@ -1,6 +0,0 @@
-	.section .piggydata,#alloc
-	.globl  input_data
-input_data:
-	.incbin "barebox-uncompressed.bin.lzo"
-	.globl  input_data_end
-input_data_end:
Signature · 7 lines
1.7.10


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

Re: [PATCH 6/7] compressed: rename barebox target to zbarebox and zbarebox.bin

Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

Today we link to whole barebox and rely on gcc to cleanup via it's garbage collector.
Now we specify only what is needed and introduce a new directory with source only related to the compressed target.

Quoted 8 lines

Build it in arch/<arm>/compressed
Rebuild all the needed object.

Keep the previous target untouched.
This fix the modules support and allow custom flags for each file.

Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic.

This does not work on all targets having a lowlevel init:

arch/arm/compressed/start.o: In function `reset':
start.c:(.text_bare_init.text+0x28): undefined reference to `board_init_lowlevel'

Why don't we simply do this:

arch/arm/Makefile +0 -2
index 647c536..12869b3 100644
@@ -150,11 +150,9 @@ TEXT_BASE = $(CONFIG_TEXT_BASE)
 
 CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
 
-ifndef CONFIG_MODULES
 # Add cleanup flags
 CPPFLAGS += -fdata-sections -ffunction-sections
 LDFLAGS_barebox += -static --gc-sections
-endif
 
 barebox.netx: barebox.bin
 	$(Q)scripts/gen_netx_image -i barebox.bin -o barebox.netx		\
Quoted 45 lines
(quoted diff) +23 -7
+void barebox_decompress(uint32_t offset)
+{
+	uint32_t compressed_start, compressed_end, len;
+	void (*uncompress)(void *compressed_start, unsigned int len);
+
+	compressed_start = (uint32_t)&input_data - offset;
+	compressed_end = (uint32_t)&input_data_end - offset;
+	len = compressed_end - compressed_start;
+
+	uncompress = barebox_uncompress;
+
+	/* call barebox_uncompress 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
+void barebox_decompress(uint32_t offset) {}
+#endif
 
 /*
  * Board code can jump here by either returning from board_init_lowlevel
@@ -137,8 +161,6 @@ void barebox_uncompress(void *compressed_start, unsigned int len)
 void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
 {
 	uint32_t r, addr, offset;
-	uint32_t compressed_start, compressed_end, len;
-	void (*uncompress)(void *compressed_start, unsigned int len);
 
 	/*
 	 * Get runtime address of this function. Do not
@@ -169,20 +191,7 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
 	__asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
 
 	if (IS_ENABLED(CONFIG_IMAGE_COMPRESSION)) {
-		compressed_start = (uint32_t)&input_data - offset;
-		compressed_end = (uint32_t)&input_data_end - offset;
-		len = compressed_end - compressed_start;
-
-		uncompress = barebox_uncompress;

Review void __naked __section(.text_ll_return) board_init_lowlevel_return(void) · line 194

Quoted 10 lines
(quoted diff) +1 -9
-
-		/* call barebox_uncompress 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");
+		barebox_decompress(offset);

With this you don't call the decompressor with it's absolute address anymore, which means that the decompressor won't run at the address it's linked at.

Sascha

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

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

Re: [PATCH 6/7] compressed: rename barebox target to zbarebox and zbarebox.bin

Quoted 28 lines · Sascha Hauer
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

Today we link to whole barebox and rely on gcc to cleanup via it's garbage collector.
Now we specify only what is needed and introduce a new directory with source only related to the compressed target.

Quoted 8 lines

Build it in arch/<arm>/compressed
Rebuild all the needed object.

Keep the previous target untouched.
This fix the modules support and allow custom flags for each file.

Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic.

This does not work on all targets having a lowlevel init:

arch/arm/compressed/start.o: In function `reset':
start.c:(.text_bare_init.text+0x28): undefined reference to `board_init_lowlevel'

Why don't we simply do this:

arch/arm/Makefile +0 -0
index 647c536..12869b3 100644

arch/arm/Makefile TEXT_BASE = $(CONFIG_TEXT_BASE) · line 157

Quoted 8 lines
arch/arm/Makefile +0 -2
@@ -150,11 +150,9 @@ TEXT_BASE = $(CONFIG_TEXT_BASE)
 
 CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
 
-ifndef CONFIG_MODULES
 # Add cleanup flags
 CPPFLAGS += -fdata-sections -ffunction-sections
 LDFLAGS_barebox += -static --gc-sections
-endif

you can not do this as this break modules

for board_init_lowlevel we need to add it to the decompressor

Best Regards,
J.

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

#9 lore raw

Re: [PATCH 6/7] compressed: rename barebox target to zbarebox and zbarebox.bin

Quoted 30 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 29 lines · Sascha Hauer
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

Today we link to whole barebox and rely on gcc to cleanup via it's garbage collector.
Now we specify only what is needed and introduce a new directory with source only related to the compressed target.

Quoted 8 lines

Build it in arch/<arm>/compressed
Rebuild all the needed object.

Keep the previous target untouched.
This fix the modules support and allow custom flags for each file.

Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic.

This does not work on all targets having a lowlevel init:

arch/arm/compressed/start.o: In function `reset':
start.c:(.text_bare_init.text+0x28): undefined reference to `board_init_lowlevel'

Why don't we simply do this:

arch/arm/Makefile +0 -0
index 647c536..12869b3 100644
@@ -150,11 +150,9 @@ TEXT_BASE = $(CONFIG_TEXT_BASE)
 
Quoted 8 lines

arch/arm/Makefile TEXT_BASE = $(CONFIG_TEXT_BASE) · line 157

Quoted 7 lines
arch/arm/Makefile +0 -2
 CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
 
-ifndef CONFIG_MODULES
 # Add cleanup flags
 CPPFLAGS += -fdata-sections -ffunction-sections
 LDFLAGS_barebox += -static --gc-sections
-endif

you can not do this as this break modules

Does it really?

I see this goes back to:

commit 8a03bff03ebf36b7460e6ec43259bc8b40731ece

Author: Sascha Hauer <[email protected]>
Date:   Thu Jul 3 10:30:44 2008 +0200

[arm] Add cleanup flags only when modules are disabled. Otherwise
we remove functions from the binary which are needed for modules

I can't see though why this should happen. What is needed for modules is defined by EXPORT_SYMBOL.

Unfortunately modules are quite broken atm for me anyway, so I can't test.

Sascha

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

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

Re: [PATCH 6/7] compressed: rename barebox target to zbarebox and zbarebox.bin

Quoted 52 lines · Sascha Hauer
Quoted 30 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 29 lines · Sascha Hauer
Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD

Today we link to whole barebox and rely on gcc to cleanup via it's garbage collector.
Now we specify only what is needed and introduce a new directory with source only related to the compressed target.

Quoted 8 lines

Build it in arch/<arm>/compressed
Rebuild all the needed object.

Keep the previous target untouched.
This fix the modules support and allow custom flags for each file.

Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic.

This does not work on all targets having a lowlevel init:

arch/arm/compressed/start.o: In function `reset':
start.c:(.text_bare_init.text+0x28): undefined reference to `board_init_lowlevel'

Why don't we simply do this:

arch/arm/Makefile +0 -0
index 647c536..12869b3 100644
@@ -150,11 +150,9 @@ TEXT_BASE = $(CONFIG_TEXT_BASE)
 
Quoted 8 lines

arch/arm/Makefile TEXT_BASE = $(CONFIG_TEXT_BASE) · line 157

Quoted 7 lines
arch/arm/Makefile +0 -2
 CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
 
-ifndef CONFIG_MODULES
 # Add cleanup flags
 CPPFLAGS += -fdata-sections -ffunction-sections
 LDFLAGS_barebox += -static --gc-sections
-endif

you can not do this as this break modules

Does it really?

I see this goes back to:

commit 8a03bff03ebf36b7460e6ec43259bc8b40731ece

Author: Sascha Hauer <[email protected]>
Date:   Thu Jul 3 10:30:44 2008 +0200

[arm] Add cleanup flags only when modules are disabled. Otherwise
we remove functions from the binary which are needed for modules

Quoted 5 lines

I can't see though why this should happen. What is needed for modules is defined by EXPORT_SYMBOL.

Unfortunately modules are quite broken atm for me anyway, so I can't test.

except you need to use the barebox file to link the ko

and that is one of the reason we do need to call the compressed barebox zbarebox

and I'd like to be able to detect when it's a normal barebox and a zbarebox so need to have start.c compiled 2 times

I really do not like this link with the whole barebox in the zbarebox

keep stuff clean and seperated is really better

Best Regards,
J.

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

#11 lore raw

Re: [PATCH 6/7] compressed: rename barebox target to zbarebox and zbarebox.bin

Quoted 24 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 13 lines · Sascha Hauer

Does it really?

I see this goes back to:

commit 8a03bff03ebf36b7460e6ec43259bc8b40731ece

Author: Sascha Hauer <[email protected]>
Date:   Thu Jul 3 10:30:44 2008 +0200

[arm] Add cleanup flags only when modules are disabled. Otherwise
we remove functions from the binary which are needed for modules

Quoted 5 lines

I can't see though why this should happen. What is needed for modules is defined by EXPORT_SYMBOL.

Unfortunately modules are quite broken atm for me anyway, so I can't test.

except you need to use the barebox file to link the ko

and that is one of the reason we do need to call the compressed barebox zbarebox

Quoted 6 lines

and I'd like to be able to detect when it's a normal barebox and a zbarebox so need to have start.c compiled 2 times

I really do not like this link with the whole barebox in the zbarebox

keep stuff clean and seperated is really better

Well, send patches ;)

Sascha

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

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

Re: [PATCH 6/7] compressed: rename barebox target to zbarebox and zbarebox.bin

Quoted 25 lines · Sascha Hauer
Quoted 24 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 13 lines · Sascha Hauer

Does it really?

I see this goes back to:

commit 8a03bff03ebf36b7460e6ec43259bc8b40731ece

Author: Sascha Hauer <[email protected]>
Date:   Thu Jul 3 10:30:44 2008 +0200

[arm] Add cleanup flags only when modules are disabled. Otherwise
we remove functions from the binary which are needed for modules

Quoted 5 lines

I can't see though why this should happen. What is needed for modules is defined by EXPORT_SYMBOL.

Unfortunately modules are quite broken atm for me anyway, so I can't test.

except you need to use the barebox file to link the ko

and that is one of the reason we do need to call the compressed barebox zbarebox

Quoted 8 lines
Quoted 6 lines

and I'd like to be able to detect when it's a normal barebox and a zbarebox so need to have start.c compiled 2 times

I really do not like this link with the whole barebox in the zbarebox

keep stuff clean and seperated is really better

Well, send patches ;)

THis is what this patch do

Best Regards,
J.

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

#13 lore raw

Re: [PATCH 6/7] compressed: rename barebox target to zbarebox and zbarebox.bin

Quoted 29 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 28 lines · Sascha Hauer
Quoted 27 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 13 lines · Sascha Hauer

Does it really?

I see this goes back to:

commit 8a03bff03ebf36b7460e6ec43259bc8b40731ece

Author: Sascha Hauer <[email protected]>
Date:   Thu Jul 3 10:30:44 2008 +0200

[arm] Add cleanup flags only when modules are disabled. Otherwise
we remove functions from the binary which are needed for modules

Quoted 5 lines

I can't see though why this should happen. What is needed for modules is defined by EXPORT_SYMBOL.

Unfortunately modules are quite broken atm for me anyway, so I can't test.

except you need to use the barebox file to link the ko

and that is one of the reason we do need to call the compressed barebox zbarebox

and I'd like to be able to detect when it's a normal barebox and a zbarebox so need to have start.c compiled 2 times

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

I really do not like this link with the whole barebox in the zbarebox

keep stuff clean and seperated is really better

Well, send patches ;)

THis is what this patch do

But it breaks the build

Sascha

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

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

Re: [PATCH 6/7] compressed: rename barebox target to zbarebox and zbarebox.bin

Quoted 30 lines · Sascha Hauer
Quoted 29 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 28 lines · Sascha Hauer
Quoted 27 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 13 lines · Sascha Hauer

Does it really?

I see this goes back to:

commit 8a03bff03ebf36b7460e6ec43259bc8b40731ece

Author: Sascha Hauer <[email protected]>
Date:   Thu Jul 3 10:30:44 2008 +0200

[arm] Add cleanup flags only when modules are disabled. Otherwise
we remove functions from the binary which are needed for modules

Quoted 5 lines

I can't see though why this should happen. What is needed for modules is defined by EXPORT_SYMBOL.

Unfortunately modules are quite broken atm for me anyway, so I can't test.

except you need to use the barebox file to link the ko

and that is one of the reason we do need to call the compressed barebox zbarebox

and I'd like to be able to detect when it's a normal barebox and a zbarebox so need to have start.c compiled 2 times

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

I really do not like this link with the whole barebox in the zbarebox

keep stuff clean and seperated is really better

Well, send patches ;)

THis is what this patch do

But it breaks the build

For this we need some help because one of the way would be to have a new target comp-y so we can specify it accross the source

Best Regards,
J.

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

#15 lore raw

Re: [PATCH 6/7] compressed: rename barebox target to zbarebox and zbarebox.bin

In reply to Jean-Christophe PLAGNIOL-VILLARD

Hi Sam,

I put the linux-kbuild ml as in barebox we use the kbuild system

we are adding the compressed image support to barebox

but we have some trouble to integrate it correctly in the kbuild system

we have file needed by the decompressor store arround the source code

arch/<arch>/boards/<baord>/
arch/<arch>/mach-<mach>/

the idea was to introduce a new target called comp-y => build-comp.o that will be build acrros the tree and then we do the finally link in the main Makefile

Could you help us to archive it or do have an other way to do so

Best Regards,
J.

Quoted 545 lines · Jean-Christophe PLAGNIOL-VILLARD

Today we link to whole barebox and rely on gcc to cleanup via it's garbage collector.
Now we specify only what is needed and introduce a new directory with source only related to the compressed target.

Build it in arch/<arm>/compressed
Rebuild all the needed object.

Keep the previous target untouched.
This fix the modules support and allow custom flags for each file.

Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic.

---
 Makefile                          |   37 ++---------
 arch/arm/Makefile                 |    9 ++-
 arch/arm/compressed/Makefile      |   69 ++++++++++++++++++++
 arch/arm/compressed/barebox.lds.S |   70 ++++++++++++++++++++
 arch/arm/compressed/piggy.lzo.S   |    6 ++
 arch/arm/cpu/start.c              |   41 +++++++-----
 compressed/misc.c                 |   14 ++++
 compressed/string.c               |  127 +++++++++++++++++++++++++++++++++++++
 piggy.lzo.S                       |    6 --
 9 files changed, 323 insertions(+), 56 deletions(-)
 create mode 100644 arch/arm/compressed/Makefile
 create mode 100644 arch/arm/compressed/barebox.lds.S
 create mode 100644 arch/arm/compressed/piggy.lzo.S
 create mode 100644 compressed/misc.c
 create mode 100644 compressed/string.c
 delete mode 100644 piggy.lzo.S
Makefile +4 -33
index 0b3da03..46c9491 100644
@@ -512,7 +512,6 @@ 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
@@ -668,11 +667,12 @@ 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)
+ifndef CONFIG_IMAGE_COMPRESSION
 	$(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
+endif
 
 ifdef CONFIG_X86
 barebox.S: barebox
@@ -702,41 +702,13 @@ 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)
-
-suffix_$(CONFIG_IMAGE_COMPRESSION_LZO)	= lzo
-
-barebox-uncompressed.bin.lzo: barebox-uncompressed.bin
-	@echo "  LZO    " $@
-	$(Q)lzop -f -9 -o $@ barebox-uncompressed.bin
-
-piggy.$(suffix_y).o: barebox-uncompressed.bin.$(suffix_y) $(src)/piggy.$(suffix_y).S
-	@echo "  CC     " $@
-	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c $(src)/piggy.$(suffix_y).S -o $@
-
-ifdef CONFIG_IMAGE_COMPRESSION
-barebox: piggy.$(suffix_y).o
-	@echo "  LD     " $@
-	$(Q)$(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \
-		-T $(barebox-compressed-lds) \
-		--start-group $(barebox-common) piggy.$(suffix_y).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 $< $@
@@ -1031,11 +1003,10 @@ endif # CONFIG_MODULES
 # Directories & files removed with 'make clean'
 CLEAN_DIRS  += $(MODVERDIR)
 CLEAN_FILES +=	barebox System.map include/generated/barebox_default_env.h \
-                .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \
+                .tmp_version .tmp_barebox* barebox.* \
 		.tmp_kallsyms* barebox_default_env* barebox.ldr \
 		scripts/bareboxenv-target \
-		Doxyfile.version barebox.srec barebox.s5p \
-		barebox-uncompressed barebox-uncompressed.bin barebox-uncompressed.bin.lzo
+		Doxyfile.version barebox.srec barebox.s5p
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_DIRS  += include/config include2 usr/include
arch/arm/Makefile +8 -1
index a93c4d5..647c536 100644
@@ -184,6 +184,14 @@ ifeq ($(CONFIG_OMAP_BUILD_IFT),y)
 KBUILD_IMAGE := MLO
 endif
 
+ifdef CONFIG_IMAGE_COMPRESSION
+KBUILD_IMAGE := zbarebox.bin
+endif
+
+comp := arch/arm/compressed
+zbarebox.S zbarebox.bin zbarebox: barebox.bin
+	$(Q)$(MAKE) $(build)=$(comp) $(comp)/$@
+
 all: $(KBUILD_IMAGE)
 
 archprepare: maketools
@@ -208,6 +216,5 @@ 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
arch/arm/compressed/Makefile new file +69 -0
new file mode 100644
index 0000000..627a411
@@ -0,0 +1,69 @@
+
+suffix_$(CONFIG_IMAGE_COMPRESSION_LZO)	= lzo
+
+OBJCOPYFLAGS_zbarebox.bin = -O binary
+
+targets := zbarebox zbarebox.bin zbarebox.S \
+	   piggy.$(suffix_y) piggy.$(suffix_y).o \
+	   lib1funcs.o lib1funcs.S ashldi3.o ashldi3.S \
+	   misc.o string.o start.o
+
+# Make sure files are removed during clean
+extra-y       += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern \
+		 lib1funcs.S ashldi3.S start.c string.c misc.c
+
+$(obj)/zbarebox.bin:	$(obj)/zbarebox FORCE
+	$(call if_changed,objcopy)
+	$(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE))
+	@echo '  Barebox: $@ is ready'
+
+$(obj)/zbarebox.S: $(obj)/zbarebox FORCE
+	$(call if_changed,disasm)
+
+# For __aeabi_uidivmod
+lib1funcs = $(obj)/lib1funcs.o
+
+$(obj)/lib1funcs.S: $(srctree)/arch/$(SRCARCH)/lib/lib1funcs.S
+	$(call cmd,shipped)
+
+CFLAGS_start.o = -D CONFIG_COMPRESSOR
+start= $(obj)/start.o
+$(obj)/start.c: $(srctree)/arch/$(SRCARCH)/cpu/start.c
+	$(call cmd,shipped)
+
+string= $(obj)/string.o
+$(obj)/string.c: $(srctree)/compressed/string.c
+	$(call cmd,shipped)
+
+misc= $(obj)/misc.o
+$(obj)/misc.c: $(srctree)/compressed/misc.c
+	$(call cmd,shipped)
+
+# For __aeabi_llsl
+ashldi3 = $(obj)/ashldi3.o
+
+$(obj)/ashldi3.S: $(srctree)/arch/$(SRCARCH)/lib/ashldi3.S
+	$(call cmd,shipped)
+
+# For __div0
+div0 = $(obj)/div0.o
+
+$(obj)/div0.c: $(srctree)/arch/$(SRCARCH)/lib/div0.c
+	$(call cmd,shipped)
+
+LDFLAGS_zbarebox	:= -Map zbarebox.map
+comp := $(obj)/piggy.$(suffix_y).o \
+	$(lib1funcs) $(ashldi3) $(start) $(string) $(misc) $(div0)
+
+$(obj)/zbarebox: $(obj)/barebox.lds $(comp) FORCE
+	@echo "  LD     " $@
+	$(Q)$(LD) $(LDFLAGS) $(LDFLAGS_zbarebox) -o $@ \
+		-T $(obj)/barebox.lds \
+		--start-group $(comp) --end-group
+
+$(obj)/piggy.$(suffix_y): $(obj)/../../../barebox.bin FORCE
+	$(call if_changed,$(suffix_y))
+
+$(obj)/piggy.$(suffix_y).o:  $(obj)/piggy.$(suffix_y) FORCE
+
+$(obj)/barebox.lds: $(obj)/barebox.lds.S
arch/arm/compressed/barebox.lds.S new file +70 -0
new file mode 100644
index 0000000..809e567
@@ -0,0 +1,70 @@
+/*
+ * (C) Copyright 2012 Sascha Hauer <[email protected]>, Pengutronix
+ *
+ * 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;
+}
arch/arm/compressed/piggy.lzo.S new file +6 -0
new file mode 100644
index 0000000..0c0d216
@@ -0,0 +1,6 @@
+	.section .piggydata,#alloc
+	.globl	input_data
+input_data:
+	.incbin	"arch/arm/compressed/piggy.lzo"
+	.globl	input_data_end
+input_data_end:
arch/arm/cpu/start.c +25 -16
index 8ab6fdc..6c745f7 100644
@@ -100,6 +100,7 @@ void __naked __bare_init reset(void)
 	board_init_lowlevel_return();
 }
 
+#ifdef CONFIG_COMPRESSOR
 extern void *input_data;
 extern void *input_data_end;
 
@@ -129,6 +130,29 @@ void barebox_uncompress(void *compressed_start, unsigned int len)
 	barebox();
 }
 
+void barebox_decompress(uint32_t offset)
+{
+	uint32_t compressed_start, compressed_end, len;
+	void (*uncompress)(void *compressed_start, unsigned int len);
+
+	compressed_start = (uint32_t)&input_data - offset;
+	compressed_end = (uint32_t)&input_data_end - offset;
+	len = compressed_end - compressed_start;
+
+	uncompress = barebox_uncompress;
+
+	/* call barebox_uncompress 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
+void barebox_decompress(uint32_t offset) {}
+#endif
 
 /*
  * Board code can jump here by either returning from board_init_lowlevel
@@ -137,8 +161,6 @@ void barebox_uncompress(void *compressed_start, unsigned int len)
 void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
 {
 	uint32_t r, addr, offset;
-	uint32_t compressed_start, compressed_end, len;
-	void (*uncompress)(void *compressed_start, unsigned int len);
 
 	/*
 	 * Get runtime address of this function. Do not
@@ -169,20 +191,7 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void)
 	__asm__ __volatile__("mcr p15, 0, %0, c7, c5, 0" : : "r" (0));
 
 	if (IS_ENABLED(CONFIG_IMAGE_COMPRESSION)) {
-		compressed_start = (uint32_t)&input_data - offset;
-		compressed_end = (uint32_t)&input_data_end - offset;
-		len = compressed_end - compressed_start;
-
-		uncompress = barebox_uncompress;
-
-		/* call barebox_uncompress 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");
+		barebox_decompress(offset);
 	} else {
 		/* call start_barebox with its absolute address */
 		r = (unsigned int)&start_barebox;
compressed/misc.c new file +14 -0
new file mode 100644
index 0000000..47e9cea
@@ -0,0 +1,14 @@
+#include <common.h>
+#include <init.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
+
+void __noreturn panic(const char *fmt, ...)
+{
+	while(1);
+}
+
+void start_barebox(void)
+{
+}
compressed/string.c new file +127 -0
new file mode 100644
index 0000000..6787e82
@@ -0,0 +1,127 @@
+/*
+ * arch/arm/boot/compressed/string.c
+ *
+ * Small subset of simple string routines
+ */
+
+#include <linux/types.h>
+
+void *memcpy(void *__dest, __const void *__src, size_t __n)
+{
+	int i = 0;
+	unsigned char *d = (unsigned char *)__dest, *s = (unsigned char *)__src;
+
+	for (i = __n >> 3; i > 0; i--) {
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+	}
+
+	if (__n & 1 << 2) {
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+		*d++ = *s++;
+	}
+
+	if (__n & 1 << 1) {
+		*d++ = *s++;
+		*d++ = *s++;
+	}
+
+	if (__n & 1)
+		*d++ = *s++;
+
+	return __dest;
+}
+
+void *memmove(void *__dest, __const void *__src, size_t count)
+{
+	unsigned char *d = __dest;
+	const unsigned char *s = __src;
+
+	if (__dest == __src)
+		return __dest;
+
+	if (__dest < __src)
+		return memcpy(__dest, __src, count);
+
+	while (count--)
+		d[count] = s[count];
+	return __dest;
+}
+
+size_t strlen(const char *s)
+{
+	const char *sc = s;
+
+	while (*sc != '\0')
+		sc++;
+	return sc - s;
+}
+
+int memcmp(const void *cs, const void *ct, size_t count)
+{
+	const unsigned char *su1 = cs, *su2 = ct, *end = su1 + count;
+	int res = 0;
+
+	while (su1 < end) {
+		res = *su1++ - *su2++;
+		if (res)
+			break;
+	}
+	return res;
+}
+
+int strcmp(const char *cs, const char *ct)
+{
+	unsigned char c1, c2;
+	int res = 0;
+
+	do {
+		c1 = *cs++;
+		c2 = *ct++;
+		res = c1 - c2;
+		if (res)
+			break;
+	} while (c1);
+	return res;
+}
+
+void *memchr(const void *s, int c, size_t count)
+{
+	const unsigned char *p = s;
+
+	while (count--)
+		if ((unsigned char)c == *p++)
+			return (void *)(p - 1);
+	return NULL;
+}
+
+char *strchr(const char *s, int c)
+{
+	while (*s != (char)c)
+		if (*s++ == '\0')
+			return NULL;
+	return (char *)s;
+}
+
+#undef memset
+
+void *memset(void *s, int c, size_t count)
+{
+	char *xs = s;
+	while (count--)
+		*xs++ = c;
+	return s;
+}
+
+void __memzero(void *s, size_t count)
+{
+	memset(s, 0, count);
+}
piggy.lzo.S deleted +0 -6
deleted file mode 100644
index 6cc618d..0000000
@@ -1,6 +0,0 @@
-	.section .piggydata,#alloc
-	.globl  input_data
-input_data:
-	.incbin "barebox-uncompressed.bin.lzo"
-	.globl  input_data_end
-input_data_end:
Signature · 1 line
1.7.10

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

#16 lore raw

PATCH v2 7/7 compressed image: add gzip support

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/arm/compressed/Makefile     |    1 +
 arch/arm/compressed/piggy.gzip.S |    6 ++++++
 arch/arm/cpu/start.c             |    4 ++++
 common/Kconfig                   |    3 +++
 lib/decompress_inflate.c         |    1 +
 5 files changed, 15 insertions(+)
 create mode 100644 arch/arm/compressed/piggy.gzip.S
arch/arm/compressed/Makefile +1 -0
index 627a411..59e7d59 100644
@@ -1,4 +1,5 @@
 
+suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip
 suffix_$(CONFIG_IMAGE_COMPRESSION_LZO)	= lzo
 
 OBJCOPYFLAGS_zbarebox.bin = -O binary
arch/arm/compressed/piggy.gzip.S new file +6 -0
new file mode 100644
index 0000000..ef3dd77
@@ -0,0 +1,6 @@
+	.section .piggydata,#alloc
+	.globl  input_data
+input_data:
+	.incbin "arch/arm/compressed/piggy.gzip"
+	.globl  input_data_end
+input_data_end:
arch/arm/cpu/start.c +4 -0
index 6c745f7..5503552 100644
@@ -110,6 +110,10 @@ extern void *input_data_end;
 #include "../../../lib/decompress_unlzo.c"
 #endif
 
+#ifdef CONFIG_IMAGE_COMPRESSION_GZIP
+#include "../../../../lib/decompress_inflate.c"
+#endif
+
 void barebox_uncompress(void *compressed_start, unsigned int len)
 {
 	void (*barebox)(void);
common/Kconfig +3 -0
index 8437e1c..702a0bd 100644
@@ -110,6 +110,9 @@ choice
 config IMAGE_COMPRESSION_LZO
 	bool "lzo"
 
+config IMAGE_COMPRESSION_GZIP
+	bool "gzip"
+
 endchoice
 
 endif
lib/decompress_inflate.c +1 -0
index 526d6a1..5c1ebb6 100644
@@ -4,6 +4,7 @@
 /* prevent inclusion of _LINUX_KERNEL_H in pre-boot environment: lots
  * errors about console_printk etc... on ARM */
 #define _LINUX_KERNEL_H
+#include <linux/decompress/mm.h>
 
 #include "zlib_inflate/inftrees.c"
 #include "zlib_inflate/inffast.c"
Signature · 7 lines
1.7.10


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