Add signing of px4 binary into makefiles

When an environment variable "SIGNING_TOOL" is defined, the make will
call this with two filename arguments: <input> and <output>.

The SIGNING_TOOL will read in the binary from input, and append
signature to the output. For example:

SIGNING_TOOL=${PWD}/Tools/cryptotools.py make px4_fmu-v5_default

Will use the example "cryptotools.py" to sign the px4_fmu-v5.bin

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
Jukka Laitinen 2020-11-03 14:39:59 +02:00 committed by Lorenz Meier
parent 0f80296340
commit 5e79773275
1 changed files with 14 additions and 2 deletions

View File

@ -148,8 +148,20 @@ if (config_romfs_root)
target_link_libraries(px4 PRIVATE romfs)
endif()
add_custom_command(OUTPUT ${PX4_BINARY_DIR_REL}/${PX4_BOARD}.bin
COMMAND ${CMAKE_OBJCOPY} -O binary ${PX4_BINARY_DIR_REL}/${FW_NAME} ${PX4_BINARY_DIR_REL}/${PX4_BOARD}.bin
if((DEFINED ENV{SIGNING_TOOL}) AND (NOT NUTTX_DIR MATCHES "external"))
set(PX4_BINARY_OUTPUT ${PX4_BINARY_DIR}/${PX4_BOARD}_unsigned.bin)
add_custom_command(OUTPUT ${PX4_BINARY_DIR_REL}/${PX4_BOARD}.bin
COMMAND $ENV{SIGNING_TOOL} $ENV{SIGNING_ARGS} ${PX4_BINARY_OUTPUT} ${PX4_BINARY_DIR}/${PX4_BOARD}.bin
DEPENDS ${PX4_BINARY_OUTPUT}
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
)
else()
set(PX4_BINARY_OUTPUT ${PX4_BINARY_DIR_REL}/${PX4_BOARD}.bin)
endif()
add_custom_command(OUTPUT ${PX4_BINARY_OUTPUT}
COMMAND ${CMAKE_OBJCOPY} -O binary ${PX4_BINARY_DIR_REL}/${FW_NAME} ${PX4_BINARY_OUTPUT}
DEPENDS px4
)