From: Minkyu Kang Date: Thu, 8 Apr 2010 12:30:47 +0000 (+0900) Subject: recovery: initial commit (DON'T USE IT!!) X-Git-Tag: JD06_20100409~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f3779837652f56e6ccbc50277fb315e6a00c0b4a;p=kernel%2Fu-boot.git recovery: initial commit (DON'T USE IT!!) Signed-off-by: Minkyu Kang --- diff --git a/Makefile b/Makefile index 0937a24..79a9ff3 100644 --- a/Makefile +++ b/Makefile @@ -286,6 +286,12 @@ U_BOOT_ONENAND = $(obj)u-boot-onenand.bin ONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin endif +ifeq ($(CONFIG_RECOVERY_U_BOOT),y) +RECOVERY_BLOCK = recovery +U_BOOT_RECOVERY = $(obj)u-boot-recovery.bin +RECOVERY_BIN ?= $(obj)recovery/recovery.bin +endif + __OBJS := $(subst $(obj),,$(OBJS)) __LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD)) @@ -293,7 +299,7 @@ __LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD)) ######################################################################### # Always append ALL so that arch config.mk's can add custom ones -ALL += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND) $(U_BOOT_ONENAND) +ALL += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(U_BOOT_NAND) $(U_BOOT_ONENAND) $(U_BOOT_RECOVERY) all: $(ALL) @@ -383,6 +389,12 @@ $(ONENAND_IPL): $(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk $(U_BOOT_ONENAND): $(ONENAND_IPL) $(obj)u-boot.bin cat $(ONENAND_BIN) $(obj)u-boot.bin > $(obj)u-boot-onenand.bin +$(RECOVERY_BLOCK): $(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk + $(MAKE) -C recovery/board/$(BOARDDIR) all + +$(U_BOOT_RECOVERY): $(RECOVERY_BLOCK) $(ONENAND_IPL) + cat $(RECOVERY_BIN) $(obj)u-boot.bin > $(obj)u-boot-recovery.bin + $(VERSION_FILE): @( printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' "$(U_BOOT_VERSION)" \ '$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ) > $@.tmp @@ -3179,6 +3191,7 @@ s5pc1xx_universal_config: unconfig @$(MKCONFIG) $(@:_config=) arm arm_cortexa8 universal samsung s5pc1xx @echo "CONFIG_ONENAND_U_BOOT = y" >> $(obj)include/config.mk @echo "ONENAND_BIN = $(obj)onenand_ipl/onenand-ipl-16k.bin" >> $(obj)include/config.mk + @echo "CONFIG_RECOVERY_U_BOOT = y" >> $(obj)include/config.mk s5pc1xx_p1p2_config: unconfig @echo "#define CONFIG_ONENAND_U_BOOT" > $(obj)include/config.h @@ -3767,6 +3780,7 @@ clean: @rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl.map} @rm -f $(ONENAND_BIN) @rm -f $(obj)onenand_ipl/u-boot.lds + @rm -f $(obj)recovery/{recovery,recovery.map} @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE) @find $(OBJTREE) -type f \ \( -name 'core' -o -name '*.bak' -o -name '*~' \ @@ -3788,6 +3802,7 @@ clobber: clean @rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm @[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f @[ ! -d $(obj)onenand_ipl ] || find $(obj)onenand_ipl -name "*" -type l -print | xargs rm -f + @[ ! -d $(obj)recovery ] || find $(obj)recovery -name "*" -type l -print | xargs rm -f @[ ! -d $(obj)api_examples ] || find $(obj)api_examples -name "*" -type l -print | xargs rm -f ifeq ($(OBJTREE),$(SRCTREE)) diff --git a/cpu/arm_cortexa8/start.S b/cpu/arm_cortexa8/start.S index 59b259e..ce4f5db 100644 --- a/cpu/arm_cortexa8/start.S +++ b/cpu/arm_cortexa8/start.S @@ -34,7 +34,7 @@ .globl _start _start: b reset -#if !defined(CONFIG_ONENAND_IPL) +#if !defined(CONFIG_ONENAND_IPL) && !defined(CONFIG_RECOVERY_BLOCK) ldr pc, _undefined_instruction ldr pc, _software_interrupt ldr pc, _prefetch_abort @@ -112,7 +112,7 @@ reset: orr r0, r0, #0xd3 msr cpsr,r0 -#if !defined(CONFIG_ONENAND_IPL) +#if !defined(CONFIG_ONENAND_IPL) && !defined(CONFIG_RECOVERY_BLOCK) #if (CONFIG_OMAP34XX) /* Copy vectors to mask ROM indirect addr */ adr r0, _start @ r0 <- current position of code @@ -136,13 +136,13 @@ next: bl cpy_clk_code @ put dpll adjust code behind vectors #endif /* NAND Boot */ #endif -#endif /* CONFIG_ONENAND_IPL */ +#endif /* CONFIG_ONENAND_IPL || CONFIG_RECOVERY_BLOCK */ /* the mask ROM code should have PLL and others stable */ #ifndef CONFIG_SKIP_LOWLEVEL_INIT bl cpu_init_crit #endif -#if !defined(CONFIG_SKIP_RELOCATE_UBOOT) || !defined(CONFIG_ONENAND_IPL) +#if !defined(CONFIG_SKIP_RELOCATE_UBOOT) || !defined(CONFIG_ONENAND_IPL) || !defined(CONFIG_RECOVERY_BLOCK) relocate: @ relocate U-Boot to RAM adr r0, _start @ r0 <- current position of code ldr r1, _TEXT_BASE @ test if we run from flash or RAM @@ -164,7 +164,7 @@ copy_loop: @ copy 32 bytes at a time /* Set up the stack */ stack_setup: ldr r0, _TEXT_BASE @ upper 128 KiB: relocated uboot -#if defined(CONFIG_ONENAND_IPL) +#if defined(CONFIG_ONENAND_IPL) && defined(CONFIG_RECOVERY_BLOCK) sub sp, r0, #128 @ leave 32 words for abort-stack #else sub r0, r0, #CONFIG_SYS_MALLOC_LEN @ malloc area @@ -173,10 +173,10 @@ stack_setup: sub r0, r0, #(CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ) #endif sub sp, r0, #12 @ leave 3 words for abort-stack -#endif /* CONFIG_ONENAND_IPL */ +#endif /* CONFIG_ONENAND_IPL || CONFIG_RECOVERY_BLOCK */ and sp, sp, #~7 @ 8 byte alinged for (ldr/str)d -#if !defined(CONFIG_ONENAND_IPL) +#if !defined(CONFIG_ONENAND_IPL) && !defined(CONFIG_RECOVERY_BLOCK) /* Clear BSS (if any). Is below tx (watch load addr - need space) */ clear_bss: ldr r0, _bss_start @ find start of bss segment @@ -187,12 +187,14 @@ clbss_l: cmp r0, r1 @ are we at the end yet add r0, r0, #4 @ increment clear index pointer bne clbss_l @ keep clearing till at end -#endif /* CONFIG_ONENAND_IPL */ +#endif /* CONFIG_ONENAND_IPL || CONFIG_RECOVERY_BLOCK */ ldr pc, _start_armboot @ jump to C code #if defined(CONFIG_ONENAND_IPL) _start_armboot: .word start_oneboot +#elif defined(CONFIG_RECOVERY_BLOCK) +_start_armboot: .word start_recovery_boot #else _start_armboot: .word start_armboot #endif @@ -224,6 +226,7 @@ cpu_init_crit: orr r0, r0, #0x00000800 @ set bit 12 (Z---) BTB mcr p15, 0, r0, c1, c0, 0 +#if !defined(CONFIG_RECOVERY_BLOCK) /* * Jump to board specific initialization... * The Mask ROM will have already initialized @@ -234,8 +237,9 @@ cpu_init_crit: bl lowlevel_init @ go setup pll,mux,memory mov lr, ip @ restore link mov pc, lr @ back to my caller +#endif -#if !defined(CONFIG_ONENAND_IPL) +#if !defined(CONFIG_ONENAND_IPL) && !defined(CONFIG_RECOVERY_BLOCK) /* ************************************************************************* * @@ -432,4 +436,4 @@ fiq: bl do_fiq #endif -#endif /* CONFIG_ONENAND_IPL */ +#endif /* CONFIG_ONENAND_IPL || CONFIG_RECOVERY_BLOCK */ diff --git a/recovery/board/samsung/universal/Makefile b/recovery/board/samsung/universal/Makefile new file mode 100644 index 0000000..42e7b32 --- /dev/null +++ b/recovery/board/samsung/universal/Makefile @@ -0,0 +1,93 @@ +# +# Samsung Universal(S5PC110) board Recovery block +# +# Copyright (C) 2010 Samsung Electronics +# Minkyu Kang +# Kyungmin Park +# +# 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. +# + +include $(TOPDIR)/config.mk + +TEXT_BASE = 0xD0020000 +TEXT_BASE_128K = 0xD003C000 +TEXT_BASE_256K = 0xD005C000 + +LDSCRIPT= $(TOPDIR)/recovery/board/$(BOARDDIR)/recovery.lds +LDFLAGS = -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS) +AFLAGS += -DCONFIG_RECOVERY_BLOCK -g -UTEXT_BASE -DTEXT_BASE=$(TEXT_BASE) +CFLAGS += -DCONFIG_RECOVERY_BLOCK -g -D__HAVE_ARCH_MEMCPY32 +OBJCFLAGS += --gap-fill=0x00 + +SOBJS += start.o _memcpy32.o +COBJS += recovery.o onenand_read.o + +SRCS := $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c)) +OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) +__OBJS := $(SOBJS) $(COBJS) +LNDIR := $(OBJTREE)/recovery/board/$(BOARDDIR) + +recoveryobj := $(OBJTREE)/recovery/ + +ALL = $(recoveryobj)recovery $(recoveryobj)recovery.bin $(recoveryobj)recovery-256k.bin + +all: $(obj).depend $(ALL) + +$(recoveryobj)recovery-256k.bin: $(recoveryobj)recovery + $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(TEXT_BASE_256K) -O binary $< $@ + cat $(OBJTREE)/onenand_ipl/onenand-ipl-16k-evt0.bin $@ > $(recoveryobj)recovery-evt0.bin + cat $(OBJTREE)/onenand_ipl/onenand-ipl-16k-fused.bin $@ > $(recoveryobj)recovery-fused.bin + cat $(OBJTREE)/onenand_ipl/onenand-ipl-16k.bin $@ > $(recoveryobj)recovery.bin + +$(recoveryobj)recovery.bin: $(recoveryobj)recovery + $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ + +$(recoveryobj)recovery: $(OBJS) + cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \ + -Map $@.map -o $@ + +# create symbolic links from common files + +# from cpu directory +$(obj)start.S: + @rm -f $@ + ln -s $(SRCTREE)/cpu/$(CPU)/start.S $@ + +# from SoC directory + +# from lib_arm +$(obj)_memcpy32.S: + ln -sf $(SRCTREE)/lib_arm/_memcpy32.S $@ + +# from recovery directory +$(obj)recovery.c: + @rm -f $@ + ln -s $(SRCTREE)/recovery/recovery.c $@ + +# from onenand_ipl directory +$(obj)onenand_ipl.h: + @rm -f $@ + ln -s $(SRCTREE)/onenand_ipl/onenand_ipl.h $@ + +$(obj)onenand_read.c: $(obj)onenand_ipl.h + @rm -f $@ + ln -s $(SRCTREE)/onenand_ipl/onenand_read.c $@ + +$(obj)%.o: $(obj)%.S + $(CC) $(AFLAGS) -c -o $@ $< + +$(obj)%.o: $(obj)$.c + $(CC) $(CFLAGS) -c -o $@ $< + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +clean: + rm recovery.c onenand_read.c + diff --git a/recovery/board/samsung/universal/recovery.lds b/recovery/board/samsung/universal/recovery.lds new file mode 100644 index 0000000..559f9f2 --- /dev/null +++ b/recovery/board/samsung/universal/recovery.lds @@ -0,0 +1,53 @@ +/* + * (C) Copyright 2005-2008 Samsung Electronics + * Kyungmin Park + * + * Derived from X-loader + * + * 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 + */ + +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) +SECTIONS +{ + . = 0x00000000; + + . = ALIGN(4); + .text : + { + start.o (.text) + *(.text) + } + + . = ALIGN(4); + .rodata : { *(.rodata) } + + . = ALIGN(4); + .data : { *(.data) } + + . = ALIGN(4); + .got : { *(.got) } + + . = ALIGN(4); + __bss_start = .; + .bss : { *(.bss) } + _end = .; +} diff --git a/recovery/recovery.c b/recovery/recovery.c new file mode 100644 index 0000000..a5a6784 --- /dev/null +++ b/recovery/recovery.c @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2010 Samsung Electronics + * Minkyu Kang + * + * 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 +#include "onenand_ipl.h" + +typedef int (init_fnc_t)(void); + +void start_recovery_boot(void) +{ + uchar *buf; + + buf = (uchar *)CONFIG_SYS_LOAD_ADDR; + + onenand_read_block(buf); + + ((init_fnc_t *)CONFIG_SYS_LOAD_ADDR)(); + + /* should never come here */ +}