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