Spy-Bi-Wire support, from examples by Mark rages.
[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 -I platforms $(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  chipcon nrf ccspi spi jtagarm7 jtag430 jtag430x2 avr
92
93 # New default.
94 config = monitor chipcon nrf spi jtagarm7 jtag430 jtag430x2 avr
95
96
97 # Build the needed list of app and lib object files from the config
98 apps= 
99 libs= lib/$(mcu).o lib/command.o lib/dco_calib.o lib/apps.o
100 hdrs=
101 ERR=
102
103 # include monitor app
104 ifeq ($(filter monitor, $(config)), monitor)
105         apps+= apps/monitor/monitor.o
106         hdrs+= monitor.h
107 endif
108
109 # include spi app
110 ifeq ($(filter spi, $(config)), spi)
111         apps+= apps/spi/spi.o
112         hdrs+= spi.h
113 endif
114
115 # include base jtag if they specified it explicitly
116 ifeq ($(filter jtag, $(config)), jtag)
117         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
118                 apps+= apps/jtag/jtag.o
119                 hdrs+= jtag.h
120         endif
121 endif
122
123 # include the sbw defs if they specified it
124 ifeq ($(filter sbw, $(config)), sbw)
125         # if they only specify sbw, include jtag
126         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
127                 apps+= apps/jtag/jtag.o
128                 hdrs+= jtag.h
129         endif
130         apps+= apps/jtag/sbw.o
131         hdrs+= sbw.h
132 endif
133
134 # include jtag430 app
135 ifeq ($(filter jtag430, $(config)), jtag430)
136         # add in base jtag code if not already
137         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
138                 apps+= apps/jtag/jtag.o
139                 hdrs+= jtag.h
140         endif
141         # add in the jtag430asm code if needed
142         ifneq ($(filter apps/jtag/jtag430asm.o, $(libs)), apps/jtag/jtag430asm.o)
143                 apps+= apps/jtag/jtag430asm.o
144         endif
145         apps+= apps/jtag/jtag430.o
146         hdrs+= jtag430.h
147 endif
148
149 # include jtag430x2 app
150 ifeq ($(filter jtag430x2, $(config)), jtag430x2)
151         # add in base jtag code if not already
152         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
153                 apps+= apps/jtag/jtag.o
154                 hdrs+= jtag.h
155         endif
156         # add in the jtag430asm code if needed
157         ifneq ($(filter jtag430asm.o, $(libs)), jtag430asm.o)
158                 libs+= apps/jtag/jtag430asm.o
159         endif
160         #add in the jtag430 app if not already
161         ifneq ($(filter apps/jtag/jtag430.o, $(apps)), apps/jtag/jtag430.0)
162                 apps+= apps/jtag/jtag430.o
163                 hdrs+= jtag430.h
164         endif
165         apps+= apps/jtag/jtag430x2.o
166         hdrs+= jtag430x2.h
167 endif
168
169 # include i2c app
170 ifeq ($(filter i2c, $(config)), i2c)
171         apps+= apps/i2c/i2c.o
172         hdrs+= i2c.h
173 endif
174
175 # include jtagarm7 app
176 ifeq ($(filter jtagarm7, $(config)), jtagarm7)
177         # add in base jtag code if not already
178         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
179                 apps+= apps/jtag/jtag.o
180                 hdrs+= jtag.h
181         endif
182         apps+= apps/jtag/jtagarm7.o
183         hdrs+= jtagarm7.h
184 endif
185
186 # include jtagarm7tdmi app
187 #ifeq ($(filter jtagarm7tdmi, $(config)), jtagarm7tdmi)
188         # add in base jtag code if not already
189         #ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
190                 #apps+= apps/jtag/jtag.o
191                 #hdrs+= jtag.h
192         #endif
193         #apps+= apps/jtag/jtagarm7tdmi.o
194         #hdrs+= jtagarm7tdmi.h
195 #endif
196
197 # include ejtag app
198 ifeq ($(filter ejtag, $(config)), ejtag)
199         # add in base jtag code if not already
200         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
201                 apps+= apps/jtag/jtag.o
202                 hdrs+= jtag.h
203         endif
204         apps+= apps/jtag/ejtag.o
205         hdrs+= ejtag.h
206 endif
207
208 # include jtagxscale app
209 ifeq ($(filter jtagxscale, $(config)), jtagxscale)
210         # add in base jtag code if not already
211         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
212                 apps+= apps/jtag/jtag.o
213                 hdrs+= jtag.h
214         endif
215         apps+= apps/jtag/jtagxscale.o
216         hdrs+= jtagxscale.h
217 endif
218
219 # include chipcon app
220 ifeq ($(filter chipcon, $(config)), chipcon)
221         apps+= apps/chipcon/chipcon.o
222         hdrs+= chipcon.h
223 endif
224
225 # include avr app
226 ifeq ($(filter avr, $(config)), avr)
227         apps+= apps/avr/avr.o
228         hdrs+= avr.h
229 endif
230
231
232
233 # include pic app
234 ifeq ($(filter pic, $(config)), pic)
235         apps+= apps/pic/pic.o
236         hdrs+= pic.h
237 endif
238
239 # include adc app
240 ifeq ($(filter adc, $(config)), adc)
241         ifeq ($(mcu), msp430x2274)
242                 apps+= apps/adc/adc.o
243                 hdrs+= adc.h
244         else
245                 ERR= $(error The ADC app only works on GoodFET boards with the msp430x2274 processor)
246         endif
247 endif
248
249 # include chipcon radio spi app
250 ifeq ($(filter ccspi, $(config)), ccspi)
251         apps+= apps/radios/ccspi.o
252         hdrs+= ccspi.h
253 endif
254
255 # include nrf app
256 ifeq ($(filter nrf, $(config)), nrf)
257         apps+= apps/radios/nrf.o
258         hdrs+= nrf.h
259 endif
260
261 # include glitch app
262 ifeq ($(filter glitch, $(config)), glitch)
263         apps+= apps/glitch/glitch.o
264         hdrs+= glitch.h
265 endif
266
267 # include smartcard app
268 ifeq ($(filter smartcard, $(config)), smartcard)
269         apps+= apps/smartcard/smartcard.o
270         hdrs+= smartcard.h
271 endif
272
273 # include ps2 app
274 ifeq ($(filter ps2, $(config)), ps2)
275         apps+= apps/plugins/ps2.o
276         hdrs+= ps2.h
277 endif
278
279 # Rules
280
281 app= goodfet
282
283 all: $(app).hex
284
285 lib/.o: config
286         ./configure
287         false
288 lib/RUNCONFIG.o:
289         ./configure
290         false
291 config:
292         cp platforms/$(platform).h include/config.h
293 appsfiles:
294         ./gen_apps $(hdrs)
295 err:;$(ERR)
296 builddate:
297         ./gen_builddate_h
298 goodfet.hex: goodfet
299
300 run:
301         ../client/goodfet.msp430 test
302
303 install: $(app).hex
304         $(BSL) -e -p $(app).hex 
305 installinfo:
306         $(BSL) -P $(app).hex -p info.txt || true  #MSP430F2xx targets only, inelegant.
307 verify:
308         $(BSL) -P $(app).hex -v $(app).hex
309 dumpinfo:
310         $(BSL) --dumpinfo
311 $(app).c: config builddate appsfiles err
312 $(app): $(app).c $(libs) $(apps)
313 $(app).hex: $(app)
314         msp430-objcopy goodfet -O ihex goodfet.hex
315 m4s: $(app).hex
316         msp430-objdump -D -m msp430 $(app).hex | m4s init
317 erase:
318         $(BSL) -e 
319 clean:
320         rm -f $(app) $(app).hex $(libs) $(apps) lib/apps.c include/config.h include/builddate.h include/apps.h
321 docs:
322         doxygen
323 pushdocs: docs
324         rsync --exclude .svn -ave ssh doc/html/* travisutk,goodfet@web.sourceforge.net:htdocs/docs/
325 .FAKE: docs
326