From 354c26ca67e21bbee11b3495d47f3ebf7f4206d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Tue, 25 Oct 2022 21:23:02 +0200 Subject: [PATCH 1/3] Change Build step to use pathcelfcrc program instead of python script --- stm-firmware/CMakeLists.txt | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/stm-firmware/CMakeLists.txt b/stm-firmware/CMakeLists.txt index 04f5a23..2eb28a8 100644 --- a/stm-firmware/CMakeLists.txt +++ b/stm-firmware/CMakeLists.txt @@ -1,7 +1,7 @@ set(CMAKE_SYSTEM_NAME Generic) set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_CROSSCOMPILING 1) -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.18) set(CMAKE_TOOLCHAIN_FILE "arm-none-eabi-gcc.cmake") @@ -43,26 +43,12 @@ else (GIT_FOUND) message("Version is set to: ${GIT_DESCRIBE}${ColorReset}") endif (GIT_FOUND) -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) - message(FATAL_ERROR "${BoldRed}Python virtual environment not set up: virtualenv: command not found!${ColorReset}") -endif (VIRTUALENV) +find_program(PATCHELFCRC patchelfcrc) +if (PATCHELFCRC) + message("patchelfcrc found: ${PATCHELFCRC}") +else(PATCHELFCRC) + message(FATAL_ERROR "${BoldRed}Patchelfcrc not found. Cannot patch CRC checksum into ELF file: patchelfcrc: command not found! See: https://git.shimatta.de/mhu/patchelfcrc${ColorReset}") +endif (PATCHELFCRC) set(ELFFILE ${PROJECT_NAME}.elf) @@ -131,8 +117,8 @@ target_include_directories(${ELFFILE} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/updat add_custom_command( TARGET ${ELFFILE} POST_BUILD - COMMAND ./python "${CMAKE_CURRENT_SOURCE_DIR}/crc-patcher/crc_patch_elf.py" "${CMAKE_CURRENT_BINARY_DIR}/${ELFFILE}" - WORKING_DIRECTORY ${VENV_BIN} + COMMAND ${PATCHELFCRC} --little-endian --verbose --granularity word --start-magic 0xa8be53f9 --end-magic 0xffa582ff -O .flashcrc -p crc-32-mpeg -S .text -S .data -S .ccmdata -S .vectors "${CMAKE_CURRENT_BINARY_DIR}/${ELFFILE}" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Running Flash CRC Patcher" ) From f46044e5fce31d264c0d25c9ba155e91d9017f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sat, 31 Dec 2022 19:24:27 +0100 Subject: [PATCH 2/3] Remove mthumb-interwork from GCC command line. It is not neededfor CM4 cores --- stm-firmware/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stm-firmware/CMakeLists.txt b/stm-firmware/CMakeLists.txt index 2eb28a8..164ee2f 100644 --- a/stm-firmware/CMakeLists.txt +++ b/stm-firmware/CMakeLists.txt @@ -57,7 +57,7 @@ set(MAPFILE ${PROJECT_NAME}.map) 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) +add_compile_options(-mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostartfiles -Wimplicit-fallthrough=3 -Wsign-compare) set(GIT_DESCRIBE "${GIT_DESCRIBE}") @@ -110,7 +110,7 @@ add_executable(${ELFFILE} ${MAIN_SOURCES} ${CFG_PARSER_SRCS} ${UI_SRCS} add_dependencies(${ELFFILE} updater-ram-code-header-blob) 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) +target_link_options(${ELFFILE} PRIVATE -mlittle-endian -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles -T${LINKER_SCRIPT} -Wl,--print-memory-usage) target_link_libraries(${ELFFILE} base64-lib linklist-lib) target_include_directories(${ELFFILE} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/updater/ram-code/include/") From 240b1ffc8f770bc00e294e0ca2adcb5722477a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Sat, 31 Dec 2022 19:25:55 +0100 Subject: [PATCH 3/3] Update gitignore for use with vscode and clangd --- stm-firmware/.gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stm-firmware/.gitignore b/stm-firmware/.gitignore index bcb7a46..3258d04 100644 --- a/stm-firmware/.gitignore +++ b/stm-firmware/.gitignore @@ -16,3 +16,10 @@ reflow-controller.includes *.files *.user.* *.user + +# VSCODE and CLANGD sepcific excludes + +.vscode/ +build/ +.cache/ +compile_commands.json