Skip to main content
JBond.1
Senior
October 8, 2023
Solved

STM32F4 can I join SRAM and SRAM2 memories?

  • October 8, 2023
  • 5 replies
  • 2750 views

Hi, I have STM32F407VET6 which has such memory layout.
0693W00000YA0E4QAL.png

Can I join SRAM (0x2000 0000 - 0x2001 BFFF) and SRAM2 (0x2001 C000 - 0x2001 FFFF) memories to one?
0693W00000Y8qzIQAR.png
Or do I must to manage them separately?
0693W00000Y8qzDQAR.png

This topic has been closed for replies.
Best answer by waclawek.jan

I've just tried unaligned writes and reads across the 0x2001C000 boundary on an STM32F407, and it works as expected.

In other words, you can fully treat the two SRAMs as one.

JW

5 replies

waclawek.jan
Super User
October 8, 2023

> Can I join SRAM (0x2000 0000 - 0x2001 BFFF) and SRAM2 (0x2001 C000 - 0x2001 FFFF) memories to one?

Yes.

JW

 

JBond.1
JBond.1Author
Senior
October 8, 2023

Just to be more specific: there wont be any issues/errors if the same object or DMA buffer overlaps combined SRAM and SRAM2?

Tesla DeLorean
Guru
October 8, 2023

This area on the F2/F4 parts can be described to linker as a single linear region of 128KB in size.

As I recall there was perhaps a usage as a USB related buffer for the upper 16KB

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
waclawek.jan
Super User
October 8, 2023

> there wont be any issues/errors if the same object or DMA buffer overlaps combined SRAM and SRAM2?

Maybe unaligned access from processor across the boundary would be problematic, so avoid using unaligned objects (packed structs or data accessed through type punning) at that area. DMA can't make unaligned accesses.

The reason why are there two separate SRAM areas is, that two busmasters (processor, DMA, OTG_HS, ETH) can access the two separate memories at the same time with no timing penalty. Only in very extreme cases would this make noticeable difference.

JW

 

waclawek.jan
waclawek.janBest answer
Super User
October 9, 2023

I've just tried unaligned writes and reads across the 0x2001C000 boundary on an STM32F407, and it works as expected.

In other words, you can fully treat the two SRAMs as one.

JW