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