The STM32 UART is finally running.
[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.  $(config) is generated by config.mk.
72
73
74
75 # Build the needed list of app and lib object files from the config
76 apps=
77
78 ifeq ($(platform),tilaunchpad)
79 libs= lib/$(platform).o lib/command.o lib/apps.o lib/msp430_serial.o
80 #libs+=lib/setjmp.o
81 else
82 libs= lib/$(mcu).o lib/command.o lib/dco_calib.o lib/apps.o lib/msp430.o lib/arduino.o $(extralibs)
83 endif
84
85 hdrs=
86 ERR=
87
88 # include monitor app
89 ifeq ($(filter monitor, $(config)), monitor)
90         apps+= apps/monitor/monitor.o
91         hdrs+= monitor.h
92 endif
93
94 # include spi app
95 ifeq ($(filter spi, $(config)), spi)
96         apps+= apps/spi/spi.o
97         hdrs+= spi.h
98 endif
99
100 # include twe app
101 ifeq ($(filter twe, $(config)), twe)
102         apps+= apps/twe/twe.o
103         hdrs+= twe.h
104 endif
105
106 # include base jtag if they specified it explicitly
107 ifeq ($(filter jtag, $(config)), jtag)
108         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
109                 apps+= apps/jtag/jtag.o
110                 hdrs+= jtag.h
111         endif
112 endif
113
114 # include MAX342x USB drivers.
115 ifeq ($(filter maxusb, $(config)), maxusb)
116         ifneq ($(filter apps/usb/maxusb.o, $(apps)), apps/usb/maxusb.o)
117                 apps+= apps/usb/maxusb.o
118                 hdrs+= maxusb.h
119         endif
120 endif
121
122 # include the sbw defs if they specified it
123 ifeq ($(filter sbw, $(config)), sbw)
124         # if they only specify sbw, include jtag
125         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
126                 apps+= apps/jtag/jtag.o
127                 hdrs+= jtag.h
128         endif
129         apps+= apps/jtag/sbw.o
130         hdrs+= sbw.h
131 endif
132
133 # include jtag430 app
134 ifeq ($(filter jtag430, $(config)), jtag430)
135         # add in base jtag code if not already
136         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
137                 apps+= apps/jtag/jtag.o
138                 hdrs+= jtag.h
139         endif
140         # add in the jtag430asm code if needed
141         ifneq ($(filter apps/jtag/jtag430asm.o, $(libs)), apps/jtag/jtag430asm.o)
142                 apps+= apps/jtag/jtag430asm.o
143         endif
144         apps+= apps/jtag/jtag430.o
145         hdrs+= jtag430.h
146 endif
147
148 # include jtag430x2 app
149 ifeq ($(filter jtag430x2, $(config)), jtag430x2)
150         # add in base jtag code if not already
151         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
152                 apps+= apps/jtag/jtag.o
153                 hdrs+= jtag.h
154         endif
155         # add in the jtag430asm code if needed
156         ifneq ($(filter jtag430asm.o, $(libs)), jtag430asm.o)
157                 libs+= apps/jtag/jtag430asm.o
158         endif
159         #add in the jtag430 app if not already
160         ifneq ($(filter apps/jtag/jtag430.o, $(apps)), apps/jtag/jtag430.0)
161                 apps+= apps/jtag/jtag430.o
162                 hdrs+= jtag430.h
163         endif
164         apps+= apps/jtag/jtag430x2.o
165         hdrs+= jtag430x2.h
166 endif
167
168 # include i2c app
169 ifeq ($(filter i2c, $(config)), i2c)
170         apps+= apps/i2c/i2c.o
171         hdrs+= i2c.h
172 endif
173
174 # include jtagarm7 app
175 ifeq ($(filter jtagarm7, $(config)), jtagarm7)
176         # add in base jtag code if not already
177         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
178                 apps+= apps/jtag/jtag.o
179                 hdrs+= jtag.h
180         endif
181         apps+= apps/jtag/jtagarm7.o
182         hdrs+= jtagarm7.h
183 endif
184
185 # include jtagarm7tdmi app
186 #ifeq ($(filter jtagarm7tdmi, $(config)), jtagarm7tdmi)
187         # add in base jtag code if not already
188         #ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
189                 #apps+= apps/jtag/jtag.o
190                 #hdrs+= jtag.h
191         #endif
192         #apps+= apps/jtag/jtagarm7tdmi.o
193         #hdrs+= jtagarm7tdmi.h
194 #endif
195
196 # include ejtag app
197 ifeq ($(filter ejtag, $(config)), ejtag)
198         # add in base jtag code if not already
199         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
200                 apps+= apps/jtag/jtag.o
201                 hdrs+= jtag.h
202         endif
203         apps+= apps/jtag/ejtag.o
204         hdrs+= ejtag.h
205 endif
206
207 # include jtagxscale app
208 ifeq ($(filter jtagxscale, $(config)), jtagxscale)
209         # add in base jtag code if not already
210         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
211                 apps+= apps/jtag/jtag.o
212                 hdrs+= jtag.h
213         endif
214         apps+= apps/jtag/jtagxscale.o
215         hdrs+= jtagxscale.h
216 endif
217
218 # include openocd app
219 ifeq ($(filter openocd, $(config)), openocd)
220         # add in base jtag code if not already
221         ifneq ($(filter apps/jtag/jtag.o, $(apps)), apps/jtag/jtag.o)
222                 apps+= apps/jtag/jtag.o
223                 hdrs+= jtag.h
224         endif
225         apps+= apps/jtag/openocd.o
226         hdrs+= openocd.h
227 endif
228
229 # include chipcon app
230 ifeq ($(filter chipcon, $(config)), chipcon)
231         apps+= apps/chipcon/chipcon.o
232         hdrs+= chipcon.h
233 endif
234
235 # include avr app
236 ifeq ($(filter avr, $(config)), avr)
237         apps+= apps/avr/avr.o
238         hdrs+= avr.h
239 endif
240
241 # include pic app
242 ifeq ($(filter pic, $(config)), pic)
243         apps+= apps/pic/pic.o
244         hdrs+= pic.h
245 endif
246
247 # include adc app
248 ifeq ($(filter adc, $(config)), adc)
249         ifeq ($(mcu), msp430f2274)
250                 apps+= apps/adc/adc.o
251                 hdrs+= adc.h
252         else
253                 ERR= $(error The ADC app only works on GoodFET boards with the msp430x2274 processor)
254         endif
255 endif
256
257 # include chipcon radio spi app
258 ifeq ($(filter ccspi, $(config)), ccspi)
259         apps+= apps/radios/ccspi.o
260         hdrs+= ccspi.h
261 endif
262
263 # include nrf app
264 ifeq ($(filter nrf, $(config)), nrf)
265         apps+= apps/radios/nrf.o
266         hdrs+= nrf.h
267 endif
268
269 # include glitch app
270 ifeq ($(filter glitch, $(config)), glitch)
271         apps+= apps/glitch/glitch.o
272         hdrs+= glitch.h
273 endif
274
275 # include smartcard app
276 ifeq ($(filter smartcard, $(config)), smartcard)
277         apps+= apps/smartcard/smartcard.o
278         hdrs+= smartcard.h
279 endif
280
281 # include ps2 app
282 ifeq ($(filter ps2, $(config)), ps2)
283         apps+= apps/plugins/ps2.o
284         hdrs+= ps2.h
285 endif
286
287 # include jscan app
288 ifeq ($(filter jscan, $(config)), jscan)
289         apps+= apps/jscan/jscan.o
290         hdrs+= jscan.h
291 endif
292
293 # Rules
294
295 app= goodfet
296
297 all: $(app).hex
298
299 lib/.o: config
300         ./configure
301         false
302 lib/RUNCONFIG.o:
303         ./configure
304         false
305 config:
306         cp platforms/$(platform).h include/config.h
307 appsfiles:
308         ./gen_apps $(hdrs)
309 err:;$(ERR)
310 builddate:
311         ./gen_builddate_h
312 goodfet.hex: goodfet
313
314 run:
315         ../client/goodfet.msp430 test
316
317 avrinstall: $(app).hex
318         #to be merged
319         avrdude -V -F -c stk500v1 -p m328p -b 57600 -P $(GOODFET) -U flash:w:$(app).hex
320
321 ifeq ($(platform),tilaunchpad)
322 install: $(app).hex
323         $(JTAG) -e -p $(app).hex
324 verify:
325         $(JTAG) -v $(app).hex
326 erase:
327         $(JTAG) -e $(app).hex
328 else
329 install: $(app).hex
330         $(MSP430BSL) -e -p $(app).hex
331 installinfo:
332         $(MSP430BSL) -P $(app).hex -p info.txt || true  #MSP430F2xx targets only, inelegant.
333 verify:
334         $(MSP430BSL) -P $(app).hex -v $(app).hex
335 erase:
336         $(MSP430BSL) -e
337
338 endif
339 dumpinfo:
340         $(MSP430BSL) --dumpinfo
341 $(app).c: config builddate appsfiles err
342 $(app): $(app).o $(libs) $(apps) 
343 armlink: $(app).o $(libs) $(apps) $(platformlibs)
344         arm-none-eabi-ld -v -Tlinkers/stm32f407.cmd -nostartfiles -o goodfet.elf $(app).o $(libs) $(apps)
345         arm-none-eabi-objcopy -Obinary goodfet.elf goodfet.bin
346 ifeq ($(platform),donbfet)
347 $(app).hex: $(app)
348         avr-objcopy -j .text -j .data -O ihex goodfet goodfet.hex
349 else
350 $(app).hex: $(app)
351         msp430-objcopy goodfet -O ihex goodfet.hex
352 endif
353 m4s: $(app).hex
354         msp430-objdump -D -m msp430 $(app).hex | m4s init
355 clean:
356         rm -f *.o $(app) $(app).hex $(libs) $(apps) lib/apps.c include/config.h include/builddate.h include/apps.h
357 docs:
358         doxygen
359 pushdocs: docs
360         rsync --exclude .svn -ave ssh doc/html/* travisutk,goodfet@web.sourceforge.net:htdocs/docs/
361 .FAKE: docs
362