TI Launchpad patch from Peter Lorenzen, edited to ease the mergequake.
[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 base jtag if they specified it explicitly
148 ifeq ($(filter jtag, $(config)), jtag)
149         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
150                 apps+= apps/jtag/jtag.o
151                 hdrs+= jtag.h
152         endif
153 endif
154
155 # include the sbw defs if they specified it
156 ifeq ($(filter sbw, $(config)), sbw)
157         # if they only specify sbw, include jtag
158         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
159                 apps+= apps/jtag/jtag.o
160                 hdrs+= jtag.h
161         endif
162         apps+= apps/jtag/sbw.o
163         hdrs+= sbw.h
164 endif
165
166 # include jtag430 app
167 ifeq ($(filter jtag430, $(config)), jtag430)
168         # add in base jtag code if not already
169         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
170                 apps+= apps/jtag/jtag.o
171                 hdrs+= jtag.h
172         endif
173         # add in the jtag430asm code if needed
174         ifneq ($(filter apps/jtag/jtag430asm.o, $(libs)), apps/jtag/jtag430asm.o)
175                 apps+= apps/jtag/jtag430asm.o
176         endif
177         apps+= apps/jtag/jtag430.o
178         hdrs+= jtag430.h
179 endif
180
181 # include jtag430x2 app
182 ifeq ($(filter jtag430x2, $(config)), jtag430x2)
183         # add in base jtag code if not already
184         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
185                 apps+= apps/jtag/jtag.o
186                 hdrs+= jtag.h
187         endif
188         # add in the jtag430asm code if needed
189         ifneq ($(filter jtag430asm.o, $(libs)), jtag430asm.o)
190                 libs+= apps/jtag/jtag430asm.o
191         endif
192         #add in the jtag430 app if not already
193         ifneq ($(filter apps/jtag/jtag430.o, $(apps)), apps/jtag/jtag430.0)
194                 apps+= apps/jtag/jtag430.o
195                 hdrs+= jtag430.h
196         endif
197         apps+= apps/jtag/jtag430x2.o
198         hdrs+= jtag430x2.h
199 endif
200
201 # include i2c app
202 ifeq ($(filter i2c, $(config)), i2c)
203         apps+= apps/i2c/i2c.o
204         hdrs+= i2c.h
205 endif
206
207 # include jtagarm7 app
208 ifeq ($(filter jtagarm7, $(config)), jtagarm7)
209         # add in base jtag code if not already
210         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
211                 apps+= apps/jtag/jtag.o
212                 hdrs+= jtag.h
213         endif
214         apps+= apps/jtag/jtagarm7.o
215         hdrs+= jtagarm7.h
216 endif
217
218 # include jtagarm7tdmi app
219 #ifeq ($(filter jtagarm7tdmi, $(config)), jtagarm7tdmi)
220         # add in base jtag code if not already
221         #ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
222                 #apps+= apps/jtag/jtag.o
223                 #hdrs+= jtag.h
224         #endif
225         #apps+= apps/jtag/jtagarm7tdmi.o
226         #hdrs+= jtagarm7tdmi.h
227 #endif
228
229 # include ejtag app
230 ifeq ($(filter ejtag, $(config)), ejtag)
231         # add in base jtag code if not already
232         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
233                 apps+= apps/jtag/jtag.o
234                 hdrs+= jtag.h
235         endif
236         apps+= apps/jtag/ejtag.o
237         hdrs+= ejtag.h
238 endif
239
240 # include jtagxscale app
241 ifeq ($(filter jtagxscale, $(config)), jtagxscale)
242         # add in base jtag code if not already
243         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
244                 apps+= apps/jtag/jtag.o
245                 hdrs+= jtag.h
246         endif
247         apps+= apps/jtag/jtagxscale.o
248         hdrs+= jtagxscale.h
249 endif
250
251 # include openocd app
252 ifeq ($(filter openocd, $(config)), openocd)
253         # add in base jtag code if not already
254         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
255                 apps+= apps/jtag/jtag.o
256                 hdrs+= jtag.h
257         endif
258         apps+= apps/jtag/openocd.o
259         hdrs+= openocd.h
260 endif
261
262 # include chipcon app
263 ifeq ($(filter chipcon, $(config)), chipcon)
264         apps+= apps/chipcon/chipcon.o
265         hdrs+= chipcon.h
266 endif
267
268 # include avr app
269 ifeq ($(filter avr, $(config)), avr)
270         apps+= apps/avr/avr.o
271         hdrs+= avr.h
272 endif
273
274 # include pic app
275 ifeq ($(filter pic, $(config)), pic)
276         apps+= apps/pic/pic.o
277         hdrs+= pic.h
278 endif
279
280 # include adc app
281 ifeq ($(filter adc, $(config)), adc)
282         ifeq ($(mcu), msp430x2274)
283                 apps+= apps/adc/adc.o
284                 hdrs+= adc.h
285         else
286                 ERR= $(error The ADC app only works on GoodFET boards with the msp430x2274 processor)
287         endif
288 endif
289
290 # include chipcon radio spi app
291 ifeq ($(filter ccspi, $(config)), ccspi)
292         apps+= apps/radios/ccspi.o
293         hdrs+= ccspi.h
294 endif
295
296 # include nrf app
297 ifeq ($(filter nrf, $(config)), nrf)
298         apps+= apps/radios/nrf.o
299         hdrs+= nrf.h
300 endif
301
302 # include glitch app
303 ifeq ($(filter glitch, $(config)), glitch)
304         apps+= apps/glitch/glitch.o
305         hdrs+= glitch.h
306 endif
307
308 # include smartcard app
309 ifeq ($(filter smartcard, $(config)), smartcard)
310         apps+= apps/smartcard/smartcard.o
311         hdrs+= smartcard.h
312 endif
313
314 # include ps2 app
315 ifeq ($(filter ps2, $(config)), ps2)
316         apps+= apps/plugins/ps2.o
317         hdrs+= ps2.h
318 endif
319
320 # Rules
321
322 app= goodfet
323
324 all: $(app).hex
325
326 lib/.o: config
327         ./configure
328         false
329 lib/RUNCONFIG.o:
330         ./configure
331         false
332 config:
333         cp platforms/$(platform).h include/config.h
334 appsfiles:
335         ./gen_apps $(hdrs)
336 err:;$(ERR)
337 builddate:
338         ./gen_builddate_h
339 goodfet.hex: goodfet
340
341 run:
342         ../client/goodfet.msp430 test
343
344 avrinstall: $(app).hex
345         #to be merged
346         avrdude -V -F -c stk500v1 -p m328p -b 57600 -P $(GOODFET) -U flash:w:$(app).hex
347
348 ifeq ($(platform),tilaunchpad)
349 install: $(app).hex
350         $(JTAG) -e -p $(app).hex
351 verify:
352         $(JTAG) -v $(app).hex
353 erase:
354         $(JTAG) -e $(app).hex
355 else
356 install: $(app).hex
357         $(MSP430BSL) -e -p $(app).hex 
358 installinfo:
359         $(MSP430BSL) -P $(app).hex -p info.txt || true  #MSP430F2xx targets only, inelegant.
360 verify:
361         $(MSP430BSL) -P $(app).hex -v $(app).hex
362 endif
363 dumpinfo:
364         $(MSP430BSL) --dumpinfo
365 erase:
366         $(MSP430BSL) -e 
367 $(app).c: config builddate appsfiles err
368 $(app): $(libs) $(apps)
369 $(app).hex: $(app)
370         msp430-objcopy goodfet -O ihex goodfet.hex
371 m4s: $(app).hex
372         msp430-objdump -D -m msp430 $(app).hex | m4s init
373 clean:
374         rm -f $(app) $(app).hex $(libs) $(apps) lib/apps.c include/config.h include/builddate.h include/apps.h
375 docs:
376         doxygen
377 pushdocs: docs
378         rsync --exclude .svn -ave ssh doc/html/* travisutk,goodfet@web.sourceforge.net:htdocs/docs/
379 .FAKE: docs
380