Single Binary Build Update
[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 norboot
17 # Note that the Hw module is a two stage clean and handled seperately
18 CLEAN_MODULES=$(addprefix clean_,$(subst hw,,$(MODULES)))
19 CLEAN_MODULES+=$(addprefix clean_,$(CFG_MODULES))
22 TARGETS= c6472 c6474 c6474l c6455 c6457 c66x
24 # The main module needs to know the device address of the i2c where the image map resides
25 MAINDEFS=-DIBL_CFG_I2C_MAP_TABLE_DATA_BUS_ADDR=$(I2C_BUS_ADDR)
27 # Add build time exclusion definitions
28 MAINDEFS+=$(addprefix -DEXCLUDE_,$(EXCLUDES))
30 # Add SPI definitions
31 SPI_CFG= $(addprefix -D,$(SPI_DEFS))
34 # Common symbols are functions which are loaded with the stage load of the IBL, and
35 # also referenced from the second stage
36 #COMMON_SYMBOLS= hwI2Cinit hwI2cMasterRead iblBootBtbl iblMalloc iblFree iblMemset iblMemcpy
37 COMMON_SYMBOLS= iblBootBtbl iblMalloc iblFree iblMemset iblMemcpy
39 ifeq ($(ENDIAN),little)
40         HEX_OPT= -order L
41         IEXT=     le
42 else
43         HEX_OPT= -order M
44         IEXT=     be
45 endif
47 ifeq ($(COMPACT_I2C),yes)
48   COMPACT= -compact
49 endif
51 include $(IBL_ROOT)/make/$(ARCH)/makedefs.mk
53 export ARCH
54 export TARGET
55 export EVM
56 export I2C_MAP_ADDR
58 .PHONY:  $(TARGETS) i2crom spiRom compare iblInit iblMain $(MODULES) $(CFG_MODULES)
59 .PHONY:  utils clean clean_modules hwClean cleant
61 $(TARGETS): iblMain
63 ifeq ($(TARGET),c66x)
64     HAS_SPI=1
65 else
66     HAS_SPI=0
67 endif
69 ifeq (EXCLUDE_SPI, $(strip $(findstring EXCLUDE_SPI, $(MAINDEFS))))
70     HAS_SPI=0
71 endif
73 ifeq (EXCLUDE_I2C, $(strip $(findstring EXCLUDE_I2C, $(MAINDEFS))))
74     HAS_I2C=0
75 else 
76    HAS_I2C=1
77 endif
79 # The I2C creation options. The I2C map file is run through the C pre-processor to generate
80 # the desired I2C mapping. There are three possible configurations - an i2c which has
81 # both endians present, or an I2C with only one of the endians
83 I2C_BE_FILE=      '"ibl_$(TARGET)/ibl.i2c.be.ccs"'
84 I2C_LE_FILE=      '"ibl_$(TARGET)/ibl.i2c.le.ccs"'
85 I2C_INIT_BE_FILE= '"ibl_$(TARGET)/ibl_init.i2c.be.ccs"'
86 I2C_INIT_LE_FILE= '"ibl_$(TARGET)/ibl_init.i2c.le.ccs"'
88 I2C_DEFS= -DI2C_BUS_ADDR=$(I2C_BUS_ADDR)
89 I2C_DEFS+= -DI2C_MAP_ADDR=$(I2C_MAP_ADDR)
90 I2C_DEFS+= -DEVM=$(EVM)
92 ifeq ($(I2CROM),both) 
93  I2C_DEFS+= -DINIT_EXE_FILE=$(I2C_INIT_LE_FILE)
94  I2C_DEFS+= -DEXE_FILE_1=$(I2C_LE_FILE) 
95  I2C_DEFS+= -DPAD_FILE_ID_1=1 
96  I2C_DEFS+= -DEXE_FILE_2=$(I2C_BE_FILE) 
97  I2C_DEFS+= -DPAD_FILE_ID_2=2 
99  SPI_CFG+= -DINIT_EXE_FILE=$(I2C_INIT_LE_FILE)
100  SPI_CFG+= -DEXE_FILE_1=$(I2C_LE_FILE) 
101  SPI_CFG+= -DPAD_FILE_ID_1=1 
102  SPI_CFG+= -DEXE_FILE_2=$(I2C_BE_FILE) 
103  SPI_CFG+= -DPAD_FILE_ID_2=2 
105 else 
106  I2C_DEFS+= -DPAD_FILE_ID_1=1
107  I2C_DEFS+= -DPAD_FILE_ID_2=1
109  SPI_CFG+= -DPAD_FILE_ID_1=1
110  SPI_CFG+= -DPAD_FILE_ID_2=1
112  ifeq ($(I2CROM),little_endian)
113   I2C_DEFS+= -DINIT_EXE_FILE=$(I2C_INIT_LE_FILE)
114   I2C_DEFS+= -DEXE_FILE_1=$(I2C_LE_FILE)
115   I2C_DEFS+= -DEXE_FILE_2='""'
117   SPI_CFG+= -DINIT_EXE_FILE=$(I2C_INIT_LE_FILE)
118   SPI_CFG+= -DEXE_FILE_1=$(I2C_LE_FILE)
119   SPI_CFG+= -DEXE_FILE_2='""'
121  else
122   I2C_DEFS+= -DINIT_EXE_FILE=$(I2C_INIT_BE_FILE)
123   I2C_DEFS+= -DEXE_FILE_1='""'
124   I2C_DEFS+= -DEXE_FILE_2=$(I2C_BE_FILE)
126   SPI_CFG+= -DINIT_EXE_FILE=$(I2C_INIT_BE_FILE)
127   SPI_CFG+= -DEXE_FILE_1='""'
128   SPI_CFG+= -DEXE_FILE_2=$(I2C_BE_FILE)
130  endif
131 endif
134 i2crom:
135         $(CC) -ppo -I../cfg/$(TARGET) $(I2C_DEFS) ibl_$(TARGET)/$@.map.pre
136         ../util/romparse/romparse $(COMPACT) -rom_base $(I2C_BUS_ADDR) ibl_$(TARGET)/$@.map.pp
137         $(CP) i2crom.ccs ibl_$(TARGET)/$@.ccs
138         $(CP) i2crom.ccs ibl_$(TARGET)/$@.dat
139         ../util/btoccs/ccs2bin -swap ibl_$(TARGET)/$@.ccs ibl_$(TARGET)/$@.bin
140         $(RM) i2crom.ccs ibl_le.b ibl.b
142 spiRom:
143         @echo Making SPI ROM
144         $(CC) -ppo -I../cfg/$(TARGET) $(SPI_CFG) ibl_$(TARGET)/$@.map.pre
145         ../util/romparse/romparse $(COMPACT) -fill 0xff -rom_base 0 ibl_$(TARGET)/$@.map.pp
146         $(CP) i2crom.ccs ibl_$(TARGET)/$@.ccs
147         $(CP) i2crom.ccs ibl_$(TARGET)/$@.dat
153 # Target compare checks if the iblInit is compiled the same for both endians
154 compare:
155         @echo -
156         @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 '
157         @echo -
159 # For the init code a raw image is created as well as the i2c code to verify
160 # endian independent code is generated. The symbols required for linking
161 # the full application are then extracted
162 iblInit: $(CFG_MODULES) $(MODULES)
163         cat ibl_$(TARGET)/ibl_init_objs_template.inc | sed -e s/ENDIAN_TAG/$(IEXT)/g > ibl_$(TARGET)/ibl_init_objs.tmp
164         $(CC) -ppo $(MAINDEFS) -DENDIAN_TAG=$(IEXT) ibl_$(TARGET)/ibl_init_objs.tmp
165         $(CP) ibl_$(TARGET)/ibl_init_objs.pp ibl_$(TARGET)/ibl_init_objs.inc
166         $(LD) -o ibl_$(TARGET)/ibl_$(TARGET)_init.out -m ibl_$(TARGET)/ibl_$(TARGET)_init.map ibl_$(TARGET)/ibl_init.cmd $(RTLIBS)
167         $(CP) ibl_$(TARGET)/ibl_$(TARGET)_init.out ibl_$(TARGET)/ibl_$(TARGET)_init.$(IEXT).out
168         $(RM) -f ibl_$(TARGET)/ibl_init_obj.inc
170         hex6x $(HEX_OPT) ibl_$(TARGET)/ibl_init_image.rmd ibl_$(TARGET)/ibl_$(TARGET)_init.out
171         $(CP) ibl_le.b ibl_$(TARGET)/ibl.b
172         ../util/btoccs/b2ccs ibl_$(TARGET)/ibl.b ibl_$(TARGET)/ibl_init.$(IEXT).ccs
174         hex6x $(HEX_OPT) ibl_$(TARGET)/ibl_init.rmd ibl_$(TARGET)/ibl_$(TARGET)_init.out
175         ../util/bconvert/bconvert64x -$(IEXT) ibl_le.b ibl.b
176         $(CP) ibl.b ibl_$(TARGET)
177         ../util/btoccs/b2i2c ibl_$(TARGET)/ibl.b ibl_$(TARGET)/ibl.i2c.b
178         ../util/btoccs/b2ccs ibl_$(TARGET)/ibl.i2c.b ibl_$(TARGET)/ibl_init.i2c.$(IEXT).ccs
180         sed -e 's/\\r//' ../util/symExtract/symExtract > ../util/symExtract/symExtract_unix
181         bash ../util/symExtract/symExtract_unix ibl_$(TARGET)/ibl_$(TARGET)_init.map ibl_$(TARGET)/ibl_init_symbols.inc $(COMMON_SYMBOLS)
182         rm -f ../util/symExtract/symExtract_unix
184         
185 iblMain: iblInit $(CFG_MODULES) $(MODULES)
186         cat ibl_$(TARGET)/ibl_objs_template.inc | sed -e s/ENDIAN_TAG/$(IEXT)/g > ibl_$(TARGET)/ibl_objs.tmp
187         $(CC) -ppo $(MAINDEFS) -DENDIAN_TAG=$(IEXT) ibl_$(TARGET)/ibl_objs.tmp
188         $(CP) ibl_$(TARGET)/ibl_objs.pp ibl_$(TARGET)/ibl_objs.inc
189         $(LD) -o ibl_$(TARGET)/ibl_$(TARGET).out -m ibl_$(TARGET)/ibl_$(TARGET).$(IEXT).map  ibl_$(TARGET)/ibl.cmd $(RTLIBS)
190         $(CP) ibl_$(TARGET)/ibl_$(TARGET).out ibl_$(TARGET)/ibl_$(TARGET).$(IEXT).out
191         $(RM) -f ibl_$(TARGET)/ibl_obj.inc
193         hex6x $(HEX_OPT) ibl_$(TARGET)/ibl.rmd ibl_$(TARGET)/ibl_$(TARGET).out
194         ../util/bconvert/bconvert64x -$(IEXT) ibl_le.b ibl.b
195         $(CP) ibl.b ibl_$(TARGET)
196         ../util/btoccs/b2i2c ibl_$(TARGET)/ibl.b ibl_$(TARGET)/ibl.i2c.b
197         ../util/btoccs/b2ccs ibl_$(TARGET)/ibl.i2c.b ibl_$(TARGET)/ibl.i2c.$(IEXT).ccs
200 $(MODULES):
201         @echo making $@
202         make -C $(IBL_ROOT)/$@/$(ARCH)/make $@
204 $(CFG_MODULES):
205         @echo making $@ SPI_CFG=$(SPI_CFG) CDEFS=$(CDEFS) EXCLUDES=$(EXCLUDES)
206         make -C $(IBL_ROOT)/$@/$(ARCH)/make CDEFS='$(MAINDEFS) $(SPI_CFG)' $@
208 utils:
209 ifeq ($(HAS_SPI),1)
210 #make -C $(IBL_ROOT)/util/spiConfig TARGET=$(TARGET) SPI_DEFS='$(SPI_DEFS)' MAINDEFS='$(MAINDEFS) $(SPI_CFG)' $(TARGET)
211 endif
212         make -C $(IBL_ROOT)/util/btoccs
213         make -C $(IBL_ROOT)/util/romparse TARGET=$(TARGET)
214         make -C $(IBL_ROOT)/util/bconvert
215         make -C $(IBL_ROOT)/util/iblConfig/build EVM=$(EVM) I2C_MAP_ADDR=$(I2C_MAP_ADDR)
217 clean: $(CLEAN_MODULES) hwClean
218         
220 $(CLEAN_MODULES):
221         @echo cleaning $(subst clean_, ,$@)
222         make -C $(IBL_ROOT)/$(subst clean_,,$@)/$(ARCH)/make clean ARCH=c64x TARGET=$(TARGET)
224 hwClean:
225         @echo cleaning hw
226         make -C $(IBL_ROOT)/hw/$(ARCH)/make cleant ARCH=$(ARCH) TARGET=$(TARGET)
227         
228 cleant:
229         rm -rf ibl_$(TARGET)/ibl_$(TARGET).be.out
230         rm -rf ibl_$(TARGET)/ibl_$(TARGET).le.out
231         rm -rf ibl_$(TARGET)/ibl_$(TARGET).be.map
232         rm -rf ibl_$(TARGET)/ibl_$(TARGET).le.map
233         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.map
234         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.out
235         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.be.map
236         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.be.out
237         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.le.map
238         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.le.out
239         rm -rf ibl_$(TARGET)/ibl_$(TARGET).out
240         rm -rf ibl_$(TARGET)/ibl_$(TARGET).map
241         rm -rf ibl_$(TARGET)/ibl_le.b
242         rm -rf ibl_$(TARGET)/ibl.b
243         rm -rf ibl_$(TARGET)/ibl.i2c.b
244         rm -rf ibl_$(TARGET)/ibl.i2c.be.ccs
245         rm -rf ibl_$(TARGET)/ibl.i2c.le.ccs
246         rm -rf ibl_$(TARGET)/ibl_init.i2c.be.ccs
247         rm -rf ibl_$(TARGET)/ibl_init.i2c.le.ccs
248         rm -rf ibl_$(TARGET)/ibl_init.le.ccs
249         rm -rf ibl_$(TARGET)/ibl_init.be.ccs
250         rm -rf ibl_$(TARGET)/i2crom*.ccs
251         rm -rf ibl_$(TARGET)/i2crom*.dat
252         rm -rf ibl_$(TARGET)/i2crom*.bin
253         rm -rf ibl_$(TARGET)/i2crom*.map.pp
254         rm -rf ibl_$(TARGET)/ibl_init_objs.inc
255         rm -rf ibl_$(TARGET)/ibl_init_objs.pp
256         rm -rf ibl_$(TARGET)/ibl_init_symbols.inc
257         rm -rf ibl_$(TARGET)/ibl_objs.inc
258         rm -rf ibl_$(TARGET)/ibl_objs.pp
259         rm -rf ibl_$(TARGET)/ibl_objs.tmp
260         rm -rf ibl_$(TARGET)/spiRom*.dat
261         rm -rf ibl_$(TARGET)/spiRom*.map.pp
262