Skip to content

Commit bbd3e39

Browse files
authored
Merge pull request #466 from APIUM/feature/mimxrt1176-flash-support
Add MIMXRT1176 (i.MX RT1170) support
2 parents d8a8c58 + ffd5fa1 commit bbd3e39

33 files changed

+1497
-350
lines changed

ports/mimxrt10xx/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ add_executable(tinyuf2
1616
)
1717
target_link_options(tinyuf2 PUBLIC
1818
"LINKER:--script=${CMAKE_CURRENT_LIST_DIR}/linker/${MCU_VARIANT}_ram.ld"
19-
"LINKER:--script=${CMAKE_CURRENT_LIST_DIR}/linker/memory.ld"
19+
"LINKER:--script=${CMAKE_CURRENT_LIST_DIR}/linker/boot.ld"
2020
"LINKER:--script=${CMAKE_CURRENT_LIST_DIR}/linker/common.ld"
2121
)
2222

ports/mimxrt10xx/Makefile

Lines changed: 108 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,108 @@
1-
# List of git submodules that is included as part of the UF2 version
2-
GIT_SUBMODULES = tinyusb
3-
4-
# For flash-pyocd-bin target
5-
FLASH_BIN_ADDR = $(UF2_$(MCU)_WRITE_ADDR)
6-
7-
include ../make.mk
8-
include port.mk
9-
10-
LD_FILES ?= \
11-
$(PORT_DIR)/linker/$(MCU)_ram.ld \
12-
$(PORT_DIR)/linker/memory.ld \
13-
$(PORT_DIR)/linker/common.ld
14-
15-
SRC_C += \
16-
$(PORT_DIR)/boards.c \
17-
$(PORT_DIR)/board_flash.c \
18-
$(PORT_DIR)/romapi_flash.c \
19-
20-
# include
21-
# INC +=
22-
23-
# iMXRT self-update file is in the same BUILD folder
24-
SELF_UF2 = $(BUILD)/update-$(OUTNAME).uf2
25-
26-
include ../rules.mk
27-
28-
#---------------------------------------------------------
29-
# Load to SRAM using sdphost
30-
# Note: you may need to give the sdphost binary executable permission first.
31-
#
32-
# SDP loads the image into the RAM locations specified in the .ld files.
33-
# - "SDP Write Address" must equal _fcfb_origin
34-
# - "SDP Jump Address" must equal _ivt_origin
35-
#
36-
# TinyUF2 will copy itself to the correct location in flash.
37-
# "UF2 Write Address" shows where the image will reside in flash if you
38-
# want to use a tool like pyocd to write the binary into flash through SWD
39-
# Note: The .elf file cannot be written directly to flash since the target
40-
# is RAM and the addresses need to be translated.
41-
#---------------------------------------------------------
42-
SDP_MIMXRT1011_PID = 0x0145
43-
SDP_MIMXRT1015_PID = 0x0130
44-
SDP_MIMXRT1021_PID = 0x0130
45-
SDP_MIMXRT1024_PID = 0x0130
46-
SDP_MIMXRT1042_PID = 0x0135
47-
SDP_MIMXRT1052_PID = 0x0130
48-
SDP_MIMXRT1062_PID = 0x0135
49-
SDP_MIMXRT1064_PID = 0x0135
50-
SDP_MIMXRT1176_PID = 0x013d
51-
52-
UF2_MIMXRT1011_ADDR= 0x60000400
53-
UF2_MIMXRT1015_ADDR= 0x60000000
54-
UF2_MIMXRT1021_ADDR= 0x60000000
55-
UF2_MIMXRT1024_ADDR= 0x60000000
56-
UF2_MIMXRT1042_ADDR= 0x60000000
57-
UF2_MIMXRT1052_ADDR= 0x60000000
58-
UF2_MIMXRT1062_ADDR= 0x60000000
59-
UF2_MIMXRT1064_ADDR= 0x70000000
60-
UF2_MIMXRT1176_ADDR= 0x30000000
61-
62-
SDP_PID = $(SDP_$(MCU)_PID)
63-
UF2_ADDR = $(UF2_$(MCU)_ADDR)
64-
65-
DBL_TAP_REG_ADDR = 0x400D410C
66-
67-
# extract _fcfb_origin and _ivt_origin from linker file
68-
FCFB_ORIGIN := $(shell sed -n 's/_fcfb_origin.*\(0x.*\);/\1/p' $(TOP)/$(PORT_DIR)/linker/$(MCU)_ram.ld)
69-
IVT_ORIGIN := $(shell sed -n 's/_ivt_origin.*\(0x.*\);/\1/p' $(TOP)/$(PORT_DIR)/linker/$(MCU)_ram.ld)
70-
71-
$(BUILD)/$(OUTNAME).hex: $(BUILD)/$(OUTNAME).elf
72-
@echo CREATE $@
73-
@$(OBJCOPY) -O ihex --change-addresses $$(( $(UF2_ADDR)-$(FCFB_ORIGIN) )) $^ $@
74-
75-
# SDPHOST is a variable if you need to change the path
76-
SDPHOST = sdphost
77-
78-
flash-sdp: $(BUILD)/$(OUTNAME).bin
79-
@if [ -z "$(SDPHOST)" ]; then echo SDPHOST is not found for this machine; exit 1; fi
80-
$(SDPHOST) -u 0x1fc9,$(SDP_PID) write-file $(FCFB_ORIGIN) $<
81-
$(SDPHOST) -u 0x1fc9,$(SDP_PID) jump-address $(IVT_ORIGIN)
82-
83-
#-------------------------- Self-update --------------------------
84-
# RT10xx run entire bootloader from SRAM and can directly flash
85-
# the bootloader region without using self-update app as other port
86-
#--------------------------------------------------------------------
87-
self-update: $(SELF_UF2)
88-
89-
# self-update uf2 file
90-
$(SELF_UF2): $(BUILD)/$(OUTNAME).bin
91-
@echo CREATE $@
92-
$(UF2CONV_PY) -f $(UF2_FAMILY_ID) -b $(UF2_ADDR) -c -o $@ $<
93-
94-
# flash by copying uf2
95-
flash-uf2: $(SELF_UF2)
96-
@echo copying $<
97-
$(UF2CONV_PY) -f $(UF2_FAMILY_ID) --deploy $<
1+
# List of git submodules that is included as part of the UF2 version
2+
GIT_SUBMODULES = tinyusb
3+
4+
# For flash-jlink/pyocd/openocd-bin target
5+
FLASH_BIN_ADDR = $(UF2_$(MCU)_ADDR)
6+
7+
include ../make.mk
8+
include port.mk
9+
10+
LD_FILES ?= \
11+
$(PORT_DIR)/linker/$(MCU)_ram.ld \
12+
$(PORT_DIR)/linker/boot.ld \
13+
$(PORT_DIR)/linker/common.ld
14+
15+
SRC_C += \
16+
$(PORT_DIR)/boards.c \
17+
$(PORT_DIR)/board_flash.c \
18+
$(PORT_DIR)/romapi_flash.c \
19+
20+
# iMXRT self-update file is in the same BUILD folder
21+
SELF_UF2 = $(BUILD)/update-$(OUTNAME).uf2
22+
23+
include ../rules.mk
24+
25+
#---------------------------------------------------------
26+
# Load to SRAM using sdphost
27+
# Note: you may need to give the sdphost binary executable permission first.
28+
#
29+
# SDP loads the image into the RAM locations specified in the .ld files.
30+
# - "SDP Write Address" must equal _fcfb_origin
31+
# - "SDP Jump Address" must equal _ivt_origin
32+
#
33+
# TinyUF2 will copy itself to the correct location in flash.
34+
# "UF2 Write Address" shows where the image will reside in flash if you
35+
# want to use a tool like pyocd to write the binary into flash through SWD
36+
# Note: The .elf file cannot be written directly to flash since the target
37+
# is RAM and the addresses need to be translated.
38+
#---------------------------------------------------------
39+
SDP_MIMXRT1011_PID = 0x0145
40+
SDP_MIMXRT1015_PID = 0x0130
41+
SDP_MIMXRT1021_PID = 0x0130
42+
SDP_MIMXRT1024_PID = 0x0130
43+
SDP_MIMXRT1042_PID = 0x0135
44+
SDP_MIMXRT1052_PID = 0x0130
45+
SDP_MIMXRT1062_PID = 0x0135
46+
SDP_MIMXRT1064_PID = 0x0135
47+
SDP_MIMXRT1176_PID = 0x013d
48+
49+
UF2_MIMXRT1011_ADDR= 0x60000400
50+
UF2_MIMXRT1015_ADDR= 0x60000000
51+
UF2_MIMXRT1021_ADDR= 0x60000000
52+
UF2_MIMXRT1024_ADDR= 0x60000000
53+
UF2_MIMXRT1042_ADDR= 0x60000000
54+
UF2_MIMXRT1052_ADDR= 0x60000000
55+
UF2_MIMXRT1062_ADDR= 0x60000000
56+
UF2_MIMXRT1064_ADDR= 0x70000000
57+
UF2_MIMXRT1176_ADDR= 0x30000400
58+
59+
SDP_PID = $(SDP_$(MCU)_PID)
60+
UF2_ADDR = $(UF2_$(MCU)_ADDR)
61+
62+
DBL_TAP_REG_ADDR = 0x400D410C
63+
64+
# extract _fcfb_origin from linker file
65+
FCFB_ORIGIN := $(shell sed -n 's/_fcfb_origin.*\(0x.*\);/\1/p' $(TOP)/$(PORT_DIR)/linker/$(MCU)_ram.ld)
66+
IVT_ORIGIN := $(shell printf "0x%X\n" $$(( ($(FCFB_ORIGIN) & ~0xFFF) + 0x1000 )))
67+
$(info FCFB_ORIGIN=$(FCFB_ORIGIN) IVT_ORIGIN=$(IVT_ORIGIN))
68+
69+
$(BUILD)/$(OUTNAME).hex: $(BUILD)/$(OUTNAME).elf
70+
@echo CREATE $@
71+
@$(OBJCOPY) -O ihex --change-addresses $$(( $(UF2_ADDR)-$(FCFB_ORIGIN) )) $^ $@
72+
73+
# SDPHOST/BLHOST are variables if you need to change the path
74+
SDPHOST = sdphost
75+
BLHOST = blhost
76+
77+
# RT117x uses blhost (MCU bootloader protocol)
78+
ifeq ($(MCU),MIMXRT1176)
79+
$(BUILD)/$(OUTNAME)_ivt0.bin: $(BUILD)/$(OUTNAME).bin
80+
$(PYTHON3) tools/make_ivt0_image.py $< $@
81+
82+
flash-sdp: $(BUILD)/$(OUTNAME)_ivt0.bin
83+
@if [ -z "$(BLHOST)" ]; then echo SDPHOST is not found for this machine; exit 1; fi
84+
$(BLHOST) -u 0x1fc9,$(SDP_PID) load-image $<
85+
86+
else
87+
# RT10xx use sdphost (Serial Download Protocol)
88+
flash-sdp: $(BUILD)/$(OUTNAME).bin
89+
@if [ -z "$(SDPHOST)" ]; then echo SDPHOST is not found for this machine; exit 1; fi
90+
$(SDPHOST) -u 0x1fc9,$(SDP_PID) write-file $(FCFB_ORIGIN) $<
91+
$(SDPHOST) -u 0x1fc9,$(SDP_PID) jump-address $(IVT_ORIGIN)
92+
endif
93+
94+
#-------------------------- Self-update --------------------------
95+
# RT10xx run entire bootloader from SRAM and can directly flash
96+
# the bootloader region without using self-update app as other port
97+
#--------------------------------------------------------------------
98+
self-update: $(SELF_UF2)
99+
100+
# self-update uf2 file
101+
$(SELF_UF2): $(BUILD)/$(OUTNAME).bin
102+
@echo CREATE $@
103+
$(UF2CONV_PY) -f $(UF2_FAMILY_ID) -b $(UF2_ADDR) -c -o $@ $<
104+
105+
# flash by copying uf2
106+
flash-uf2: $(SELF_UF2)
107+
@echo copying $<
108+
$(UF2CONV_PY) -f $(UF2_FAMILY_ID) --deploy $<

0 commit comments

Comments
 (0)