mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
3f600d869e
QN908X CPUs require the image to have a valid checksum. The checksum is a simple addition of the first 7 uint32_t values stored in the 8th position of the image header. This position is a reseved entry of the Cortex-M Vector Table and its value depends on other fields that are computed at link time. Performing this checksum at link time seems hard to do, so instead this patch uses a python script to patch the checksum from the ELF file. This redefines the value of FLASHFILE to the new .elf file with the checksum fixed. With this patch, OpenOCD can program and verify QN908X images since now they have a valid checksum value.
31 lines
1.3 KiB
Makefile
31 lines
1.3 KiB
Makefile
# This board uses OpenOCD. Note that support for QN908x in OpenOCD at the time
|
|
# of writing has not been merged in the tree and is only available at
|
|
# http://openocd.zylin.com/#/c/5584/ .
|
|
PROGRAMMER ?= openocd
|
|
|
|
# Using dap or jlink depends on which firmware the OpenSDA debugger is running
|
|
#DEBUG_ADAPTER ?= dap
|
|
DEBUG_ADAPTER ?= jlink
|
|
|
|
# Use the shared OpenOCD configuration
|
|
OPENOCD_CONFIG ?= $(RIOTBOARD)/common/qn908x/dist/openocd.cfg
|
|
|
|
# Disable the watchdog when flashing. OpenOCD runs a CRC program in RAM to
|
|
# verify the image, which needs to have the WDT disabled but it is normally
|
|
# enabled after a 'reset halt' command.
|
|
OPENOCD_PRE_FLASH_CMDS += "-c qn908x disable_wdog"
|
|
|
|
# In order to boot, the CPU requires that the Vector table contain a valid
|
|
# checksum in one of the "reserved" fields. We don't generate this checksum when
|
|
# compiling and linking the code, instead this make target computes the checksum
|
|
# in another ELF file and we set it as the FLASHFILE.
|
|
ELFFILE ?= $(BINDIR)/$(APPLICATION).elf
|
|
ELFFILE_CHECKSUM ?= $(ELFFILE:.elf=-checksum.elf)
|
|
|
|
$(ELFFILE_CHECKSUM): $(ELFFILE)
|
|
$(Q)$(OBJCOPY) --dump-section .vectors=$<.vectors $<
|
|
$(Q)$(RIOTBOARD)/common/qn908x/dist/nxp_checksum.py $(if $(Q),--quiet) \
|
|
$<.vectors
|
|
$(Q)$(OBJCOPY) --update-section .vectors=$<.vectors $< $@
|
|
FLASHFILE ?= $(ELFFILE_CHECKSUM)
|