Struggling with STM32 USART.
[goodfet] / firmware / config.mk
1 ##################################
2 ## These are production boards.
3 ##################################
4
5 #Unset by default, but can be explicitly set later.
6 config=undef
7
8 ifneq (,$(findstring $(board),goodfet20 goodfet10 goodfet11))
9 mcu ?= msp430f1612
10 platform := goodfet
11 endif
12
13 ifneq (,$(findstring $(board),goodfet21))
14 mcu ?= msp430f2618
15 platform := goodfet
16 endif
17
18 ifneq (,$(findstring $(board),goodfet30 goodfet31))
19 mcu ?= msp430f2274
20 platform := goodfet
21 # This will link to fit in a '2254, so unneeded packages should be omited.
22 CONFIG_ccspi = n
23 CONFIG_nrf = y
24 endif
25
26 ifneq (,$(findstring $(board),goodfet40 goodfet41))
27 mcu ?= msp430f2618
28 platform := goodfet
29 CONFIG_nrf = y
30 endif
31
32 ifneq (,$(findstring $(board),stm32f4discovery))
33
34 periph ?= /opt/STM32F4xx_StdPeriph_Driver
35 discovery ?= /opt/STM32F4-Discovery_FW_V1.1.0
36
37 usbcore ?= $(discovery)/Libraries/STM32_USB_Device_Library/Core
38 usbsrc ?= $(usbcore)/src
39 otginc ?= /opt/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32_USB_OTG_Driver/inc
40 otgsrc ?= /opt/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32_USB_OTG_Driver/src
41
42 pincs ?=  -I$(periph)/inc -I$(usbcore)/inc -I$(otginc) -I$(discovery)/Libraries/CMSIS/ST/STM32F4xx/Include  -I$(discovery)/Libraries/CMSIS/Include -Dassert_param\(x\)= -DUSE_USB_OTG_FS -I/opt/STM32F4-Discovery_FW_V1.1.0/Utilities/STM32F4-Discovery
43 psrc ?=  /opt/STM32F4xx_StdPeriph_Driver/src
44
45
46 GCC     = arm-none-eabi-gcc
47 CC      = arm-none-eabi-gcc
48 LD      = arm-none-eabi-ld -v
49 AR      = arm-none-eabi-ar
50 AS      = arm-none-eabi-as
51 CP      = arm-none-eabi-objcopy
52 OD      = arm-none-eabi-objdump
53 CFLAGS  = -c -fno-common -O1 -g -mcpu=cortex-m3 -mthumb $(pincs)
54 AFLAGS  = -ahls -mapcs-32
55 LFLAGS  = -Ttmplink.cmd -nostartfiles
56 CPFLAGS = -Obinary
57 ODFLAGS = -S
58 LDFLAGS = 
59
60
61 mcu ?= stm32f407
62 platform := stm32f4discovery
63 config = monitor
64
65 # This is a pain.
66 #usblibs =  $(usbsrc)/usbd_core.o $(usbsrc)/usbd_req.o $(usbsrc)/usbd_ioreq.o $(usbsrc)/usbd_core.o $(otgsrc)/usb_dcd.o $(otgsrc)/usb_dcd_int.o $(otgsrc)/usb_hcd.o $(otgsrc)/usb_hcd_int.o $(otgsrc)/usb_otg.o
67 extralibs = lib/cortexm3.o lib/system_stm32f4xx.o $(psrc)/stm32f4xx_rcc.o $(psrc)/stm32f4xx_gpio.o $(psrc)/stm32f4xx_usart.o $(usblibs) 
68
69 endif
70
71 ifneq (,$(findstring $(board),facedancer10))
72 mcu ?= msp430f2618
73 platform := goodfet
74 config = monitor spi maxusb
75 endif
76
77 ifeq ($(board),z1)
78 mcu ?= msp430f2617
79 platform := z1
80 config = monitor spi ccspi
81 MSP430BSL?=goodfet.bsl --z1  --speed=38400
82 endif
83
84 ifneq (,$(findstring $(board),goodfet24))
85 mcu ?= msp430f2618
86 platform := goodfet
87 CONFIG_glitch = y
88 endif
89
90 ifneq (,$(findstring $(board),nhb12b))
91 mcu ?= msp430f2618
92 CONFIG_nrf = y
93 platform := nhb12b
94 endif
95
96 ifneq (,$(findstring $(board),nhb12))
97 mcu ?= msp430f2618
98 CONFIG_nrf = y
99 platform := nhb12
100 endif
101
102 ifneq (,$(findstring $(board),goodfet50 goodfet51))
103 mcu ?= msp430f5510
104 platform := goodfet
105 endif
106
107 ifeq ($(board),telosb)
108 mcu ?= msp430f1611
109 platform := telosb
110 config := monitor spi ccspi
111 CFLAGS += -Duseuart1
112 endif
113
114 ifeq ($(board),telosbbt)
115 mcu ?=msp430f1612
116 platform := telosb
117 config := monitor spi ccspi
118 endif
119
120
121
122
123 ##################################
124 ## These are experimental boards.
125 ##################################
126
127 ifneq (,$(findstring $(board),donbfet))
128 GCC := avr-gcc
129 CC := avr-gcc
130 mcu ?= atmega644p
131 platform = donbfet
132 CFLAGS=$(DEBUG) -Iinclude -mmcu=$(mcu) -W -Os -mcall-prologues -Wall -Wextra -Wuninitialized -fpack-struct -fshort-enums -funsigned-bitfields
133 config := monitor avr spi jscan
134 endif
135
136 ifneq (,$(findstring $(board),arduino))
137 GCC := avr-gcc
138 mcu ?= atmega168
139 #BSL := avrdude -V -F -c stk500v1 -p m328p -b 57600 -P /dev/tty.usbserial-* -U flash:w:blink.hex
140 LDFLAGS := 
141 config := monitor
142 endif
143
144 ifneq (,$(findstring $(board),tilaunchpad))
145 mcu ?=msp430f1612
146 CFLAGS := -DDEBUG_LEVEL=3 -DDEBUG_START=1 -DINBAND_DEBUG
147 CFLAGS+= -Werror -Wall
148 config := monitor chipcon i2c
149 endif
150
151
152
153 mcu ?= undef
154 ifeq ($(mcu),undef)
155 $(error Please define board, as explained in the README)
156 endif
157 #platform := $(board)
158
159 AVAILABLE_APPS = monitor spi jtag sbw jtag430 jtag430x2 i2c jtagarm7 ejtag jtagxscale openocd chipcon avr pic adc nrf ccspi glitch smartcard ps2 slc2  maxusb
160
161 # defaults
162 CONFIG_monitor    ?= y
163 CONFIG_spi        ?= y
164 CONFIG_maxusb     ?= y
165 CONFIG_jtag       ?= n
166 CONFIG_sbw        ?= n
167 CONFIG_jtag430    ?= y
168 CONFIG_jtag430x2  ?= y
169 CONFIG_i2c        ?= n
170 CONFIG_jtagarm7   ?= n
171 CONFIG_ejtag      ?= n
172 CONFIG_jtagxscale ?= n
173 CONFIG_openocd    ?= y
174 CONFIG_chipcon    ?= y
175 CONFIG_avr        ?= y
176 CONFIG_pic        ?= n
177 CONFIG_adc        ?= n
178 CONFIG_nrf        ?= n
179 CONFIG_ccspi      ?= n
180 CONFIG_glitch     ?= n
181 CONFIG_smartcard  ?= n
182 CONFIG_ps2        ?= n
183 CONFIG_slc2       ?= n
184
185 #The CONFIG_foo vars are only interpreted if $(config) is "unset".
186 ifeq ($(config),undef)
187 config += $(foreach app,$(AVAILABLE_APPS),$(if $(findstring $(CONFIG_$(app)),y yes t true Y YES T TRUE),$(app)))
188 endif