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