USB modes cleanup (#5396)
[opentx.git] / radio / src / targets / taranis / bootloader / CMakeLists.txt
blob9c792481e56eba14eb789d48a5630f35c1e30366
1 # TODO if the files order is different (these 2 SRC sections exchanged), the bootloader hangs for 20s in USB init. Why?
3 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
5 if(PCB STREQUAL X9E)
6   set(BOOTLOADER_SRC
7     ${BOOTLOADER_SRC}
8     ../../common/arm/stm32/f4/system_stm32f4xx.c
9     ../../../${STM32LIB_DIR}/CMSIS/Device/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f40_41xxx.s
10     ../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
11     ../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c
12     ../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c
13     ../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c
14     ../../../${STM32LIB_DIR}/STM32F4xx_StdPeriph_Driver/src/misc.c
15     )
16 else()
17   set(BOOTLOADER_SRC
18     ${BOOTLOADER_SRC}
19     ../../common/arm/stm32/f2/system_stm32f2xx.c
20     ../../../${STM32LIB_DIR}/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s
21     ../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rcc.c
22     ../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
23     ../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c
24     ../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_i2c.c
25     ../../../${STM32LIB_DIR}/STM32F2xx_StdPeriph_Driver/src/misc.c
26     )
27 endif()
29 set(BOOTLOADER_SRC
30   ${BOOTLOADER_SRC}
31   ../../../gui/${GUI_DIR}/lcd.cpp
32   ../../../gui/${GUI_DIR}/fonts.cpp
33   ../../../keys.cpp
34   ../../../strhelpers.cpp
35   ../../../${STM32USB_DIR}/STM32_USB_OTG_Driver/src/usb_core.c
36   ../../../${STM32USB_DIR}/STM32_USB_OTG_Driver/src/usb_dcd.c
37   ../../../${STM32USB_DIR}/STM32_USB_OTG_Driver/src/usb_dcd_int.c
38   ../../../${STM32USB_DIR}/STM32_USB_Device_Library/Core/src/usbd_core.c
39   ../../../${STM32USB_DIR}/STM32_USB_Device_Library/Core/src/usbd_ioreq.c
40   ../../../${STM32USB_DIR}/STM32_USB_Device_Library/Core/src/usbd_req.c
41   ../../../${STM32USB_DIR}/STM32_USB_Device_Library/Class/msc/src/usbd_msc_data.c
42   ../../../${STM32USB_DIR}/STM32_USB_Device_Library/Class/msc/src/usbd_msc_scsi.c
43   ../../../${STM32USB_DIR}/STM32_USB_Device_Library/Class/msc/src/usbd_msc_bot.c
44   ../../../${STM32USB_DIR}/STM32_USB_Device_Library/Class/msc/src/usbd_msc_core.c
45   ../../../${FATFS_DIR}/ff.c
46   ../../../${FATFS_DIR}/option/ccsbcs.c
47   ../${LCD_DRIVER}
48   ../backlight_driver.cpp
49   ../keys_driver.cpp
50   ../i2c_driver.cpp
51   ../flash_driver.cpp
52   ../diskio.cpp
53   ../../common/arm/stm32/usbd_usr.cpp
54   ../../common/arm/stm32/usbd_storage_msd.cpp
55   ../../common/arm/stm32/delays.cpp
56   ../../common/arm/stm32/usbd_desc.c
57   ../../common/arm/stm32/usb_bsp.c
58   ../../common/arm/stm32/usb_driver.cpp
59   ../pwr_driver.cpp
60   init.c
61   boot.cpp
62   )
64 remove_definitions(-DLUA -DDEBUG)
65 add_definitions(-DBOOT)
67 set(CMAKE_EXE_LINKER_FLAGS "-mcpu=${MCU} -mthumb -nostartfiles -lm -T${RADIO_SRC_DIRECTORY}/targets/taranis/stm32_ramboot.ld -Wl,-Map=bootloader.map,--cref,--no-warn-mismatch,--gc-sections")
69 add_executable(bootloader ${BOOTLOADER_SRC})
70 add_dependencies(bootloader ${BITMAPS_TARGET} firmware_translations)
72 add_custom_command(
73   TARGET bootloader POST_BUILD
74   COMMAND arm-none-eabi-objcopy -O binary bootloader.elf bootloader.bin
76 if(PYTHONINTERP_FOUND)
77   add_custom_command(
78     TARGET bootloader POST_BUILD
79     COMMAND ${PYTHON_EXECUTABLE} ${RADIO_DIRECTORY}/util/bin2lbm.py bootloader.bin bootloader.lbm
80   )
81 endif()
83 PrintTargetReport("bootloader")