25 lines
1.3 KiB
CMake
25 lines
1.3 KiB
CMake
# Host tool wm_tool packs the firmware into .img / _gz.img / .fls.
|
|
set(NL_WM_TOOL ${CMAKE_BINARY_DIR}/wm_tool)
|
|
add_custom_command(OUTPUT ${NL_WM_TOOL}
|
|
COMMAND cc -O2 -w -o ${NL_WM_TOOL} ${SDK_DIR}/tools/wm_tool.c -lpthread
|
|
DEPENDS ${SDK_DIR}/tools/wm_tool.c
|
|
COMMENT "Building host tool wm_tool")
|
|
add_custom_target(nl_wm_tool DEPENDS ${NL_WM_TOOL})
|
|
|
|
# 2M layout: update area 0x100000, run area 0x10100 (same as the old Klyqa images).
|
|
function(nl_add_images target)
|
|
add_dependencies(${target} nl_wm_tool)
|
|
set(out ${CMAKE_BINARY_DIR}/${target})
|
|
add_custom_command(TARGET ${target} POST_BUILD
|
|
COMMAND ${CMAKE_OBJCOPY} --output-target=binary -S -g -x -X -R .sbss -R .bss -R .reginfo -R .stack
|
|
$<TARGET_FILE:${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} $<TARGET_FILE:${target}>
|
|
COMMENT "Packing ${target}.fls and ${target}_gz.img")
|
|
endfunction()
|