Makefile 7.6 KB

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