compressed image update
Subsystems (3)
cover compressed image update
Hi,
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-gzip
for you to fetch changes up to 5c808702b4235a39d78042f9ad4f99647c9b8c54:
compressed image: add gzip support (2012-07-22 20:35:48 +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: allow to link only what is needed compressed image: add gzip support
Makefile | 31 +++++++++++++++++++++---------- arch/arm/Makefile | 7 +++++++ arch/arm/cpu/start.c | 20 +++++++++++++++++--- arch/arm/lib/Makefile | 2 +- arch/arm/lib/barebox.lds.S | 2 +- commands/Makefile | 2 +- common/Kconfig | 25 ++++++++++++++++++++++--- compressed/Makefile | 5 +++++ compressed/misc.c | 10 ++++++++++ compressed/string.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/decompress/mm.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/decompress_inflate.c | 1 + lib/decompress_unlzo.c | 1 + piggy.gzip.S | 6 ++++++ 14 files changed, 288 insertions(+), 19 deletions(-) create mode 100644 compressed/Makefile create mode 100644 compressed/misc.c create mode 100644 compressed/string.c create mode 100644 include/linux/decompress/mm.h create mode 100644 piggy.gzip.S
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 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
@@ -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
@@ -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 · 1 line
1.7.10
PATCH 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
@@ -289,3 +289,4 @@ exit_1: exit:return ret; } +#define decompress decompress_unlzo
Signature · 1 line
1.7.10
PATCH 3/7 compressed image: factorise compressor type
In reply to Jean-Christophe PLAGNIOL-VILLARDThis 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 · 1 line
1.7.10
PATCH 4/7 decompressor: import malloc/free implementation for linux 3.4
In reply to Jean-Christophe PLAGNIOL-VILLARDThis 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
@@ -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 · 1 line
1.7.10
PATCH 5/7 ARM: add early malloc support needed by the decompressor
In reply to Jean-Christophe PLAGNIOL-VILLARDThis 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
@@ -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 · 1 line
1.7.10
PATCH 6/7 compressed: allow to link only what is needed
In reply to Jean-Christophe PLAGNIOL-VILLARDToday 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.
The architecture will have to specify the needed file for the link via comp-arch-y.
Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic.
--- Makefile | 16 ++++--- arch/arm/Makefile | 7 +++ compressed/Makefile | 5 ++ compressed/misc.c | 10 ++++ compressed/string.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 compressed/Makefile create mode 100644 compressed/misc.c create mode 100644 compressed/string.c
Makefile +10 -6
@@ -412,6 +412,7 @@ scripts: scripts_basic include/config/auto.conf # Objects we will link into barebox / subdirs we need to visit common-y := common/ drivers/ commands/ lib/ crypto/ net/ fs/ +comp-y := compressed/ ifeq ($(dot-config),1) # Read in config
@@ -474,7 +475,7 @@ CFLAGS += $(call cc-option,-Wno-pointer-sign,) # this default value export KBUILD_IMAGE ?= barebox -barebox-dirs := $(patsubst %/,%,$(filter %/, $(common-y))) +barebox-dirs := $(patsubst %/,%,$(filter %/, $(common-y) $(comp-y))) barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \ $(common-n) $(common-) \
@@ -482,6 +483,8 @@ barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \ $(net-n) $(net-) $(libs-n) $(libs-)))) common-y := $(patsubst %/, %/built-in.o, $(common-y)) +comp-y := $(patsubst %/, %/built-in.o, $(comp-y)) +comp-arch-y := $(patsubst %/, %/built-in.o, $(comp-arch-y)) # Build barebox # ---------------------------------------------------------------------------
@@ -509,8 +512,9 @@ common-y := $(patsubst %/, %/built-in.o, $(common-y)) # # System.map is generated to document addresses of all kernel symbols +barebox-comp := $(comp-y) barebox-common := $(common-y) -barebox-all := $(barebox-common) +barebox-all := $(barebox-common) $(barebox-comp) barebox-lds := $(lds-y) barebox-compressed-lds := $(lds-compressed-y)
@@ -726,11 +730,11 @@ piggy.$(suffix_y).o: barebox-uncompressed.bin.$(suffix_y) $(src)/piggy.$(suffix_ $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c $(src)/piggy.$(suffix_y).S -o $@ ifdef CONFIG_IMAGE_COMPRESSION -barebox: piggy.$(suffix_y).o - @echo " LD " $@ +barebox: piggy.$(suffix_y).o $(barebox-comp) + @echo " LD " $@ $(barebox-comp) $(Q)$(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \ -T $(barebox-compressed-lds) \ - --start-group $(barebox-common) piggy.$(suffix_y).o --end-group + --start-group $(barebox-comp) $(comp-arch-y) piggy.$(suffix_y).o --end-group else barebox: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o) FORCE $(call barebox-modpost)
@@ -743,7 +747,7 @@ barebox.srec: barebox # The actual objects are generated when descending, # make sure no implicit rule kicks in -$(sort $(barebox-head) $(barebox-common) ) $(barebox-lds): $(barebox-dirs) ; +$(sort $(barebox-head) $(barebox-common) $(barebox-comp) ) $(barebox-lds): $(barebox-dirs) ; # Handle descending into subdirectories listed in $(barebox-dirs) # Preset locale variables to speed up the build process. Limit locale
arch/arm/Makefile +7 -0
@@ -207,6 +207,13 @@ endif common-y += $(BOARD) $(MACH) common-y += arch/arm/lib/ arch/arm/cpu/ +# those file will not be recompibled +# we assume they are already compiled +# for the normal barebox +comp-arch-y += arch/arm/lib/lib1funcs.o +comp-arch-y += arch/arm/lib/div0.o +comp-arch-y += arch/arm/cpu/start.o + lds-y := arch/arm/lib/barebox.lds lds-compressed-y := arch/arm/lib/barebox-compressed.lds
compressed/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# only unsed by the decompressor +# +obj-y += misc.o +obj-y += string.o
compressed/misc.c new file +10 -0
@@ -0,0 +1,10 @@ +#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 ); +}
compressed/string.c new file +127 -0
127 lines not on this page · raw message
Signature · 1 line
1.7.10
PATCH 7/7 compressed image: add gzip support
In reply to Jean-Christophe PLAGNIOL-VILLARD--- Makefile | 7 ++++++- arch/arm/cpu/start.c | 4 ++++ common/Kconfig | 3 +++ lib/decompress_inflate.c | 1 + piggy.gzip.S | 6 ++++++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 piggy.gzip.S
Makefile +6 -1
@@ -719,8 +719,13 @@ barebox-uncompressed: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsym barebox-uncompressed.bin: barebox-uncompressed $(call if_changed,objcopy) +suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo +barebox-uncompressed.bin.gzip: barebox-uncompressed.bin + @echo " GZIP " $@ + $(Q)gzip -n -9 -c barebox-uncompressed.bin > $@ + barebox-uncompressed.bin.lzo: barebox-uncompressed.bin @echo " LZO " $@ $(Q)lzop -f -9 -o $@ barebox-uncompressed.bin
@@ -1039,7 +1044,7 @@ CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \ .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 + barebox-uncompressed barebox-uncompressed.bin* # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include2 usr/include
arch/arm/cpu/start.c +4 -0
@@ -109,6 +109,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
@@ -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
@@ -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"
piggy.gzip.S new file +6 -0
@@ -0,0 +1,6 @@ + .section .piggydata,#alloc + .globl input_data +input_data: + .incbin "barebox-uncompressed.bin.gzip" + .globl input_data_end +input_data_end:
Signature · 1 line
1.7.10
PATCH 1/7 stddev: make it selectable via Kconfig
In reply to Jean-Christophe PLAGNIOL-VILLARDHi Jean-Christophe,
Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD
enable is by default for simple and hush
we do not need toNO_SHELLthis allow to save 1KiB
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Wrong list. This series was intended for the Barebox list.
baruch
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -PATCH 1/7 stddev: make it selectable via Kconfig
In reply to Jean-Christophe PLAGNIOL-VILLARDLe Sun, 22 Jul 2012 15:18:56 +0200,
Jean-Christophe PLAGNIOL-VILLARD <[email protected]> a ?crit :
Quoted 10 lines
enable is by default for simple and hush
we do not need toNO_SHELLthis allow to save 1KiB
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- commands/Makefile | 2 +- common/Kconfig | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)
Hum, I guess this should have been sent to the barebox@ mailing list, rather than the linux-arm-kernel@ mailing list, no?
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/7 stddev: make it selectable via Kconfig
Quoted 8 lines · Thomas Petazzoni
Le Sun, 22 Jul 2012 15:18:56 +0200,
Jean-Christophe PLAGNIOL-VILLARD <[email protected]> a ?crit :Quoted 5 lines
enable is by default for simple and hush
we do not need toNO_SHELLthis allow to save 1KiB
Quoted 8 lines
Quoted 5 lines
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- commands/Makefile | 2 +- common/Kconfig | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)Hum, I guess this should have been sent to the barebox@ mailing list, rather than the linux-arm-kernel@ mailing list, no?
yeap I send it to the wrong ml
Best Regards,
PATCH 1/7 stddev: make it selectable via Kconfig
In reply to Jean-Christophe PLAGNIOL-VILLARDenable 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
@@ -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
@@ -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
PATCH 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
@@ -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
PATCH 3/7 compressed image: factorise compressor type
In reply to Jean-Christophe PLAGNIOL-VILLARDThis 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 4/7 decompressor: import malloc/free implementation for linux 3.4
In reply to Jean-Christophe PLAGNIOL-VILLARDThis 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
@@ -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
PATCH 5/7 ARM: add early malloc support needed by the decompressor
In reply to Jean-Christophe PLAGNIOL-VILLARDThis 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
@@ -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
PATCH 6/7 compressed: allow to link only what is needed
In reply to Jean-Christophe PLAGNIOL-VILLARDToday 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.
The architecture will have to specify the needed file for the link via comp-arch-y.
Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic.
--- Makefile | 16 ++++--- arch/arm/Makefile | 7 +++ compressed/Makefile | 5 ++ compressed/misc.c | 10 ++++ compressed/string.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 compressed/Makefile create mode 100644 compressed/misc.c create mode 100644 compressed/string.c
Makefile +10 -6
@@ -412,6 +412,7 @@ scripts: scripts_basic include/config/auto.conf # Objects we will link into barebox / subdirs we need to visit common-y := common/ drivers/ commands/ lib/ crypto/ net/ fs/ +comp-y := compressed/ ifeq ($(dot-config),1) # Read in config
@@ -474,7 +475,7 @@ CFLAGS += $(call cc-option,-Wno-pointer-sign,) # this default value export KBUILD_IMAGE ?= barebox -barebox-dirs := $(patsubst %/,%,$(filter %/, $(common-y))) +barebox-dirs := $(patsubst %/,%,$(filter %/, $(common-y) $(comp-y))) barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \ $(common-n) $(common-) \
@@ -482,6 +483,8 @@ barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \ $(net-n) $(net-) $(libs-n) $(libs-)))) common-y := $(patsubst %/, %/built-in.o, $(common-y)) +comp-y := $(patsubst %/, %/built-in.o, $(comp-y)) +comp-arch-y := $(patsubst %/, %/built-in.o, $(comp-arch-y)) # Build barebox # ---------------------------------------------------------------------------
@@ -509,8 +512,9 @@ common-y := $(patsubst %/, %/built-in.o, $(common-y)) # # System.map is generated to document addresses of all kernel symbols +barebox-comp := $(comp-y) barebox-common := $(common-y) -barebox-all := $(barebox-common) +barebox-all := $(barebox-common) $(barebox-comp) barebox-lds := $(lds-y) barebox-compressed-lds := $(lds-compressed-y)
@@ -726,11 +730,11 @@ piggy.$(suffix_y).o: barebox-uncompressed.bin.$(suffix_y) $(src)/piggy.$(suffix_ $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -c $(src)/piggy.$(suffix_y).S -o $@ ifdef CONFIG_IMAGE_COMPRESSION -barebox: piggy.$(suffix_y).o - @echo " LD " $@ +barebox: piggy.$(suffix_y).o $(barebox-comp) + @echo " LD " $@ $(barebox-comp) $(Q)$(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \ -T $(barebox-compressed-lds) \ - --start-group $(barebox-common) piggy.$(suffix_y).o --end-group + --start-group $(barebox-comp) $(comp-arch-y) piggy.$(suffix_y).o --end-group else barebox: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsyms.o) FORCE $(call barebox-modpost)
@@ -743,7 +747,7 @@ barebox.srec: barebox # The actual objects are generated when descending, # make sure no implicit rule kicks in -$(sort $(barebox-head) $(barebox-common) ) $(barebox-lds): $(barebox-dirs) ; +$(sort $(barebox-head) $(barebox-common) $(barebox-comp) ) $(barebox-lds): $(barebox-dirs) ; # Handle descending into subdirectories listed in $(barebox-dirs) # Preset locale variables to speed up the build process. Limit locale
arch/arm/Makefile +7 -0
@@ -207,6 +207,13 @@ endif common-y += $(BOARD) $(MACH) common-y += arch/arm/lib/ arch/arm/cpu/ +# those file will not be recompibled +# we assume they are already compiled +# for the normal barebox +comp-arch-y += arch/arm/lib/lib1funcs.o +comp-arch-y += arch/arm/lib/div0.o +comp-arch-y += arch/arm/cpu/start.o + lds-y := arch/arm/lib/barebox.lds lds-compressed-y := arch/arm/lib/barebox-compressed.lds
compressed/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# only unsed by the decompressor +# +obj-y += misc.o +obj-y += string.o
compressed/misc.c new file +10 -0
@@ -0,0 +1,10 @@ +#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 ); +}
compressed/string.c new file +127 -0
127 lines not on this page · raw message
Signature · 7 lines
1.7.10 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 7/7 compressed image: add gzip support
In reply to Jean-Christophe PLAGNIOL-VILLARD--- Makefile | 7 ++++++- arch/arm/cpu/start.c | 4 ++++ common/Kconfig | 3 +++ lib/decompress_inflate.c | 1 + piggy.gzip.S | 6 ++++++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 piggy.gzip.S
Makefile +6 -1
@@ -719,8 +719,13 @@ barebox-uncompressed: $(barebox-lds) $(barebox-head) $(barebox-common) $(kallsym barebox-uncompressed.bin: barebox-uncompressed $(call if_changed,objcopy) +suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo +barebox-uncompressed.bin.gzip: barebox-uncompressed.bin + @echo " GZIP " $@ + $(Q)gzip -n -9 -c barebox-uncompressed.bin > $@ + barebox-uncompressed.bin.lzo: barebox-uncompressed.bin @echo " LZO " $@ $(Q)lzop -f -9 -o $@ barebox-uncompressed.bin
@@ -1039,7 +1044,7 @@ CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \ .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 + barebox-uncompressed barebox-uncompressed.bin* # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include2 usr/include
arch/arm/cpu/start.c +4 -0
@@ -109,6 +109,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
@@ -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
@@ -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"
piggy.gzip.S new file +6 -0
@@ -0,0 +1,6 @@ + .section .piggydata,#alloc + .globl input_data +input_data: + .incbin "barebox-uncompressed.bin.gzip" + .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