2025-10-12 10:31 PM - last edited on 2025-10-13 3:21 AM by mƎALLEm
Hi everyone,
I’m currently working with an STM32H747 and trying to perform SD card write operations using core M4. The SMMC1 peripheral is connected to the D1 domain, which (as far as I understand) means that the M4 core (D2 domain) doesn’t have direct access to it.
When I try to write to the SD card from M4 (using MDMA), it always fails — f_mkfs returns an error. However, when I run exactly the same code on core M7, everything works perfectly fine.
So my questions are:
Does it make sense that the M4 cannot access SMMC1 because of the D1 domain connection?
Is there any way to make SD write operations work from the M4 core (for example, through shared memory, DMA Settings, or another workaround)?
Thanks in advance.
Solved! Go to Solution.
2025-10-13 4:22 PM
Long night..... but IT WORKED !!!
with only one line changed
FRESULT res; /* FatFs function common result code */
__attribute__((section(".RAM_D1"))) uint32_t byteswritten, bytesread; /* File write/read counts */
uint8_t wtext[] = "STM32 FATFS works great!"; /* File write buffer */
__attribute__((section(".RAM_D1"))) uint8_t rtext[_MAX_SS];/* File read buffer */
IDK why i putted write buffer to D1 but now its ok!
2025-10-13 2:39 AM
Hello @Patryk_Kucia
You are right, the SDMMC1 peripheral is located within the D1 domain of the STM32H747, which means it is not directly accessible by the D2 domain (Cortex-M4 core). As a result, the Cortex-M4 core cannot perform SD card operations using SDMMC1. To enable SD card access from the Cortex-M4 core, we recommend utilizing the SDMMC2 peripheral, which is mapped to the D2 domain and can be directly controlled by the Cortex-M4.
2025-10-13 3:28 AM - edited 2025-10-13 3:30 AM
Hello,
See also this thread: STM32H757 SDMMC1 only works with M7 core
2025-10-13 2:10 PM
Yes but in STM32H747-Disco it is connected to SDMMC1 not SDMMC2 and they have different pinout. Unless I can change the mapping so that SDMMC2 will have pins from SDMMC1???
2025-10-13 2:30 PM
So it is possible but how? Saket_Om just said that it is not posible and in your link it just works from changing the clock?
2025-10-13 2:56 PM
Okay, I don't know how, but somehow SDMMC1 works on the M4 core only on PLL2R at 50MHz. The problem is that it only works when the MDMA template isn't used, and I need it for the RTOS because FatFS requires MDMA when working with FreeRTOS.
2025-10-13 4:10 PM
OK, I managed to successfully create a filesystem and upload a text file there. However, the uploaded text, once read from the SD card by the computer is not the text I typed. The save itself worked successfully via MDMA when I added these lines to the M4 linker:
.RAM_D1 (NOLOAD) :
{
. = ALIGN(8);
. = ORIGIN(RAM_D1) + 0x4000;
*(.RAM_D1)
. = ALIGN(8);
} >RAM_D1RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512Kmain:
__attribute__((section(".RAM_D1"))) uint32_t byteswritten, bytesread; /* File write/read counts */
__attribute__((section(".RAM_D1"))) uint8_t wtext[] = "STM32 FATFS works great!"; /* File write buffer */
__attribute__((section(".RAM_D1"))) uint8_t rtext[_MAX_SS];/* File read buffer */
res = f_write(&SDFile, wtext, strlen((char *)wtext), (void *)&byteswritten);
if((byteswritten == 0) || (res != FR_OK))
{
printf("f_write error!\r\n");
Error_Handler();
}
else
{
f_close(&SDFile);
printf("f_close OK!\r\n");
}fatfs.c:
__attribute__((section(".RAM_D1"))) uint8_t retSD; /* Return value for SD */
__attribute__((section(".RAM_D1"))) char SDPath[4]; /* SD logical drive path */
__attribute__((section(".RAM_D1"))) FATFS SDFatFS; /* File system object for SD logical drive */
__attribute__((section(".RAM_D1"))) FIL SDFile; /* File object for SD */My question is: what's causing the garbage data to be saved instead of my data(file name is OK only content is cracked)??. should I somehow protect the area where I'm trying to allocate these buffers in D1 from the M7 core side? i tryed this:
.RAM_D1_RESERVED_FOR_M4 (NOLOAD) :
{
. = ORIGIN(RAM_D1) + 0x8000; /* offset 0x8000 */
__ram_d1_m4_start_reserved = .;
. = . + 0x10000;
__ram_d1_m4_end_reserved = .;
} >RAM_D1but nothing changed.
2025-10-13 4:22 PM
Long night..... but IT WORKED !!!
with only one line changed
FRESULT res; /* FatFs function common result code */
__attribute__((section(".RAM_D1"))) uint32_t byteswritten, bytesread; /* File write/read counts */
uint8_t wtext[] = "STM32 FATFS works great!"; /* File write buffer */
__attribute__((section(".RAM_D1"))) uint8_t rtext[_MAX_SS];/* File read buffer */
IDK why i putted write buffer to D1 but now its ok!