mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-13 03:19:58 +03:00
[BUILD] Initial and very basic support for CMake
Only F411 based targets have been ported for now
This commit is contained in:
parent
30146b482e
commit
8035a59639
13 changed files with 834 additions and 5 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -12,10 +12,11 @@ startup_stm32f10x_md_gcc.s
|
|||
.vagrant/
|
||||
.vscode/
|
||||
cov-int*
|
||||
obj/
|
||||
patches/
|
||||
tools/
|
||||
downloads/
|
||||
/build/
|
||||
/obj/
|
||||
/patches/
|
||||
/tools/
|
||||
/downloads/
|
||||
|
||||
# script-generated files
|
||||
docs/Manual.pdf
|
||||
|
|
51
CMakeLists.txt
Normal file
51
CMakeLists.txt
Normal file
|
@ -0,0 +1,51 @@
|
|||
cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
set(TOOLCHAIN_OPTIONS "arm-none-eabi")
|
||||
set(TOOLCHAIN "arm-none-eabi" CACHE STRING "Toolchain to use. Available: ${TOOLCHAIN_OPTIONS}")
|
||||
set_property(CACHE TOOLCHAIN PROPERTY STRINGS ${TOOLCHAIN_OPTIONS})
|
||||
if (NOT ${TOOLCHAIN} IN_LIST TOOLCHAIN_OPTIONS)
|
||||
message(FATAL_ERROR "Invalid toolchain ${TOOLCHAIN}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${TOOLCHAIN}.cmake")
|
||||
|
||||
project(INAV VERSION 2.5.0)
|
||||
|
||||
ENABLE_LANGUAGE(ASM)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_EXTENSIONS ON)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_EXTENSIONS ON)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_program(RUBY_EXECUTABLE ruby)
|
||||
if (NOT RUBY_EXECUTABLE)
|
||||
message(FATAL_ERROR "Could not find ruby")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND git rev-parse --short HEAD
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
RESULT_VARIABLE NO_GIT_HASH
|
||||
OUTPUT_VARIABLE GIT_SHORT_HASH)
|
||||
if (NO_GIT_HASH)
|
||||
message(FATAL_ERROR "Could not find git revision. Is git installed?")
|
||||
endif()
|
||||
|
||||
set(INAV_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(INAV_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
||||
set(INAV_UTILS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/utils")
|
||||
set(INAV_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/main")
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(settings)
|
||||
include(inav)
|
||||
include(stm32)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
collect_targets()
|
||||
|
||||
message("-- Build type: ${CMAKE_BUILD_TYPE}")
|
63
cmake/arm-none-eabi.cmake
Normal file
63
cmake/arm-none-eabi.cmake
Normal file
|
@ -0,0 +1,63 @@
|
|||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
|
||||
if(WIN32)
|
||||
set(TOOL_EXECUTABLE_SUFFIX ".exe")
|
||||
endif()
|
||||
|
||||
set(TARGET_TRIPLET "arm-none-eabi")
|
||||
set(gcc "${TARGET_TRIPLET}-gcc${TOOL_EXECUTABLE_SUFFIX}")
|
||||
|
||||
find_program(GCC "${gcc}")
|
||||
if (NOT GCC)
|
||||
message(FATAL_ERROR "Could not find ${gcc}")
|
||||
endif()
|
||||
|
||||
set(ARM_NONE_EABI_GCC_VERSION 9.2.1)
|
||||
|
||||
execute_process(COMMAND "${GCC}" -dumpversion
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
OUTPUT_VARIABLE GCC_VERSION)
|
||||
|
||||
if (NOT ${ARM_NONE_EABI_GCC_VERSION} STREQUAL ${GCC_VERSION})
|
||||
# TODO: Show how to override on cmdline or install builtin compiler
|
||||
message(FATAL_ERROR "Expecting gcc version ${ARM_NONE_EABI_GCC_VERSION}, but found ${GCC_VERSION}")
|
||||
endif()
|
||||
|
||||
get_filename_component(TOOLCHAIN_BIN_DIR "${GCC}" DIRECTORY)
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
set(CMAKE_ASM_COMPILER "${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-gcc${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "asm compiler")
|
||||
set(CMAKE_C_COMPILER "${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-gcc${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "c compiler")
|
||||
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-g++${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "c++ compiler")
|
||||
set(CMAKE_OBJCOPY "${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-objcopy${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "objcopy tool")
|
||||
set(CMAKE_OBJDUMP "${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-objdump${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "objdump tool")
|
||||
set(CMAKE_SIZE "${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-size${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "size tool")
|
||||
set(CMAKE_DEBUGER "${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-gdb${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "debuger")
|
||||
set(CMAKE_CPPFILT "${TOOLCHAIN_BIN_DIR}/${TARGET_TRIPLET}-c++filt${TOOL_EXECUTABLE_SUFFIX}" CACHE INTERNAL "c++filt")
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
|
||||
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo)
|
||||
endif()
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build Type" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES})
|
||||
|
||||
set(arm_none_eabi_debug "-Og -g")
|
||||
set(arm_none_eabi_release "-O2 -DNDEBUG -flto -fuse-linker-plugin")
|
||||
set(arm_none_eabi_relwithdebinfo "-ggdb3 ${arm_none_eabi_release}")
|
||||
|
||||
SET(CMAKE_C_FLAGS_DEBUG ${arm_none_eabi_debug} CACHE INTERNAL "c compiler flags debug")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG ${arm_none_eabi_debug} CACHE INTERNAL "c++ compiler flags debug")
|
||||
SET(CMAKE_ASM_FLAGS_DEBUG ${arm_none_eabi_debug} CACHE INTERNAL "asm compiler flags debug")
|
||||
|
||||
SET(CMAKE_C_FLAGS_RELEASE ${arm_none_eabi_release} CACHE INTERNAL "c compiler flags release")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE ${arm_none_eabi_release} CACHE INTERNAL "cxx compiler flags release")
|
||||
SET(CMAKE_ASM_FLAGS_RELEASE ${arm_none_eabi_release} CACHE INTERNAL "asm compiler flags release")
|
||||
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO ${arm_none_eabi_relwithdebinfo} CACHE INTERNAL "c compiler flags release")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${arm_none_eabi_relwithdebinfo} CACHE INTERNAL "cxx compiler flags release")
|
||||
SET(CMAKE_ASM_FLAGS_RELWITHDEBINFO ${arm_none_eabi_relwithdebinfo} CACHE INTERNAL "asm compiler flags release")
|
65
cmake/inav.cmake
Normal file
65
cmake/inav.cmake
Normal file
|
@ -0,0 +1,65 @@
|
|||
set(INAV_INCLUDE_DIRS
|
||||
"${INAV_LIB_DIR}"
|
||||
"${INAV_MAIN_SRC_DIR}"
|
||||
"${INAV_LIB_DIR}/main/MAVLink"
|
||||
)
|
||||
|
||||
# TODO: We need a way to override HSE_VALUE
|
||||
set(INAV_DEFINITIONS
|
||||
__FORKNAME__=inav
|
||||
__REVISION__="${GIT_SHORT_HASH}"
|
||||
HSE_VALUE=8000000
|
||||
)
|
||||
|
||||
set(INAV_COMPILE_OPTIONS
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wunsafe-loop-optimizations
|
||||
-Wdouble-promotion
|
||||
-Wstrict-prototypes
|
||||
-Werror=switch
|
||||
)
|
||||
|
||||
macro(main_sources) # list-var
|
||||
list(TRANSFORM ${ARGV0} PREPEND "${INAV_MAIN_SRC_DIR}/")
|
||||
endmacro()
|
||||
|
||||
macro(exclude_basenames) # list-var excludes-var
|
||||
set(_filtered "")
|
||||
foreach(item ${${ARGV0}})
|
||||
get_filename_component(basename ${item} NAME)
|
||||
if (NOT ${basename} IN_LIST ${ARGV1})
|
||||
list(APPEND _filtered ${item})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${ARGV0} ${_filtered})
|
||||
endmacro()
|
||||
|
||||
macro(glob_except) # var-name pattern excludes-var
|
||||
file(GLOB ${ARGV0} ${ARGV1})
|
||||
exclude_basenames(${ARGV0} ${ARGV2})
|
||||
endmacro()
|
||||
|
||||
function(setup_firmware_target name)
|
||||
target_compile_options(${name} PRIVATE ${INAV_COMPILE_OPTIONS})
|
||||
target_include_directories(${name} PRIVATE ${INAV_INCLUDE_DIRS})
|
||||
target_compile_definitions(${name} PRIVATE ${INAV_DEFINITIONS} __TARGET__="${name}")
|
||||
enable_settings(${name})
|
||||
# XXX: Don't make SETTINGS_GENERATED_C part of the build,
|
||||
# since it's compiled via #include in settings.c. This will
|
||||
# change once we move off PGs
|
||||
target_sources(${name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${name}/${SETTINGS_GENERATED_H}")
|
||||
set_target_properties(${name} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||
)
|
||||
get_property(targets GLOBAL PROPERTY VALID_TARGETS)
|
||||
set_property(GLOBAL PROPERTY VALID_TARGETS "${targets} ${name}")
|
||||
endfunction()
|
||||
|
||||
function(collect_targets)
|
||||
get_property(targets GLOBAL PROPERTY VALID_TARGETS)
|
||||
list(SORT targets)
|
||||
add_custom_target("targets"
|
||||
COMMAND cmake -E echo "Valid targets: ${targets}")
|
||||
set_property(TARGET "targets" PROPERTY TARGET_MESSAGES OFF)
|
||||
endfunction()
|
25
cmake/settings.cmake
Normal file
25
cmake/settings.cmake
Normal file
|
@ -0,0 +1,25 @@
|
|||
set(SETTINGS_GENERATED "settings_generated")
|
||||
set(SETTINGS_GENERATED_C "${SETTINGS_GENERATED}.c")
|
||||
set(SETTINGS_GENERATED_H "${SETTINGS_GENERATED}.h")
|
||||
set(SETTINGS_FILE "${INAV_MAIN_SRC_DIR}/fc/settings.yaml")
|
||||
set(SETTINGS_GENERATOR "${INAV_UTILS_DIR}/settings.rb")
|
||||
|
||||
function(enable_settings target)
|
||||
set(dir "${CMAKE_CURRENT_BINARY_DIR}/${target}")
|
||||
target_include_directories(${target} PRIVATE ${dir})
|
||||
get_target_property(options ${target} COMPILE_OPTIONS)
|
||||
get_target_property(includes ${target} INCLUDE_DIRECTORIES)
|
||||
list(TRANSFORM includes PREPEND "-I")
|
||||
get_target_property(defs ${target} COMPILE_DEFINITIONS)
|
||||
list(TRANSFORM defs PREPEND "-D")
|
||||
list(APPEND cflags ${options})
|
||||
list(APPEND cflags ${includes})
|
||||
list(APPEND cflags ${defs})
|
||||
add_custom_command(
|
||||
OUTPUT ${dir}/${SETTINGS_GENERATED_H} ${dir}/${SETTINGS_GENERATED_C}
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E env CFLAGS="${cflags}" TARGET=${target}
|
||||
${RUBY_EXECUTABLE} ${SETTINGS_GENERATOR} ${INAV_DIR} ${SETTINGS_FILE} -o "${dir}"
|
||||
DEPENDS ${SETTINGS_GENERATOR} ${SETTINGS_FILE}
|
||||
)
|
||||
endfunction()
|
65
cmake/stm32-usb.cmake
Normal file
65
cmake/stm32-usb.cmake
Normal file
|
@ -0,0 +1,65 @@
|
|||
set(STM32_STDPERIPH_USBOTG_DIR "${INAV_LIB_DIR}/main/STM32_USB_OTG_Driver")
|
||||
set(STM32_STDPERIPH_USBCORE_DIR "${INAV_LIB_DIR}/main/STM32_USB_Device_Library/Core")
|
||||
set(STM32_STDPERIPH_USBCDC_DIR "${INAV_LIB_DIR}/main/STM32_USB_Device_Library/Class/cdc")
|
||||
set(STM32_STDPERIPH_USBHID_DIR "${INAV_LIB_DIR}/main/STM32_USB_Device_Library/Class/hid")
|
||||
set(STM32_STDPERIPH_USBWRAPPER_DIR "${INAV_LIB_DIR}/main/STM32_USB_Device_Library/Class/hid_cdc_wrapper")
|
||||
set(STM32_STDPERIPH_USBMSC_DIR "${INAV_LIB_DIR}/main/STM32_USB_Device_Library/Class/msc")
|
||||
set(STM32_STDPERIPH_USBFS_DIR "${INAV_LIB_DIR}/main/STM32_USB-FS-Device_Driver")
|
||||
|
||||
set(STM32_STDPERIPH_USB_INCLUDE_DIRS
|
||||
"${STM32_STDPERIPH_USBOTG_DIR}/inc"
|
||||
"${STM32_STDPERIPH_USBCORE_DIR}/inc"
|
||||
"${STM32_STDPERIPH_USBCDC_DIR}/inc"
|
||||
"${STM32_STDPERIPH_USBHID_DIR}/inc"
|
||||
"${STM32_STDPERIPH_USBWRAPPER_DIR}/inc"
|
||||
"${STM32_STDPERIPH_USBMSC_DIR}/inc"
|
||||
"${STM32_STDPERIPH_USBFS_DIR}/inc"
|
||||
)
|
||||
|
||||
SET(STM32_STDPERIPH_USBOTG_SRC_EXCLUDES
|
||||
usb_bsp_template.c
|
||||
usb_conf_template.c
|
||||
usb_hcd_int.c
|
||||
usb_hcd.c
|
||||
usb_otg.c
|
||||
)
|
||||
set(STM32_STDPERIPH_USBOTG_SRC
|
||||
usb_core.c
|
||||
usb_dcd.c
|
||||
usb_dcd_int.c
|
||||
)
|
||||
list(TRANSFORM STM32_STDPERIPH_USBOTG_SRC PREPEND "${STM32_STDPERIPH_USBOTG_DIR}/src/")
|
||||
|
||||
set(STM32_STDPERIPH_USBCORE_SRC
|
||||
usbd_core.c
|
||||
usbd_ioreq.c
|
||||
usbd_req.c
|
||||
)
|
||||
list(TRANSFORM STM32_STDPERIPH_USBCORE_SRC PREPEND "${STM32_STDPERIPH_USBCORE_DIR}/src/")
|
||||
|
||||
set(STM32_STDPERIPH_USBCDC_SRC
|
||||
"${STM32_STDPERIPH_USBCDC_DIR}/src/usbd_cdc_core.c"
|
||||
)
|
||||
|
||||
set(STM32_STDPERIPH_USBHID_SRC
|
||||
"${STM32_STDPERIPH_USBHID_DIR}/src/usbd_hid_core.c"
|
||||
)
|
||||
|
||||
set(STM32_STDPERIPH_USBWRAPPER_SRC
|
||||
"${STM32_STDPERIPH_USBWRAPPER_DIR}/src/usbd_hid_cdc_wrapper.c"
|
||||
)
|
||||
|
||||
set(STM32_STDPERIPH_USBMSC_SRC
|
||||
usbd_msc_bot.c
|
||||
usbd_msc_core.c
|
||||
usbd_msc_data.c
|
||||
usbd_msc_scsi.c
|
||||
)
|
||||
list(TRANSFORM STM32_STDPERIPH_USBMSC_SRC PREPEND "${STM32_STDPERIPH_USBMSC_DIR}/src/")
|
||||
|
||||
list(APPEND STM32_STDPERIPH_USB_SRC ${STM32_STDPERIPH_USBOTG_SRC})
|
||||
list(APPEND STM32_STDPERIPH_USB_SRC ${STM32_STDPERIPH_USBCORE_SRC})
|
||||
list(APPEND STM32_STDPERIPH_USB_SRC ${STM32_STDPERIPH_USBCDC_SRC})
|
||||
list(APPEND STM32_STDPERIPH_USB_SRC ${STM32_STDPERIPH_USBHID_SRC})
|
||||
list(APPEND STM32_STDPERIPH_USB_SRC ${STM32_STDPERIPH_USBWRAPPER_SRC})
|
||||
list(APPEND STM32_STDPERIPH_USB_SRC ${STM32_STDPERIPH_USBMSC_SRC})
|
263
cmake/stm32.cmake
Normal file
263
cmake/stm32.cmake
Normal file
|
@ -0,0 +1,263 @@
|
|||
include(arm-none-eabi)
|
||||
include(stm32-usb)
|
||||
|
||||
set(CMSIS_DIR "${INAV_LIB_DIR}/main/CMSIS")
|
||||
set(CMSIS_INCLUDE_DIR "${CMSIS_DIR}/Core/Include")
|
||||
set(CMSIS_DSP_DIR "${INAV_LIB_DIR}/main/CMSIS/DSP")
|
||||
set(CMSIS_DSP_INCLUDE_DIR "${CMSIS_DSP_DIR}/Include")
|
||||
|
||||
set(CMSIS_DSP_SRC
|
||||
BasicMathFunctions/arm_mult_f32.c
|
||||
TransformFunctions/arm_rfft_fast_f32.c
|
||||
TransformFunctions/arm_cfft_f32.c
|
||||
TransformFunctions/arm_rfft_fast_init_f32.c
|
||||
TransformFunctions/arm_cfft_radix8_f32.c
|
||||
TransformFunctions/arm_bitreversal2.S
|
||||
CommonTables/arm_common_tables.c
|
||||
ComplexMathFunctions/arm_cmplx_mag_f32.c
|
||||
StatisticsFunctions/arm_max_f32.c
|
||||
)
|
||||
list(TRANSFORM CMSIS_DSP_SRC PREPEND "${CMSIS_DSP_DIR}/Source/")
|
||||
|
||||
set(STM32_STARTUP_DIR "${INAV_MAIN_SRC_DIR}/startup")
|
||||
|
||||
set(STM32_VCP_SRC
|
||||
drivers/serial_usb_vcp.c
|
||||
drivers/usb_io.c
|
||||
)
|
||||
main_sources(STM32_VCP_SRC)
|
||||
|
||||
set(STM32_MSC_SRC
|
||||
msc/usbd_msc_desc.c
|
||||
msc/usbd_storage.c
|
||||
)
|
||||
main_sources(STM32_MSC_SRC)
|
||||
|
||||
set(STM32_MSC_FLASH_SRC
|
||||
msc/usbd_storage_emfat.c
|
||||
msc/emfat.c
|
||||
msc/emfat_file.c
|
||||
)
|
||||
main_sources(STM32_MSC_FLASH_SRC)
|
||||
|
||||
set(STM32F4_STDPERIPH_DIR "${INAV_LIB_DIR}/main/STM32F4/Drivers/STM32F4xx_StdPeriph_Driver")
|
||||
set(STM32F4_CMSIS_DEVICE_DIR "${INAV_LIB_DIR}/main/STM32F4/Drivers/CMSIS/Device/ST/STM32F4xx")
|
||||
set(STM32F4_CMSIS_DRIVERS_DIR "${INAV_LIB_DIR}/main/STM32F4/Drivers/CMSIS")
|
||||
set(STM32F4_VCP_DIR "${INAV_MAIN_SRC_DIR}/vcpf4")
|
||||
|
||||
set(STM32F4_STDPERIPH_SRC_EXCLUDES
|
||||
stm32f4xx_can.c
|
||||
stm32f4xx_cec.c
|
||||
stm32f4xx_crc.c
|
||||
stm32f4xx_cryp.c
|
||||
stm32f4xx_cryp_aes.c
|
||||
stm32f4xx_cryp_des.c
|
||||
stm32f4xx_cryp_tdes.c
|
||||
stm32f4xx_dbgmcu.c
|
||||
stm32f4xx_dsi.c
|
||||
stm32f4xx_flash_ramfunc.c
|
||||
stm32f4xx_fmpi2c.c
|
||||
stm32f4xx_fmc.c
|
||||
stm32f4xx_hash.c
|
||||
stm32f4xx_hash_md5.c
|
||||
stm32f4xx_hash_sha1.c
|
||||
stm32f4xx_lptim.c
|
||||
stm32f4xx_qspi.c
|
||||
stm32f4xx_sai.c
|
||||
stm32f4xx_spdifrx.c
|
||||
)
|
||||
|
||||
set(STM32F4_STDPERIPH_SRC_DIR "${STM32F4_STDPERIPH_DIR}/Src")
|
||||
glob_except(STM32F4_STDPERIPH_SRC "${STM32F4_STDPERIPH_SRC_DIR}/*.c" STM32F4_STDPERIPH_SRC_EXCLUDES)
|
||||
|
||||
set(STM32F4_VCP_SRC
|
||||
stm32f4xx_it.c
|
||||
usb_bsp.c
|
||||
usbd_desc.c
|
||||
usbd_usr.c
|
||||
usbd_cdc_vcp.c
|
||||
)
|
||||
list(TRANSFORM STM32F4_VCP_SRC PREPEND "${STM32F4_VCP_DIR}/")
|
||||
|
||||
set(STM32F4_MSC_SRC
|
||||
drivers/usb_msc_f4xx.c
|
||||
)
|
||||
main_sources(STM32F4_MSC_SRC)
|
||||
|
||||
set(STM32F4_INCLUDE_DIRS
|
||||
"${CMSIS_INCLUDE_DIR}"
|
||||
"${CMSIS_DSP_INCLUDE_DIR}"
|
||||
"${STM32F4_STDPERIPH_DIR}/inc"
|
||||
"${STM32F4_CMSIS_DEVICE_DIR}"
|
||||
"${STM32F4_CMSIS_DRIVERS_DIR}"
|
||||
"${STM32F4_VCP_DIR}"
|
||||
)
|
||||
|
||||
set(STM32_INCLUDE_DIRS
|
||||
"${INAV_MAIN_SRC_DIR}/target"
|
||||
)
|
||||
|
||||
set(STM32_LINKER_DIR "${INAV_MAIN_SRC_DIR}/target/link")
|
||||
|
||||
#if(SEMIHOSTING)
|
||||
# set(SEMIHOSTING_DEFINITIONS "SEMIHOSTING")
|
||||
# set(SEMIHOSTING_LDFLAGS
|
||||
# --specs=rdimon.specs
|
||||
# -lc
|
||||
# -lrdimon
|
||||
# )
|
||||
#else()
|
||||
# set(SYS)
|
||||
#endif()
|
||||
#ifneq ($(SEMIHOSTING),)
|
||||
#SEMIHOSTING_CFLAGS = -DSEMIHOSTING
|
||||
#SEMIHOSTING_LDFLAGS = --specs=rdimon.specs -lc -lrdimon
|
||||
#SYSLIB :=
|
||||
#else
|
||||
#SEMIHOSTING_LDFLAGS =
|
||||
#SEMIHOSTING_CFLAGS =
|
||||
#SYSLIB := -lnosys
|
||||
#endif
|
||||
|
||||
set(STM32_LINK_LIBRARIES
|
||||
-lm
|
||||
-lc
|
||||
)
|
||||
|
||||
set(STM32_LINK_OPTIONS
|
||||
-nostartfiles
|
||||
--specs=nano.specs
|
||||
-static
|
||||
-Wl,-gc-sections,-Map,target.map
|
||||
-Wl,-L${STM32_LINKER_DIR}
|
||||
-Wl,--cref
|
||||
-Wl,--no-wchar-size-warning
|
||||
-Wl,--print-memory-usage
|
||||
)
|
||||
|
||||
set(STM32F4_SRC
|
||||
target/system_stm32f4xx.c
|
||||
drivers/accgyro/accgyro.c
|
||||
drivers/accgyro/accgyro_mpu.c
|
||||
drivers/adc_stm32f4xx.c
|
||||
drivers/adc_stm32f4xx.c
|
||||
drivers/bus_i2c_stm32f40x.c
|
||||
drivers/serial_softserial.c
|
||||
drivers/serial_uart_stm32f4xx.c
|
||||
drivers/system_stm32f4xx.c
|
||||
drivers/timer.c
|
||||
drivers/timer_impl_stdperiph.c
|
||||
drivers/timer_stm32f4xx.c
|
||||
drivers/uart_inverter.c
|
||||
drivers/dma_stm32f4xx.c
|
||||
drivers/sdcard/sdmmc_sdio_f4xx.c
|
||||
)
|
||||
|
||||
main_sources(STM32F4_SRC)
|
||||
|
||||
set(STM32F4_DEFINITIONS
|
||||
STM32F4
|
||||
USE_STDPERIPH_DRIVER
|
||||
ARM_MATH_MATRIX_CHECK
|
||||
ARM_MATH_ROUNDING
|
||||
__FPU_PRESENT=1
|
||||
UNALIGNED_SUPPORT_DISABLE
|
||||
ARM_MATH_CM4
|
||||
)
|
||||
|
||||
set(STM32F4_COMMON_OPTIONS
|
||||
-mthumb
|
||||
-mcpu=cortex-m4
|
||||
-march=armv7e-m
|
||||
-mfloat-abi=hard
|
||||
-mfpu=fpv4-sp-d16
|
||||
-fsingle-precision-constant
|
||||
)
|
||||
|
||||
set(STM32F4_COMPILE_OPTIONS
|
||||
)
|
||||
|
||||
set(SETM32F4_LINK_OPTIONS
|
||||
)
|
||||
|
||||
set(STM32F411_STDPERIPH_SRC_EXCLUDES "stm32f4xx_fsmc.c")
|
||||
|
||||
set(STM32F411_COMPILE_DEFINITIONS
|
||||
FLASH_SIZE=512
|
||||
)
|
||||
|
||||
macro(get_stm32_target_features) # out-var dir
|
||||
file(READ "${ARGV1}/target.h" _contents)
|
||||
string(REGEX MATCH "#define[\t ]+USE_VCP" HAS_VCP ${_contents})
|
||||
if(HAS_VCP)
|
||||
list(APPEND ${ARGV0} VCP)
|
||||
endif()
|
||||
string(REGEX MATCH "define[\t ]+USE_FLASHFS" HAS_FLASHFS ${_contents})
|
||||
if(HAS_FLASHFS)
|
||||
list(APPEND ${ARGV0} FLASHFS)
|
||||
endif()
|
||||
if (HAS_FLASHFS) # || SDCARD
|
||||
list(APPEND ${ARGV0} MSC)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(target_stm32 name)
|
||||
# Main .elf target
|
||||
add_executable(${name} ${COMMON_SRC} ${CMSIS_DSP_SRC})
|
||||
file(GLOB target_c_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.c")
|
||||
file(GLOB target_h_sources "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
|
||||
target_sources(${name} PRIVATE ${target_c_sources} ${target_h_sources})
|
||||
target_include_directories(${name} PRIVATE . ${STM32_INCLUDE_DIRS})
|
||||
target_link_libraries(${name} PRIVATE ${STM32_LINK_LIBRARIES})
|
||||
target_link_options(${name} PRIVATE ${STM32_LINK_OPTIONS})
|
||||
get_stm32_target_features(features "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set_property(TARGET ${name} PROPERTY FEATURES ${features})
|
||||
if(VCP IN_LIST features)
|
||||
target_sources(${name} PRIVATE ${STM32_VCP_SRC})
|
||||
endif()
|
||||
if(MSC IN_LIST features)
|
||||
target_sources(${name} PRIVATE ${STM32_MSC_SRC})
|
||||
if (FLASHFS IN_LIST features)
|
||||
target_sources(${name} PRIVATE ${STM32_MSC_FLASH_SRC})
|
||||
endif()
|
||||
endif()
|
||||
# Generate .hex
|
||||
set(hexdir "${CMAKE_BINARY_DIR}/hex")
|
||||
set(hex "${hexdir}/$<TARGET_FILE_PREFIX:${name}>.hex")
|
||||
add_custom_command(TARGET ${name} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${hexdir}"
|
||||
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${name}> "${hex}")
|
||||
# clean_<target>
|
||||
set(clean_target "clean_${name}")
|
||||
add_custom_target(${clean_target}
|
||||
COMMAND cmake -E rm -r "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
COMMENT "Removeng intermediate files for ${name}")
|
||||
set_property(TARGET ${clean_target} PROPERTY TARGET_MESSAGES OFF)
|
||||
endfunction()
|
||||
|
||||
function(target_stm32f4xx name)
|
||||
target_stm32(${name})
|
||||
target_sources(${name} PRIVATE ${STM32F4_SRC})
|
||||
target_compile_options(${name} PRIVATE ${STM32F4_COMMON_OPTIONS} ${STM32F4_COMPILE_OPTIONS})
|
||||
target_include_directories(${name} PRIVATE ${STM32_STDPERIPH_USB_INCLUDE_DIRS} ${STM32F4_INCLUDE_DIRS})
|
||||
target_compile_definitions(${name} PRIVATE ${STM32F4_DEFINITIONS})
|
||||
target_link_options(${name} PRIVATE ${STM32F4_COMMON_OPTIONS} ${STM32F4_LINK_OPTIONS})
|
||||
|
||||
get_property(features TARGET ${name} PROPERTY FEATURES)
|
||||
if(VCP IN_LIST features)
|
||||
target_sources(${name} PRIVATE ${STM32_STDPERIPH_USB_SRC} ${STM32F4_VCP_SRC})
|
||||
endif()
|
||||
if(MSC IN_LIST features)
|
||||
target_sources(${name} PRIVATE ${STM32F4_MSC_SRC})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(target_stm32f411 name)
|
||||
target_stm32f4xx(${name})
|
||||
set(STM32F411_STDPERIPH_SRC ${STM32F4_STDPERIPH_SRC})
|
||||
exclude_basenames(STM32F411_STDPERIPH_SRC STM32F411_STDPERIPH_SRC_EXCLUDES)
|
||||
target_sources(${name} PRIVATE "${STM32_STARTUP_DIR}/startup_stm32f411xe.s" ${STM32F411_STDPERIPH_SRC})
|
||||
target_link_options(${name} PRIVATE "-T${STM32_LINKER_DIR}/stm32_flash_f411.ld")
|
||||
target_compile_definitions(${name} PRIVATE STM32F411xE ${STM32F411_COMPILE_DEFINITIONS})
|
||||
setup_firmware_target(${name})
|
||||
endfunction()
|
276
src/main/CMakeLists.txt
Normal file
276
src/main/CMakeLists.txt
Normal file
|
@ -0,0 +1,276 @@
|
|||
set(COMMON_SRC
|
||||
main.c
|
||||
|
||||
target/common_hardware.c
|
||||
|
||||
build/assert.c
|
||||
build/build_config.c
|
||||
build/debug.c
|
||||
build/version.c
|
||||
|
||||
common/bitarray.c
|
||||
common/calibration.c
|
||||
common/colorconversion.c
|
||||
common/crc.c
|
||||
common/encoding.c
|
||||
common/filter.c
|
||||
common/gps_conversion.c
|
||||
common/log.c
|
||||
common/logic_condition.c
|
||||
common/global_functions.c
|
||||
common/global_variables.c
|
||||
common/maths.c
|
||||
common/memory.c
|
||||
common/olc.c
|
||||
common/printf.c
|
||||
common/streambuf.c
|
||||
common/string_light.c
|
||||
common/time.c
|
||||
common/typeconversion.c
|
||||
common/uvarint.c
|
||||
|
||||
config/config_eeprom.c
|
||||
config/config_streamer.c
|
||||
config/feature.c
|
||||
config/parameter_group.c
|
||||
config/general_settings.c
|
||||
|
||||
drivers/adc.c
|
||||
drivers/buf_writer.c
|
||||
drivers/bus.c
|
||||
drivers/bus_busdev_i2c.c
|
||||
drivers/bus_busdev_spi.c
|
||||
drivers/bus_i2c_soft.c
|
||||
drivers/bus_spi.c
|
||||
drivers/display.c
|
||||
drivers/display_canvas.c
|
||||
drivers/display_font_metadata.c
|
||||
drivers/exti.c
|
||||
drivers/io.c
|
||||
drivers/io_pca9685.c
|
||||
drivers/irlock.c
|
||||
drivers/light_led.c
|
||||
drivers/osd.c
|
||||
drivers/persistent.c
|
||||
drivers/resource.c
|
||||
drivers/rx_nrf24l01.c
|
||||
drivers/rx_spi.c
|
||||
drivers/rx_xn297.c
|
||||
drivers/pitotmeter_adc.c
|
||||
drivers/pitotmeter_virtual.c
|
||||
drivers/pwm_esc_detect.c
|
||||
drivers/pwm_mapping.c
|
||||
drivers/pwm_output.c
|
||||
drivers/pinio.c
|
||||
drivers/rcc.c
|
||||
drivers/rx_pwm.c
|
||||
drivers/serial.c
|
||||
drivers/serial_uart.c
|
||||
drivers/sound_beeper.c
|
||||
drivers/stack_check.c
|
||||
drivers/system.c
|
||||
drivers/time.c
|
||||
drivers/timer.c
|
||||
drivers/usb_msc.c
|
||||
drivers/lights_io.c
|
||||
drivers/1-wire.c
|
||||
drivers/1-wire/ds_crc.c
|
||||
drivers/1-wire/ds2482.c
|
||||
drivers/temperature/ds18b20.c
|
||||
drivers/temperature/lm75.c
|
||||
drivers/pitotmeter_ms4525.c
|
||||
|
||||
fc/cli.c
|
||||
fc/config.c
|
||||
fc/controlrate_profile.c
|
||||
fc/fc_core.c
|
||||
fc/fc_init.c
|
||||
fc/fc_tasks.c
|
||||
fc/fc_hardfaults.c
|
||||
fc/fc_msp.c
|
||||
fc/fc_msp_box.c
|
||||
fc/rc_smoothing.c
|
||||
fc/rc_adjustments.c
|
||||
fc/rc_controls.c
|
||||
fc/rc_curves.c
|
||||
fc/rc_modes.c
|
||||
fc/runtime_config.c
|
||||
fc/settings.c
|
||||
fc/stats.c
|
||||
|
||||
flight/failsafe.c
|
||||
flight/hil.c
|
||||
flight/imu.c
|
||||
flight/mixer.c
|
||||
flight/pid.c
|
||||
flight/pid_autotune.c
|
||||
flight/rth_estimator.c
|
||||
flight/servos.c
|
||||
flight/wind_estimator.c
|
||||
flight/gyroanalyse.c
|
||||
flight/rpm_filter.c
|
||||
flight/dynamic_gyro_notch.c
|
||||
|
||||
io/beeper.c
|
||||
io/esc_serialshot.c
|
||||
io/servo_sbus.c
|
||||
io/frsky_osd.c
|
||||
io/osd_dji_hd.c
|
||||
io/lights.c
|
||||
io/piniobox.c
|
||||
io/pwmdriver_i2c.c
|
||||
io/serial.c
|
||||
io/serial_4way.c
|
||||
io/serial_4way_avrootloader.c
|
||||
io/serial_4way_stk500v2.c
|
||||
io/statusindicator.c
|
||||
io/rcdevice.c
|
||||
io/rcdevice_cam.c
|
||||
|
||||
msp/msp_serial.c
|
||||
|
||||
rx/crsf.c
|
||||
rx/eleres.c
|
||||
rx/fport.c
|
||||
rx/ibus.c
|
||||
rx/jetiexbus.c
|
||||
rx/msp.c
|
||||
rx/msp_override.c
|
||||
rx/nrf24_cx10.c
|
||||
rx/nrf24_inav.c
|
||||
rx/nrf24_h8_3d.c
|
||||
rx/nrf24_syma.c
|
||||
rx/nrf24_v202.c
|
||||
rx/pwm.c
|
||||
rx/frsky_crc.c
|
||||
rx/rx.c
|
||||
rx/rx_spi.c
|
||||
rx/sbus.c
|
||||
rx/sbus_channels.c
|
||||
rx/spektrum.c
|
||||
rx/sumd.c
|
||||
rx/sumh.c
|
||||
rx/uib_rx.c
|
||||
rx/xbus.c
|
||||
|
||||
scheduler/scheduler.c
|
||||
|
||||
sensors/acceleration.c
|
||||
sensors/battery.c
|
||||
sensors/boardalignment.c
|
||||
sensors/compass.c
|
||||
sensors/diagnostics.c
|
||||
sensors/gyro.c
|
||||
sensors/initialisation.c
|
||||
sensors/esc_sensor.c
|
||||
sensors/irlock.c
|
||||
sensors/temperature.c
|
||||
|
||||
uav_interconnect/uav_interconnect_bus.c
|
||||
uav_interconnect/uav_interconnect_rangefinder.c
|
||||
|
||||
blackbox/blackbox.c
|
||||
blackbox/blackbox_encoding.c
|
||||
blackbox/blackbox_io.c
|
||||
|
||||
cms/cms.c
|
||||
cms/cms_menu_battery.c
|
||||
cms/cms_menu_blackbox.c
|
||||
cms/cms_menu_builtin.c
|
||||
cms/cms_menu_imu.c
|
||||
cms/cms_menu_ledstrip.c
|
||||
cms/cms_menu_misc.c
|
||||
cms/cms_menu_mixer_servo.c
|
||||
cms/cms_menu_navigation.c
|
||||
cms/cms_menu_osd.c
|
||||
cms/cms_menu_saveexit.c
|
||||
cms/cms_menu_vtx.c
|
||||
|
||||
drivers/accgyro/accgyro_mpu6000.c
|
||||
drivers/accgyro/accgyro_mpu6500.c
|
||||
drivers/barometer/barometer_bmp085.c
|
||||
drivers/barometer/barometer_bmp280.c
|
||||
drivers/barometer/barometer_ms56xx.c
|
||||
drivers/compass/compass_ak8975.c
|
||||
drivers/compass/compass_hmc5883l.c
|
||||
drivers/compass/compass_mag3110.c
|
||||
drivers/compass/compass_qmc5883l.c
|
||||
drivers/compass/compass_ist8308.c
|
||||
drivers/compass/compass_ist8310.c
|
||||
drivers/compass/compass_lis3mdl.c
|
||||
drivers/display_ug2864hsweg01.c
|
||||
drivers/flash.c
|
||||
drivers/flash_m25p16.c
|
||||
drivers/light_ws2811strip.c
|
||||
drivers/max7456.c
|
||||
drivers/rangefinder/rangefinder_hcsr04.c
|
||||
drivers/rangefinder/rangefinder_hcsr04_i2c.c
|
||||
drivers/rangefinder/rangefinder_srf10.c
|
||||
drivers/rangefinder/rangefinder_vl53l0x.c
|
||||
drivers/rangefinder/rangefinder_virtual.c
|
||||
drivers/opflow/opflow_fake.c
|
||||
drivers/opflow/opflow_virtual.c
|
||||
drivers/pitotmeter_adc.c
|
||||
drivers/vtx_common.c
|
||||
|
||||
io/rangefinder_msp.c
|
||||
io/rangefinder_benewake.c
|
||||
io/opflow_cxof.c
|
||||
io/opflow_msp.c
|
||||
io/dashboard.c
|
||||
io/displayport_frsky_osd.c
|
||||
io/displayport_max7456.c
|
||||
io/displayport_msp.c
|
||||
io/displayport_oled.c
|
||||
io/displayport_hott.c
|
||||
io/flashfs.c
|
||||
io/gps.c
|
||||
io/gps_ublox.c
|
||||
io/gps_nmea.c
|
||||
io/gps_naza.c
|
||||
io/ledstrip.c
|
||||
io/osd.c
|
||||
io/osd_canvas.c
|
||||
io/osd_common.c
|
||||
io/osd_grid.c
|
||||
io/osd_hud.c
|
||||
|
||||
navigation/navigation.c
|
||||
navigation/navigation_fixedwing.c
|
||||
navigation/navigation_fw_launch.c
|
||||
navigation/navigation_geo.c
|
||||
navigation/navigation_multicopter.c
|
||||
navigation/navigation_pos_estimator.c
|
||||
navigation/navigation_pos_estimator_agl.c
|
||||
navigation/navigation_pos_estimator_flow.c
|
||||
navigation/navigation_rover_boat.c
|
||||
|
||||
sensors/barometer.c
|
||||
sensors/pitotmeter.c
|
||||
sensors/rangefinder.c
|
||||
sensors/opflow.c
|
||||
|
||||
telemetry/crsf.c
|
||||
telemetry/frsky.c
|
||||
telemetry/frsky_d.c
|
||||
telemetry/hott.c
|
||||
telemetry/ibus_shared.c
|
||||
telemetry/ibus.c
|
||||
telemetry/ltm.c
|
||||
telemetry/mavlink.c
|
||||
telemetry/msp_shared.c
|
||||
telemetry/smartport.c
|
||||
telemetry/sim.c
|
||||
telemetry/telemetry.c
|
||||
|
||||
io/vtx.c
|
||||
io/vtx_string.c
|
||||
io/vtx_smartaudio.c
|
||||
io/vtx_tramp.c
|
||||
io/vtx_ffpv24g.c
|
||||
io/vtx_control.c
|
||||
)
|
||||
|
||||
main_sources(COMMON_SRC)
|
||||
|
||||
add_subdirectory(target)
|
|
@ -30,8 +30,13 @@
|
|||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#if defined(USE_FLASHFS)
|
||||
|
||||
#include "drivers/flash.h"
|
||||
#include "flashfs.h"
|
||||
|
||||
#include "io/flashfs.h"
|
||||
|
||||
static flashPartition_t *flashPartition;
|
||||
|
||||
|
@ -559,3 +564,5 @@ void flashfsInit(void)
|
|||
flashfsSeekAbs(flashfsIdentifyStartOfFreeSpace());
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
7
src/main/target/CMakeLists.txt
Normal file
7
src/main/target/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
file(GLOB entries *)
|
||||
foreach(subdir ${entries})
|
||||
set(entry "${subdir}/CMakeLists.txt")
|
||||
if (EXISTS ${entry})
|
||||
add_subdirectory(${subdir})
|
||||
endif()
|
||||
endforeach()
|
4
src/main/target/MATEKF411/CMakeLists.txt
Normal file
4
src/main/target/MATEKF411/CMakeLists.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
target_stm32f411(MATEKF411)
|
||||
target_stm32f411(MATEKF411_FD_SFTSRL)
|
||||
target_stm32f411(MATEKF411_RSSI)
|
||||
target_stm32f411(MATEKF411_SFTSRL2)
|
1
src/main/target/MATEKF411SE/CMakeLists.txt
Normal file
1
src/main/target/MATEKF411SE/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
|||
target_stm32f411(MATEKF411SE)
|
1
src/main/target/NOX/CMakeLists.txt
Normal file
1
src/main/target/NOX/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
|||
target_stm32f411(NOX)
|
Loading…
Add table
Add a link
Reference in a new issue