zephyr/boards/common/openocd.board.cmake
qianfan Zhao ffbe747225 openocd.board.cmake: Fix flash load address
'make flash' always erase the flash banks from sector 0, and flashing
the Zephyr.bin file to base address of flash even if there has a
bootloader placed on the first sector.

Users maybe want placed Zephyr to another location instead of sector
0 by adding 'zephyr,code-partition' in dts. But the openocd scripts
doesn't deal with that currently.

Fix this issue, flash zephyr.elf instead of zephyr.bin, elf file
contain load address and openocd scripts can deal with it.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2018-12-07 11:34:56 -05:00

24 lines
701 B
CMake

set_ifndef(BOARD_FLASH_RUNNER openocd)
set_ifndef(BOARD_DEBUG_RUNNER openocd)
# "load_image" or "flash write_image erase"?
if(CONFIG_X86 OR CONFIG_ARC)
set_ifndef(OPENOCD_USE_LOAD_IMAGE YES)
endif()
if(OPENOCD_USE_LOAD_IMAGE)
set_ifndef(OPENOCD_FLASH load_image)
else()
set_ifndef(OPENOCD_FLASH "flash write_image erase")
endif()
# zephyr.elf, or something else?
set_ifndef(OPENOCD_IMAGE "${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME}")
set(OPENOCD_CMD_LOAD_DEFAULT "${OPENOCD_FLASH} ${OPENOCD_IMAGE}")
set(OPENOCD_CMD_VERIFY_DEFAULT "verify_image ${OPENOCD_IMAGE}")
board_finalize_runner_args(openocd
--cmd-load "${OPENOCD_CMD_LOAD_DEFAULT}"
--cmd-verify "${OPENOCD_CMD_VERIFY_DEFAULT}"
)