RTL00_WEB/USDK/flasher.mk

212 lines
8.9 KiB
Makefile
Raw Permalink Normal View History

2017-06-21 00:00:20 +00:00
# RTL8710 Flasher v0.0.alfa
# pvvx 21.09.2016
include userset.mk
include $(SDK_PATH)paths.mk
2017-09-26 19:05:35 +00:00
include project.mk
2017-06-21 00:00:20 +00:00
#---------------------------
# Default
#---------------------------
2018-04-20 07:53:32 +00:00
FLASHER_TYPE ?= Jlink
FLASHER_PATH ?= $(SDK_PATH)flasher/
FLASHER_SPEED ?= 1000 # Start speed 1000 kHz
2017-06-21 00:00:20 +00:00
#---------------------------
# Make bunary tools
2018-04-20 07:53:32 +00:00
IMAGETOOL ?= $(PYTHON) $(SDK_PATH)rtlaimage.py
#---------------------------
2017-06-21 00:00:20 +00:00
# openocd tools
2018-04-20 07:53:32 +00:00
OPENOCD ?= d:/MCU/OpenOCD/bin/openocd.exe
#---------------------------
# jlink tools
JLINK_PATH ?= D:/MCU/SEGGER/JLink_V612i/
2017-06-21 00:00:20 +00:00
JLINK_EXE ?= JLink.exe
2018-04-20 07:53:32 +00:00
JLINK_GDB ?= JLinkGDBServer.exe
2017-06-21 00:00:20 +00:00
NMAPFILE = $(OBJ_DIR)/$(TARGET).nmap
RAM1_IMAGE ?= $(BIN_DIR)/ram_1.bin
RAM1P_IMAGE ?= $(BIN_DIR)/ram_1.p.bin
2018-04-20 07:53:32 +00:00
RAM2_IMAGE ?= $(BIN_DIR)/ram_2.bin
RAM2P_IMAGE ?= $(BIN_DIR)/ram_2.p.bin
2017-06-21 00:00:20 +00:00
2018-04-20 07:53:32 +00:00
RAM3_IMAGE ?= $(BIN_DIR)/sdram.bin
RAM3P_IMAGE ?= $(BIN_DIR)/sdram.p.bin
2017-06-21 00:00:20 +00:00
FLASH_IMAGE = $(BIN_DIR)/ram_all.bin
OTA_IMAGE = $(BIN_DIR)/ota.bin
#all: FLASH_IMAGE = $(BIN_DIR)/ram_all.bin
#all: OTA_IMAGE = $(BIN_DIR)/ota.bin
mp: FLASH_IMAGE = $(BIN_DIR)/ram_all_mp.bin
mp: OTA_IMAGE = $(BIN_DIR)/ota_mp.bin
2018-04-20 07:53:32 +00:00
.PHONY: genbin flashburn reset test readfullflash flash_boot flash_webfs flash_OTA flash_images runram runsdram
.NOTPARALLEL: all mp genbin flashburn reset test readfullflash _endgenbin flash_webfs flash_OTA flash_images
2017-06-21 00:00:20 +00:00
2018-01-18 19:51:24 +00:00
all: $(ELFFILE) $(FLASH_IMAGE) _endgenbin
mp: $(ELFFILE) $(FLASH_IMAGE) _endgenbin
2017-06-21 00:00:20 +00:00
2018-01-18 19:51:24 +00:00
genbin: $(ELFFILE) $(FLASH_IMAGE) _endgenbin
2017-06-21 00:00:20 +00:00
2018-01-18 19:51:24 +00:00
$(ELFFILE):
$(error Falsher: file $@ not found)
2017-06-21 00:00:20 +00:00
2018-01-18 19:51:24 +00:00
$(NMAPFILE): $(ELFFILE)
@echo "==========================================================="
@echo "Build names map file"
@echo $@
@$(NM) $< | sort > $@
# @echo "==========================================================="
2017-06-21 00:00:20 +00:00
2018-01-18 19:51:24 +00:00
$(FLASH_IMAGE):$(ELFFILE)
@echo "==========================================================="
$(IMAGETOOL) -a -r -o $(BIN_DIR)/ $(ELFFILE)
2017-06-21 00:00:20 +00:00
_endgenbin:
@echo "-----------------------------------------------------------"
@echo "Image ($(OTA_IMAGE)) size $(shell printf '%d\n' $$(( $$(stat --printf="%s" $(OTA_IMAGE)) )) ) bytes"
@echo "Image ($(FLASH_IMAGE)) size $(shell printf '%d\n' $$(( $$(stat --printf="%s" $(FLASH_IMAGE)) )) ) bytes"
@echo "==========================================================="
ifeq ($(FLASHER_TYPE), Jlink)
reset:
2018-04-20 07:53:32 +00:00
@$(JLINK_PATH)$(JLINK_EXE) -Device CORTEX-M3 -If SWD -Speed $(FLASHER_SPEED) $(FLASHER_PATH)RTL_Reset.JLinkScript
2017-06-21 00:00:20 +00:00
runram:
2018-04-20 07:53:32 +00:00
@$(JLINK_PATH)$(JLINK_EXE) -Device CORTEX-M3 -If SWD -Speed $(FLASHER_SPEED) $(FLASHER_PATH)RTL_RunRAM.JLinkScript
2017-10-17 14:42:32 +00:00
runsdram:
2018-04-20 07:53:32 +00:00
@$(JLINK_PATH)$(JLINK_EXE) -Device CORTEX-M3 -If SWD -Speed $(FLASHER_SPEED) $(FLASHER_PATH)RTL_RunRAM_SDR.JLinkScript
2017-06-21 00:00:20 +00:00
readfullflash:
2018-04-20 07:53:32 +00:00
@$(JLINK_PATH)$(JLINK_EXE) -Device CORTEX-M3 -If SWD -Speed $(FLASHER_SPEED) $(FLASHER_PATH)RTL_FFlash.JLinkScript
2018-01-18 19:51:24 +00:00
2017-06-21 00:00:20 +00:00
2018-04-20 07:53:32 +00:00
flash_boot:
2017-10-18 21:34:22 +00:00
@echo define call1>$(FLASHER_PATH)file_info.jlink
2018-04-20 07:53:32 +00:00
@echo set '$$'ImageSize = $(shell printf '0x%X\n' $$(stat --printf="%s" $(RAM1P_IMAGE))>>$(FLASHER_PATH)file_info.jlink
2017-10-18 21:34:22 +00:00
@echo set '$$'ImageAddr = 0x000000>>$(FLASHER_PATH)file_info.jlink
@echo end>>$(FLASHER_PATH)file_info.jlink
@echo define call2>>$(FLASHER_PATH)file_info.jlink
2018-04-20 07:53:32 +00:00
@echo FlasherWrite $(RAM2P_IMAGE) '$$'ImageAddr '$$'ImageSize>>$(FLASHER_PATH)file_info.jlink
2017-10-18 21:34:22 +00:00
@echo end>>$(FLASHER_PATH)file_info.jlink
2018-04-20 07:53:32 +00:00
@cmd /K start $(JLINK_PATH)$(JLINK_GDBSRV) -device Cortex-M3 -if SWD -ir -endian little -speed $(FLASHER_SPEED)
2017-10-18 21:34:22 +00:00
@$(GDB) -x $(FLASHER_PATH)gdb_wrfile.jlink
2018-04-20 07:53:32 +00:00
flash_images:
@cmd /K start $(JLINK_PATH)$(JLINK_GDBSRV) -device Cortex-M3 -if SWD -ir -endian little -speed $(FLASHER_SPEED)
@$(GDB) -x $(FLASHER_PATH)gdb_images.jlink
flash_OTA:
@cmd /K start $(JLINK_PATH)$(JLINK_GDBSRV) -device Cortex-M3 -if SWD -ir -endian little -speed $(FLASHER_SPEED)
@$(GDB) -x $(FLASHER_PATH)gdb_ota.jlink
flash_webfs:
2017-06-21 00:00:20 +00:00
@echo define call1>$(FLASHER_PATH)file_info.jlink
@echo set '$$'ImageSize = $(shell printf '0x%X\n' $$(stat --printf="%s" $(BIN_DIR)/WEBFiles.bin))>>$(FLASHER_PATH)file_info.jlink
@echo set '$$'ImageAddr = 0x0D0000>>$(FLASHER_PATH)file_info.jlink
@echo end>>$(FLASHER_PATH)file_info.jlink
@echo define call2>>$(FLASHER_PATH)file_info.jlink
@echo FlasherWrite $(BIN_DIR)/WEBFiles.bin '$$'ImageAddr '$$'ImageSize>>$(FLASHER_PATH)file_info.jlink
@echo end>>$(FLASHER_PATH)file_info.jlink
2018-04-20 07:53:32 +00:00
@cmd /K start $(JLINK_PATH)$(JLINK_GDBSRV) -device Cortex-M3 -if SWD -ir -endian little -speed $(FLASHER_SPEED)
2017-06-21 00:00:20 +00:00
@$(GDB) -x $(FLASHER_PATH)gdb_wrfile.jlink
2018-04-20 07:53:32 +00:00
flash_espfs:
2017-06-21 00:00:20 +00:00
@echo define call1>$(FLASHER_PATH)file_info.jlink
@echo set '$$'ImageSize = $(shell printf '0x%X\n' $$(stat --printf="%s" $(BIN_DIR)/webpages.espfs))>>$(FLASHER_PATH)file_info.jlink
@echo set '$$'ImageAddr = 0x0D0000>>$(FLASHER_PATH)file_info.jlink
@echo end>>$(FLASHER_PATH)file_info.jlink
@echo define call2>>$(FLASHER_PATH)file_info.jlink
@echo FlasherWrite $(BIN_DIR)/webpages.espfs '$$'ImageAddr '$$'ImageSize>>$(FLASHER_PATH)file_info.jlink
@echo end>>$(FLASHER_PATH)file_info.jlink
2018-04-20 07:53:32 +00:00
@cmd /K start $(JLINK_PATH)$(JLINK_GDBSRV) -device Cortex-M3 -if SWD -ir -endian little -speed $(FLASHER_SPEED)
2017-06-21 00:00:20 +00:00
@$(GDB) -x $(FLASHER_PATH)gdb_wrfile.jlink
2018-04-20 07:53:32 +00:00
flashburn:
@echo define call1>$(FLASHER_PATH)flash_file.jlink
@echo SetFirwareSize build/bin/ram_all.bin>>$(FLASHER_PATH)flash_file.jlink
@echo end>>$(FLASHER_PATH)flash_file.jlink
@echo define call2>>$(FLASHER_PATH)flash_file.jlink
@echo FlasherWrite build/bin/ram_all.bin 0 '$$'Image1Size>>$(FLASHER_PATH)flash_file.jlink
@echo end>>$(FLASHER_PATH)flash_file.jlink
@echo define call3>>$(FLASHER_PATH)flash_file.jlink
@echo FlasherWrite build/bin/ram_all.bin '$$'Image2Addr '$$'Image2Size>>$(FLASHER_PATH)flash_file.jlink
@echo end>>$(FLASHER_PATH)flash_file.jlink
@cmd /K start $(JLINK_PATH)$(JLINK_GDBSRV) -device Cortex-M3 -if SWD -ir -endian little -speed $(FLASHER_SPEED)
@$(GDB) -x $(FLASHER_PATH)gdb_wrflash.jlink
2017-06-21 00:00:20 +00:00
#@taskkill /F /IM $(JLINK_GDBSRV)
else
2017-12-28 15:43:58 +00:00
2018-04-20 07:53:32 +00:00
flash_boot:
@$(OPENOCD) -f interface/$(FLASHER_TYPE).cfg -c 'transport select swd' -c 'adapter_khz 1000' \
2017-07-29 19:11:18 +00:00
-f $(FLASHER_PATH)rtl8710.ocd -c 'init' -c 'reset halt' -c 'adapter_khz $(FLASHER_SPEED)' \
-c 'rtl8710_flash_auto_erase 1' -c 'rtl8710_flash_auto_verify 1' \
-c 'rtl8710_flash_write $(RAM1P_IMAGE) 0' \
-c 'rtl8710_reboot' -c 'reset run' -c shutdown
2017-06-21 00:00:20 +00:00
2018-04-20 07:53:32 +00:00
flash_images:
@$(OPENOCD) -f interface/$(FLASHER_TYPE).cfg -c 'transport select swd' -c 'adapter_khz 1000' \
2017-07-29 19:11:18 +00:00
-f $(FLASHER_PATH)rtl8710.ocd -c 'init' -c 'reset halt' -c 'adapter_khz $(FLASHER_SPEED)' \
-c 'rtl8710_flash_auto_erase 1' -c 'rtl8710_flash_auto_verify 1' \
2018-04-20 07:53:32 +00:00
-c 'rtl8710_flash_write $(OTA_IMAGE) 0x0b000' \
2017-07-29 19:11:18 +00:00
-c 'rtl8710_reboot' -c 'reset run' -c shutdown
2017-12-28 15:43:58 +00:00
flash_OTA:
2018-04-20 07:53:32 +00:00
@$(OPENOCD) -f interface/$(FLASHER_TYPE).cfg -c 'transport select swd' -c 'adapter_khz 1000' \
2017-12-28 15:43:58 +00:00
-f $(FLASHER_PATH)rtl8710.ocd -c 'init' -c 'reset halt' -c 'adapter_khz $(FLASHER_SPEED)' \
-c 'rtl8710_flash_auto_erase 1' -c 'rtl8710_flash_auto_verify 1' \
2018-04-20 07:53:32 +00:00
-c 'rtl8710_flash_write $(OTA_IMAGE) 0x80000' \
2017-12-28 15:43:58 +00:00
-c 'rtl8710_reboot' -c 'reset run' -c shutdown
2017-06-21 00:00:20 +00:00
2018-04-20 07:53:32 +00:00
flash_webfs:
@$(OPENOCD) -f interface/$(FLASHER_TYPE).cfg -c 'transport select swd' -c 'adapter_khz 1000' \
2017-07-29 19:11:18 +00:00
-f $(FLASHER_PATH)rtl8710.ocd -c 'init' -c 'reset halt' -c 'adapter_khz $(FLASHER_SPEED)' \
-c 'rtl8710_flash_auto_erase 1' -c 'rtl8710_flash_auto_verify 1' \
-c 'rtl8710_flash_write $(BIN_DIR)/WEBFiles.bin 0xd0000' \
-c 'rtl8710_reboot' -c 'reset run' -c shutdown
2017-06-21 00:00:20 +00:00
flashespfs:
2018-04-20 07:53:32 +00:00
@$(OPENOCD) -f interface/$(FLASHER_TYPE).cfg -c 'transport select swd' -c 'adapter_khz 1000' \
2017-07-29 19:11:18 +00:00
-f $(FLASHER_PATH)rtl8710.ocd -c 'init' -c 'reset halt' -c 'adapter_khz $(FLASHER_SPEED)' \
-c 'rtl8710_flash_auto_erase 1' -c 'rtl8710_flash_auto_verify 1' \
-c 'rtl8710_flash_write $(BIN_DIR)/webpages.espfs 0xd0000' \
-c 'rtl8710_reboot' -c 'reset run' -c shutdown
2017-06-21 00:00:20 +00:00
reset:
2018-04-20 07:53:32 +00:00
@$(OPENOCD) -f interface/$(FLASHER_TYPE).cfg -c 'transport select swd' -c 'adapter_khz 1000' \
2017-07-29 19:11:18 +00:00
-f $(FLASHER_PATH)rtl8710.ocd -c 'init' -c 'reset halt' -c 'adapter_khz $(FLASHER_SPEED)' \
-c 'mww 0x40000210 0x111157' -c 'rtl8710_reboot' -c shutdown
2017-06-21 00:00:20 +00:00
runram:
2018-04-20 07:53:32 +00:00
@$(OPENOCD) -f interface/$(FLASHER_TYPE).cfg -c 'transport select swd' -c 'adapter_khz 1000' \
2017-07-29 19:11:18 +00:00
-f $(FLASHER_PATH)rtl8710.ocd -c 'init' -c 'reset halt' -c 'adapter_khz $(FLASHER_SPEED)' \
2018-01-18 19:51:24 +00:00
-c 'load_image $(RAM1_IMAGE) 0x10000bc8 bin' \
2017-07-29 19:11:18 +00:00
-c 'load_image $(RAM2_IMAGE) 0x10006000 bin' \
2017-08-30 20:46:18 +00:00
-c 'mww 0x40000210 0x20111157' -c 'rtl8710_reboot' -c shutdown
2017-06-21 00:00:20 +00:00
2017-12-28 15:43:58 +00:00
runsdram:
2018-04-20 07:53:32 +00:00
@$(OPENOCD) -f interface/$(FLASHER_TYPE).cfg -c 'transport select swd' -c 'adapter_khz 1000' \
2017-12-28 15:43:58 +00:00
-f $(FLASHER_PATH)rtl8710.ocd -c 'init' -c 'reset halt' -c 'adapter_khz $(FLASHER_SPEED)' \
2018-01-18 19:51:24 +00:00
-c 'load_image $(RAM1_IMAGE) 0x10000bc8 bin' \
2017-12-28 15:43:58 +00:00
-c 'load_image $(RAM2_IMAGE) 0x10006000 bin' \
-c 'boot_load_srdam $(RAM3_IMAGE) 0x30000000' \
-c shutdown
2018-04-20 07:53:32 +00:00
flashburn:
@$(OPENOCD) -f interface/$(FLASHER_TYPE).cfg -c 'transport select swd' -c 'adapter_khz 1000' \
-f $(FLASHER_PATH)rtl8710.ocd -c 'init' -c 'reset halt' -c 'adapter_khz $(FLASHER_SPEED)' \
-c 'rtl8710_flash_auto_erase 1' -c 'rtl8710_flash_auto_verify 1' \
-c 'rtl8710_flash_write $(RAM1P_IMAGE) 0' \
-c 'rtl8710_flash_write $(OTA_IMAGE) 0xb000' \
-c 'rtl8710_reboot' -c 'reset run' -c shutdown
2017-07-29 19:11:18 +00:00
endif
2017-06-21 00:00:20 +00:00
clean:
@rm -f $(BIN_DIR)/*.bin