Thank you both for your replies.
I also tried now to use the external QSPI Flash on MX RT1064 EVK board.
I followed the example of the flash_component_nor project from the SDK. However, I observed some strange behaviour when integrating it into my project.
Generally the access to external QSPI Flash works well. But I encountered strange behaviour when deleting some unused code from my project. In the below snippets the function controll_task is unused and does not appear in the resulting .axf file.
When using the project with snippet 1, everything works fine. The sha256sum of the resulting .axf file is equal to hash_1.
#define USE_CONTROL_TASK (0)
static void controll_task(void *pvParameters)
{
#if USE_CONTROL_TASK == 1
some_functions();
more_functions();
#else
vTaskSuspend(NULL);
#endif
}
When commenting out the two functions inside the preprocessor #if (snippet 2) everything works fine too. Also the sha256sum of the resulting .axf file is equal to hash_2 = hash_1
#define USE_CONTROL_TASK (0)
static void controll_task(void *pvParameters)
{
#if USE_CONTROL_TASK == 1
#else
vTaskSuspend(NULL);
#endif
}
However, when deleting the internal functions (snippet 3) there arises a hardfault when executing (more on that below). The sha256sum of the resulting .axf file equals hash_3 which is different from hash_1/2.
1) So. first question: how can the resulting .axf files be different when changing code that should be transparent to the compiler/linker?
#define USE_CONTROL_TASK (0)
static void controll_task(void *pvParameters)
{
#if USE_CONTROL_TASK == 1
#else
vTaskSuspend(NULL);
#endif
}
Coming now the hardfault: As in the flash_component_nor demo project I configure the clocks for the SPI as follows:
const clock_usb_pll_config_t g_ccmConfigUsbPll = {.loopDivider = 0U};
CLOCK_InitUsb1Pll(&g_ccmConfigUsbPll);
CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 24);
CLOCK_SetMux(kCLOCK_FlexspiMux, 0x3);
CLOCK_SetDiv(kCLOCK_FlexspiDiv, 2);
But when executing CLOCK_InitUsb1Pdf(...) function the hardfault is caused by the last assignment in the this code:
void CLOCK_InitUsb1Pfd(clock_pfd_t pfd, uint8_t pfdFrac)
{
uint32_t pfdIndex = (uint32_t)pfd;
uint32_t pfd480;
pfd480 = CCM_ANALOG->PFD_480 &
~(((uint32_t)((uint32_t)CCM_ANALOG_PFD_480_PFD0_CLKGATE_MASK | CCM_ANALOG_PFD_480_PFD0_FRAC_MASK)
<< (8UL * pfdIndex)));
CCM_ANALOG->PFD_480 = pfd480 | ((uint32_t)CCM_ANALOG_PFD_480_PFD0_CLKGATE_MASK << (8UL * pfdIndex));
CCM_ANALOG->PFD_480 = pfd480 | (CCM_ANALOG_PFD_480_PFD0_FRAC(pfdFrac) << (8UL * pfdIndex));
}
The debugger reported an error reading from inaccessible memory region:

And the corresponding fault view:

After this fault, the MX RT1064 is no longer acessible to flash new firmware and one has to change to "Serial Download" boot option. The corresponding flashing error is:
MCUXpresso IDE RedlinkMulti Driver v11.1 (Feb 24 2020 13:57:55 - crt_emu_cm_redlink build 11)
Found chip XML file in /home/pascal/workspace/evkmimxrt1064_i2c_sensor_read/Debug/MIMXRT1064xxxxA.xml
Reconnected to existing LinkServer process.
============= SCRIPT: RT1064_connect.scp =============
RT1064 Connect Script
DpID = 0BD11477
APID = 0x04770041
Error: No Halt Confirmation
Disabling MPU
Configure FlexRAM for 768KB OC RAM, 128KB I-TCM, 128KB D-TCM
Finished
============= END SCRIPT =============================
Probe Firmware: DAPLink CMSIS-DAP (ARM)
Serial Number: 02320000151211d400000000000000000000000097969905
VID:PID: 0D28:0204
USB Path: /dev/hidraw0
Using memory from core 0 after searching for a good core
debug interface type = Cortex-M7 (DAP DP ID 0BD11477) over SWD TAP 0
processor type = Cortex-M7 (CPU ID 00000C27) on DAP AP 0
number of h/w breakpoints = 8
number of flash patches = 0
number of h/w watchpoints = 4
Probe(0): Connected&Reset. DpID: 0BD11477. CpuID: 00000C27. Info: <None>
Debug protocol: SWD. RTCK: Disabled. Vector catch: Disabled.
Content of CoreSight Debug ROM(s):
RBASE E00FD000: CID B105100D PID 000008E88C ROM (type 0x1)
ROM 1 E00FE000: CID B105100D PID 04000BB4C8 ROM (type 0x1)
ROM 2 E00FF000: CID B105100D PID 04000BB4C7 ROM (type 0x1)
ROM 3 E000E000: CID B105E00D PID 04000BB00C Gen SCS (type 0x0)
ROM 3 E0001000: CID B105E00D PID 04000BB002 Gen DWT (type 0x0)
ROM 3 E0002000: CID B105E00D PID 04000BB00E Gen (type 0x0)
ROM 3 E0000000: CID B105E00D PID 04000BB001 Gen ITM (type 0x0)
ROM 2 E0041000: CID B105900D PID 04001BB975 CSt ARM ETMv4.0 type 0x13 Trace Source - Core
ROM 2 E0042000: CID B105900D PID 04004BB906 CSt type 0x14 Debug Control - Trigger, e.g. ECT
ROM 1 E0040000: CID B105900D PID 04000BB9A9 CSt type 0x11 Trace Sink - TPIU
ROM 1 E0043000: CID B105F00D PID 04001BB101 Sys (type 0x0)
NXP: MIMXRT1064xxxxA
DAP stride is 1024 bytes (256 words)
Inspected v.2 External Flash Device on SPI using SFDP JEDEC ID MIMXRT1064.cfx
Image 'iMXRT1064_SFDP_QSPI Feb 17 2020 13:59:06'
Opening flash driver MIMXRT1064.cfx
Sending VECTRESET to run flash driver
state - running or following reset request - re-read of state failed - rc Nn(05). Wire ACK Wait in DAP access
state - running or following reset request - re-read of state failed - rc Nn(05). Wire ACK Wait in DAP access
AFTER driver startup timeout (302 5ms retries)
Driver Addresses
Start: 20000000
Entry: 2000009D
End: 2000075C
Stack: 20002760
Mailbox:2000A760
Driver Register State
R0: 402A4000
R1: FFFF8011
R2: F1AE8124
R3: 0F1A23A2
R4: 200004EC
R5: 402A4000
R6: 00000004
R7: 00000001
R8: 00000001
R9: 00000000
R10: 00000000
R11: 00000001
R12: 00000000
SP: 20002628
LR: 00211FBF
PC: 002140E2
xPSR: 81000000
MSP: 20002628
PSP: 20002760
CFBP: 00000001 (CONTROL=0x0, FAULTMASK=0x0, BASEPRI=0x0, PRIMASK=0x1)
Flash Driver V.2 startup failed - rc Ef(34): Timed-out initializing flash.
chip initialization failed - Ef(34): Timed-out initializing flash.
failed to initialize flash driver MIMXRT1064.cfx
Hence, the second question is:
2) Do you have any idea why the change above in snippet 3 causes the Init function of UsbPdf1 to access inaccessible memory region?
Thanks for your support.