Skip to main content
LCE
Principal II
June 9, 2026
Question

H7: DTCM variables strange behaviour

  • June 9, 2026
  • 17 replies
  • 189 views

Heyho,

H723..H735, using DTCM a lot, also ITCM for some functions.

Recently I found some strange behaviour:

  • the global pointer sFlashIntCtl.pu8WrBuf to the buffer u8FlashIntPageBuf (global) is set in function A
    • setting the pointer is working, printf via UART
  • later on function A calls function B
    • pointer sFlashIntCtl.pu8WrBuf is not changed anywhere, no IRQ or anywhere
  • first thing function B is doing:
    • check if pointer sFlashIntCtl.pu8WrBuf != NULL
    • check fails, because sFlashIntCtl.pu8WrBuf = 0 (checked via UART, see below)

Here’s the UART output:

function A UART output:

*** start *** wr SPI flash to APP flash

&u8FlashIntPageBuf[0] 20000800
sFlashIntCtl.pu8WrBuf 20000800 <- this OKAY
sOspiFlashCtl.pu8RdBuf 20000800
sFlashIntCtl.u32WrAddr 08040000
sFlashIntCtl.u32ChkAddr 08040000
sOspiFlashCtl.u32RdAddr 00000100
sOspiFlashCtl.u32RdLen 32

...
function A calls function B


function B UART output:

#E FlashIntWrPage(): pu8WrBuf = NULL

sFlashIntCtl.pu8WrBuf 00000000 <- WTF ?
&u8FlashIntPageBuf[0] 20000800

 

Any ideas?

17 replies

TDK
June 10, 2026

> In the OSPI read function “OspiFlashRdPage()” the unrelated global struct variables “sFlashIntCtl.pu8WrBuf” and “sFlashIntCtl.u32WrAddr” are changed within the read from OSPI loop:

Then there is overlap in the memory structure. Probably a bad pointer somewhere. Keep checking.

If you show your work here, likely someone can spot the issue. Show screenshots which prove the structures are not overlapping. Show the exact line the watchpoint gets hit on, etc.

"If you feel a post has answered your question, please click ""Accept as Solution""."
LCE
LCEAuthor
Principal II
June 10, 2026

After turning optimisation back ON for some functions (internal flash control and OSPI flash), taking the OSPI flash functions out of ITCM, and the OSPI flash variables out of DTCM, it’s working again.

… which leaves me with a bad feeling. What was the cause of this?

I tried all kinds of combinations of optimisation  / ITCM / DTCM concerning OSPI flash, only the above combination made it working again.

 

​@mƎALLEm I’m pretty sure that it’s not a problem of my specific custom H733-board. I started this development on the H735-DK, but with a different OSPI flash.
The things I observed make no sense whatsoever and should not occur in any combination of the above mentioned things.

Anyway, there still might lurk a bug somewhere. 😶

Pavel A.
June 11, 2026

No miracles. Something writes there: interrupts, DMA, maybe stack is switched to this area? 

LCE
LCEAuthor
Principal II
June 11, 2026

> maybe stack is switched to this area

How can that happen?