OSPI - Debugging external loader and strange write failure
- November 17, 2021
- 4 replies
- 2925 views
Some Background:
MCU: STM32L4R9ZGJ6
SDK: STM32Cube_FW_L4_V1.14.0
Programmer: STM32CubeProgrammer v2.2.0
External Flash: OSPI (MT35XL512ABA1G12)
Application IDE: STM32Cube IDE 1.6.1
External Loader IDE: Keil uVision 5.16a
Project is was started on the STM32L4R9I-DISCO development kit. We have been on a custom board for over a year without issues.
Hello,
I encountered a strange issue today when loading data to an OSPI flash memory using a custom external loader (*.stldr). This external loader has been working fine for ~2 years when loading ~2MB of GUI assets to OSPI flash and has not changed during this time. Today, I attempted to write 32 bytes of data to a specific region in OSPI flash in addition to the GUI assets that are already written and the 32 bytes result in a write failure. If I write 16 bytes it works fine. Trial and error testing shows that if I write anything beyond 16 bytes in addition to the GUI assets, the write fails. The data being written is not contiguous and the 32 bytes are being written to an entirely different sector of OSPI flash. Below is code for both the failure case and passing case:
**** Failure Case -> Write 32 bytes ****
Linker:
flashTest:
{
*(flashTest flashTest.*)
*(.gnu.linkonce.r.*)
. = ALIGN(4);
KEEP(*(.flashTest)) /* Keep variable even if not referenced */
} >OCTOSPI_APPApp code:
const uint8_t testData[] __attribute__((section(".flashTest"))) =
{
0xAA, 0xBB, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xAA, 0xAB,
0xAA, 0xBB, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xAA, 0xAB,
};STM32CubeProgrammer verbose error log (Level 3): 32ByteProgramFail.log (Attached)
**** Success Case -> Write <= 16 bytes ****
Linker (Same as above):
flashTest :
{
*(flashTest flashTest.*)
*(.gnu.linkonce.r.*)
. = ALIGN(4);
KEEP(*(.flashTest)) /* Keep variable even if not referenced */
} >OCTOSPI_APPApp code:
const uint8_t testData[] __attribute__((section(".flashTest"))) =
{
0xAA, 0xBB, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xAA, 0xAB,
};STM32CubeProgrammer verbose error log (Level 3): 16ByteProgramSucceed.log (Attached)
For reference, here is how the linker places the GUI assets in OSPI flash:
/* Constant data into "OCTOSPI_GUI" Memory Mapped Flash type memory (TouchGFX GUI generated assets) */
ExtFlashSection :
{
*(ExtFlashSection ExtFlashSection.*)
*(.gnu.linkonce.r.*)
. = ALIGN(4);
} >OCTOSPI_GUI Summary:
It baffles me how I can write 2 MB of GUI data to one location, but fail to write 32 bytes to another, yet writing anything less than 16 bytes works so long as it is 4-byte aligned. I thought maybe it was an alignment issue and tried 20 bytes, 24 bytes, 28 bytes, etc with the same failure. I even tried a different region of OSPI flash memory.
Questions:
1. Any clue to what may be causing this strange failure?
2. What is the best way to debug the external loader in real-time while STM32CubeProgrammer is using it? Is this even possible? The external loader project is built using Keil uVision.
Thanks,
Derek