2024-09-11 07:53 AM
Hello everyone,
I’ve been working on a project using the STM32F7 Discovery board and I’m trying to execute code from external SDRAM. However, I’ve run into a puzzling issue and could use some guidance. Here’s a detailed breakdown of the problem:
When I attempt to jump to code that’s loaded in SDRAM, the program counter (PC) seems to advance and execute instructions, but none of the registers (R0-R15) are being updated as expected.
There are no hard faults or other exceptions being triggered, which is unusual because, in other attempts with incorrect MPU settings, I’ve triggered hard faults for unexecutable regions.
It appears as if the CPU is fetching instructions from SDRAM, but they have no effect on the processor state.
MPU Configuration:
I’ve ensured the SDRAM region is marked as executable with the correct access permissions:
I’ve experimented with marking the region as shareable and non-shareable, but enabling shareable seemed to cause other issues with synchronization, so I left it as non-shareable.
Cache Settings:
I tried disabling the instruction cache and invalidating the cache before execution, using:
This did not resolve the issue, and the behavior remains the same.
Thumb Mode:
I made sure the jump address to the SDRAM code has the least significant bit (LSB) set to 1 to ensure the processor switches to Thumb mode:
FMC/SDRAM Timing:
I’ve double-checked the SDRAM timing parameters like CAS latency, row cycle delay, write recovery time, etc., and they seem to match the SDRAM chip’s datasheet.
Fault Handlers:
I’ve set up fault handlers (Hard Fault, Memory Management, Bus Fault), but none of them are getting triggered during execution.
Basic Memory Test:
I ran simple memory tests to write and read data from the SDRAM, and it functions as expected for data storage. The issue only arises when trying to execute code from the SDRAM.
The CPU seems to fetch instructions from SDRAM (since the PC advances), but these instructions don’t affect the registers.
No hard faults or other exceptions occur, which would typically happen if the region wasn’t properly executable.
What could cause the CPU to "silently" fail to execute instructions from SDRAM without triggering a hard fault?
Could this be related to specific instruction set issues (Thumb/ARM) or some subtle MPU or FMC timing misconfiguration?
Has anyone experienced similar issues running code from external SDRAM on the STM32F7?
Any insights or suggestions would be greatly appreciated!
2024-10-26 03:12 PM
Hello,
Try to inspire from one of the examples provided in X-CUBE-32F7PERF:
– “7-ExtSDRAM-Swapped_rwDTCM”
– "7-ExtPSRAM_rwDTCM"
Linked to the application note AN4667 "STM32F7 Series system architecture and performance".