Arduino port is working, but only at 9600 baud.
[goodfet] / firmware / Makefile
1
2 #include `uname`.mak
3 GOODFET?=/dev/tty.usbser*
4
5 #For Arduino,
6 #BSL?=avrdude -V -F -c stk500v1 -p m328p -b 57600 -P /dev/tty.usbserial-* -U flash:w:blink.hex
7 #For tos-bsl, use --invert-reset --invert-test
8 MSP430BSL?=goodfet.bsl --speed=38400
9
10 #One of these should be defined explicitly.
11 #Default removed because of confusion.
12
13 #mcu?=msp430x2274
14 #mcu?=msp430x2618
15 #mcu?=msp430x1612
16 #mcu?=atmega168
17 mcu?=RUNCONFIG
18
19 #platform?=goodfet
20 #platform?=telosb
21 #platform?=z1
22 #platform?=nhbadge
23 #platform?=nhbadgeb
24 #platofrm?=arduino
25 platform?=goodfet
26
27 #N.B., gcc WILL NOT BITCH if this file doesn't exist.
28 GCCINC?=
29
30 #GCC?=avr-gcc
31 GCC?=msp430-gcc -T ldscripts/$(mcu).x
32
33 CCEXTRA?=  -D$(mcu) -D$(platform) -Dplatform=$(platform) -DGCC $(GCCINC) -I include -I platforms
34 CC=$(GCC) -Wall -Os -fno-strict-aliasing -g -mmcu=$(mcu)  $(CCEXTRA)
35
36 # Available Applications
37 # ======================
38 # Below is a list of available applications and their descriptions.
39
40 # PRODUCTION: 
41 # None have made it to production grade quality
42
43 # BETA:
44 # monitor -- Basic monitor
45 # spi -- Turns GF into USB-to-SPI adapter
46 # jtag -- Low level JTAG (needed by all other JTAG code)
47 # sbw -- Makes JTAG Spy-by-wire multiplexable
48
49 # ALPHA:
50 # jtag430 -- 16-bit MSP430 JTAG
51 # jtag430x2 -- 20-bit MSP430 JTAG
52
53 # PRE-ALPHA:
54 #  Bus protocols:
55 # i2c -- Turns GF into USB-to-i2c adapter
56 # jtagarm7 -- ARM7TDMI JTAG
57 # ejtag -- MIPS JTAG
58 # jtagxscale -- XScale JTAG
59 # openocd -- OpenOCD bitbang device
60
61 #  Microcontrollers:
62 # chipcon -- Chipcon radio 8051 debugging
63 # avr -- AVR debugger
64 # pic -- PIC24H/dsPIC33F debugger
65 # adc -- ADC10 (still specific to x2274, GoodFET32)
66
67 #  Radios:
68 # nrf -- Nordic RF SPI
69 # ccspi -- Chipcon SPI
70
71 # Miscelaneous:
72 # glitch -- Glitch research tool
73 # smartcard -- Smartcard IO
74 # ps2 -- PS2 spy
75
76
77 # Configurations
78 # ==============
79 # This is what you need to customize to specify which apps you want in your
80 # firmware.  The "config" variable is just a space-delimited list of apps you
81 # want included.  The makefile will take the list of apps and include all of
82 # the proper code needed to build your desired firmware.
83
84 # bare minimum
85 # config = monitor
86
87 # basic JTAG adapter
88 # config = monitor jtag
89
90 # Chipcon hacking
91 # config = monitor chipcon ccspi
92
93 # Glitch research
94 # config = monitor glitch
95
96 # XScale PXA255 JTAG
97 # config = monitor jtagxscale
98
99 # OpenOCD bit-bang device
100 #config = monitor openocd
101
102 # Old Default Config
103 # config = monitor sbw  chipcon nrf ccspi spi jtagarm7 jtag430 jtag430x2 avr
104
105 # New default.
106 config ?= monitor chipcon spi jtag430 jtag430x2 avr openocd ccspi
107
108 # Build the needed list of app and lib object files from the config
109 apps= 
110 libs= lib/$(mcu).o lib/command.o lib/dco_calib.o lib/apps.o lib/msp430.o lib/arduino.o
111 hdrs=
112 ERR=
113
114 # include monitor app
115 ifeq ($(filter monitor, $(config)), monitor)
116         apps+= apps/monitor/monitor.o
117         hdrs+= monitor.h
118 endif
119
120 # include spi app
121 ifeq ($(filter spi, $(config)), spi)
122         apps+= apps/spi/spi.o
123         hdrs+= spi.h
124 endif
125
126 # include base jtag if they specified it explicitly
127 ifeq ($(filter jtag, $(config)), jtag)
128         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
129                 apps+= apps/jtag/jtag.o
130                 hdrs+= jtag.h
131         endif
132 endif
133
134 # include the sbw defs if they specified it
135 ifeq ($(filter sbw, $(config)), sbw)
136         # if they only specify sbw, include jtag
137         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
138                 apps+= apps/jtag/jtag.o
139                 hdrs+= jtag.h
140         endif
141         apps+= apps/jtag/sbw.o
142         hdrs+= sbw.h
143 endif
144
145 # include jtag430 app
146 ifeq ($(filter jtag430, $(config)), jtag430)
147         # add in base jtag code if not already
148         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
149                 apps+= apps/jtag/jtag.o
150                 hdrs+= jtag.h
151         endif
152         # add in the jtag430asm code if needed
153         ifneq ($(filter apps/jtag/jtag430asm.o, $(libs)), apps/jtag/jtag430asm.o)
154                 apps+= apps/jtag/jtag430asm.o
155         endif
156         apps+= apps/jtag/jtag430.o
157         hdrs+= jtag430.h
158 endif
159
160 # include jtag430x2 app
161 ifeq ($(filter jtag430x2, $(config)), jtag430x2)
162         # add in base jtag code if not already
163         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
164                 apps+= apps/jtag/jtag.o
165                 hdrs+= jtag.h
166         endif
167         # add in the jtag430asm code if needed
168         ifneq ($(filter jtag430asm.o, $(libs)), jtag430asm.o)
169                 libs+= apps/jtag/jtag430asm.o
170         endif
171         #add in the jtag430 app if not already
172         ifneq ($(filter apps/jtag/jtag430.o, $(apps)), apps/jtag/jtag430.0)
173                 apps+= apps/jtag/jtag430.o
174                 hdrs+= jtag430.h
175         endif
176         apps+= apps/jtag/jtag430x2.o
177         hdrs+= jtag430x2.h
178 endif
179
180 # include i2c app
181 ifeq ($(filter i2c, $(config)), i2c)
182         apps+= apps/i2c/i2c.o
183         hdrs+= i2c.h
184 endif
185
186 # include jtagarm7 app
187 ifeq ($(filter jtagarm7, $(config)), jtagarm7)
188         # add in base jtag code if not already
189         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
190                 apps+= apps/jtag/jtag.o
191                 hdrs+= jtag.h
192         endif
193         apps+= apps/jtag/jtagarm7.o
194         hdrs+= jtagarm7.h
195 endif
196
197 # include jtagarm7tdmi app
198 #ifeq ($(filter jtagarm7tdmi, $(config)), jtagarm7tdmi)
199         # add in base jtag code if not already
200         #ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
201                 #apps+= apps/jtag/jtag.o
202                 #hdrs+= jtag.h
203         #endif
204         #apps+= apps/jtag/jtagarm7tdmi.o
205         #hdrs+= jtagarm7tdmi.h
206 #endif
207
208 # include ejtag app
209 ifeq ($(filter ejtag, $(config)), ejtag)
210         # add in base jtag code if not already
211         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
212                 apps+= apps/jtag/jtag.o
213                 hdrs+= jtag.h
214         endif
215         apps+= apps/jtag/ejtag.o
216         hdrs+= ejtag.h
217 endif
218
219 # include jtagxscale app
220 ifeq ($(filter jtagxscale, $(config)), jtagxscale)
221         # add in base jtag code if not already
222         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
223                 apps+= apps/jtag/jtag.o
224                 hdrs+= jtag.h
225         endif
226         apps+= apps/jtag/jtagxscale.o
227         hdrs+= jtagxscale.h
228 endif
229
230 # include openocd app
231 ifeq ($(filter openocd, $(config)), openocd)
232         # add in base jtag code if not already
233         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
234                 apps+= apps/jtag/jtag.o
235                 hdrs+= jtag.h
236         endif
237         apps+= apps/jtag/openocd.o
238         hdrs+= openocd.h
239 endif
240
241 # include chipcon app
242 ifeq ($(filter chipcon, $(config)), chipcon)
243         apps+= apps/chipcon/chipcon.o
244         hdrs+= chipcon.h
245 endif
246
247 # include avr app
248 ifeq ($(filter avr, $(config)), avr)
249         apps+= apps/avr/avr.o
250         hdrs+= avr.h
251 endif
252
253 # include pic app
254 ifeq ($(filter pic, $(config)), pic)
255         apps+= apps/pic/pic.o
256         hdrs+= pic.h
257 endif
258
259 # include adc app
260 ifeq ($(filter adc, $(config)), adc)
261         ifeq ($(mcu), msp430x2274)
262                 apps+= apps/adc/adc.o
263                 hdrs+= adc.h
264         else
265                 ERR= $(error The ADC app only works on GoodFET boards with the msp430x2274 processor)
266         endif
267 endif
268
269 # include chipcon radio spi app
270 ifeq ($(filter ccspi, $(config)), ccspi)
271         apps+= apps/radios/ccspi.o
272         hdrs+= ccspi.h
273 endif
274
275 # include nrf app
276 ifeq ($(filter nrf, $(config)), nrf)
277         apps+= apps/radios/nrf.o
278         hdrs+= nrf.h
279 endif
280
281 # include glitch app
282 ifeq ($(filter glitch, $(config)), glitch)
283         apps+= apps/glitch/glitch.o
284         hdrs+= glitch.h
285 endif
286
287 # include smartcard app
288 ifeq ($(filter smartcard, $(config)), smartcard)
289         apps+= apps/smartcard/smartcard.o
290         hdrs+= smartcard.h
291 endif
292
293 # include ps2 app
294 ifeq ($(filter ps2, $(config)), ps2)
295         apps+= apps/plugins/ps2.o
296         hdrs+= ps2.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 install: $(app).hex
327         $(MSP430BSL) -e -p $(app).hex 
328 installinfo:
329         $(MSP430BSL) -P $(app).hex -p info.txt || true  #MSP430F2xx targets only, inelegant.
330 verify:
331         $(MSP430BSL) -P $(app).hex -v $(app).hex
332 dumpinfo:
333         $(MSP430BSL) --dumpinfo
334 $(app).c: config builddate appsfiles err
335 $(app): $(libs) $(apps)
336 $(app).hex: $(app)
337         msp430-objcopy goodfet -O ihex goodfet.hex
338 m4s: $(app).hex
339         msp430-objdump -D -m msp430 $(app).hex | m4s init
340 erase:
341         $(MSP430BSL) -e 
342 clean:
343         rm -f $(app) $(app).hex $(libs) $(apps) lib/apps.c include/config.h include/builddate.h include/apps.h
344 docs:
345         doxygen
346 pushdocs: docs
347         rsync --exclude .svn -ave ssh doc/html/* travisutk,goodfet@web.sourceforge.net:htdocs/docs/
348 .FAKE: docs
349