From 0095b14667afe844113725228671d8810b45d9e0 Mon Sep 17 00:00:00 2001 From: Gustavo de Souza dos Reis Date: Wed, 28 Jun 2023 08:59:04 -0300 Subject: [PATCH] Auto generate hpm files if bin2hpm is installed --- CMakeLists.txt | 14 ++++++++++++++ .../nxp/lpc17xx/bootloader/CMakeLists.txt | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6a914a97..8d8158887 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,4 +108,18 @@ add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD COMMENT "Converting the AXF output to a binary file" ) +##Generate hpm files if bin2hpm is installed + +find_program(BIN2HPM NAMES "bin2hpm") +if(BIN2HPM) + add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD + COMMAND bin2hpm -c 1 -n -m 0x315A -p 0x00 ${CMAKE_PROJECT_NAME}.bin -o ${CMAKE_PROJECT_NAME}.hpm + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + COMMENT "Creating HPM file from binary" + ) + message(STATUS "bin2hpm found in the $PATH, .hpm files will be generated automatically.") +else() + message(NOTICE "bin2hpm not found in the $PATH, .hpm files will not be generated.") +endif() + include( ${CMAKE_SOURCE_DIR}/probe/openocd.cmake ) diff --git a/port/ucontroller/nxp/lpc17xx/bootloader/CMakeLists.txt b/port/ucontroller/nxp/lpc17xx/bootloader/CMakeLists.txt index 06d0da405..2bf631d9b 100644 --- a/port/ucontroller/nxp/lpc17xx/bootloader/CMakeLists.txt +++ b/port/ucontroller/nxp/lpc17xx/bootloader/CMakeLists.txt @@ -42,3 +42,14 @@ add_custom_command(TARGET newboot POST_BUILD WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMENT "Generate a raw binary image of the bootloader" ) + +##Generate hpm files if bin2hpm is installed + +find_program(BIN2HPM NAMES "bin2hpm") +if(BIN2HPM) + add_custom_command(TARGET newboot POST_BUILD + COMMAND bin2hpm -c 0 -n -m 0x315A -p 0x00 newboot.bin -o newboot.hpm + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + COMMENT "Creating HPM file from binary" + ) +endif()