reflow-oven-control-sw/stm-firmware/updater/ram-code/CMakeLists.txt

59 lines
2.8 KiB
CMake
Raw Permalink Normal View History

2021-03-23 22:15:11 +01:00
project(updater-ram-code)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING 1)
cmake_minimum_required(VERSION 3.0)
set(CMAKE_TOOLCHAIN_FILE "arm-none-eabi-gcc.cmake")
find_package(Python COMPONENTS Interpreter)
if (Python_FOUND)
message("Python interpreter used for converting updater RAM code: ${Python_EXECUTABLE}")
else (Python_FOUND)
message(FATAL_ERROR "${BoldRed}Python interpreter not found! Please install python 3.${ColorReset}")
endif (Python_FOUND)
2021-03-23 22:15:11 +01:00
set(ELFFILE ${PROJECT_NAME}.elf)
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/ram-link.ld)
set(ELFFILE "${PROJECT_NAME}.elf")
aux_source_directory("." SRCS)
aux_source_directory("fatfs" FATFS_SRCS)
aux_source_directory("3rd-party/sha256" SHA256_SRCS)
2021-03-23 22:15:11 +01:00
aux_source_directory("fatfs/shimatta_sdio_driver" SDIO_SRCS)
set(STM_PERIPH_SRCS "../../stm-periph/backup-ram.c" "../../stm-periph/rcc-manager.c" "../../stm-periph/crc-unit.c")
2021-04-06 20:55:41 +02:00
set(SAFETY_MEMORY_SRCS "../../safety/safety-memory.c")
2021-03-23 22:15:11 +01:00
add_executable(${ELFFILE} ${SRCS} ${FATFS_SRCS} ${SDIO_SRCS} ${STM_PERIPH_SRCS} ${SAFETY_MEMORY_SRCS} ${SHA256_SRCS})
2021-03-23 22:15:11 +01:00
target_include_directories(${ELFFILE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include ../../include ${CMAKE_CURRENT_SOURCE_DIR}/3rd-party)
2021-03-23 22:15:11 +01:00
target_compile_options(${ELFFILE} PRIVATE -Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
2021-04-08 21:50:42 +02:00
target_compile_options(${ELFFILE} PRIVATE -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostartfiles -Wimplicit-fallthrough=3 -Wsign-compare -Os -g3)
2023-01-01 21:12:00 +01:00
target_compile_definitions(${ELFFILE} PRIVATE -DHSE_VALUE=8000000UL -DSTM32F407xx -DSTM32F4XX -DARM_MATH_CM4 -DSAFETY_MEMORY_STRIPOUT_DUMP)
2021-03-23 22:15:11 +01:00
target_link_options(${ELFFILE} PRIVATE -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles -T${LINKER_SCRIPT} -Wl,--print-memory-usage)
set(GEN_HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/include/generated")
set(GEN_HEADER_FILE "${GEN_HEADER_PATH}/${PROJECT_NAME}.bin.h")
target_include_directories(${ELFFILE} INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/include/")
set(GEN_HEADER_FILE "${CMAKE_CURRENT_BINARY_DIR}/include/generated/${PROJECT_NAME}.bin.h")
add_custom_target(updater-ram-code-header-blob DEPENDS ${GEN_HEADER_FILE})
add_custom_command(DEPENDS
${ELFFILE}
OUTPUT
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.bin"
COMMAND
${CMAKE_OBJCOPY} -O binary ${ELFFILE} "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.bin"
)
add_custom_command(DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.bin"
OUTPUT
${GEN_HEADER_FILE}
COMMAND
mkdir -p ${GEN_HEADER_PATH} && ${Python_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/bin2carray.py" "${GEN_HEADER_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.bin"
2021-03-23 22:15:11 +01:00
)