Skip to content

Commit

Permalink
Merge pull request #2658 from cesanta/rt1170
Browse files Browse the repository at this point in the history
RT1170
  • Loading branch information
cpq authored Mar 23, 2024
2 parents f58b90f + 7cc3d89 commit d9a6e85
Show file tree
Hide file tree
Showing 22 changed files with 942 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/nxp/rt1060-evk-make-baremetal-builtin/sysinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void SystemInit(void) { // Called automatically by startup code (ints masked)
SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); // Enable FPU
asm("DSB");
asm("ISB");
// 53.4.2: Disable watchdog after reset (unlocked)
// 58.4.2: Disable watchdog after reset (unlocked)
RTWDOG->CS &= ~RTWDOG_CS_EN_MASK;
RTWDOG->TOVAL = 0xFFFF;
while (RTWDOG->CS & RTWDOG_CS_ULK_MASK) spin(1); // wait for lock
Expand Down
2 changes: 1 addition & 1 deletion examples/nxp/rt1060-evk-make-freertos-builtin/sysinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void SystemInit(void) { // Called automatically by startup code (ints masked)
SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); // Enable FPU
asm("DSB");
asm("ISB");
// 53.4.2: Disable watchdog after reset (unlocked)
// 58.4.2: Disable watchdog after reset (unlocked)
RTWDOG->CS &= ~RTWDOG_CS_EN_MASK;
RTWDOG->TOVAL = 0xFFFF;
while (RTWDOG->CS & RTWDOG_CS_ULK_MASK) spin(1); // wait for lock
Expand Down
86 changes: 86 additions & 0 deletions examples/nxp/rt1170-evk-make-baremetal-builtin/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
CFLAGS = -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion
CFLAGS += -Wformat-truncation -fno-common -Wconversion
CFLAGS += -g3 -Os -ffunction-sections -fdata-sections
CFLAGS += -I. -Icmsis_core/CMSIS/Core/Include -Icmsis_mcu/devices/MIMXRT1176
CFLAGS += -Icmsis_mcu/devices/MIMXRT1176/drivers -DCPU_MIMXRT1176DVMAA_cm7
CFLAGS += -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-d16 $(CFLAGS_EXTRA)
CFLAGS += -Wno-conversion -Wno-unused-parameter # due to NXP FSL code
LDSCRIPT = link.ld
LDFLAGS ?= -T$(LDSCRIPT) -nostdlib -nostartfiles --specs nano.specs -lc -lgcc -Wl,--gc-sections -Wl,-Map=$@.map

SOURCES = main.c syscalls.c sysinit.c
SOURCES += cmsis_mcu/devices/MIMXRT1176/gcc/startup_MIMXRT1176_cm7.S # NXP startup file. Compiler-dependent!
SOURCES += cmsis_mcu/devices/MIMXRT1176/drivers/fsl_clock.c cmsis_mcu/devices/MIMXRT1176/drivers/fsl_anatop_ai.c cmsis_mcu/devices/MIMXRT1176/drivers/fsl_pmu.c cmsis_mcu/devices/MIMXRT1176/drivers/fsl_dcdc.c cmsis_mcu/devices/MIMXRT1176/drivers/fsl_common_arm.c # NXP support files
CFLAGS += -D__ATOLLIC__ -D__STARTUP_CLEAR_BSS # Make startup code work as expected

# Mongoose options are defined in mongoose_custom.h
SOURCES += mongoose.c net.c packed_fs.c

# Example specific build options. See README.md
CFLAGS += -DHTTP_URL=\"http://0.0.0.0/\" -DHTTPS_URL=\"https://0.0.0.0/\"

ifeq ($(OS),Windows_NT)
RM = cmd /C del /Q /F /S
else
RM = rm -rf
endif

all build example update: SOURCES += flash_image.c
all build example: firmware.bin

ram: LDSCRIPT = link_ram.ld
ram: firmware.bin

firmware.bin: firmware.elf
arm-none-eabi-objcopy -O binary $< $@

firmware.elf: cmsis_core cmsis_mcu $(SOURCES) hal.h link_ram.ld link.ld Makefile
arm-none-eabi-gcc $(SOURCES) $(CFLAGS) $(LDFLAGS) -o $@
arm-none-eabi-size $@

flash: firmware.bin
# flash

cmsis_core: # ARM CMSIS core headers
git clone -q --depth 1 -b 5.9.0 https://github.com/ARM-software/CMSIS_5 $@
cmsis_mcu:
curl -sL https://mcuxpresso.nxp.com/cmsis_pack/repo/NXP.MIMXRT1176_DFP.18.0.0.pack -o $@.zip
mkdir $@ && cd $@ && unzip -q ../$@.zip
mbedtls: # mbedTLS library
git clone --depth 1 -b v2.28.2 https://github.com/mbed-tls/mbedtls $@

ifeq ($(TLS), mbedtls)
CFLAGS += -DMG_TLS=MG_TLS_MBED -Wno-conversion -Imbedtls/include
CFLAGS += -DMBEDTLS_CONFIG_FILE=\"mbedtls_config.h\" mbedtls/library/*.c
firmware.elf: mbedtls
endif

# Automated remote test. Requires env variable VCON_API_KEY set. See https://vcon.io/automated-firmware-tests/
DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/15
update: firmware.bin
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/ota --data-binary @$<

update updateram: CFLAGS += -DUART_DEBUG=LPUART2

test: update
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 | tee /tmp/output.txt
grep 'READY, IP:' /tmp/output.txt # Check for network init


updateram: ram
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/ota --data-binary @firmware.bin
curl -su :$(VCON_API_KEY) $(DEVICE_URL)/rpc/swd.exec -d '{"req":"init"}'
curl -su :$(VCON_API_KEY) $(DEVICE_URL)/rpc/swd.exec -d '{"req":"wm,e000edf0,a05f0003 wm,e000edfc,1"}'
PC=`curl -su :$(VCON_API_KEY) $(DEVICE_URL)/rpc/swd.exec -d '{"req":"rm,4"}' | jq -r .resp[5:]` && \
SP=`curl -su :$(VCON_API_KEY) $(DEVICE_URL)/rpc/swd.exec -d '{"req":"rm,0"}' | jq -r .resp[5:]` && \
REQ="wm,e000ed08,0 wr,d,$$SP wr,f,$$PC" && \
curl -su :$(VCON_API_KEY) $(DEVICE_URL)/rpc/swd.exec -d '{"req":"'"$$REQ"'"}'
curl -su :$(VCON_API_KEY) $(DEVICE_URL)/rpc/swd.exec -d '{"req":"wm,e000edf0,a05f0001"}'

testram: updateram
curl --fail-with-body -su :$(VCON_API_KEY) $(DEVICE_URL)/tx?t=5 | tee /tmp/output.txt
grep 'READY, IP:' /tmp/output.txt # Check for network init


clean:
$(RM) firmware.* *.su cmsis_core cmsis_mcu mbedtls *.zip
109 changes: 109 additions & 0 deletions examples/nxp/rt1170-evk-make-baremetal-builtin/dcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* Copyright 2020-2021 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#define __DCD_DATA \
0xD2, 0x04, 0xB8, 0x41, 0xCC, 0x04, 0x0C, 0x04, 0x40, 0xCC, 0x02, 0x00, \
0x00, 0x00, 0x07, 0x03, 0x40, 0x0E, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x14, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x18, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x1C, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x24, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x28, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x30, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x38, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x3C, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x44, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x48, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x4C, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x50, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x54, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x58, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x60, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x64, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x68, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x6C, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x74, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x78, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x7C, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x84, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x88, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x8C, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x90, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x94, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0x98, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0x9C, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xA0, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0xA4, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xA8, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xAC, 0x00, 0x00, 0x00, 0x10, \
0x40, 0x0E, 0x80, 0xB8, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xBC, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xC0, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0xC4, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xC8, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xCC, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xD4, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xD8, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xE0, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xE4, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0xE8, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xEC, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xF0, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x80, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xF8, \
0x00, 0x00, 0x00, 0x00, 0x40, 0x0E, 0x80, 0xFC, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0E, 0x82, 0x54, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x58, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x5C, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0x60, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x64, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x68, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0x6C, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x70, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x74, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0x78, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x7C, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x80, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0x84, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x88, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x8C, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0x90, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x94, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0x98, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0x9C, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xA0, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xA4, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0xA8, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xAC, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xB0, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0xB4, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xB8, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xBC, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0xC0, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xC4, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xC8, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0xCC, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xD0, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xD4, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0xD8, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xDC, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xE0, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0xE4, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xE8, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xEC, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x82, 0xF0, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x82, 0xFC, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x83, 0x00, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x83, 0x04, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x83, 0x08, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x83, 0x0C, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x83, 0x10, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x83, 0x14, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x83, 0x18, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x83, 0x1C, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x83, 0x20, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x83, 0x24, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x83, 0x28, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x83, 0x2C, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x83, 0x30, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x83, 0x34, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x83, 0x38, \
0x00, 0x00, 0x00, 0x08, 0x40, 0x0E, 0x83, 0x3C, 0x00, 0x00, 0x00, 0x08, \
0x40, 0x0E, 0x83, 0x40, 0x00, 0x00, 0x00, 0x08, 0x40, 0x0D, 0x40, 0x00, \
0x10, 0x00, 0x00, 0x04, 0x40, 0x0D, 0x40, 0x08, 0x00, 0x00, 0x00, 0x81, \
0x40, 0x0D, 0x40, 0x0C, 0x00, 0x00, 0x00, 0x81, 0x40, 0x0D, 0x40, 0x10, \
0x80, 0x00, 0x00, 0x1D, 0x40, 0x0D, 0x40, 0x40, 0x00, 0x00, 0x0F, 0x32, \
0x40, 0x0D, 0x40, 0x44, 0x00, 0x77, 0x2A, 0x22, 0x40, 0x0D, 0x40, 0x48, \
0x00, 0x01, 0x0A, 0x0D, 0x40, 0x0D, 0x40, 0x4C, 0x21, 0x21, 0x04, 0x08, \
0x40, 0x0D, 0x40, 0x90, 0x80, 0x00, 0x00, 0x00, 0x40, 0x0D, 0x40, 0x94, \
0x00, 0x00, 0x00, 0x02, 0x40, 0x0D, 0x40, 0x98, 0x00, 0x00, 0x00, 0x00, \
0x40, 0x0D, 0x40, 0x9C, 0xA5, 0x5A, 0x00, 0x0F, 0xC0, 0x00, 0x04, 0x00, \
0xC0, 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x00, \
0xC0, 0x00, 0x04, 0x00, 0xCC, 0x00, 0x14, 0x04, 0x40, 0x0D, 0x40, 0x3C, \
0x00, 0x00, 0x00, 0x03, 0x40, 0x0D, 0x40, 0x9C, 0xA5, 0x5A, 0x00, 0x0C, \
0xC0, 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x00, \
0xC0, 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x00, 0xCC, 0x00, 0x14, 0x04, \
0x40, 0x0D, 0x40, 0x3C, 0x00, 0x00, 0x00, 0x03, 0x40, 0x0D, 0x40, 0x9C, \
0xA5, 0x5A, 0x00, 0x0C, 0xC0, 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x00, \
0xC0, 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x00, \
0xCC, 0x00, 0x1C, 0x04, 0x40, 0x0D, 0x40, 0x3C, 0x00, 0x00, 0x00, 0x03, \
0x40, 0x0D, 0x40, 0xA0, 0x00, 0x00, 0x00, 0x33, 0x40, 0x0D, 0x40, 0x9C, \
0xA5, 0x5A, 0x00, 0x0A, 0xC0, 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x00, \
0xC0, 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x00, 0xC0, 0x00, 0x04, 0x00, \
0xCC, 0x00, 0x14, 0x04, 0x40, 0x0D, 0x40, 0x3C, 0x00, 0x00, 0x00, 0x03, \
0x40, 0x0D, 0x40, 0x4C, 0x21, 0x21, 0x04, 0x09
61 changes: 61 additions & 0 deletions examples/nxp/rt1170-evk-make-baremetal-builtin/flash_image.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "dcd.h" // pin settings for MIMXRT1060-EVKB board
#include "fsl_flexspi.h" // peripheral structures
#include "fsl_romapi.h" // peripheral structures
#include "hal.h"

extern uint32_t __isr_vector[];

// RM 10.7.2
__attribute__((section(".dcd"), used))
const uint8_t __ivt_dcd_data[] = {__DCD_DATA};

// RM 10.7.1
__attribute__((section(".dat"), used)) const uint32_t __ivt_boot_data[] = {
FlexSPI1_AMBA_BASE, // boot start location
64 * 1024 * 1024, // size
0, // Plugin flag
0Xffffffff // empty - extra data word
};

__attribute__((section(".ivt"), used)) const uint32_t __ivt[8] = {
0x412000d1, // header: 41 - version, 2000 size, d1 tag
(uint32_t) __isr_vector, // entry
0, // reserved
(uint32_t) __ivt_dcd_data, // dcd
(uint32_t) __ivt_boot_data, // boot data
(uint32_t) __ivt, // this is us - ivt absolute address
0, // csf absolute address
0, // reserved for HAB
};

#define __FLEXSPI_QSPI_LUT { \
[0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xEC, RADDR_SDR, FLEXSPI_4PAD, 0x20),\
[1] = FLEXSPI_LUT_SEQ(DUMMY_SDR, FLEXSPI_4PAD, 0x06, READ_SDR, FLEXSPI_4PAD, 0x04),\
[4 * 1 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x05, READ_SDR, FLEXSPI_1PAD, 0x04),\
[4 * 3 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x06, STOP, FLEXSPI_1PAD, 0x0),\
[4 * 5 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x21, RADDR_SDR, FLEXSPI_1PAD, 0x20),\
[4 * 8 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0xD8, RADDR_SDR, FLEXSPI_1PAD, 0x18),\
[4 * 9 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x12, RADDR_SDR, FLEXSPI_1PAD, 0x20),\
[4 * 9 + 1] = FLEXSPI_LUT_SEQ(WRITE_SDR, FLEXSPI_1PAD, 0x04, STOP, FLEXSPI_1PAD, 0x0),\
[4 * 11 + 0] = FLEXSPI_LUT_SEQ(CMD_SDR, FLEXSPI_1PAD, 0x60, STOP, FLEXSPI_1PAD, 0x0),\
}

// MIMXRT1170-EVKB flash chip config: W25Q512NWEIQ
__attribute__((section(".cfg"), used))
const flexspi_nor_config_t __qspi_flash_cfg = {
.memConfig = {.tag = FLEXSPI_CFG_BLK_TAG,
.version = FLEXSPI_CFG_BLK_VERSION,
.readSampleClkSrc = 1, // ReadSampleClk_LoopbackFromDqsPad
.csHoldTime = 3,
.csSetupTime = 3,
.controllerMiscOption = BIT(4),
.deviceType = 1, // serial NOR
.sflashPadType = 4,
.serialClkFreq = 7, // 133MHz
.sflashA1Size = 64 * 1024 * 1024,
.lookupTable = __FLEXSPI_QSPI_LUT},
.pageSize = 256,
.sectorSize = 4 * 1024,
.ipcmdSerialClkFreq = 1,
.blockSize = 64 * 1024,
.isUniformBlockSize = false};
Loading

0 comments on commit d9a6e85

Please sign in to comment.