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