merging...
[goodfet] / firmware / Makefile
1
2 #include `uname`.mak
3 GOODFET?=/dev/ttyUSB0
4
5 #For tos-bsl, use --invert-reset --invert-test
6 BSL?=goodfet.bsl --speed=38400
7
8 #One of these should be defined explicitly.
9 #Default removed because of confusion.
10
11 #mcu=msp430x2274
12 mcu=msp430x2618
13 #mcu?=msp430x1612
14 #mcu?=RUNCONFIG
15
16 #platform=goodfet
17 #platform=telosb
18 #platform=z1
19 #platform=nhbadge
20 #platform=nhbadgeb
21 platform?=goodfet
22
23 #N.B., gcc WILL NOT BITCH if this file doesn't exist.
24 #GCCINC=-T ldscripts/161x.x
25 GCCINC=-T ldscripts/$(mcu).x
26
27 CCEXTRA?=
28 CC=msp430-gcc -Wall -Os -g -mmcu=$(mcu) -D$(mcu) -D$(platform) -Dplatform=$(platform) -DGCC $(GCCINC) -I include -I platforms $(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
54 #  Microcontrollers:
55 # chipcon -- Chipcon radio 8051 debugging
56 # avr -- AVR debugger
57 # pic -- PIC24H/dsPIC33F debugger
58 # adc -- ADC10 (still specific to x2274, GoodFET32)
59
60 #  Radios:
61 # nrf -- Nordic RF SPI
62 # ccspi -- Chipcon SPI
63
64 # Miscelaneous:
65 # glitch -- Glitch research tool
66 # smartcard -- Smartcard IO
67 # ps2 -- PS2 spy
68
69
70 # Configurations
71 # ==============
72 # This is what you need to customize to specify which apps you want in your
73 # firmware.  The "config" variable is just a space-delimited list of apps you
74 # want included.  The makefile will take the list of apps and include all of
75 # the proper code needed to build your desired firmware.
76
77 # bare minimum
78 # config = monitor
79
80 # basic JTAG adapter
81 # config = monitor jtag
82
83 # Chipcon hacking
84 # config = monitor chipcon ccspi
85
86 # Glitch research
87 # config = monitor glitch
88
89 # XScale PXA255 JTAG
90 # config = monitor jtagxscale
91
92 # Old Default Config
93 # config = monitor sbw  chipcon nrf ccspi spi jtagarm7 jtag430 jtag430x2 avr
94
95 # New default.
96 config ?= monitor chipcon ccspi nrf spi jtagarm7 jtag430 jtag430x2 avr
97
98 # Build the needed list of app and lib object files from the config
99 apps= 
100 libs= lib/$(mcu).o lib/command.o lib/dco_calib.o lib/apps.o
101 hdrs=
102 ERR=
103
104 # include monitor app
105 ifeq ($(filter monitor, $(config)), monitor)
106         apps+= apps/monitor/monitor.o
107         hdrs+= monitor.h
108 endif
109
110 # include spi app
111 ifeq ($(filter spi, $(config)), spi)
112         apps+= apps/spi/spi.o
113         hdrs+= spi.h
114 endif
115
116 # include base jtag if they specified it explicitly
117 ifeq ($(filter jtag, $(config)), jtag)
118         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
119                 apps+= apps/jtag/jtag.o
120                 hdrs+= jtag.h
121         endif
122 endif
123
124 # include the sbw defs if they specified it
125 ifeq ($(filter sbw, $(config)), sbw)
126         # if they only specify sbw, include jtag
127         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
128                 apps+= apps/jtag/jtag.o
129                 hdrs+= jtag.h
130         endif
131         apps+= apps/jtag/sbw.o
132         hdrs+= sbw.h
133 endif
134
135 # include jtag430 app
136 ifeq ($(filter jtag430, $(config)), jtag430)
137         # add in base jtag code if not already
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         # add in the jtag430asm code if needed
143         ifneq ($(filter apps/jtag/jtag430asm.o, $(libs)), apps/jtag/jtag430asm.o)
144                 apps+= apps/jtag/jtag430asm.o
145         endif
146         apps+= apps/jtag/jtag430.o
147         hdrs+= jtag430.h
148 endif
149
150 # include jtag430x2 app
151 ifeq ($(filter jtag430x2, $(config)), jtag430x2)
152         # add in base jtag code if not already
153         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
154                 apps+= apps/jtag/jtag.o
155                 hdrs+= jtag.h
156         endif
157         # add in the jtag430asm code if needed
158         ifneq ($(filter jtag430asm.o, $(libs)), jtag430asm.o)
159                 libs+= apps/jtag/jtag430asm.o
160         endif
161         #add in the jtag430 app if not already
162         ifneq ($(filter apps/jtag/jtag430.o, $(apps)), apps/jtag/jtag430.0)
163                 apps+= apps/jtag/jtag430.o
164                 hdrs+= jtag430.h
165         endif
166         apps+= apps/jtag/jtag430x2.o
167         hdrs+= jtag430x2.h
168 endif
169
170 # include i2c app
171 ifeq ($(filter i2c, $(config)), i2c)
172         apps+= apps/i2c/i2c.o
173         hdrs+= i2c.h
174 endif
175
176 # include jtagarm7 app
177 ifeq ($(filter jtagarm7, $(config)), jtagarm7)
178         # add in base jtag code if not already
179         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
180                 apps+= apps/jtag/jtag.o
181                 hdrs+= jtag.h
182         endif
183         apps+= apps/jtag/jtagarm7.o
184         hdrs+= jtagarm7.h
185 endif
186
187 # include jtagarm7tdmi app
188 #ifeq ($(filter jtagarm7tdmi, $(config)), jtagarm7tdmi)
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         #apps+= apps/jtag/jtagarm7tdmi.o
195         #hdrs+= jtagarm7tdmi.h
196 #endif
197
198 # include ejtag app
199 ifeq ($(filter ejtag, $(config)), ejtag)
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/ejtag.o
206         hdrs+= ejtag.h
207 endif
208
209 # include jtagxscale app
210 ifeq ($(filter jtagxscale, $(config)), jtagxscale)
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/jtagxscale.o
217         hdrs+= jtagxscale.h
218 endif
219
220 # include chipcon app
221 ifeq ($(filter chipcon, $(config)), chipcon)
222         apps+= apps/chipcon/chipcon.o
223         hdrs+= chipcon.h
224 endif
225
226 # include avr app
227 ifeq ($(filter avr, $(config)), avr)
228         apps+= apps/avr/avr.o
229         hdrs+= avr.h
230 endif
231
232 # include pic app
233 ifeq ($(filter pic, $(config)), pic)
234         apps+= apps/pic/pic.o
235         hdrs+= pic.h
236 endif
237
238 # include adc app
239 ifeq ($(filter adc, $(config)), adc)
240         ifeq ($(mcu), msp430x2274)
241                 apps+= apps/adc/adc.o
242                 hdrs+= adc.h
243         else
244                 ERR= $(error The ADC app only works on GoodFET boards with the msp430x2274 processor)
245         endif
246 endif
247
248 # include chipcon radio spi app
249 ifeq ($(filter ccspi, $(config)), ccspi)
250         apps+= apps/radios/ccspi.o
251         hdrs+= ccspi.h
252 endif
253
254 # include nrf app
255 ifeq ($(filter nrf, $(config)), nrf)
256         apps+= apps/radios/nrf.o
257         hdrs+= nrf.h
258 endif
259
260 # include glitch app
261 ifeq ($(filter glitch, $(config)), glitch)
262         apps+= apps/glitch/glitch.o
263         hdrs+= glitch.h
264 endif
265
266 # include smartcard app
267 ifeq ($(filter smartcard, $(config)), smartcard)
268         apps+= apps/smartcard/smartcard.o
269         hdrs+= smartcard.h
270 endif
271
272 # include ps2 app
273 ifeq ($(filter ps2, $(config)), ps2)
274         apps+= apps/plugins/ps2.o
275         hdrs+= ps2.h
276 endif
277
278 # Rules
279
280 app= goodfet
281
282 all: $(app).hex
283
284 lib/.o: config
285         ./configure
286         false
287 lib/RUNCONFIG.o:
288         ./configure
289         false
290 config:
291         cp platforms/$(platform).h include/config.h
292 appsfiles:
293         ./gen_apps $(hdrs)
294 err:;$(ERR)
295 builddate:
296         ./gen_builddate_h
297 goodfet.hex: goodfet
298
299 run:
300         ../client/goodfet.msp430 test
301
302 install: $(app).hex
303         $(BSL) -e -p $(app).hex 
304 installinfo:
305         $(BSL) -P $(app).hex -p info.txt || true  #MSP430F2xx targets only, inelegant.
306 verify:
307         $(BSL) -P $(app).hex -v $(app).hex
308 dumpinfo:
309         $(BSL) --dumpinfo
310 $(app).c: config builddate appsfiles err
311 $(app): $(libs) $(apps)
312 $(app).hex: $(app)
313         msp430-objcopy goodfet -O ihex goodfet.hex
314 m4s: $(app).hex
315         msp430-objdump -D -m msp430 $(app).hex | m4s init
316 erase:
317         $(BSL) -e 
318 clean:
319         rm -f $(app) $(app).hex $(libs) $(apps) lib/apps.c include/config.h include/builddate.h include/apps.h
320 docs:
321         doxygen
322 pushdocs: docs
323         rsync --exclude .svn -ave ssh doc/html/* travisutk,goodfet@web.sourceforge.net:htdocs/docs/
324 .FAKE: docs
325