Update USB Product strings based on board version
[SCSI2SD-V6.git] / Makefile.revF
1 # Assume newlib gcc toolchain
2 ARMCC=arm-none-eabi-gcc
3 OBJCOPY=arm-none-eabi-objcopy
4
5 CPPFLAGS=-DSTM32F2xx -DSTM32F205xx -DUSE_HAL_DRIVER -Wall -DS2S_USB_FS -DREV_2019
6 CFLAGS=-mcpu=cortex-m3 -mthumb -mslow-flash-data \
7         -std=gnu11 \
8         -specs=nosys.specs \
9         -Os -g \
10
11 LDFLAGS= \
12         "-Tsrc/firmware/link.ld" \
13
14 INCLUDE = -Iinclude
15
16
17 STM32CubeMX_INCUDE = \
18         -ISTM32CubeMX/revF/Inc \
19         -ISTM32CubeMX/revF/Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc \
20         -ISTM32CubeMX/revF/Middlewares/ST/STM32_USB_Host_Library/Core/Inc \
21         -ISTM32CubeMX/revF/Drivers/CMSIS/Include \
22         -ISTM32CubeMX/revF/Drivers/CMSIS/Device/ST/STM32F2xx/Include \
23         -ISTM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Inc \
24         -ISTM32CubeMX/revF/Middlewares/Third_Party/FatFs/src/ \
25         -ISTM32CubeMX/revF/Middlewares/Third_Party/FatFs/src/drivers \
26         -ISTM32CubeMX/revF/Middlewares/ST/STM32_USB_Device_Library/Core/Inc \
27         -Isrc/firmware/usb_device \
28
29 all: build/firmware.V6.revF.dfu
30
31 build/revF/stm32cubemx/dma.o: STM32CubeMX/revF/Src/dma.c
32 build/revF/stm32cubemx/fsmc.o: STM32CubeMX/revF/Src/fsmc.c
33 build/revF/stm32cubemx/gpio.o: STM32CubeMX/revF/Src/gpio.c
34 build/revF/stm32cubemx/main.o: STM32CubeMX/revF/Src/main.c
35 build/revF/stm32cubemx/sdio.o: STM32CubeMX/revF/Src/sdio.c
36 build/revF/stm32cubemx/spi.o: STM32CubeMX/revF/Src/spi.c
37 build/revF/stm32cubemx/tim.o: STM32CubeMX/revF/Src/tim.c
38 build/revF/stm32cubemx/stm32f2xx_hal_msp.o: STM32CubeMX/revF/Src/stm32f2xx_hal_msp.c
39 build/revF/stm32cubemx/stm32f2xx_it.o: STM32CubeMX/revF/Src/stm32f2xx_it.c
40 build/revF/stm32cubemx/usart.o: STM32CubeMX/revF/Src/usart.c
41 build/revF/stm32cubemx/usbd_conf.o: STM32CubeMX/revF/Src/usbd_conf.c
42 build/revF/stm32cubemx/stm32f2xx_hal.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal.c
43 build/revF/stm32cubemx/stm32f2xx_hal_cortex.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_cortex.c
44 build/revF/stm32cubemx/stm32f2xx_hal_dma.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_dma.c
45 build/revF/stm32cubemx/stm32f2xx_hal_flash.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash.c
46 build/revF/stm32cubemx/stm32f2xx_hal_flash_ex.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_flash_ex.c
47 build/revF/stm32cubemx/stm32f2xx_hal_gpio.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_gpio.c
48 build/revF/stm32cubemx/stm32f2xx_hal_hcd.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_hcd.c
49 build/revF/stm32cubemx/stm32f2xx_hal_pcd.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd.c
50 build/revF/stm32cubemx/stm32f2xx_hal_pcd_ex.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_pcd_ex.c
51 build/revF/stm32cubemx/stm32f2xx_hal_rcc.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_rcc.c
52 build/revF/stm32cubemx/stm32f2xx_hal_sd.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sd.c
53 build/revF/stm32cubemx/stm32f2xx_hal_spi.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_spi.c
54 build/revF/stm32cubemx/stm32f2xx_hal_sram.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_sram.c
55 build/revF/stm32cubemx/stm32f2xx_hal_tim.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim.c
56 build/revF/stm32cubemx/stm32f2xx_hal_tim_ex.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_tim_ex.c
57 build/revF/stm32cubemx/stm32f2xx_hal_uart.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_hal_uart.c
58 build/revF/stm32cubemx/stm32f2xx_ll_fsmc.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_fsmc.c
59 build/revF/stm32cubemx/stm32f2xx_ll_sdmmc.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_sdmmc.c
60 build/revF/stm32cubemx/stm32f2xx_ll_usb.o: STM32CubeMX/revF/Drivers/STM32F2xx_HAL_Driver/Src/stm32f2xx_ll_usb.c
61 build/revF/stm32cubemx/usbd_core.o: STM32CubeMX/revF/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c
62 build/revF/stm32cubemx/usbd_ctlreq.o: STM32CubeMX/revF/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c
63 build/revF/stm32cubemx/usbd_ioreq.o: STM32CubeMX/revF/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c
64 build/revF/stm32cubemx/system_stm32f2xx.o: STM32CubeMX/revF/Drivers/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c
65 build/revF/stm32cubemx/startup_stm32f205xx.o: STM32CubeMX/revF/Drivers/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc/startup_stm32f205xx.s
66
67 STM32OBJS = \
68         build/revF/stm32cubemx/dma.o \
69         build/revF/stm32cubemx/fsmc.o \
70         build/revF/stm32cubemx/gpio.o \
71         build/revF/stm32cubemx/main.o \
72         build/revF/stm32cubemx/sdio.o \
73         build/revF/stm32cubemx/spi.o \
74         build/revF/stm32cubemx/tim.o \
75         build/revF/stm32cubemx/stm32f2xx_hal_msp.o \
76         build/revF/stm32cubemx/stm32f2xx_it.o \
77         build/revF/stm32cubemx/usart.o \
78         build/revF/stm32cubemx/usbd_conf.o \
79         build/revF/stm32cubemx/stm32f2xx_hal.o \
80         build/revF/stm32cubemx/stm32f2xx_hal_cortex.o \
81         build/revF/stm32cubemx/stm32f2xx_hal_dma.o \
82         build/revF/stm32cubemx/stm32f2xx_hal_flash.o \
83         build/revF/stm32cubemx/stm32f2xx_hal_flash_ex.o \
84         build/revF/stm32cubemx/stm32f2xx_hal_gpio.o \
85         build/revF/stm32cubemx/stm32f2xx_hal_hcd.o \
86         build/revF/stm32cubemx/stm32f2xx_hal_pcd.o \
87         build/revF/stm32cubemx/stm32f2xx_hal_pcd_ex.o \
88         build/revF/stm32cubemx/stm32f2xx_hal_rcc.o \
89         build/revF/stm32cubemx/stm32f2xx_hal_sd.o \
90         build/revF/stm32cubemx/stm32f2xx_hal_spi.o \
91         build/revF/stm32cubemx/stm32f2xx_hal_sram.o \
92         build/revF/stm32cubemx/stm32f2xx_hal_tim.o \
93         build/revF/stm32cubemx/stm32f2xx_hal_tim_ex.o \
94         build/revF/stm32cubemx/stm32f2xx_hal_uart.o \
95         build/revF/stm32cubemx/stm32f2xx_ll_fsmc.o \
96         build/revF/stm32cubemx/stm32f2xx_ll_sdmmc.o \
97         build/revF/stm32cubemx/stm32f2xx_ll_usb.o \
98         build/revF/stm32cubemx/usbd_core.o \
99         build/revF/stm32cubemx/usbd_ctlreq.o \
100         build/revF/stm32cubemx/usbd_ioreq.o \
101         build/revF/stm32cubemx/system_stm32f2xx.o \
102         build/revF/stm32cubemx/startup_stm32f205xx.o \
103
104 # Modified versin from stm32cubemx for a composite class with both
105 # mass-storage and HID interfaces
106 USBCOMPOSITE_SRC= \
107         src/firmware/usb_device/usb_device.c \
108         src/firmware/usb_device/usbd_composite.c \
109         src/firmware/usb_device/usbd_desc.c \
110         src/firmware/usb_device/usbd_hid.c \
111         src/firmware/usb_device/usbd_msc_bot.c \
112         src/firmware/usb_device/usbd_msc.c \
113         src/firmware/usb_device/usbd_msc_data.c \
114         src/firmware/usb_device/usbd_msc_scsi.c \
115         src/firmware/usb_device/usbd_msc_storage_sd.c \
116
117 SRC = \
118         src/firmware/bootloader.c \
119         src/firmware/bsp.c \
120         src/firmware/cdrom.c \
121         src/firmware/config.c \
122         src/firmware/disk.c \
123         src/firmware/diagnostic.c \
124         src/firmware/fpga.c \
125         src/firmware/geometry.c \
126         src/firmware/hidpacket.c \
127         src/firmware/hwversion.c \
128         src/firmware/inquiry.c \
129         src/firmware/led.c \
130         src/firmware/main.c \
131         src/firmware/mo.c \
132         src/firmware/mode.c \
133         src/firmware/scsiPhy.c \
134         src/firmware/scsi.c \
135         src/firmware/sd.c \
136         src/firmware/spinlock.c \
137         src/firmware/tape.c \
138         src/firmware/time.c \
139         src/firmware/vendor.c \
140         src/firmware/bsp_driver_sd.c \
141         ${USBCOMPOSITE_SRC}
142
143 build/revF/firmware.elf: $(SRC) rtl/fpga_bitmap.o $(STM32OBJS)
144         $(ARMCC) $(CPPFLAGS) $(CFLAGS) -o $@ $(STM32CubeMX_INCUDE) $(INCLUDE) $^ $(LDFLAGS)
145         @EBSS=`arm-none-eabi-nm build/revF/firmware.elf | grep _ebss | cut -f1 "-d "`; \
146         echo HEAPSIZE = $$((0x2001C000 - 0x$${EBSS})) bytes
147         @echo STACKSIZE = 16384 bytes
148
149
150 build/revF/firmware.bin: build/revF/firmware.elf
151         $(OBJCOPY) -O binary $< $@
152
153 # Example to hard-code config within firmware
154 #sudo arm-none-eabi-objcopy --update-section .fixed_config=config.dat firmware.elf -O binary firmware.bin
155
156 build/revF/stm32cubemx/%.o:
157         mkdir -p build/revF/stm32cubemx
158         $(ARMCC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(STM32CubeMX_INCUDE) $(INCLUDE) $^
159
160
161 build/revF/stm32cubemx/stm32f2xx_it.o:
162         mkdir -p build/revF/stm32cubemx
163         $(ARMCC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(STM32CubeMX_INCUDE) $(INCLUDE) $^
164         $(OBJCOPY) -N EXTI4_IRQHandler $@
165
166 build/revF/stm32cubemx/system_stm32f2xx.o:
167         mkdir -p build/revF/stm32cubemx
168         $(ARMCC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(STM32CubeMX_INCUDE) $(INCLUDE) $^
169         $(OBJCOPY) --redefine-sym SystemInit=OrigSystemInit $@
170
171 build/revF/scsiPhy.s: src/firmware/scsiPhy.c
172         $(ARMCC) $(CPPFLAGS) $(CFLAGS) -S -o $@ $(STM32CubeMX_INCUDE) $(INCLUDE) $^
173
174
175 build/firmware.V6.revF.dfu: build/revF/firmware.bin
176         python tools/dfu-convert.py -b 0x08000000:$< $@
177
178 clean:
179         rm -rf build/revF build/firmware.V6.revF.dfu
180
181 program:
182         dfu-util --download build/firmware.V6.revF.dfu --alt 0
183