2021-03-21 22:38:22 +01:00
|
|
|
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")
|
|
|
|
|
|
|
|
project(reflow-controller)
|
|
|
|
|
|
|
|
if(NOT WIN32)
|
|
|
|
string(ASCII 27 Esc)
|
|
|
|
set(ColorReset "${Esc}[m")
|
|
|
|
set(ColorBold "${Esc}[1m")
|
|
|
|
set(Red "${Esc}[31m")
|
|
|
|
set(Green "${Esc}[32m")
|
|
|
|
set(Yellow "${Esc}[33m")
|
|
|
|
set(Blue "${Esc}[34m")
|
|
|
|
set(Magenta "${Esc}[35m")
|
|
|
|
set(Cyan "${Esc}[36m")
|
|
|
|
set(White "${Esc}[37m")
|
|
|
|
set(BoldRed "${Esc}[1;31m")
|
|
|
|
set(BoldGreen "${Esc}[1;32m")
|
|
|
|
set(BoldYellow "${Esc}[1;33m")
|
|
|
|
set(BoldBlue "${Esc}[1;34m")
|
|
|
|
set(BoldMagenta "${Esc}[1;35m")
|
|
|
|
set(BoldCyan "${Esc}[1;36m")
|
|
|
|
set(BoldWhite "${Esc}[1;37m")
|
|
|
|
endif()
|
|
|
|
|
2021-04-10 19:38:04 +02:00
|
|
|
find_package(Git)
|
|
|
|
if (GIT_FOUND)
|
|
|
|
message("Git found")
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${GIT_EXECUTABLE} describe --always --tags --dirty
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_DESCRIBE
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
message("${BoldGreen}Git based version number: ${GIT_DESCRIBE}${ColorReset}")
|
|
|
|
else (GIT_FOUND)
|
|
|
|
set(GIT_DESCRIBE "v0.0.0-unknown")
|
|
|
|
message("${BoldRed}No git installation found. It is highly recommended using git to generate the version number")
|
|
|
|
message("Version is set to: ${GIT_DESCRIBE}${ColorReset}")
|
|
|
|
endif (GIT_FOUND)
|
2021-03-23 22:15:11 +01:00
|
|
|
|
2021-07-16 21:57:30 +02:00
|
|
|
find_program(VIRTUALENV virtualenv)
|
|
|
|
if (VIRTUALENV)
|
|
|
|
message("Python virtual environment found")
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${VIRTUALENV} venv
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
OUTPUT_QUIET
|
|
|
|
COMMAND_ERROR_IS_FATAL ANY
|
|
|
|
)
|
|
|
|
set(VENV_BIN "${CMAKE_CURRENT_BINARY_DIR}/venv/bin")
|
|
|
|
execute_process(
|
|
|
|
COMMAND ./pip install -r "${CMAKE_CURRENT_SOURCE_DIR}/crc-patcher/requirements.txt"
|
|
|
|
WORKING_DIRECTORY ${VENV_BIN}
|
|
|
|
OUTPUT_QUIET
|
|
|
|
COMMAND_ERROR_IS_FATAL ANY
|
|
|
|
)
|
|
|
|
message("${BoldGreen}python virtual environment set up!${ColorReset}")
|
|
|
|
else(VIRTUALENV)
|
2021-07-17 15:25:25 +02:00
|
|
|
message(FATAL_ERROR "${BoldRed}Python virtual environment not set up: virtualenv: command not found!${ColorReset}")
|
2021-07-16 21:57:30 +02:00
|
|
|
endif (VIRTUALENV)
|
|
|
|
|
|
|
|
|
2021-03-21 22:38:22 +01:00
|
|
|
set(ELFFILE ${PROJECT_NAME}.elf)
|
2021-04-10 19:38:04 +02:00
|
|
|
set(HEXFILE ${PROJECT_NAME}.hex)
|
2021-07-16 21:17:59 +02:00
|
|
|
set(MAPFILE ${PROJECT_NAME}.map)
|
2021-03-21 22:38:22 +01:00
|
|
|
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/stm32f407vet6_flash.ld)
|
|
|
|
|
|
|
|
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
|
|
|
add_compile_options(-mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostartfiles -Wimplicit-fallthrough=3 -Wsign-compare)
|
|
|
|
|
|
|
|
|
2021-03-23 22:15:11 +01:00
|
|
|
set(GIT_DESCRIBE "${GIT_DESCRIBE}")
|
|
|
|
add_definitions(-DBASE64_LOOKUP_TABLE_SECTION=\".ccm.bss\" -DSHELLMATTA_HELP_ALIAS=\"?\" -DGIT_VER=${GIT_DESCRIBE} -DHSE_VALUE=8000000UL -DSTM32F407xx -DSTM32F4XX -DARM_MATH_CM4)
|
2021-03-21 22:38:22 +01:00
|
|
|
|
2021-10-10 22:09:46 +02:00
|
|
|
add_subdirectory(doxygen)
|
2021-03-23 22:15:11 +01:00
|
|
|
add_subdirectory(updater/ram-code)
|
2021-03-21 22:38:22 +01:00
|
|
|
|
2021-03-23 22:15:11 +01:00
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
2021-03-21 22:38:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2021-04-10 19:38:04 +02:00
|
|
|
add_definitions(-DDEBUGBUILD)
|
2021-05-22 00:13:07 +02:00
|
|
|
add_compile_options(-O0 -g)
|
2021-07-16 21:17:59 +02:00
|
|
|
add_link_options(-Wl,-Map=${MAPFILE})
|
2021-03-21 22:38:22 +01:00
|
|
|
ELSE()
|
2021-04-10 19:38:04 +02:00
|
|
|
add_compile_options(-O3 -g)
|
|
|
|
add_link_options(-Wl,--gc-sections)
|
2021-03-21 22:38:22 +01:00
|
|
|
ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
|
2021-04-06 19:25:25 +02:00
|
|
|
|
2021-04-10 19:38:04 +02:00
|
|
|
if (UART_ON_DEBUG_HEADER)
|
2021-04-06 19:25:25 +02:00
|
|
|
add_definitions(-DUART_ON_DEBUG_HEADER)
|
2021-04-10 19:38:04 +02:00
|
|
|
message("${BoldRed}UART forced to debug header${ColorReset}")
|
|
|
|
endif (UART_ON_DEBUG_HEADER)
|
2021-04-06 19:25:25 +02:00
|
|
|
|
2021-03-23 22:15:11 +01:00
|
|
|
add_subdirectory(base64-lib)
|
2021-04-10 22:35:30 +02:00
|
|
|
add_subdirectory(linklist-lib)
|
2021-03-23 22:15:11 +01:00
|
|
|
|
2021-03-21 22:38:22 +01:00
|
|
|
aux_source_directory("." MAIN_SOURCES)
|
|
|
|
aux_source_directory("config-parser" CFG_PARSER_SRCS)
|
|
|
|
aux_source_directory("ui" UI_SRCS)
|
|
|
|
aux_source_directory("fatfs" FAT_SRCS)
|
|
|
|
aux_source_directory("fatfs/shimatta_sdio_driver" SDIO_SRCS)
|
|
|
|
aux_source_directory("boot" BOOT_SRCS)
|
|
|
|
aux_source_directory("setup" SETUP_SRCS)
|
|
|
|
aux_source_directory("stm-periph" STM_PERIPH_SRCS)
|
|
|
|
aux_source_directory("settings" SETTINGS_SRCS)
|
|
|
|
aux_source_directory("safety" SAFETY_SRCS)
|
|
|
|
aux_source_directory("shellmatta/src" SHELLMATTA_SRCS)
|
|
|
|
aux_source_directory("updater" UPDATER_SRCS)
|
2021-05-22 16:40:08 +02:00
|
|
|
aux_source_directory("temp-profile" PROFILE_SRCS)
|
2021-03-21 22:38:22 +01:00
|
|
|
|
|
|
|
add_executable(${ELFFILE} ${MAIN_SOURCES} ${CFG_PARSER_SRCS} ${UI_SRCS}
|
|
|
|
${FAT_SRCS} ${SDIO_SRCS} ${BOOT_SRCS} ${SETUP_SRCS}
|
2021-05-22 16:40:08 +02:00
|
|
|
${STM_PERIPH_SRCS} ${SETTINGS_SRCS} ${SAFETY_SRCS}
|
|
|
|
${SHELLMATTA_SRCS} ${UPDATER_SRCS} ${PROFILE_SRCS}
|
2021-03-23 22:15:11 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
add_dependencies(${ELFFILE} updater-ram-code-header-blob)
|
2021-03-21 22:38:22 +01:00
|
|
|
|
|
|
|
target_include_directories(${ELFFILE} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/shellmatta/api ${CMAKE_CURRENT_SOURCE_DIR}/config-parser/include)
|
|
|
|
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)
|
2021-04-10 22:35:30 +02:00
|
|
|
target_link_libraries(${ELFFILE} base64-lib linklist-lib)
|
2021-03-23 22:15:11 +01:00
|
|
|
target_include_directories(${ELFFILE} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/updater/ram-code/include/")
|
2021-03-21 22:38:22 +01:00
|
|
|
|
2021-07-16 21:57:30 +02:00
|
|
|
add_custom_command(
|
|
|
|
TARGET ${ELFFILE}
|
|
|
|
POST_BUILD
|
2022-08-09 00:23:23 +02:00
|
|
|
COMMAND ./python "${CMAKE_CURRENT_SOURCE_DIR}/crc-patcher/crc_patch_elf.py" "${CMAKE_CURRENT_BINARY_DIR}/${ELFFILE}"
|
2021-07-16 21:57:30 +02:00
|
|
|
WORKING_DIRECTORY ${VENV_BIN}
|
|
|
|
COMMENT "Running Flash CRC Patcher"
|
|
|
|
)
|
|
|
|
|
2021-04-10 19:38:04 +02:00
|
|
|
set(HEX_PATH "${CMAKE_CURRENT_BINARY_DIR}/${HEXFILE}")
|
2021-10-03 19:27:41 +02:00
|
|
|
add_custom_target(update-image ALL DEPENDS ${HEX_PATH} "${HEX_PATH}.sha")
|
2021-04-10 19:38:04 +02:00
|
|
|
add_custom_command(
|
|
|
|
DEPENDS ${ELFFILE}
|
|
|
|
OUTPUT ${HEX_PATH}
|
2021-10-03 19:27:41 +02:00
|
|
|
COMMAND ${CMAKE_OBJCOPY} -O ihex ${ELFFILE} ${HEX_PATH}
|
|
|
|
)
|
|
|
|
add_custom_command(
|
|
|
|
DEPENDS ${HEX_PATH}
|
|
|
|
OUTPUT "${HEX_PATH}.sha"
|
|
|
|
COMMAND sha256sum "${HEX_PATH}" | cut -d " " -f 1 > "${HEX_PATH}.sha"
|
|
|
|
)
|