Setting the default config in the Makefile so that it builds the exact same
[goodfet] / firmware / Makefile
1
2 #include `uname`.mak
3 #GOODFET?=/dev/ttyUSB0
4
5 #For tos-bsl, use --invert-reset --invert-test
6 BSL?=goodfet.bsl --speed=38400
7
8 #One of these should be defined explicitly.
9 #Default removed because of confusion.
10
11 #mcu=msp430x2274
12 #mcu=msp430x2618
13 #mcu?=msp430x1612
14 mcu?=RUNCONFIG
15
16 #platform=goodfet
17 #platform=telosb
18 #platform=z1
19 platform?=goodfet
20
21 #N.B., gcc WILL NOT BITCH if this file doesn't exist.
22 #GCCINC=-T ldscripts/161x.x
23 GCCINC=-T ldscripts/$(mcu).x
24
25 CCEXTRA?=
26 CC=msp430-gcc -Wall -Os -g -mmcu=$(mcu) -D$(mcu) -D$(platform) -Dplatform=$(platform) -DGCC $(GCCINC) -I include $(CCEXTRA)
27
28 # Available Applications
29 # ======================
30 # Below is a list of available applications and their descriptions.
31
32 # PRODUCTION: 
33 # None have made it to production grade quality
34
35 # BETA:
36 # monitor -- Basic monitor
37 # spi -- Turns GF into USB-to-SPI adapter
38 # jtag -- Low level JTAG (needed by all other JTAG code)
39 # sbw -- Makes JTAG Spy-by-wire multiplexable
40
41 # ALPHA:
42 # jtag430 -- 16-bit MSP430 JTAG
43 # jtag430x2 -- 20-bit MSP430 JTAG
44
45 # PRE-ALPHA:
46 #  Bus protocols:
47 # i2c -- Turns GF into USB-to-i2c adapter
48 # jtagarm7 -- ARM7TDMI JTAG
49 # ejtag -- MIPS JTAG
50 # jtagxscale -- XScale JTAG
51
52 #  Microcontrollers:
53 # chipcon -- Chipcon radio 8051 debugging
54 # avr -- AVR debugger
55 # pic -- PIC24H/dsPIC33F debugger
56 # adc -- ADC10 (still specific to x2274, GoodFET32)
57
58 #  Radios:
59 # nrf -- Nordic RF SPI
60 # ccspi -- Chipcon SPI
61
62 # Miscelaneous:
63 # glitch -- Glitch research tool
64 # smartcard -- Smartcard IO
65 # ps2 -- PS2 spy
66
67
68 # Configurations
69 # ==============
70 # This is what you need to customize to specify which apps you want in your
71 # firmware.  The "config" variable is just a space-delimited list of apps you
72 # want included.  The makefile will take the list of apps and include all of
73 # the proper code needed to build your desired firmware.
74
75 # bare minimum
76 # config = monitor
77
78 # basic JTAG adapter
79 # config = monitor jtag
80
81 # Chipcon hacking
82 # config = monitor chipcon ccspi
83
84 # Glitch research
85 # config = monitor glitch
86
87 # XScale PXA255 JTAG
88 # config = monitor jtagxscale
89
90 # Old Default Config
91 config = monitor sbw glitch chipcon nrf ccspi spi jtagarm7 jtag430 jtag430x2 avr
92
93
94 # Build the needed list of app and lib object files from the config
95 apps= 
96 libs= lib/$(mcu).o lib/command.o lib/dco_calib.o lib/apps.o
97 hdrs=
98 ERR=
99
100 # include monitor app
101 ifeq ($(filter monitor, $(config)), monitor)
102         apps+= apps/monitor/monitor.o
103         hdrs+= monitor.h
104 endif
105
106 # include spi app
107 ifeq ($(filter spi, $(config)), spi)
108         apps+= apps/spi/spi.o
109         hdrs+= spi.h
110 endif
111
112 # include base jtag if they specified it explicitly
113 ifeq ($(filter jtag, $(config)), jtag)
114         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
115                 apps+= apps/jtag/jtag.o
116                 hdrs+= jtag.h
117         endif
118 endif
119
120 # include the sbw defs if they specified it
121 ifeq ($(filter sbw, $(config)), sbw)
122         # if they only specify sbw, include jtag
123         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
124                 apps+= apps/jtag/jtag.o
125                 hdrs+= jtag.h
126         endif
127         apps+= apps/jtag/sbw.o
128 endif
129
130 # include jtag430 app
131 ifeq ($(filter jtag430, $(config)), jtag430)
132         # add in base jtag code if not already
133         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
134                 apps+= apps/jtag/jtag.o
135                 hdrs+= jtag.h
136         endif
137         # add in the jtag430asm code if needed
138         ifneq ($(filter apps/jtag/jtag430asm.o, $(libs)), apps/jtag/jtag430asm.o)
139                 apps+= apps/jtag/jtag430asm.o
140         endif
141         apps+= apps/jtag/jtag430.o
142         hdrs+= jtag430.h
143 endif
144
145 # include jtag430x2 app
146 ifeq ($(filter jtag430x2, $(config)), jtag430x2)
147         # add in base jtag code if not already
148         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
149                 apps+= apps/jtag/jtag.o
150                 hdrs+= jtag.h
151         endif
152         # add in the jtag430asm code if needed
153         ifneq ($(filter jtag430asm.o, $(libs)), jtag430asm.o)
154                 libs+= apps/jtag/jtag430asm.o
155         endif
156         #add in the jtag430 app if not already
157         ifneq ($(filter apps/jtag/jtag430.o, $(apps)), apps/jtag/jtag430.0)
158                 apps+= apps/jtag/jtag430.o
159                 hdrs+= jtag430.h
160         endif
161         apps+= apps/jtag/jtag430x2.o
162         hdrs+= jtag430x2.h
163 endif
164
165 # include i2c app
166 ifeq ($(filter i2c, $(config)), i2c)
167         apps+= apps/i2c/i2c.o
168         hdrs+= i2c.h
169 endif
170
171 # include jtagarm7 app
172 ifeq ($(filter jtagarm7, $(config)), jtagarm7)
173         # add in base jtag code if not already
174         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
175                 apps+= apps/jtag/jtag.o
176                 hdrs+= jtag.h
177         endif
178         apps+= apps/jtag/jtagarm7.o
179         hdrs+= jtagarm7.h
180 endif
181
182 # include jtagarm7tdmi app
183 #ifeq ($(filter jtagarm7tdmi, $(config)), jtagarm7tdmi)
184         # add in base jtag code if not already
185         #ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
186                 #apps+= apps/jtag/jtag.o
187                 #hdrs+= jtag.h
188         #endif
189         #apps+= apps/jtag/jtagarm7tdmi.o
190         #hdrs+= jtagarm7tdmi.h
191 #endif
192
193 # include ejtag app
194 ifeq ($(filter ejtag, $(config)), ejtag)
195         # add in base jtag code if not already
196         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
197                 apps+= apps/jtag/jtag.o
198                 hdrs+= jtag.h
199         endif
200         apps+= apps/jtag/ejtag.o
201         hdrs+= ejtag.h
202 endif
203
204 # include jtagxscale app
205 ifeq ($(filter jtagxscale, $(config)), jtagxscale)
206         # add in base jtag code if not already
207         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
208                 apps+= apps/jtag/jtag.o
209                 hdrs+= jtag.h
210         endif
211         apps+= apps/jtag/jtagxscale.o
212         hdrs+= jtagxscale.h
213 endif
214
215 # include chipcon app
216 ifeq ($(filter chipcon, $(config)), chipcon)
217         apps+= apps/chipcon/chipcon.o
218         hdrs+= chipcon.h
219 endif
220
221 # include avr app
222 ifeq ($(filter avr, $(config)), avr)
223         apps+= apps/avr/avr.o
224         hdrs+= avr.h
225 endif
226
227 # include pic app
228 ifeq ($(filter pic, $(config)), pic)
229         apps+= apps/pic/pic.o
230         hdrs+= pic.h
231 endif
232
233 # include adc app
234 ifeq ($(filter adc, $(config)), adc)
235         ifeq ($(mcu), msp430x2274)
236                 apps+= apps/adc/adc.o
237                 hdrs+= adc.h
238         else
239                 ERR= $(error The ADC app only works on GoodFET boards with the msp430x2274 processor)
240         endif
241 endif
242
243 # include chipcon radio spi app
244 ifeq ($(filter ccspi, $(config)), ccspi)
245         apps+= apps/radios/ccspi.o
246         hdrs+= ccspi.h
247 endif
248
249 # include nrf app
250 ifeq ($(filter nrf, $(config)), nrf)
251         apps+= apps/radios/nrf.o
252         hdrs+= nrf.h
253 endif
254
255 # include glitch app
256 ifeq ($(filter glitch, $(config)), glitch)
257         apps+= apps/glitch/glitch.o
258         hdrs+= glitch.h
259 endif
260
261 # include smartcard app
262 ifeq ($(filter smartcard, $(config)), smartcard)
263         apps+= apps/smartcard/smartcard.o
264         hdrs+= smartcard.h
265 endif
266
267 # include ps2 app
268 ifeq ($(filter ps2, $(config)), ps2)
269         apps+= apps/plugins/ps2.o
270         hdrs+= ps2.h
271 endif
272
273 # Rules
274
275 app= goodfet
276
277 all: $(app).hex
278
279 lib/.o: config
280         ./configure
281         false
282 lib/RUNCONFIG.o:
283         ./configure
284         false
285 config:
286         cp platforms/$(platform).h include/config.h
287 appsfiles:
288         ./gen_apps $(hdrs)
289 err:;$(ERR)
290 builddate:
291         ./gen_builddate_h
292 goodfet.hex: goodfet
293
294 run:
295         ../client/goodfet.msp430 test
296
297 install: $(app).hex
298         $(BSL) -e -p $(app).hex 
299         #ls info.txt && $(BSL) -P $(app).hex -p info.txt || true  #MSP430F2xx targets only, inelegant.
300 verify:
301         $(BSL) -P $(app).hex -v $(app).hex
302 dumpinfo:
303         $(BSL) --dumpinfo
304 $(app).c: config builddate appsfiles err
305 $(app): $(app).c $(libs) $(apps)
306 $(app).hex: $(app)
307         msp430-objcopy goodfet -O ihex goodfet.hex
308 m4s: $(app).hex
309         msp430-objdump -D -m msp430 $(app).hex | m4s init
310 erase:
311         $(BSL) -e 
312 clean:
313         rm -f $(app) $(app).hex $(libs) $(apps) lib/apps.c include/config.h include/builddate.h include/apps.h
314 docs:
315         doxygen
316 pushdocs: docs
317         rsync --exclude .svn -ave ssh doc/html/* travisutk,goodfet@web.sourceforge.net:htdocs/docs/
318 .FAKE: docs
319