Merge pull request 'Use patchelfcrc program for CRC patching.' (#45) from port-to-patchelfcrc into dev
Reviewed-on: #45
This commit is contained in:
commit
049afbd66f
7
stm-firmware/.gitignore
vendored
7
stm-firmware/.gitignore
vendored
@ -16,3 +16,10 @@ reflow-controller.includes
|
||||
*.files
|
||||
*.user.*
|
||||
*.user
|
||||
|
||||
# VSCODE and CLANGD sepcific excludes
|
||||
|
||||
.vscode/
|
||||
build/
|
||||
.cache/
|
||||
compile_commands.json
|
||||
|
@ -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)
|
||||
@ -71,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}")
|
||||
@ -124,15 +110,15 @@ 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/")
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user