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))
#########################################################################
# 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)
$(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
@$(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
@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 '*~' \
@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))
.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
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
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
/* 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
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
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
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
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)
/*
*************************************************************************
*
bl do_fiq
#endif
-#endif /* CONFIG_ONENAND_IPL */
+#endif /* CONFIG_ONENAND_IPL || CONFIG_RECOVERY_BLOCK */
--- /dev/null
+#
+# Samsung Universal(S5PC110) board Recovery block
+#
+# Copyright (C) 2010 Samsung Electronics
+# Minkyu Kang <mk7.kang@samsung.com>
+# Kyungmin Park <kyungmin.park@samsung.com>
+#
+# 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
+
--- /dev/null
+/*
+ * (C) Copyright 2005-2008 Samsung Electronics
+ * Kyungmin Park <kyungmin.park@samsung.com>
+ *
+ * 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 = .;
+}
--- /dev/null
+/*
+ * (C) Copyright 2010 Samsung Electronics
+ * Minkyu Kang <mk7.kang@samsung.com>
+ *
+ * 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 <common.h>
+#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 */
+}