photon: add DOWNLOAD function to upload firmware through DFU

This commit is contained in:
Simon Piriou 2017-04-23 12:26:52 +02:00 committed by Gregory Nutt
parent a76266106a
commit e1a4e88a55
3 changed files with 43 additions and 0 deletions

19
Kconfig
View File

@ -313,6 +313,25 @@ config UIMAGE_ENTRY_POINT
hex "uImage entry point"
default 0x0
endif
menuconfig DFU_BINARY
bool "DFU binary format"
select RAW_BINARY
---help---
Create the dfu binary used with dfu-utils.
if DFU_BINARY
config DFU_BASE
hex "Address DFU image is loaded to"
config DFU_VID
hex "VID to use for DFU image"
config DFU_PID
hex "PID to use for DFU image"
endif
endmenu # Binary Output Formats

View File

@ -28,6 +28,10 @@ CONFIG_INTELHEX_BINARY=y
# CONFIG_MOTOROLA_SREC is not set
CONFIG_RAW_BINARY=y
# CONFIG_UBOOT_UIMAGE is not set
CONFIG_DFU_BINARY=y
CONFIG_DFU_BASE=0x8020000
CONFIG_DFU_VID=0x2b04
CONFIG_DFU_PID=0xd006
#
# Customize Header Files

View File

@ -68,6 +68,9 @@ NM = $(ARCROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
DFUSUFFIX = dfu-suffix
DFUUTIL = dfu-util
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
@ -114,3 +117,20 @@ HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe
HOSTLDFLAGS =
ifeq ($(CONFIG_DFU_BINARY),y)
define DOWNLOAD
$(Q) echo "DFUSUFFIX: $(1).dfu"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(1) $(1).dfu
$(Q) $(DFUSUFFIX) -v $(subst 0x,,$(CONFIG_DFU_VID)) -p $(subst 0x,,$(CONFIG_DFU_PID)) -a $(1).dfu
$(Q) $(DFUUTIL) -d $(CONFIG_DFU_VID):$(CONFIG_DFU_PID) -a 0 -s $(CONFIG_DFU_BASE) -D $(1).dfu
endef
else
define DOWNLOAD
$(Q) $(ECHO) "Photon firmware upload through JTAG is not supported"
endef
endif