cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743 - NUCLEO SPI-DMA not working - always busy

DPham.2
Associate II

I have attached my sample project with STM32H7

https://1drv.ms/u/s!AuUAN7PWAxFS8l9pJ-mzXLp1vpXc?e=oFnJSX

In short, The basic function HAL_SPI_Transmit(&hspi1, aTxBuffer, 2, 1) work fine but it took a long time.For that reason, I tried to use HAL_SPI_Transmit_DMA to improve the SPI speed (HAL took so long time !!) like the function below

HAL_SPI_Transmit_DMA(&hspi1, aTxBuffer, 1);

while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);

However, it looks like it is stuck at HAL_SPI_STATE_READY T.T -> always Busy ???

I don't know why the STM32H7 cannot work properly. I think that the DMA is not working well like this post: "https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices"

I try to apply "Solution example 1": Simple placement of all memory to the D1 domain. However, I don't know how to change the .ld file extension. It is so complicated for newbies like me when using STM32Cube IDE

Could anyone make SPI_DMA work with high speed in STM32H7. Thank you so much

7 REPLIES 7
TDK
Guru

> I try to apply "Solution example 1": Simple placement of all memory to the D1 domain. However, I don't know how to change the .ld file extension. It is so complicated for newbies like me when using STM32Cube IDE

Yes, it's complicated, but it's laid out on that page quite well. Nothing on that page says to change the .ld file extension.

Where do you get stuck?

If you feel a post has answered your question, please click "Accept as Solution".

Thank you for your reply,

In order to overcome the DMA issue, I select solution 1 which is considered to be the simple method.

0693W00000D03myQAB.pngFrom here there are some confusing things

In cased System Workbench for STM32 - STM32 IDE

quote "Replace DTCMRAM with RAM_D1 for section placement in linkerscript (.ld file extension). E.g. like this:

.data :

{

  ... /* Keep same */

} >RAM_D1 AT> FLASH

this should be done also for .bss and ._user_heap_stack sections."

=>Question 1: there are two .id files one is flash one is Ram. -> I think that we need to change all (it depend on your programming method - store in FLASH OR RAM )

STM32H743ZITX_FLASH.id and STM32H743ZITX_RAM.ld

0693W00000D03nrQAB.png 

=>Question 2

"Replace DTCMRAM with RAM_D1 " is not clear. In my case, it is hard to know which one to modify ???

0693W00000D03ofQAB.png 

For example , does it mean ? we should replace " DTCMRAM  (xrw)  : ORIGIN = 0x20000000,  LENGTH = 128K" with " RAM_D1 (xrw)  : ORIGIN = 0x20000000,  LENGTH = 128K" ???

Question 3:

Quote ".data :

{

  ... /* Keep same */

} >RAM_D1 AT> FLASH

this should be done also for .bss and ._user_heap_stack sections."

when I open " STM32H743ZITX_RAM.ld " I saw some line

 .data :

 {

  . = ALIGN(4);

  _sdata = .;    /* create a global symbol at data start */

  *(.data)      /* .data sections */

  *(.data*)     /* .data* sections */

  . = ALIGN(4);

  _edata = .;    /* define a global symbol at data end */

 } >RAM_D1

.bss :

 {

  /* This is used by the startup in order to initialize the .bss section */

  _sbss = .;     /* define a global symbol at bss start */

  __bss_start__ = _sbss;

  *(.bss)

  *(.bss*)

  *(COMMON)

  . = ALIGN(4);

  _ebss = .;     /* define a global symbol at bss end */

  __bss_end__ = _ebss;

 } >RAM_D1

 ._user_heap_stack :

 {

  . = ALIGN(8);

  PROVIDE ( end = . );

  PROVIDE ( _end = . );

  . = . + _Min_Heap_Size;

  . = . + _Min_Stack_Size;

  . = ALIGN(8);

 } >RAM_D1

---------

DO you mean that we should modify like this

 .data :

 {

  . = ALIGN(4);

  _sdata = .;    /* create a global symbol at data start */

  *(.data)      /* .data sections */

  *(.data*)     /* .data* sections */

  . = ALIGN(4);

  _edata = .;    /* define a global symbol at data end */

 } >RAM_D1 AT> FLASH

.bss :

 {

  /* This is used by the startup in order to initialize the .bss section */

  _sbss = .;     /* define a global symbol at bss start */

  __bss_start__ = _sbss;

  *(.bss)

  *(.bss*)

  *(COMMON)

  . = ALIGN(4);

  _ebss = .;     /* define a global symbol at bss end */

  __bss_end__ = _ebss;

 } >RAM_D1 AT> FLASH

 ._user_heap_stack :

 {

  . = ALIGN(8);

  PROVIDE ( end = . );

  PROVIDE ( _end = . );

  . = . + _Min_Heap_Size;

  . = . + _Min_Stack_Size;

_estack = .; /* <<<< line added */

  . = ALIGN(8);

 } >RAM_D1

-------------------------

Question 4:

quote : "and remove the original _estack definition."

_estack = ORIGIN(RAM_D1) + LENGTH(RAM_D1); /* end of "RAM_D1" Ram type memory */

/* <<<< line Delete ???*/

do u mean we should delete this line?

Question 5:

finally, we disable Dcache in stm32CUBE, I am right? :D

Please understand that from my view, the solution may not clear, which may cause confusion to the reader?

yours sincerely,

MasterT
Lead

There are many examples for H7 SPI, just download stm32CubeMX.

https://www.st.com/en/embedded-software/stm32cubeh7.html

AP Note:

AN5033

Application note

STM32Cube MCU Package examples for STM32H7 Series

See:

0693W00000D07tUQAR.png

=>Question 1: there are two .id files one is flash one is Ram. -> I think that we need to change all (it depend on your programming method - store in FLASH OR RAM )

The FLASH linker script is used by default. You should just delete the other one to avoid confusion.

=>Question 2

 

"Replace DTCMRAM with RAM_D1 " is not clear. In my case, it is hard to know which one to modify ???

Don't touch what you have circled here. Follow the previous picture for what to replace, you circled it in your previous picture.

Question 3:

Delete the RAM linker script.

Question 4:

Yes.

Question 5:

Yes

If you feel a post has answered your question, please click "Accept as Solution".

Dear MasterT,

Thank you for your suggestion

the main issue is The Hal speed is so slow even with the DMA

After checking the example, I think the SPI Low level may help, I will read it.

Thank you for your answer :D

I only have one concerned about question 2 ?

In a nutshell, here's what I changed, ​(see the attached picture)

Please check if I'm doing it right? "Replace DTCMRAM with RAM_D1 for section placement in linkerscript (.ld file extension). "

0693W00000D0VGbQAN.png

JohnsAby
Associate II

Hi,

Your issue got solved ? if yes, please provide more information.

I am also facing some issues in SPI with DMA, please find my queries

1) Is it allowed to use 3 wire communication for SPI with DMA(only SPI Transfer used) ?

2) I have done the implementation of 3 wire SPI using DMA and when I do SPI transfer using

HAL_SPI_Transmit_DMA(&SPIx_handle, (uint8_t *)TxBuffer, 8u); the HAL_SPI_GetState(&SPIx_handle) is stuck at HAL_SPI_STATE_BUSY.

Not changing the state.

Any help is appreciated, Thanks in advance