diff --git a/cmake/image.cmake b/cmake/image.cmake index 7cfb8fe..8e20c0a 100644 --- a/cmake/image.cmake +++ b/cmake/image.cmake @@ -15,6 +15,10 @@ function(nl_add_images target) $ ${out}.bin COMMAND ${NL_WM_TOOL} -b ${out}.bin -sb ${SDK_DIR}/Bin/secboot.img -fc compress -it 2M -ua 100000 -ra 10100 -df -o ${out} + COMMAND ${CMAKE_COMMAND} -DVERSION_HEADER=${CMAKE_BINARY_DIR}/generated/nl_version.h + -DMKIMAGE=${CMAKE_SOURCE_DIR}/tools/mkimage/nl_mkimage.py -DIMAGE=${out}_gz.img + -DDEVICE=${NINLIGHT_DEVICE} -DOUT=${out}_ota.img + -P ${CMAKE_SOURCE_DIR}/cmake/run_mkimage.cmake COMMAND ${CMAKE_SIZE} $ COMMENT "Packing ${target}.fls and ${target}_gz.img") endfunction() diff --git a/cmake/run_mkimage.cmake b/cmake/run_mkimage.cmake new file mode 100644 index 0000000..a0ac4ec --- /dev/null +++ b/cmake/run_mkimage.cmake @@ -0,0 +1,8 @@ +file(READ ${VERSION_HEADER} V) +string(REGEX MATCH "\"([^\"]*)\"" _m "${V}") +set(VERSION "${CMAKE_MATCH_1}") +execute_process(COMMAND python3 ${MKIMAGE} --image ${IMAGE} --device ${DEVICE} --version ${VERSION} --out ${OUT} + RESULT_VARIABLE rc) +if(NOT rc EQUAL 0) + message(FATAL_ERROR "nl_mkimage failed (${rc})") +endif() diff --git a/tools/build_all.sh b/tools/build_all.sh index b0a65bf..3879b88 100755 --- a/tools/build_all.sh +++ b/tools/build_all.sh @@ -11,3 +11,4 @@ for d in "${DEVICES[@]}"; do cmake --build "$OUT/$d" done ls -1 "$OUT"/*/ninlight_*.fls +ls -1 "$OUT"/*/ninlight_*_ota.img