Code for talking to the MAX3420 USB Device Controller.
[goodfet] / firmware / Makefile
1 -include config.mk
2
3
4 platform?=goodfet
5 mcu?=RUNCONFIG
6
7 #include `uname`.mak
8 GOODFET?=/dev/tty.usbser*
9
10 #For tos-bsl, use --invert-reset --invert-test
11 MSP430BSL?=goodfet.bsl --speed=38400
12 JTAG=msp430-jtag
13
14
15 #N.B., gcc WILL NOT BITCH if this file doesn't exist.
16 GCCINC?=
17
18 #GCC?=avr-gcc
19 # We use -Wl,-dT because gcc adds the msp430mcu definitions at the
20 # very end of the command line, so they only have an effect for a
21 # default linker script
22 GCC?=msp430-gcc
23 LDFLAGS?=-mmcu=$(mcu) #-Wl,-dT ldscripts/$(mcu).x
24
25 CCEXTRA?=  $(CFLAGS) -D$(mcu) -D$(platform) -Dplatform=$(platform) -Dboard=$(board) $(GCCINC) -I include -I platforms
26 CC=$(GCC) -Wall -O1 -fno-strict-aliasing -g -mmcu=$(mcu)  $(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 # openocd -- OpenOCD bitbang device
52
53 #  Microcontrollers:
54 # chipcon -- Chipcon radio 8051 debugging
55 # avr -- AVR debugger
56 # pic -- PIC24H/dsPIC33F debugger
57 # adc -- ADC10 (still specific to x2274, GoodFET32)
58
59 #  Radios:
60 # nrf -- Nordic RF SPI
61 # ccspi -- Chipcon SPI
62
63 # Miscelaneous:
64 # glitch -- Glitch research tool
65 # smartcard -- Smartcard IO
66 # ps2 -- PS2 spy
67
68
69 # Configurations
70 # ==============
71 # This is what you need to customize to specify which apps you want in your
72 # firmware.  The "config" variable is just a space-delimited list of apps you
73 # want included.  The makefile will take the list of apps and include all of
74 # the proper code needed to build your desired firmware.
75
76 # bare minimum
77 # config = monitor
78
79 # basic JTAG adapter
80 # config = monitor jtag
81
82 # Chipcon hacking
83 # config = monitor chipcon ccspi
84
85 # Glitch research
86 # config = monitor glitch
87
88 # XScale PXA255 JTAG
89 # config = monitor jtagxscale
90
91 # OpenOCD bit-bang device
92 #config = monitor openocd
93
94 # Old Default Config
95 # config = monitor sbw  chipcon nrf ccspi spi jtagarm7 jtag430 jtag430x2 avr
96
97 # New default.
98 ifeq ($(platform),tilaunchpad)
99 config ?= monitor chipcon i2c
100 else
101 config ?= monitor chipcon spi jtag430 jtag430x2 avr openocd ccspi
102 endif
103
104
105 # Build the needed list of app and lib object files from the config
106 apps=
107
108 ifeq ($(platform),tilaunchpad)
109 libs= lib/$(platform).o lib/command.o lib/apps.o lib/msp430_serial.o
110 #libs+=lib/setjmp.o
111 else
112 libs= lib/$(mcu).o lib/command.o lib/dco_calib.o lib/apps.o lib/msp430.o lib/arduino.o
113 endif
114
115 hdrs=
116 ERR=
117
118 # include monitor app
119 ifeq ($(filter monitor, $(config)), monitor)
120         apps+= apps/monitor/monitor.o
121         hdrs+= monitor.h
122 endif
123
124 # include spi app
125 ifeq ($(filter spi, $(config)), spi)
126         apps+= apps/spi/spi.o
127         hdrs+= spi.h
128 endif
129
130 # include twe app
131 ifeq ($(filter twe, $(config)), twe)
132         apps+= apps/twe/twe.o
133         hdrs+= twe.h
134 endif
135
136 # include base jtag if they specified it explicitly
137 ifeq ($(filter jtag, $(config)), jtag)
138         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
139                 apps+= apps/jtag/jtag.o
140                 hdrs+= jtag.h
141         endif
142 endif
143
144 # include MAX342x USB drivers.
145 ifeq ($(filter maxusb, $(config)), maxusb)
146         ifneq ($(filter apps/usb/maxusb.o, $(apps)), apps/usb/maxusb.o)
147                 apps+= apps/usb/maxusb.o
148                 hdrs+= maxusb.h
149         endif
150 endif
151
152 # include the sbw defs if they specified it
153 ifeq ($(filter sbw, $(config)), sbw)
154         # if they only specify sbw, include jtag
155         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
156                 apps+= apps/jtag/jtag.o
157                 hdrs+= jtag.h
158         endif
159         apps+= apps/jtag/sbw.o
160         hdrs+= sbw.h
161 endif
162
163 # include jtag430 app
164 ifeq ($(filter jtag430, $(config)), jtag430)
165         # add in base jtag code if not already
166         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
167                 apps+= apps/jtag/jtag.o
168                 hdrs+= jtag.h
169         endif
170         # add in the jtag430asm code if needed
171         ifneq ($(filter apps/jtag/jtag430asm.o, $(libs)), apps/jtag/jtag430asm.o)
172                 apps+= apps/jtag/jtag430asm.o
173         endif
174         apps+= apps/jtag/jtag430.o
175         hdrs+= jtag430.h
176 endif
177
178 # include jtag430x2 app
179 ifeq ($(filter jtag430x2, $(config)), jtag430x2)
180         # add in base jtag code if not already
181         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
182                 apps+= apps/jtag/jtag.o
183                 hdrs+= jtag.h
184         endif
185         # add in the jtag430asm code if needed
186         ifneq ($(filter jtag430asm.o, $(libs)), jtag430asm.o)
187                 libs+= apps/jtag/jtag430asm.o
188         endif
189         #add in the jtag430 app if not already
190         ifneq ($(filter apps/jtag/jtag430.o, $(apps)), apps/jtag/jtag430.0)
191                 apps+= apps/jtag/jtag430.o
192                 hdrs+= jtag430.h
193         endif
194         apps+= apps/jtag/jtag430x2.o
195         hdrs+= jtag430x2.h
196 endif
197
198 # include i2c app
199 ifeq ($(filter i2c, $(config)), i2c)
200         apps+= apps/i2c/i2c.o
201         hdrs+= i2c.h
202 endif
203
204 # include jtagarm7 app
205 ifeq ($(filter jtagarm7, $(config)), jtagarm7)
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/jtagarm7.o
212         hdrs+= jtagarm7.h
213 endif
214
215 # include jtagarm7tdmi app
216 #ifeq ($(filter jtagarm7tdmi, $(config)), jtagarm7tdmi)
217         # add in base jtag code if not already
218         #ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
219                 #apps+= apps/jtag/jtag.o
220                 #hdrs+= jtag.h
221         #endif
222         #apps+= apps/jtag/jtagarm7tdmi.o
223         #hdrs+= jtagarm7tdmi.h
224 #endif
225
226 # include ejtag app
227 ifeq ($(filter ejtag, $(config)), ejtag)
228         # add in base jtag code if not already
229         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
230                 apps+= apps/jtag/jtag.o
231                 hdrs+= jtag.h
232         endif
233         apps+= apps/jtag/ejtag.o
234         hdrs+= ejtag.h
235 endif
236
237 # include jtagxscale app
238 ifeq ($(filter jtagxscale, $(config)), jtagxscale)
239         # add in base jtag code if not already
240         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
241                 apps+= apps/jtag/jtag.o
242                 hdrs+= jtag.h
243         endif
244         apps+= apps/jtag/jtagxscale.o
245         hdrs+= jtagxscale.h
246 endif
247
248 # include openocd app
249 ifeq ($(filter openocd, $(config)), openocd)
250         # add in base jtag code if not already
251         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
252                 apps+= apps/jtag/jtag.o
253                 hdrs+= jtag.h
254         endif
255         apps+= apps/jtag/openocd.o
256         hdrs+= openocd.h
257 endif
258
259 # include chipcon app
260 ifeq ($(filter chipcon, $(config)), chipcon)
261         apps+= apps/chipcon/chipcon.o
262         hdrs+= chipcon.h
263 endif
264
265 # include avr app
266 ifeq ($(filter avr, $(config)), avr)
267         apps+= apps/avr/avr.o
268         hdrs+= avr.h
269 endif
270
271 # include pic app
272 ifeq ($(filter pic, $(config)), pic)
273         apps+= apps/pic/pic.o
274         hdrs+= pic.h
275 endif
276
277 # include adc app
278 ifeq ($(filter adc, $(config)), adc)
279         ifeq ($(mcu), msp430f2274)
280                 apps+= apps/adc/adc.o
281                 hdrs+= adc.h
282         else
283                 ERR= $(error The ADC app only works on GoodFET boards with the msp430x2274 processor)
284         endif
285 endif
286
287 # include chipcon radio spi app
288 ifeq ($(filter ccspi, $(config)), ccspi)
289         apps+= apps/radios/ccspi.o
290         hdrs+= ccspi.h
291 endif
292
293 # include nrf app
294 ifeq ($(filter nrf, $(config)), nrf)
295         apps+= apps/radios/nrf.o
296         hdrs+= nrf.h
297 endif
298
299 # include glitch app
300 ifeq ($(filter glitch, $(config)), glitch)
301         apps+= apps/glitch/glitch.o
302         hdrs+= glitch.h
303 endif
304
305 # include smartcard app
306 ifeq ($(filter smartcard, $(config)), smartcard)
307         apps+= apps/smartcard/smartcard.o
308         hdrs+= smartcard.h
309 endif
310
311 # include ps2 app
312 ifeq ($(filter ps2, $(config)), ps2)
313         apps+= apps/plugins/ps2.o
314         hdrs+= ps2.h
315 endif
316
317 # include jscan app
318 ifeq ($(filter jscan, $(config)), jscan)
319         apps+= apps/jscan/jscan.o
320         hdrs+= jscan.h
321 endif
322
323 # Rules
324
325 app= goodfet
326
327 all: $(app).hex
328
329 lib/.o: config
330         ./configure
331         false
332 lib/RUNCONFIG.o:
333         ./configure
334         false
335 config:
336         cp platforms/$(platform).h include/config.h
337 appsfiles:
338         ./gen_apps $(hdrs)
339 err:;$(ERR)
340 builddate:
341         ./gen_builddate_h
342 goodfet.hex: goodfet
343
344 run:
345         ../client/goodfet.msp430 test
346
347 avrinstall: $(app).hex
348         #to be merged
349         avrdude -V -F -c stk500v1 -p m328p -b 57600 -P $(GOODFET) -U flash:w:$(app).hex
350
351 ifeq ($(platform),tilaunchpad)
352 install: $(app).hex
353         $(JTAG) -e -p $(app).hex
354 verify:
355         $(JTAG) -v $(app).hex
356 erase:
357         $(JTAG) -e $(app).hex
358 else
359 install: $(app).hex
360         $(MSP430BSL) -e -p $(app).hex
361 installinfo:
362         $(MSP430BSL) -P $(app).hex -p info.txt || true  #MSP430F2xx targets only, inelegant.
363 verify:
364         $(MSP430BSL) -P $(app).hex -v $(app).hex
365 erase:
366         $(MSP430BSL) -e
367
368 endif
369 dumpinfo:
370         $(MSP430BSL) --dumpinfo
371 $(app).c: config builddate appsfiles err
372 $(app): $(libs) $(apps)
373
374 ifeq ($(platform),donbfet)
375 $(app).hex: $(app)
376         avr-objcopy -j .text -j .data -O ihex goodfet goodfet.hex
377 else
378 $(app).hex: $(app)
379         msp430-objcopy goodfet -O ihex goodfet.hex
380 endif
381 m4s: $(app).hex
382         msp430-objdump -D -m msp430 $(app).hex | m4s init
383 clean:
384         rm -f $(app) $(app).hex $(libs) $(apps) lib/apps.c include/config.h include/builddate.h include/apps.h
385 docs:
386         doxygen
387 pushdocs: docs
388         rsync --exclude .svn -ave ssh doc/html/* travisutk,goodfet@web.sourceforge.net:htdocs/docs/
389 .FAKE: docs
390