mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-02 20:32:48 +00:00
'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>
24 lines
701 B
CMake
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}"
|
|
)
|