Add Pre-Bootloader support
Subsystems (6)
v4 cover Add Pre-Bootloader support
Hi,
v4:
integrate Sascha comments
split pbl and barebox start on arm (more easy to review and maintain) optimezed copy of the piggydata only if needed
fix make clean
v3:
drop
ARM: Separate assembler functions into their own section
drop already applied
decompress_unlzo: define decompress_unlzo as decompress
update early malloc to the end of the malloc space
v2:
add custom cppflags to pbl
on arm always the garbage collector
please pull
The following changes since commit 6efca01b82a59f32b016f9cfd46b12e8e632ee92:
eukrea_cpuimx35: fix USB host (2012-08-02 11:01:18 +0200)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git tags/pbl
for you to fetch changes up to 1d861eb2a6384495261122f183842fcd8a8e059e:
arm: always enable the garbage collector for pbl (2012-08-03 18:09:16 +0800)
----------------------------------------------------------------
Add pre-bootloader (pbl) image support
This allows for creating a pre-bootloader binary for
- nand boot
- mmc boot
- compressed image
Currently on the compressed image is implemented the boot really on current lowlevel init support. In a second step this could be move to the pbl c code with generic framework.
The pbl will be incharge of the lowlevel init if needed. The barebox will skip it.
The decompressor support lzo and gzip and allow to add easly more.
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (10):
kbuild: add pre-bootloader (pbl) target
Add pre-bootloader (pbl) image support
pbl: discard unwind symbol if enable in barebox Add compressed image support
decompressor: import malloc/free implementation for linux 3.4
ARM: add early malloc support needed by the decompressor compressed image: add gzip support
at91: add lowlevel init to the pbl
kbuild: allow to have custom cppflags for pbl
arm: always enable the garbage collector for pbl
Sascha Hauer (2):
Makefile.clean: include Makefiles again
ARM pbl: Add .gitignore for generated files
Makefile | 11 ++++- arch/arm/Kconfig | 2 + arch/arm/Makefile | 11 +++++ arch/arm/cpu/Makefile | 3 +- arch/arm/cpu/start-pbl.c | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ arch/arm/cpu/start-reset.c | 67 ++++++++++++++++++++++++++ arch/arm/cpu/start.c | 54 +++++++-------------- arch/arm/lib/Makefile | 4 ++ arch/arm/lib/barebox.lds.S | 3 +- arch/arm/mach-at91/Makefile | 2 + arch/arm/pbl/.gitignore | 5 ++ arch/arm/pbl/Makefile | 40 ++++++++++++++++ arch/arm/pbl/piggy.gzip.S | 6 +++ arch/arm/pbl/piggy.lzo.S | 6 +++ arch/arm/pbl/zbarebox.lds.S | 78 +++++++++++++++++++++++++++++++ common/Kconfig | 44 +++++++++++++++++ include/asm-generic/memory_layout.h | 1 + include/asm-generic/sections.h | 2 + include/linux/decompress/mm.h | 68 +++++++++++++++++++++++++++ lib/decompress_inflate.c | 1 + pbl/Makefile | 5 ++ pbl/misc.c | 14 ++++++ pbl/string.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.build | 48 +++++++++++++++++-- scripts/Makefile.clean | 2 +- scripts/Makefile.lib | 14 ++++++ 26 files changed, 715 insertions(+), 46 deletions(-) create mode 100644 arch/arm/cpu/start-pbl.c create mode 100644 arch/arm/cpu/start-reset.c create mode 100644 arch/arm/pbl/.gitignore create mode 100644 arch/arm/pbl/Makefile create mode 100644 arch/arm/pbl/piggy.gzip.S create mode 100644 arch/arm/pbl/piggy.lzo.S create mode 100644 arch/arm/pbl/zbarebox.lds.S create mode 100644 include/linux/decompress/mm.h create mode 100644 pbl/Makefile create mode 100644 pbl/misc.c create mode 100644 pbl/string.c
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 1/12 Makefile.clean: include Makefiles again
From: Sascha Hauer <[email protected]>
This makes it possible to add architecure specific clean targets again.
--- scripts/Makefile.clean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.clean +1 -1
@@ -14,7 +14,7 @@ clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj # The filename Kbuild has precedence over Makefile kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) -#include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) +include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) # Figure out what we need to build from the various variables # ==========================================================================
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 2/12 kbuild: add pre-bootloader (pbl) target
This will allow to link compiled object to the built-in-pbl.o across the source tree that will be finally link to the pbl.
Now we compile the source %.c in pbl-%.o and provide -D__PBL__ so we can known in the source when it's compile for barebox or the pbl.
--- Makefile | 5 ++++- scripts/Makefile.build | 48 +++++++++++++++++++++++++++++++++++++++++++++--- scripts/Makefile.lib | 14 ++++++++++++++ 3 files changed, 63 insertions(+), 4 deletions(-)
Makefile +4 -1
@@ -481,6 +481,7 @@ barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \ $(core-n) $(core-) $(drivers-n) $(drivers-) \ $(net-n) $(net-) $(libs-n) $(libs-)))) +pbl-common-y := $(patsubst %/, %/built-in-pbl.o, $(common-y)) common-y := $(patsubst %/, %/built-in.o, $(common-y)) # Build barebox
@@ -510,6 +511,8 @@ common-y := $(patsubst %/, %/built-in.o, $(common-y)) # System.map is generated to document addresses of all kernel symbols barebox-common := $(common-y) +barebox-pbl-common := $(pbl-common-y) +export barebox-pbl-common barebox-all := $(barebox-common) barebox-lds := $(lds-y)
@@ -714,7 +717,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-lds) $(barebox-pbl-common): $(barebox-dirs) ; # Handle descending into subdirectories listed in $(barebox-dirs) # Preset locale variables to speed up the build process. Limit locale
scripts/Makefile.build +45 -3
97 lines not on this page · raw message
scripts/Makefile.lib +14 -0
@@ -21,6 +21,17 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) # o if we encounter foo/ in $(obj-m), remove it from $(obj-m) # and add the directory to the list of dirs to descend into: $(subdir-m) +# for non dirs add pbl- prefix to the target +# so we recompile the source with custom flags and custom quiet +__pbl-y := $(notdir $(pbl-y)) +pbl-y := $(patsubst %.o,pbl-%.o,$(__pbl-y)) +# add subdir from $(obj-y) too so we do not need to have the dir define in +# both $(obj-y) and $(pbl-y) +__pbl-y := $(filter-out $(pbl-y), $(filter %/, $(obj-y))) +pbl-y += $(__pbl-y) + +pbl-y := $(sort $(patsubst %/, %/built-in-pbl.o, $(pbl-y))) + __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) subdir-y += $(__subdir-y) __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
@@ -46,7 +57,9 @@ multi-objs := $(multi-objs-y) $(multi-objs-m) # $(subdir-obj-y) is the list of objects in $(obj-y) which do not live # in the local directory +__subdir-obj-y := $(foreach o,$(pbl-y),$(if $(filter-out $(o),$(notdir $(o))),$(o))) subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o))) +subdir-obj-y += $(__subdir-obj-y) # $(obj-dirs) is a list of directories that contain object files obj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
@@ -63,6 +76,7 @@ targets := $(addprefix $(obj)/,$(targets)) obj-y := $(addprefix $(obj)/,$(obj-y)) obj-m := $(addprefix $(obj)/,$(obj-m)) lib-y := $(addprefix $(obj)/,$(lib-y)) +pbl-y := $(addprefix $(obj)/,$(pbl-y)) subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) real-objs-y := $(addprefix $(obj)/,$(real-objs-y)) real-objs-m := $(addprefix $(obj)/,$(real-objs-m))
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 3/12 Add pre-bootloader (pbl) image support
In reply to Jean-Christophe PLAGNIOL-VILLARDThis allows for creating a pre-bootloader binary for
- nand boot
- mmc boot
- compressed image
The pbl will be incharge of the lowlevel init if needed. The barebox will skip it.
Import string functions from linux 3.4 (arch/arm/boot/compressed/string.c) and implement a dummy panic.
For now on introduce dummy zbarebox* targets and c code that will contain later the decompressor. This only implemeted on ARM.
This patch is based on Sascha Hauer <[email protected]> Add compressed image support patch
---
Makefile | 6 +-
arch/arm/Kconfig | 1 +
arch/arm/Makefile | 7 ++
arch/arm/cpu/Makefile | 3 +-
arch/arm/cpu/{start.c => start-pbl.c} | 58 ++-------
arch/arm/cpu/{start.c => start-reset.c} | 49 +-------
arch/arm/cpu/start.c | 54 +++------
arch/arm/lib/Makefile | 4 +
arch/arm/lib/barebox.lds.S | 3 +-
arch/arm/pbl/Makefile | 25 ++++
arch/arm/{lib/barebox.lds.S => pbl/zbarebox.lds.S} | 56 +++------
common/Kconfig | 30 +++++
include/asm-generic/memory_layout.h | 1 +
pbl/Makefile | 5 +
pbl/misc.c | 14 +++
pbl/string.c | 127 ++++++++++++++++++++
16 files changed, 268 insertions(+), 175 deletions(-)
copy arch/arm/cpu/{start.c => start-pbl.c} (64%)
copy arch/arm/cpu/{start.c => start-reset.c} (58%)
create mode 100644 arch/arm/pbl/Makefile
copy arch/arm/{lib/barebox.lds.S => pbl/zbarebox.lds.S} (60%)
create mode 100644 pbl/Makefile
create mode 100644 pbl/misc.c
create mode 100644 pbl/string.cMakefile +5 -1
@@ -474,6 +474,8 @@ CFLAGS += $(call cc-option,-Wno-pointer-sign,) # this default value export KBUILD_IMAGE ?= barebox +common-$(CONFIG_PBL_IMAGE) += pbl/ + barebox-dirs := $(patsubst %/,%,$(filter %/, $(common-y))) barebox-alldirs := $(sort $(barebox-dirs) $(patsubst %/,%,$(filter %/, \
@@ -520,7 +522,7 @@ barebox-lds := $(lds-y) # May be overridden by arch/$(ARCH)/Makefile quiet_cmd_barebox__ ?= LD $@ cmd_barebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_barebox) -o $@ \ - -T $(barebox-lds) $(barebox-head) \ + -T $(barebox-lds) \ --start-group $(barebox-common) --end-group \ $(filter-out $(barebox-lds) $(barebox-common) FORCE ,$^)
@@ -674,7 +676,9 @@ OBJCOPYFLAGS_barebox.bin = -O binary barebox.bin: barebox FORCE $(call if_changed,objcopy) +ifndef CONFIG_PBL_IMAGE $(call cmd,check_file_size,$(CONFIG_BAREBOX_MAX_IMAGE_SIZE)) +endif ifdef CONFIG_X86 barebox.S: barebox
arch/arm/Kconfig +1 -0
@@ -4,6 +4,7 @@ config ARM select HAS_MODULES select HAVE_CONFIGURABLE_MEMORY_LAYOUT select HAVE_CONFIGURABLE_TEXT_BASE + select HAVE_PBL_IMAGE default y config ARM_AMBA
arch/arm/Makefile +7 -0
@@ -197,6 +197,13 @@ ifeq ($(CONFIG_ARCH_DAVINCI),y) KBUILD_IMAGE := barebox.ubl endif +pbl := arch/arm/pbl +zbarebox.S zbarebox.bin zbarebox: barebox.bin + $(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@ + +archclean: + $(MAKE) $(clean)=$(pbl) + all: $(KBUILD_IMAGE) archprepare: maketools
arch/arm/cpu/Makefile +2 -1
@@ -1,7 +1,7 @@ obj-y += cpu.o obj-$(CONFIG_ARM_EXCEPTIONS) += exceptions.o obj-$(CONFIG_ARM_EXCEPTIONS) += interrupts.o -obj-y += start.o +obj-y += start.o start-reset.o # # Any variants can be called as start-armxyz.S
@@ -15,3 +15,4 @@ obj-$(CONFIG_CPU_32v6) += cache-armv6.o obj-$(CONFIG_CPU_32v7) += cache-armv7.o obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o +pbl-y += start-pbl.o start-reset.o
arch/arm/cpu/start-pbl.c renamed from arch/arm/cpu/start.c +13 -45
81 lines not on this page · raw message
arch/arm/cpu/start-reset.c renamed from arch/arm/cpu/start.c +2 -47
65 lines not on this page · raw message
arch/arm/cpu/start.c +16 -38
73 lines not on this page · raw message
arch/arm/lib/Makefile +4 -0
@@ -21,3 +21,7 @@ obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS) += memset.o obj-$(CONFIG_ARM_UNWIND) += unwind.o obj-$(CONFIG_MODULES) += module.o extra-y += barebox.lds + +pbl-y += lib1funcs.o +pbl-y += ashldi3.o +pbl-y += div0.o
arch/arm/lib/barebox.lds.S +2 -1
@@ -31,8 +31,9 @@ SECTIONS { . = TEXT_BASE; +#ifndef CONFIG_PBL_IMAGE PRE_IMAGE - +#endif . = ALIGN(4); .text : {
arch/arm/pbl/Makefile new file +25 -0
@@ -0,0 +1,25 @@ + +OBJCOPYFLAGS_zbarebox.bin = -O binary + +targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S + +$(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) + +LDFLAGS_zbarebox := -Map zbarebox.map +zbarebox-common := $(barebox-pbl-common) +zbarebox-lds := $(obj)/zbarebox.lds + +quiet_cmd_zbarebox__ ?= LD $@ + cmd_zbarebox__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_zbarebox) -o $@ \ + -T $(zbarebox-lds) \ + --start-group $(zbarebox-common) --end-group \ + $(filter-out $(zbarebox-lds) $(zbarebox-common) FORCE ,$^) + +$(obj)/zbarebox: $(zbarebox-lds) $(zbarebox-common) FORCE + $(call if_changed,zbarebox__)
arch/arm/pbl/zbarebox.lds.S renamed from arch/arm/lib/barebox.lds.S +14 -42
96 lines not on this page · raw message
common/Kconfig +30 -0
@@ -101,6 +101,36 @@ config ENVIRONMENT_VARIABLES menu "memory layout " +config HAVE_PBL_IMAGE + bool + +config HAVE_IMAGE_COMPRESSION + bool + +config PBL_IMAGE + bool "Pre-Bootloader image" + depends on HAVE_PBL_IMAGE + +if PBL_IMAGE + +config IMAGE_COMPRESSION + bool "Compressed image" + depends on HAVE_IMAGE_COMPRESSION + +if IMAGE_COMPRESSION + +choice + prompt "Compression" + +config IMAGE_COMPRESSION_LZO + bool "lzo" + +endchoice + +endif + +endif + config MMU bool "Enable MMU" help
include/asm-generic/memory_layout.h +1 -0
@@ -13,6 +13,7 @@#endif +#define HEAD_TEXT_BASE MALLOC_BASE#define MALLOC_SIZE CONFIG_MALLOC_SIZE#define STACK_SIZE CONFIG_STACK_SIZE
pbl/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# only unsed by the pbl +# +pbl-y += misc.o +pbl-y += string.o
pbl/misc.c new file +14 -0
@@ -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 ) +{ +}
pbl/string.c new file +127 -0
127 lines not on this page · raw message
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 4/12 pbl: discard unwind symbol if enable in barebox
In reply to Jean-Christophe PLAGNIOL-VILLARD--- arch/arm/Kconfig | 1 + arch/arm/Makefile | 4 ++++ arch/arm/pbl/Makefile | 16 ++++++++++++++-- arch/arm/pbl/piggy.lzo.S | 6 ++++++ arch/arm/pbl/zbarebox.lds.S | 4 ++++ 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 arch/arm/pbl/piggy.lzo.S
arch/arm/Kconfig +1 -0
@@ -5,6 +5,7 @@ config ARM select HAVE_CONFIGURABLE_MEMORY_LAYOUT select HAVE_CONFIGURABLE_TEXT_BASE select HAVE_PBL_IMAGE + select HAVE_IMAGE_COMPRESSION default y config ARM_AMBA
arch/arm/Makefile +4 -0
@@ -197,6 +197,10 @@ ifeq ($(CONFIG_ARCH_DAVINCI),y) KBUILD_IMAGE := barebox.ubl endif +ifdef CONFIG_IMAGE_COMPRESSION +KBUILD_IMAGE := zbarebox.bin +endif + pbl := arch/arm/pbl zbarebox.S zbarebox.bin zbarebox: barebox.bin $(Q)$(MAKE) $(build)=$(pbl) $(pbl)/$@
arch/arm/pbl/Makefile +14 -2
@@ -1,7 +1,14 @@ +suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo + OBJCOPYFLAGS_zbarebox.bin = -O binary +piggy_o := piggy.$(suffix_y).o + +targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S \ + $(piggy_o) piggy.$(suffix_y) -targets := zbarebox.lds zbarebox zbarebox.bin zbarebox.S +# Make sure files are removed during clean +extra-y += piggy.gzip piggy.lzo piggy.lzma piggy.xzkern $(obj)/zbarebox.bin: $(obj)/zbarebox FORCE $(call if_changed,objcopy)
@@ -12,7 +19,7 @@ $(obj)/zbarebox.S: $(obj)/zbarebox FORCE $(call if_changed,disasm) LDFLAGS_zbarebox := -Map zbarebox.map -zbarebox-common := $(barebox-pbl-common) +zbarebox-common := $(barebox-pbl-common) $(obj)/$(piggy_o) zbarebox-lds := $(obj)/zbarebox.lds quiet_cmd_zbarebox__ ?= LD $@
@@ -23,3 +30,8 @@ quiet_cmd_zbarebox__ ?= LD $@ $(obj)/zbarebox: $(zbarebox-lds) $(zbarebox-common) FORCE $(call if_changed,zbarebox__) + +$(obj)/piggy.$(suffix_y): $(obj)/../../../barebox.bin FORCE + $(call if_changed,$(suffix_y)) + +$(obj)/$(piggy_o): $(obj)/piggy.$(suffix_y) FORCE
arch/arm/pbl/piggy.lzo.S new file +6 -0
@@ -0,0 +1,6 @@ + .section .piggydata,#alloc + .globl input_data +input_data: + .incbin "arch/arm/pbl/piggy.lzo" + .globl input_data_end +input_data_end:
arch/arm/pbl/zbarebox.lds.S +4 -0
@@ -46,6 +46,10 @@ SECTIONS __bare_init_end = .; *(.text*) } + + /* Discard unwind if enable in barebox */ + /DISCARD/ : { *(.ARM.ex*) } + BAREBOX_BARE_INIT_SIZE . = ALIGN(4);
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 5/12 Add compressed image support
In reply to Jean-Christophe PLAGNIOL-VILLARDThis allows for creating a lzo compressed binary unsing the pbl.
Only copy the piggydata if needed.
Add CONFIG_PBL_FORCE_PIGGYDATA_COPY option
In some case we need to copy the PIGGYDATA as the link address as example we run from SRAM and shutdown the SDRAM/DDR for reconfiguration but most of the time we just need to copy the executable code.
based on Sascha Hauer
Add compressed image support
--- arch/arm/cpu/start-pbl.c | 59 +++++++++++++++++++++++++++++++++++++--- arch/arm/pbl/zbarebox.lds.S | 1 + common/Kconfig | 12 +++++++- include/asm-generic/sections.h | 2 ++ 4 files changed, 69 insertions(+), 5 deletions(-)
arch/arm/cpu/start-pbl.c +55 -4
@@ -33,8 +33,33 @@ void __naked __section(.text_head_entry) pbl_start(void)barebox_arm_head (); } -void barebox_pbl (uint32_t offset) +extern void *input_data; +extern void *input_data_end; + +#define STATIC static + +#ifdef CONFIG_IMAGE_COMPRESSION_LZO +#include "../../../lib/decompress_unlzo.c" +#endif + +static void barebox_uncompress (void *compressed_start,unsigned int len) { +void (*barebox)(void ); + +if (IS_ENABLED (CONFIG_THUMB2_BAREBOX )) + barebox = (void *)(TEXT_BASE +1 ); +else + barebox = (void *)TEXT_BASE ; + +decompress ((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 (); }/*
@@ -44,6 +69,7 @@ void barebox_pbl(uint32_t offset) void __naked __section(.text_ll_return) board_init_lowlevel_return(void) {uint32_t r, addr, offset; +uint32_t pg_start, pg_end, pg_len;/* * Get runtime address of this function. Do not
@@ -58,6 +84,30 @@ void __naked __section(.text_ll_return) board_init_lowlevel_return(void)/* Get offset between linked address and runtime address */ offset = (uint32_t )__ll_return - addr; + pg_start = (uint32_t )&input_data - offset; + pg_end = (uint32_t )&input_data_end - offset; + pg_len = pg_end - pg_start; + +if (IS_ENABLED (CONFIG_PBL_FORCE_PIGGYDATA_COPY )) + goto copy_piggy_link; + +/* +* Check if the piggydata binary will be overwritten +* by the uncompressed binary or by the pbl relocation +*/ +if (!offset || + !((pg_start >=TEXT_BASE && pg_start <TEXT_BASE + pg_len *4 ) || + ((uint32_t )_text >= pg_start && (uint32_t )_text <= pg_end))) + goto copy_link; + +copy_piggy_link: +/* +* copy piggydata binary to its link address +*/ +memcpy (&input_data, (void *)pg_start, pg_len); + pg_start = (uint32_t )&input_data; + +copy_link:/* relocate to link address if necessary */ if (offset) memcpy((void *)_text, (void *)(_text - offset),
@@ -69,12 +119,13 @@ 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 )); - r = (unsigned int )&barebox_pbl; + r = (unsigned int )&barebox_uncompress;/* call barebox_uncompress with its absolute address */ __asm__ __volatile__("mov r0, %1\n" +"mov r1, %2\n" "mov pc, %0\n" : - : "r"(r), "r"(offset), - :"r0" ); + :"r" (r),"r" (pg_start),"r" (pg_len) + :"r0" ,"r1" ); }
arch/arm/pbl/zbarebox.lds.S +1 -0
@@ -74,4 +74,5 @@ SECTIONS __piggydata_end = .; _barebox_image_size = __piggydata_end - HEAD_TEXT_BASE; + _barebox_pbl_size = __bss_start - HEAD_TEXT_BASE; }
common/Kconfig +11 -1
@@ -111,11 +111,20 @@ config PBL_IMAGE bool "Pre-Bootloader image" depends on HAVE_PBL_IMAGE +config PBL_FORCE_PIGGYDATA_COPY + bool + help + In some case we need to copy the PIGGYDATA as the link address + as example we run from SRAM and shutdown the SDRAM/DDR for + reconfiguration but most of the time we just need to copy the + executable code. + if PBL_IMAGE config IMAGE_COMPRESSION - bool "Compressed image" + bool depends on HAVE_IMAGE_COMPRESSION + default y if IMAGE_COMPRESSION
@@ -511,6 +520,7 @@ config DEFAULT_ENVIRONMENT config DEFAULT_ENVIRONMENT_COMPRESSED bool depends on DEFAULT_ENVIRONMENT + depends on !IMAGE_COMPRESSION_LZO default y if ZLIB default y if BZLIB default y if LZO_DECOMPRESS
include/asm-generic/sections.h +2 -0
@@ -7,8 +7,10 @@ extern char __bare_init_start[], __bare_init_end[];extern char _end[];extern void *_barebox_image_size;extern void *_barebox_bare_init_size; +extern void *_barebox_pbl_size;#define barebox_image_size (unsigned int)&_barebox_image_size#define barebox_bare_init_size (unsigned int)&_barebox_bare_init_size +#define barebox_pbl_size (unsigned int)&_barebox_pbl_size#endif /* _ASM_GENERIC_SECTIONS_H_ */
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 6/12 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.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 7/12 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-pbl.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/cpu/start-pbl.c +8 -0
@@ -23,11 +23,15 @@#include <common.h> #include <init.h> +#include <sizes.h> #include <asm/barebox-arm.h> #include <asm/barebox-arm-head.h> #include <asm-generic/memory_layout.h> #include <asm/sections.h> +unsigned long free_mem_ptr; +unsigned long free_mem_end_ptr; + void __naked __section(.text_head_entry) pbl_start(void) {barebox_arm_head ();
@@ -46,6 +50,10 @@ static void barebox_uncompress(void *compressed_start, unsigned int len) {void (*barebox)(void ); +/* set 128 KiB at the end of the MALLOC_BASE for early malloc */ + free_mem_ptr =MALLOC_BASE +MALLOC_SIZE -SZ_128K ; + free_mem_end_ptr = free_mem_ptr +SZ_128K ; +if (IS_ENABLED (CONFIG_THUMB2_BAREBOX )) barebox = (void *)(TEXT_BASE +1 );else
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 8/12 compressed image: add gzip support
In reply to Jean-Christophe PLAGNIOL-VILLARD--- arch/arm/cpu/start-pbl.c | 4 ++++ arch/arm/pbl/Makefile | 1 + arch/arm/pbl/piggy.gzip.S | 6 ++++++ common/Kconfig | 4 ++++ lib/decompress_inflate.c | 1 + 5 files changed, 16 insertions(+) create mode 100644 arch/arm/pbl/piggy.gzip.S
arch/arm/cpu/start-pbl.c +4 -0
@@ -46,6 +46,10 @@ extern void *input_data_end;#include "../../../lib/decompress_unlzo.c" #endif +#ifdef CONFIG_IMAGE_COMPRESSION_GZIP +#include "../../../../lib/decompress_inflate.c" +#endif +static void barebox_uncompress (void *compressed_start,unsigned int len) {void (*barebox)(void );
arch/arm/pbl/Makefile +1 -0
@@ -1,4 +1,5 @@ +suffix_$(CONFIG_IMAGE_COMPRESSION_GZIP) = gzip suffix_$(CONFIG_IMAGE_COMPRESSION_LZO) = lzo OBJCOPYFLAGS_zbarebox.bin = -O binary
arch/arm/pbl/piggy.gzip.S new file +6 -0
@@ -0,0 +1,6 @@ + .section .piggydata,#alloc + .globl input_data +input_data: + .incbin "arch/arm/pbl/piggy.gzip" + .globl input_data_end +input_data_end:
common/Kconfig +4 -0
@@ -134,6 +134,9 @@ choice config IMAGE_COMPRESSION_LZO bool "lzo" +config IMAGE_COMPRESSION_GZIP + bool "gzip" + endchoice endif
@@ -521,6 +524,7 @@ config DEFAULT_ENVIRONMENT_COMPRESSED bool depends on DEFAULT_ENVIRONMENT depends on !IMAGE_COMPRESSION_LZO + depends on !IMAGE_COMPRESSION_GZIP default y if ZLIB default y if BZLIB default y if LZO_DECOMPRESS
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"
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 9/12 ARM pbl: Add .gitignore for generated files
In reply to Jean-Christophe PLAGNIOL-VILLARDFrom: Sascha Hauer <[email protected]>
--- arch/arm/pbl/.gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 arch/arm/pbl/.gitignore
arch/arm/pbl/.gitignore new file +5 -0
@@ -0,0 +1,5 @@ +piggy.gzip +piggy.lzo +zbarebox +zbarebox.bin +zbarebox.lds
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 10/12 at91: add lowlevel init to the pbl
In reply to Jean-Christophe PLAGNIOL-VILLARD--- arch/arm/mach-at91/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-at91/Makefile +2 -0
@@ -4,6 +4,8 @@ lowlevel_init-y = at91sam926x_lowlevel_init.o lowlevel_init-$(CONFIG_ARCH_AT91RM9200) = at91rm9200_lowlevel_init.o obj-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += $(lowlevel_init-y) +pbl-$(CONFIG_MACH_DO_LOWLEVEL_INIT) += $(lowlevel_init-y) + obj-$(CONFIG_AT91SAM9_RESET) += at91sam9_reset.o obj-$(CONFIG_AT91SAM9G45_RESET) += at91sam9g45_reset.o
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 11/12 kbuild: allow to have custom cppflags for pbl
In reply to Jean-Christophe PLAGNIOL-VILLARD--- scripts/Makefile.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.build +2 -2
@@ -188,7 +188,7 @@ quiet_cmd_pbl_cc_o_c = PBLCC $@ ifndef CONFIG_MODVERSIONS cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< -cmd_pbl_cc_o_c = $(CC) -D__PBL__ $(c_flags) -c -o $@ $< +cmd_pbl_cc_o_c = $(CC) -D__PBL__ $(c_flags) $(PBL_CPPFLAGS) -c -o $@ $< else # When module versioning is enabled the following steps are executed:
@@ -282,7 +282,7 @@ quiet_cmd_as_o_S = AS $(quiet_modtag) $@ cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< quiet_cmd_pbl_as_o_S = PBLAS $@ -cmd_pbl_as_o_S = $(CC) -D__PBL__ $(a_flags) -c -o $@ $< +cmd_pbl_as_o_S = $(CC) -D__PBL__ $(a_flags) $(PBL_CPPFLAGS) -c -o $@ $< pbl-%.o: %.S $(call if_changed_dep,pbl_as_o_S)
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v4 12/12 arm: always enable the garbage collector for pbl
In reply to Jean-Christophe PLAGNIOL-VILLARDThis allow to save arround 1KiB on at91
--- arch/arm/pbl/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/pbl/Makefile +2 -0
@@ -19,7 +19,9 @@ $(obj)/zbarebox.bin: $(obj)/zbarebox FORCE $(obj)/zbarebox.S: $(obj)/zbarebox FORCE $(call if_changed,disasm) +PBL_CPPFLAGS += -fdata-sections -ffunction-sections LDFLAGS_zbarebox := -Map zbarebox.map +LDFLAGS_zbarebox += -static --gc-sections zbarebox-common := $(barebox-pbl-common) $(obj)/$(piggy_o) zbarebox-lds := $(obj)/zbarebox.lds
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 8 lines · Jean-Christophe PLAGNIOL-VILLARD
are available in the git repository at:
git://git.jcrosoft.org/barebox.gittags/pblfor you to fetch changes up to
1d861eb2a6384495261122f183842fcd8a8e059e:arm: always enable the garbage collector for pbl (2012-08-03 18:09:16 +0800)
I applied this series for next. This is not complete yet, so before this series hits any release, the following should happen:
- Currently most boards do not compile with compression enabled. This is because the pbl needs the lowlevel init functions. Most boards fail with 'undefined reference to board_init_lowlevel'. To fix this a pbl-y += lowlevel.o is needed.
Unfortunately there is a class of boards which silently fail with image compression, namely all i.MX boards which compile with internal boot mode. Here the flash header is just missing when not explicitly enabled for pbl.
- The SoCs which generate some SoC specific image (OMAP -> MLO, Netx -> barebox.netx) only generate the compressed binary, but not the SoC specific file.
- Documentation to be written.
I have a patch in preparation to fix the first two topics.
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