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