bug fixes in mainDisplay and spit method of GoodFETMCPCANCommunication
[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 # jtagarm7 -- ARM7TDMI JTAG
41
42 # PRE-ALPHA:
43 #  Bus protocols:
44 # i2c -- Turns GF into USB-to-i2c adapter
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 #  Radions:
56 # nrf -- Nordic RF SPI
57 # ccspi -- Chipcon SPI
58 # atmel_radio -- Atmel radio
59
60 # Miscelaneous:
61 # glitch -- Glitch research tool
62 # smartcard -- Smartcard IO
63 # ps2 -- PS2 spy
64
65
66 # Configurations
67 # ==============
68 # This is what you need to customize to specify which apps you want in
69 # your firmware.  The "config" variable is just a space-delimited list
70 # of apps you want included.  The makefile will take the list of apps
71 # and include all of the proper code needed to build your desired
72 # firmware.  $(config) is generated by config.mk.
73
74
75
76 # Build the needed list of app and lib object files from the config
77 apps=
78
79 ifeq ($(platform),tilaunchpad)
80 libs= lib/$(platform).o lib/command.o lib/apps.o lib/msp430_serial.o
81 #libs+=lib/setjmp.o
82 else
83 libs= lib/$(mcu).o lib/command.o lib/dco_calib.o lib/apps.o lib/msp430.o lib/arduino.o $(extralibs)
84 endif
85
86 hdrs=
87 ERR=
88
89 # include monitor app
90 ifeq ($(filter monitor, $(config)), monitor)
91         apps+= apps/monitor/monitor.o
92         hdrs+= monitor.h
93 endif
94
95 # include spi app
96 ifeq ($(filter spi, $(config)), spi)
97         apps+= apps/spi/spi.o
98         hdrs+= spi.h
99 endif
100
101 # include twe app
102 ifeq ($(filter twe, $(config)), twe)
103         apps+= apps/twe/twe.o
104         hdrs+= twe.h
105 endif
106
107 # include base jtag if they specified it explicitly
108 ifeq ($(filter jtag, $(config)), jtag)
109         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
110                 apps+= apps/jtag/jtag.o
111                 hdrs+= jtag.h
112         endif
113 endif
114
115 # include MAX342x USB drivers.
116 ifeq ($(filter maxusb, $(config)), maxusb)
117         ifneq ($(filter apps/usb/maxusb.o, $(apps)), apps/usb/maxusb.o)
118                 apps+= apps/usb/maxusb.o
119                 hdrs+= maxusb.h
120         endif
121 endif
122
123 # include the sbw defs if they specified it
124 ifeq ($(filter sbw, $(config)), sbw)
125         # if they only specify sbw, include jtag
126         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
127                 apps+= apps/jtag/jtag.o
128                 hdrs+= jtag.h
129         endif
130         apps+= apps/jtag/sbw.o
131         hdrs+= sbw.h
132 endif
133
134 # include jtag430 app
135 ifeq ($(filter jtag430, $(config)), jtag430)
136         # add in base jtag code if not already
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         # add in the jtag430asm code if needed
142         ifneq ($(filter apps/jtag/jtag430asm.o, $(libs)), apps/jtag/jtag430asm.o)
143                 apps+= apps/jtag/jtag430asm.o
144         endif
145         apps+= apps/jtag/jtag430.o
146         hdrs+= jtag430.h
147 endif
148
149 # include jtag430x2 app
150 ifeq ($(filter jtag430x2, $(config)), jtag430x2)
151         # add in base jtag code if not already
152         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
153                 apps+= apps/jtag/jtag.o
154                 hdrs+= jtag.h
155         endif
156         # add in the jtag430asm code if needed
157         ifneq ($(filter jtag430asm.o, $(libs)), jtag430asm.o)
158                 libs+= apps/jtag/jtag430asm.o
159         endif
160         #add in the jtag430 app if not already
161         ifneq ($(filter apps/jtag/jtag430.o, $(apps)), apps/jtag/jtag430.0)
162                 apps+= apps/jtag/jtag430.o
163                 hdrs+= jtag430.h
164         endif
165         apps+= apps/jtag/jtag430x2.o
166         hdrs+= jtag430x2.h
167 endif
168
169 # include i2c app
170 ifeq ($(filter i2c, $(config)), i2c)
171         apps+= apps/i2c/i2c.o
172         hdrs+= i2c.h
173 endif
174
175 # include jtagarm7 app
176 ifeq ($(filter jtagarm7, $(config)), jtagarm7)
177         # add in base jtag code if not already
178         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
179                 apps+= apps/jtag/jtag.o
180                 hdrs+= jtag.h
181         endif
182         apps+= apps/jtag/jtagarm7.o
183         hdrs+= jtagarm7.h
184 endif
185
186 # include jtagarm7tdmi app
187 #ifeq ($(filter jtagarm7tdmi, $(config)), jtagarm7tdmi)
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/jtagarm7tdmi.o
194         #hdrs+= jtagarm7tdmi.h
195 #endif
196
197 # include ejtag app
198 ifeq ($(filter ejtag, $(config)), ejtag)
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/ejtag.o
205         hdrs+= ejtag.h
206 endif
207
208 # include jtagxscale app
209 ifeq ($(filter jtagxscale, $(config)), jtagxscale)
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/jtagxscale.o
216         hdrs+= jtagxscale.h
217 endif
218
219 # include openocd app
220 ifeq ($(filter openocd, $(config)), openocd)
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/openocd.o
227         hdrs+= openocd.h
228 endif
229
230 # include chipcon app
231 ifeq ($(filter chipcon, $(config)), chipcon)
232         apps+= apps/chipcon/chipcon.o
233         hdrs+= chipcon.h
234 endif
235
236 # include avr app
237 ifeq ($(filter avr, $(config)), avr)
238         apps+= apps/avr/avr.o
239         hdrs+= avr.h
240 endif
241
242 # include pic app
243 ifeq ($(filter pic, $(config)), pic)
244         apps+= apps/pic/pic.o
245         hdrs+= pic.h
246 endif
247
248 # include adc app
249 ifeq ($(filter adc, $(config)), adc)
250         ifeq ($(mcu), msp430f2274)
251                 apps+= apps/adc/adc.o
252                 hdrs+= adc.h
253         else
254                 ERR= $(error The ADC app only works on GoodFET boards with the msp430x2274 processor)
255         endif
256 endif
257
258 # include chipcon radio spi app
259 ifeq ($(filter ccspi, $(config)), ccspi)
260         apps+= apps/radios/ccspi.o
261         hdrs+= ccspi.h
262 endif
263
264 # include nrf app
265 ifeq ($(filter nrf, $(config)), nrf)
266         apps+= apps/radios/nrf.o
267         hdrs+= nrf.h
268 endif
269
270 # include atmel_radio app
271 ifeq ($(filter atmel_radio, $(config)), atmel_radio)
272         apps+= apps/radios/atmel_radio.o
273         hdrs+= atmel_radio.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 plugin app
289 ifeq ($(filter plugin, $(config)), plugin)
290         apps+= apps/plugin.o
291         hdrs+= plugin.h
292 endif
293
294 # include jscan app
295 ifeq ($(filter jscan, $(config)), jscan)
296         apps+= apps/jscan/jscan.o
297         hdrs+= jscan.h
298 endif
299
300 # Rules
301
302 app= goodfet
303
304 all: $(app).hex
305
306 lib/.o: config
307         ./configure
308         false
309 lib/RUNCONFIG.o:
310         ./configure
311         false
312 config:
313         cp platforms/$(platform).h include/config.h
314 appsfiles:
315         ./gen_apps $(hdrs)
316 err:;$(ERR)
317 builddate:
318         ./gen_builddate_h
319 goodfet.hex: goodfet
320
321 run:
322         ../client/goodfet.msp430 test
323
324 avrinstall: $(app).hex
325         #to be merged
326 ifdef AVR_PLATFORM
327         avrdude -V -F -c stk500v1 -p $(AVR_PLATFORM) -b 57600 -P $(GOODFET) -U flash:w:$(app).hex
328 else
329         avrdude -V -F -c stk500v1 -p m328p -b 57600 -P $(GOODFET) -U flash:w:$(app).hex
330 endif
331
332 ifeq ($(platform),tilaunchpad)
333 install: $(app).hex
334         $(JTAG) -e -p $(app).hex
335 verify:
336         $(JTAG) -v $(app).hex
337 erase:
338         $(JTAG) -e $(app).hex
339 else
340 install: $(app).hex
341         #Note that 'make install' no longer erases the chip.
342         #Use 'make reinstall' if you want that.
343         $(MSP430BSL) -p $(app).hex
344 reinstall: $(app).hex
345         $(MSP430BSL) -e -p $(app).hex
346 installinfo:
347         $(MSP430BSL) -P $(app).hex -p info.txt || true  #MSP430F2xx targets only, inelegant.
348 verify:
349         $(MSP430BSL) -P $(app).hex -v $(app).hex
350 erase:
351         $(MSP430BSL) -e
352
353 endif
354 dumpinfo:
355         $(MSP430BSL) --dumpinfo
356 $(app).c: config builddate appsfiles err
357 $(app): $(app).o $(libs) $(apps) 
358 armlink: $(app).o $(libs) $(apps) $(platformlibs)
359         arm-none-eabi-ld -v -Tlinkers/stm32f407.cmd -nostartfiles -o goodfet.elf $(app).o $(libs) $(apps)
360         arm-none-eabi-objcopy -Obinary goodfet.elf goodfet.bin
361 ifeq ($(platform),donbfet)
362 $(app).hex: $(app)
363         avr-objcopy -j .text -j .data -O ihex goodfet goodfet.hex
364 else
365 $(app).hex: $(app)
366         msp430-objcopy goodfet -O ihex goodfet.hex
367 endif
368 m4s: $(app).hex
369         msp430-objdump -D -m msp430 $(app).hex | m4s init
370 clean:
371         rm -f *.o $(app) $(app).hex $(libs) $(apps) lib/apps.c include/config.h include/builddate.h include/apps.h
372 docs:
373         doxygen
374 pushdocs: docs
375         rsync --exclude .svn -ave ssh doc/html/* travisutk,goodfet@web.sourceforge.net:htdocs/docs/
376 .FAKE: docs
377