recovery: code trimming
authorSangHee Kim <sh0130.kim@samsung.com>
Fri, 23 Apr 2010 05:32:15 +0000 (14:32 +0900)
committerSangHee Kim <sh0130.kim@samsung.com>
Fri, 23 Apr 2010 05:32:15 +0000 (14:32 +0900)
all configs are merged to '$(RECOVERY_BLOCK)\config.mk'

Makefile
recovery/Makefile
recovery/board/samsung/universal/Makefile
recovery/board/samsung/universal/config.mk
recovery/config.mk [new file with mode: 0644]
recovery/drivers/onenand/Makefile
recovery/drivers/usb/Makefile

index 3a0bed5..dde48b2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -290,6 +290,7 @@ ifeq ($(CONFIG_RECOVERY_U_BOOT),y)
 RECOVERY_BLOCK = recovery
 U_BOOT_RECOVERY = $(obj)u-boot-recovery.bin
 RECOVERY_BIN ?= $(obj)recovery/recovery.bin
+export RECOVERY_BLOCK
 endif
 
 __OBJS := $(subst $(obj),,$(OBJS))
@@ -390,7 +391,7 @@ $(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 $(ONENAND_IPL)
-               $(MAKE) -C recovery/ all
+               $(MAKE) -C recovery all
 
 $(U_BOOT_RECOVERY):    $(RECOVERY_BLOCK) $(obj)u-boot.bin
                cat $(RECOVERY_BIN) $(obj)u-boot.bin > $(obj)u-boot-recovery.bin
index 4c813dd..b929a24 100644 (file)
 # the License, or (at your option) any later version.
 #
 
-include $(TOPDIR)/config.mk
+include $(TOPDIR)/$(RECOVERY_BLOCK)/config.mk
 
-recoveryobj := $(OBJTREE)/recovery/
-RECOVERYCFG := $(recoveryobj)board/$(BOARDDIR)/config.mk
-include $(RECOVERYCFG)
+recoveryobj := $(SRCTREE)/$(RECOVERY_BLOCK)/
 
-LDSCRIPT = board/$(BOARDDIR)/recovery.lds
-LDSCRIPT := $(addprefix $(recoveryobj),$(LDSCRIPT))
-LDFLAGS        = -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS)
-OBJCFLAGS += --gap-fill=0x00
+# Recovery block' size should be 1 block (256K)
+# Recovery block includes the onenand_ipl(16K), so actual size is 240K
+# 256K - 16K(IPL Size)
+TEXT_BASE_256K         = 0x3403C000
 
 OBJS = recovery.o
 OBJS += onenand.o
@@ -55,7 +53,7 @@ $(recoveryobj)recovery-256k.bin:      $(recoveryobj)recovery
        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:        $(obj).depend $(OBJS) $(LIBS) $(LIBBOARD) $(RECOVERYCFG)
+$(recoveryobj)recovery:        $(obj).depend $(OBJS) $(LIBS) $(LIBBOARD)
        $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
                --start-group $(__LIBS) --end-group $(PLATFORM_LIBGCC) \
                -Map $@.map -o $@
index dde6ad0..5789bdb 100644 (file)
 # the License, or (at your option) any later version.
 #
 
-include $(TOPDIR)/config.mk
-
-RECOVERYCFG = config.mk
-include $(RECOVERYCFG)
+include $(TOPDIR)/recovery/config.mk
 
 LIB    := $(obj)lib$(BOARD).a
 
@@ -28,7 +25,7 @@ OBJS := $(addprefix $(obj),$(COBJS))
 
 all:   $(LIB)
 
-$(LIB):        $(obj).depend $(SOBJS) $(OBJS) $(RECOVERYCFG)
+$(LIB):        $(obj).depend $(SOBJS) $(OBJS)
        $(AR) $(ARFLAGS) $@ $(SOBJS) $(OBJS)
 
 # create symbolic links from common files
@@ -52,17 +49,8 @@ $(obj)dlmalloc.c:
        @rm -f $@
        ln -s $(SRCTREE)/common/$@ $@
 
-clean:
-       @rm -rf ../../../$(BOARDHEADER)
-
 #########################################################################
 
-$(obj)%.o:     $(obj)%.S
-       $(CC) $(AFLAGS) -c -o $@ $<
-
-$(obj)%.o:     $(obj)$.c
-       $(CC) $(CFLAGS) -c -o $@ $<
-
 include $(SRCTREE)/rules.mk
 
 sinclude $(obj).depend
index 4127423..a75e97c 100644 (file)
@@ -1,13 +1,12 @@
 #
-# Copyright (C) 2010 # Samsung Elecgtronics
+# Copyright (C) 2010 Samsung Electronics
+# Minkyu Kang <mk7.kang@samsung.com>
+# Kyungmin Park <kyungmin.park@samsung.com>
 #
 
-# Recovery block' size should be 1 block (256K)
-# Recovery block includes the onenand_ipl(16K), so actual size is 240K
-TEXT_BASE      = 0x34000000
-# 256K - 16K(IPL Size)
-TEXT_BASE_256K         = 0x3403C000
-
-AFLAGS += -DCONFIG_RECOVERY_BLOCK -g -UTEXT_BASE -DTEXT_BASE=$(TEXT_BASE)
-CFLAGS += -DCONFIG_RECOVERY_BLOCK -g -D__HAVE_ARCH_MEMCPY32
-
+# On S5PC110 we use the 336 MiB OneDRAM bank at
+#
+# 0x30000000 to 0x35000000 (80MiB)
+# 0x40000000 to 0x50000000 (256MiB)
+#
+TEXT_BASE = 0x34000000
diff --git a/recovery/config.mk b/recovery/config.mk
new file mode 100644 (file)
index 0000000..9019aa1
--- /dev/null
@@ -0,0 +1,273 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# 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
+#
+
+#########################################################################
+
+ifneq ($(OBJTREE),$(SRCTREE))
+ifeq ($(CURDIR),$(SRCTREE))
+dir :=
+else
+dir := $(subst $(SRCTREE)/,,$(CURDIR))
+endif
+
+obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
+src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
+
+$(shell mkdir -p $(obj))
+else
+obj :=
+src :=
+endif
+
+# clean the slate ...
+PLATFORM_RELFLAGS =
+PLATFORM_CPPFLAGS =
+PLATFORM_LDFLAGS =
+
+#########################################################################
+
+HOSTCFLAGS     = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
+                 $(HOSTCPPFLAGS)
+HOSTSTRIP      = strip
+
+#
+# Mac OS X / Darwin's C preprocessor is Apple specific.  It
+# generates numerous errors and warnings.  We want to bypass it
+# and use GNU C's cpp.  To do this we pass the -traditional-cpp
+# option to the compiler.  Note that the -traditional-cpp flag
+# DOES NOT have the same semantics as GNU C's flag, all it does
+# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
+#
+# Apple's linker is similar, thanks to the new 2 stage linking
+# multiple symbol definitions are treated as errors, hence the
+# -multiply_defined suppress option to turn off this error.
+#
+
+ifeq ($(HOSTOS),darwin)
+HOSTCC         = cc
+HOSTCFLAGS     += -traditional-cpp
+HOSTLDFLAGS    += -multiply_defined suppress
+else
+HOSTCC         = gcc
+endif
+
+ifeq ($(HOSTOS),cygwin)
+HOSTCFLAGS     += -ansi
+endif
+
+# We build some files with extra pedantic flags to try to minimize things
+# that won't build on some weird host compiler -- though there are lots of
+# exceptions for files that aren't complaint.
+
+HOSTCFLAGS_NOPED = $(filter-out -pedantic,$(HOSTCFLAGS))
+HOSTCFLAGS     += -pedantic
+
+#########################################################################
+#
+# Option checker (courtesy linux kernel) to ensure
+# only supported compiler options are used
+#
+cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
+               > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+
+#
+# Include the make variables (CC, etc...)
+#
+AS     = $(CROSS_COMPILE)as
+LD     = $(CROSS_COMPILE)ld
+CC     = $(CROSS_COMPILE)gcc
+CPP    = $(CC) -E
+AR     = $(CROSS_COMPILE)ar
+NM     = $(CROSS_COMPILE)nm
+LDR    = $(CROSS_COMPILE)ldr
+STRIP  = $(CROSS_COMPILE)strip
+OBJCOPY = $(CROSS_COMPILE)objcopy
+OBJDUMP = $(CROSS_COMPILE)objdump
+RANLIB = $(CROSS_COMPILE)RANLIB
+
+#########################################################################
+
+# Load generated board configuration
+sinclude $(OBJTREE)/include/autoconf.mk
+
+ifdef  VENDOR
+BOARDDIR = $(VENDOR)/$(BOARD)
+else
+BOARDDIR = $(BOARD)
+endif
+ifdef  BOARD
+sinclude $(TOPDIR)/recovery/board/$(BOARDDIR)/config.mk
+endif
+
+#########################################################################
+
+# sinclude $(TOPDIR)/recovery/lib_$(ARCH)/config.mk
+
+CROSS_COMPILE ?= arm-linux-
+
+PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__
+
+# Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
+PLATFORM_CPPFLAGS += $(call cc-option,-marm,)
+
+# Try if EABI is supported, else fall back to old API,
+# i. e. for example:
+# - with ELDK 4.2 (EABI supported), use:
+#      -mabi=aapcs-linux -mno-thumb-interwork
+# - with ELDK 4.1 (gcc 4.x, no EABI), use:
+#      -mabi=apcs-gnu -mno-thumb-interwork
+# - with ELDK 3.1 (gcc 3.x), use:
+#      -mapcs-32 -mno-thumb-interwork
+PLATFORM_CPPFLAGS += $(call cc-option,\
+                               -mabi=aapcs-linux -mno-thumb-interwork,\
+                               $(call cc-option,\
+                                       -mapcs-32,\
+                                       $(call cc-option,\
+                                               -mabi=apcs-gnu,\
+                                       )\
+                               ) $(call cc-option,-mno-thumb-interwork,)\
+                       )
+
+# For EABI, make sure to provide raise()
+ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS)))
+# This file is parsed several times; make sure to add only once.
+ifeq (,$(findstring lib_arm/eabi_compat.o,$(PLATFORM_LIBS)))
+PLATFORM_LIBS += $(OBJTREE)/lib_arm/eabi_compat.o
+endif
+endif
+LDSCRIPT := $(SRCTREE)/recovery/board/$(BOARDDIR)/recovery.lds
+
+#########################################################################
+
+# sinclude $(TOPDIR)/recovery/cpu/$(CPU)/config.mk
+PLATFORM_RELFLAGS += -fno-strict-aliasing -fno-common -ffixed-r8 \
+                    -msoft-float
+
+# Make ARMv5 to allow more compilers to work, even though its v7a.
+PLATFORM_CPPFLAGS += -march=armv5
+# =========================================================================
+#
+# Supply options according to compiler version
+#
+# =========================================================================
+PLATFORM_RELFLAGS +=$(call cc-option,-mshort-load-bytes,\
+                   $(call cc-option,-malignment-traps,))
+
+#########################################################################
+
+#########################################################################
+
+#########################################################################
+
+
+#########################################################################
+
+ifneq (,$(findstring s,$(MAKEFLAGS)))
+ARFLAGS = cr
+else
+ARFLAGS = crv
+endif
+RELFLAGS= $(PLATFORM_RELFLAGS)
+DBGFLAGS= -g # -DDEBUG
+OPTFLAGS= -Os #-fomit-frame-pointer
+OBJCFLAGS += --gap-fill=0x00
+
+gccincdir := $(shell $(CC) -print-file-name=include)
+
+CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)                \
+       -D__KERNEL__
+ifneq ($(TEXT_BASE),)
+CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
+endif
+
+ifneq ($(RESET_VECTOR_ADDRESS),)
+CPPFLAGS += -DRESET_VECTOR_ADDRESS=$(RESET_VECTOR_ADDRESS)
+endif
+
+ifneq ($(OBJTREE),$(SRCTREE))
+CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
+endif
+
+CPPFLAGS += -I$(TOPDIR)/include
+CPPFLAGS += -fno-builtin -ffreestanding -nostdinc      \
+       -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
+
+CPPFLAGS += -DCONFIG_RECOVERY_BLOCK -D__HAVE_ARCH_MEMCPY32
+
+ifdef BUILD_TAG
+CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
+       -DBUILD_TAG='"$(BUILD_TAG)"'
+else
+CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
+endif
+
+CFLAGS += $(call cc-option,-fno-stack-protector)
+
+# avoid trigraph warnings while parsing pci.h (produced by NIOS gcc-2.9)
+# this option have to be placed behind -Wall -- that's why it is here
+ifeq ($(ARCH),nios)
+ifeq ($(findstring 2.9,$(shell $(CC) --version)),2.9)
+CFLAGS := $(CPPFLAGS) -Wall -Wno-trigraphs
+endif
+endif
+
+# $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
+# option to the assembler.
+AFLAGS_DEBUG :=
+
+# turn jbsr into jsr for m68k
+ifeq ($(ARCH),m68k)
+ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
+AFLAGS_DEBUG := -Wa,-gstabs,-S
+endif
+endif
+
+AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
+
+LDFLAGS += -Bstatic -T $(LDSCRIPT) $(PLATFORM_LDFLAGS)
+ifneq ($(TEXT_BASE),)
+LDFLAGS += -Ttext $(TEXT_BASE)
+endif
+
+#########################################################################
+
+export HOSTCC HOSTCFLAGS HOSTLDFLAGS PEDCFLAGS HOSTSTRIP CROSS_COMPILE \
+       AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
+export TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
+
+#########################################################################
+
+# Allow boards to use custom optimize flags on a per dir/file basis
+BCURDIR := $(notdir $(CURDIR))
+$(obj)%.s:     %.S
+       $(CPP) $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $<
+$(obj)%.o:     %.S
+       $(CC)  $(AFLAGS) $(AFLAGS_$(@F)) $(AFLAGS_$(BCURDIR)) -o $@ $< -c
+$(obj)%.o:     %.c
+       $(CC)  $(CFLAGS) $(CFLAGS_$(@F)) $(CFLAGS_$(BCURDIR)) -o $@ $< -c
+$(obj)%.i:     %.c
+       $(CPP) $(CFLAGS) $(CFLAGS_$(@F)) $(CFLAGS_$(BCURDIR)) -o $@ $< -c
+$(obj)%.s:     %.c
+       $(CC)  $(CFLAGS) $(CFLAGS_$(@F)) $(CFLAGS_$(BCURDIR)) -o $@ $< -c -S
+
+#########################################################################
index c84e3ea..8b989c1 100644 (file)
 # MA 02111-1307 USA
 #
 
-include $(TOPDIR)/config.mk
-
-recoveryobj := $(OBJTREE)/recovery/
-RECOVERYCFG := $(recoveryobj)board/$(BOARDDIR)/config.mk
-include $(RECOVERYCFG)
+include $(TOPDIR)/recovery/config.mk
 
 LIB := $(obj)libonenand.a
 
index 68c1c9f..6cda9ae 100644 (file)
 # MA 02111-1307 USA
 #
 
-include $(TOPDIR)/config.mk
-
-recoveryobj := $(OBJTREE)/recovery/
-RECOVERYCFG := $(recoveryobj)board/$(BOARDDIR)/config.mk
-include $(RECOVERYCFG)
+include $(TOPDIR)/recovery/config.mk
 
 LIB := $(obj)libusb.a