Added support for C6657
[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 c665x
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) || $(TARGET),c665x )
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         cp ibl_$(TARGET)/$@.bin ../util/iblConfig/build/ibl.bin
141         (cd ../util/iblConfig/build;./iblConfig.out)
142         cp ../util/iblConfig/build/ibl.bin ibl_$(TARGET)/$@.bin
143         $(RM) i2crom.ccs ibl_le.b ibl.b
145 spiRom:
146         @echo Making SPI ROM
147         $(CC) -ppo -I../cfg/$(TARGET) $(SPI_CFG) ibl_$(TARGET)/$@.map.pre
148         ../util/romparse/romparse $(COMPACT) -fill 0xff -rom_base 0 ibl_$(TARGET)/$@.map.pp
149         $(CP) i2crom.ccs ibl_$(TARGET)/$@.ccs
150         $(CP) i2crom.ccs ibl_$(TARGET)/$@.dat
156 # Target compare checks if the iblInit is compiled the same for both endians
157 compare:
158         @echo -
159         @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 '
160         @echo -
162 # For the init code a raw image is created as well as the i2c code to verify
163 # endian independent code is generated. The symbols required for linking
164 # the full application are then extracted
165 iblInit: $(CFG_MODULES) $(MODULES)
166         cat ibl_$(TARGET)/ibl_init_objs_template.inc | sed -e s/ENDIAN_TAG/$(IEXT)/g > ibl_$(TARGET)/ibl_init_objs.tmp
167         $(CC) -ppo $(MAINDEFS) -DENDIAN_TAG=$(IEXT) ibl_$(TARGET)/ibl_init_objs.tmp
168         $(CP) ibl_$(TARGET)/ibl_init_objs.pp ibl_$(TARGET)/ibl_init_objs.inc
169         $(LD) -o ibl_$(TARGET)/ibl_$(TARGET)_init.out -m ibl_$(TARGET)/ibl_$(TARGET)_init.map ibl_$(TARGET)/ibl_init.cmd $(RTLIBS)
170         $(CP) ibl_$(TARGET)/ibl_$(TARGET)_init.out ibl_$(TARGET)/ibl_$(TARGET)_init.$(IEXT).out
171         $(RM) -f ibl_$(TARGET)/ibl_init_obj.inc
173         hex6x $(HEX_OPT) ibl_$(TARGET)/ibl_init_image.rmd ibl_$(TARGET)/ibl_$(TARGET)_init.out
174         $(CP) ibl_le.b ibl_$(TARGET)/ibl.b
175         ../util/btoccs/b2ccs ibl_$(TARGET)/ibl.b ibl_$(TARGET)/ibl_init.$(IEXT).ccs
177         hex6x $(HEX_OPT) ibl_$(TARGET)/ibl_init.rmd ibl_$(TARGET)/ibl_$(TARGET)_init.out
178         ../util/bconvert/bconvert64x -$(IEXT) ibl_le.b ibl.b
179         $(CP) ibl.b ibl_$(TARGET)
180         ../util/btoccs/b2i2c ibl_$(TARGET)/ibl.b ibl_$(TARGET)/ibl.i2c.b
181         ../util/btoccs/b2ccs ibl_$(TARGET)/ibl.i2c.b ibl_$(TARGET)/ibl_init.i2c.$(IEXT).ccs
183         sed -e 's/\r//' ../util/symExtract/symExtract > ../util/symExtract/symExtract_unix
184         bash ../util/symExtract/symExtract_unix ibl_$(TARGET)/ibl_$(TARGET)_init.map ibl_$(TARGET)/ibl_init_symbols.inc $(COMMON_SYMBOLS)
185         rm -f ../util/symExtract/symExtract_unix
187         
188 iblMain: iblInit $(CFG_MODULES) $(MODULES)
189         cat ibl_$(TARGET)/ibl_objs_template.inc | sed -e s/ENDIAN_TAG/$(IEXT)/g > ibl_$(TARGET)/ibl_objs.tmp
190         $(CC) -ppo $(MAINDEFS) -DENDIAN_TAG=$(IEXT) ibl_$(TARGET)/ibl_objs.tmp
191         $(CP) ibl_$(TARGET)/ibl_objs.pp ibl_$(TARGET)/ibl_objs.inc
192         $(LD) -o ibl_$(TARGET)/ibl_$(TARGET).out -m ibl_$(TARGET)/ibl_$(TARGET).$(IEXT).map  ibl_$(TARGET)/ibl.cmd $(RTLIBS)
193         $(CP) ibl_$(TARGET)/ibl_$(TARGET).out ibl_$(TARGET)/ibl_$(TARGET).$(IEXT).out
194         $(RM) -f ibl_$(TARGET)/ibl_obj.inc
196         hex6x $(HEX_OPT) ibl_$(TARGET)/ibl.rmd ibl_$(TARGET)/ibl_$(TARGET).out
197         ../util/bconvert/bconvert64x -$(IEXT) ibl_le.b ibl.b
198         $(CP) ibl.b ibl_$(TARGET)
199         ../util/btoccs/b2i2c ibl_$(TARGET)/ibl.b ibl_$(TARGET)/ibl.i2c.b
200         ../util/btoccs/b2ccs ibl_$(TARGET)/ibl.i2c.b ibl_$(TARGET)/ibl.i2c.$(IEXT).ccs
203 $(MODULES):
204         @echo making $@
205         make -C $(IBL_ROOT)/$@/$(ARCH)/make $@
207 $(CFG_MODULES):
208         @echo making $@ SPI_CFG=$(SPI_CFG) CDEFS=$(CDEFS) EXCLUDES=$(EXCLUDES)
209         make -C $(IBL_ROOT)/$@/$(ARCH)/make CDEFS='$(MAINDEFS) $(SPI_CFG)' $@
211 utils:
212 ifeq ($(HAS_SPI),1)
213 #make -C $(IBL_ROOT)/util/spiConfig TARGET=$(TARGET) SPI_DEFS='$(SPI_DEFS)' MAINDEFS='$(MAINDEFS) $(SPI_CFG)' $(TARGET)
214 endif
215         make -C $(IBL_ROOT)/util/btoccs
216         make -C $(IBL_ROOT)/util/romparse TARGET=$(TARGET)
217 ifeq ($(HAS_I2C),1)
218         make -C $(IBL_ROOT)/util/i2cConfig $(TARGET) MAINDEFS='$(MAINDEFS) $(SPI_CFG)' 
219 endif
220         make -C $(IBL_ROOT)/util/bconvert
221         make -C $(IBL_ROOT)/util/iblConfig/build EVM=$(EVM) I2C_MAP_ADDR=$(I2C_MAP_ADDR)
223 clean: $(CLEAN_MODULES) hwClean
224         
226 $(CLEAN_MODULES):
227         @echo cleaning $(subst clean_, ,$@)
228         make -C $(IBL_ROOT)/$(subst clean_,,$@)/$(ARCH)/make clean ARCH=c64x TARGET=$(TARGET)
230 hwClean:
231         @echo cleaning hw
232         make -C $(IBL_ROOT)/hw/$(ARCH)/make cleant ARCH=$(ARCH) TARGET=$(TARGET)
233         
234 cleant:
235         rm -rf ibl_$(TARGET)/ibl_$(TARGET).be.out
236         rm -rf ibl_$(TARGET)/ibl_$(TARGET).le.out
237         rm -rf ibl_$(TARGET)/ibl_$(TARGET).be.map
238         rm -rf ibl_$(TARGET)/ibl_$(TARGET).le.map
239         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.map
240         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.out
241         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.be.map
242         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.be.out
243         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.le.map
244         rm -rf ibl_$(TARGET)/ibl_$(TARGET)_init.le.out
245         rm -rf ibl_$(TARGET)/ibl_$(TARGET).out
246         rm -rf ibl_$(TARGET)/ibl_$(TARGET).map
247         rm -rf ibl_$(TARGET)/ibl_le.b
248         rm -rf ibl_$(TARGET)/ibl.b
249         rm -rf ibl_$(TARGET)/ibl.i2c.b
250         rm -rf ibl_$(TARGET)/ibl.i2c.be.ccs
251         rm -rf ibl_$(TARGET)/ibl.i2c.le.ccs
252         rm -rf ibl_$(TARGET)/ibl_init.i2c.be.ccs
253         rm -rf ibl_$(TARGET)/ibl_init.i2c.le.ccs
254         rm -rf ibl_$(TARGET)/ibl_init.le.ccs
255         rm -rf ibl_$(TARGET)/ibl_init.be.ccs
256         rm -rf ibl_$(TARGET)/i2crom*.ccs
257         rm -rf ibl_$(TARGET)/i2crom*.dat
258         rm -rf ibl_$(TARGET)/i2crom*.bin
259         rm -rf ibl_$(TARGET)/i2crom*.map.pp
260         rm -rf ibl_$(TARGET)/ibl_init_objs.inc
261         rm -rf ibl_$(TARGET)/ibl_init_objs.pp
262         rm -rf ibl_$(TARGET)/ibl_init_symbols.inc
263         rm -rf ibl_$(TARGET)/ibl_objs.inc
264         rm -rf ibl_$(TARGET)/ibl_objs.pp
265         rm -rf ibl_$(TARGET)/ibl_objs.tmp
266         rm -rf ibl_$(TARGET)/spiRom*.dat
267         rm -rf ibl_$(TARGET)/spiRom*.map.pp
268