Bug fix for automatic file format detection
[keystone-rtos/ibl.git] / src / make / makestg2
1 #*****************************************************************************
2 #* FILE PURPOSE: 2nd stage makefile for the intermediate boot loader
3 #*****************************************************************************
4 #* FILE NAME: makestg2
5 #*
6 #* DESCRIPTION: This makefile is invoked with build specific options
7 #*
8 #******************************************************************************
10 ifndef IBL_ROOT
11         IBL_ROOT=..
12 endif
14 CFG_MODULES= main device
15 MODULES= ethboot nandboot driver hw interp ecc
17 CLEAN_MODULES=$(addprefix clean_,$(MODULES))
18 CLEAN_MODULES+=$(addprefix clean,$(CFG_MODULES))
21 TARGETS= c6472 c6474 c6474l c6455 c6457
23 # The main module needs to know the device address of the i2c where the image map resides
24 MAINDEFS=-DIBL_I2C_MAP_TABLE_DATA_BUS_ADDR=$(I2C_BUS_ADDR)
26 # Add build time exclusion definitions
27 MAINDEFS+=$(addprefix -DEXCLUDE_,$(EXCLUDES))
30 # Common symbols are functions which are loaded with the stage load of the IBL, and
31 # also referenced from the second stage
32 COMMON_SYMBOLS= hwI2Cinit hwI2cMasterRead iblBootBtbl iblMalloc iblFree iblMemset iblMemcpy
34 ifeq ($(ENDIAN),little)
35         HEX_OPT= -order L
36         IEXT=     le
37 else
38         HEX_OPT= -order M
39         IEXT=     be
40 endif
42 ifeq ($(COMPACT_I2C),yes)
43   COMPACT= -compact
44 endif
46 include $(IBL_ROOT)/make/$(ARCH)/makedefs.mk
48 export ARCH
49 export TARGET
51 $(TARGETS): iblMain
55 # The I2C creation options. The I2C map file is run through the C pre-processor to generate
56 # the desired I2C mapping. There are three possible configurations - an i2c which has
57 # both endians present, or an I2C with only one of the endians
59 I2C_BE_FILE=      '"ibl_$(TARGET)/ibl.i2c.be.ccs"'
60 I2C_LE_FILE=      '"ibl_$(TARGET)/ibl.i2c.le.ccs"'
61 I2C_INIT_BE_FILE= '"ibl_$(TARGET)/ibl_init.i2c.be.ccs"'
62 I2C_INIT_LE_FILE= '"ibl_$(TARGET)/ibl_init.i2c.le.ccs"'
64 I2C_DEFS= -DI2C_BUS_ADDR=$(I2C_BUS_ADDR) 
66 ifeq ($(I2CROM),both) 
67  I2C_DEFS+= -DINIT_EXE_FILE=$(I2C_INIT_LE_FILE)
68  I2C_DEFS+= -DEXE_FILE_1=$(I2C_LE_FILE) 
69  I2C_DEFS+= -DPAD_FILE_ID_1=1 
70  I2C_DEFS+= -DEXE_FILE_2=$(I2C_BE_FILE) 
71  I2C_DEFS+= -DPAD_FILE_ID_2=2 
72 else 
73  I2C_DEFS+= -DPAD_FILE_ID_1=1
74  I2C_DEFS+= -DPAD_FILE_ID_2=1
76  ifeq ($(I2CROM),little_endian)
77   I2C_DEFS+= -DINIT_EXE_FILE=$(I2C_INIT_LE_FILE)
78   I2C_DEFS+= -DEXE_FILE_1=$(I2C_LE_FILE)
79   I2C_DEFS+= -DEXE_FILE_2='""'
80  else
81   I2C_DEFS+= -DINIT_EXE_FILE=$(I2C_INIT_BE_FILE)
82   I2C_DEFS+= -DEXE_FILE_1='""'
83   I2C_DEFS+= -DEXE_FILE_2=$(I2C_BE_FILE)
84  endif
85 endif
88 i2cRom:
89         $(CC) -ppo -I../cfg/$(TARGET) $(I2C_DEFS) ibl_$(TARGET)/$@.map.pre
90         ../util/romparse/romparse $(COMPACT) -rom_base $(I2C_BUS_ADDR) ibl_$(TARGET)/$@.map.pp
91         $(CP) i2crom.ccs ibl_$(TARGET)/$@.ccs
92         $(CP) i2crom.ccs ibl_$(TARGET)/$@.dat
93         $(RM) i2crom.ccs ibl_le.b ibl.b
100 # Target compare checks if the iblInit is compiled the same for both endians
101 compare:
102         @echo -
103         @sh -c 'if diff -q ibl_$(TARGET)/ibl_init.le.ccs ibl_$(TARGET)/ibl_init.be.ccs ; then echo IBL init endian neutral ; else echo !!! WARNING !!!! IBL ini NOT endian neutral !!! ; fi '
104         @echo -
106 # For the init code a raw image is created as well as the i2c code to verify
107 # endian independent code is generated. The symbols required for linking
108 # the full application are then extracted
109 iblInit: $(CFG_MODULES) $(MODULES) utils
110         cat ibl_$(TARGET)/ibl_init_objs_template.inc | sed -e s/ENDIAN_TAG/$(IEXT)/g > ibl_$(TARGET)/ibl_init_objs.inc
111         $(LD) -o ibl_$(TARGET)/ibl_$(TARGET)_init.out -m ibl_$(TARGET)/ibl_$(TARGET)_init.map ibl_$(TARGET)/ibl_init.cmd $(RTLIBS)
112         $(CP) ibl_$(TARGET)/ibl_$(TARGET)_init.out ibl_$(TARGET)/ibl_$(TARGET)_init.$(IEXT).out
113         $(RM) -f ibl_$(TARGET)/ibl_init_obj.inc
115         hex6x $(HEX_OPT) ibl_$(TARGET)/ibl_init_image.rmd ibl_$(TARGET)/ibl_$(TARGET)_init.out
116         $(CP) ibl_le.b ibl_$(TARGET)/ibl.b
117         ../util/btoccs/b2ccs ibl_$(TARGET)/ibl.b ibl_$(TARGET)/ibl_init.$(IEXT).ccs
119         hex6x $(HEX_OPT) ibl_$(TARGET)/ibl_init.rmd ibl_$(TARGET)/ibl_$(TARGET)_init.out
120         ../util/bconvert/bconvert64x -$(IEXT) ibl_le.b ibl.b
121         $(CP) ibl.b ibl_$(TARGET)
122         ../util/btoccs/b2i2c ibl_$(TARGET)/ibl.b ibl_$(TARGET)/ibl.i2c.b
123         ../util/btoccs/b2ccs ibl_$(TARGET)/ibl.i2c.b ibl_$(TARGET)/ibl_init.i2c.$(IEXT).ccs
125         bash ../util/symExtract/symExtract ibl_$(TARGET)/ibl_$(TARGET)_init.map ibl_$(TARGET)/ibl_init_symbols.inc $(COMMON_SYMBOLS)
127         
128 iblMain: iblInit $(CFG_MODULES) $(MODULES)
129         cat ibl_$(TARGET)/ibl_objs_template.inc | sed -e s/ENDIAN_TAG/$(IEXT)/g > ibl_$(TARGET)/ibl_objs.tmp
130         $(CC) -ppo $(MAINDEFS) -DENDIAN_TAG=$(IEXT) ibl_$(TARGET)/ibl_objs.tmp
131         $(CP) ibl_$(TARGET)/ibl_objs.pp ibl_$(TARGET)/ibl_objs.inc
132         $(LD) -o ibl_$(TARGET)/ibl_$(TARGET).out -m ibl_$(TARGET)/ibl_$(TARGET).$(IEXT).map  ibl_$(TARGET)/ibl.cmd $(RTLIBS)
133         $(CP) ibl_$(TARGET)/ibl_$(TARGET).out ibl_$(TARGET)/ibl_$(TARGET).$(IEXT).out
134         $(RM) -f ibl_$(TARGET)/ibl_obj.inc
136         hex6x $(HEX_OPT) ibl_$(TARGET)/ibl.rmd ibl_$(TARGET)/ibl_$(TARGET).out
137         ../util/bconvert/bconvert64x -$(IEXT) ibl_le.b ibl.b
138         $(CP) ibl.b ibl_$(TARGET)
139         ../util/btoccs/b2i2c ibl_$(TARGET)/ibl.b ibl_$(TARGET)/ibl.i2c.b
140         ../util/btoccs/b2ccs ibl_$(TARGET)/ibl.i2c.b ibl_$(TARGET)/ibl.i2c.$(IEXT).ccs
143 $(MODULES):
144         @echo making $@
145         make -C $(IBL_ROOT)/$@/$(ARCH)/make $@
147 $(CFG_MODULES):
148         @echo making $@
149         make -C $(IBL_ROOT)/$@/$(ARCH)/make CDEFS='$(MAINDEFS)' $@
151 utils:
152         make -C $(IBL_ROOT)/util/btoccs
153         make -C $(IBL_ROOT)/util/romparse TARGET=$(TARGET)
154         make -C $(IBL_ROOT)/util/i2cRead  TARGET=$(TARGET) $(TARGET)
155         make -C $(IBL_ROOT)/util/i2cWrite TARGET=$(TARGET) $(TARGET)
156         make -C $(IBL_ROOT)/util/i2cConfig $(TARGET)
157         make -C $(IBL_ROOT)/util/bconvert
159 clean: $(CLEAN_MODULES)
160         
162 $(CLEAN_MODULES):
163         @echo cleaning $(subst clean_, ,$@)
164         make -C $(IBL_ROOT)/$(subst clean_,,$@)/$(ARCH)/make clean
165         
166 cleant:
167         rm -rf ibl_$(TARGET)/ibl_$(TARGET).out
168         rm -rf ibl_$(TARGET)/ibl_$(TARGET).map
169         rm -rf ibl_$(TARGET)/ibl_le.b
170         rm -rf ibl_$(TARGET)/ibl.b
171         rm -rf ibl_$(TARGET)/ibl.i2c.b
172         rm -rf ibl_$(TARGET)/ibl.i2c.ccs
173         rm -rf ibl_$(TARGET)/i2crom.ccs
174