# STM32H7 ETH Tx fails depending on buffer address

**URL:** <https://forums.freertos.org/t/stm32h7-eth-tx-fails-depending-on-buffer-address/18087>\
**Category:** ARM\
**Created:** [August 29, 2023, 3:58pm UTC](https://forums.freertos.org/t/stm32h7-eth-tx-fails-depending-on-buffer-address/18087 "2023-08-29T15:58:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jchabod](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@jchabod](https://forums.freertos.org/u/jchabod)\
**Post date:** [August 29, 2023, 3:58pm UTC](https://forums.freertos.org/t/stm32h7-eth-tx-fails-depending-on-buffer-address/18087/1 "2023-08-29T15:58:12Z")

</div>

Hi,

I have been porting an application on STM32H723 with FreeRTOS. I am using STMCube IDE 1.10.0 for the configuration, along with LWIP and MBEDTLS

Based on samples on GITHUB (stm32-hotspot/STM32H7-LwIP-Examples - I cannot post any link but you’ll find) I was able to make a good start, however, as soon as I add MbedTLS I get issues in Tx of ETH buffers.

After long debugging, I figured out that the DMA failed when the buffer is outside the memory region “RAM\_D2” (0x3000\_0000 + 32K) (no Ack of emission and we’re stuck waiting for the semaphore)

Currently I patched my application to manually copy the UDP (Multicast) buffer into a reserved region in RAM\_D2 and it works fine, but I do not understand where this issue comes from. (And I want to remove this ugly patch)

Just to make it clear, here is the “ugly” patch that works:

```auto

#ifdef SOPC_FREERTOS_UDP_RAM_BASE
    static uint8_t* DTCMR_Buffer = (void*) 0x30007000; // DTCM + 28K (=32 - 4 K)
    SOPC_ASSERT(buffer->length < 4 * 1024);
    static SOPC_Mutex* mutex = NULL;

    if (NULL == mutex)
    {
        SOPC_Mutex_Initialization(mutex);
    }

    SOPC_Mutex_Lock(mutex);

    memcpy(DTCMR_Buffer, buffer->data, buffer->length);
    ssize_t res = sendto(sock, DTCMR_Buffer, buffer->length, 0, destAddr->ai_addr, destAddr->ai_addrlen);

    SOPC_Mutex_Unlock(mutex);
#else
#warning \
    "SOPC_FREERTOS_UDP_RAM_BASE is not defined and UDP sending may probably fail if RAM section is not properly set with DMA!"
    ssize_t res = sendto(sock, buffer->data, buffer->length, 0, destAddr->ai_addr, destAddr->ai_addrlen);
#endif

```

I can confirm that

- the Tx descriptor are correctly located in RAM\_D2 (cache disabled).
- the MPU is configured as (from example on github):
  - region 0 : disable 4GB
  - region 1 : RAM\_D2 disable cache/share/buffer for 32K (full size)
  - region 2 : RAM\_D2 disable cache, enable share/buffer for 512b (where the TRx & Rx descr. are located)
  - I added regions 3…6 that were initially not in the demo:
  - region 3 & 4 : enable all on RAMD1 : 265 + 64K (hum I do not understand how all this was OK previoulsy without this…)
  - region 5 :enable all on DTCM (I need more HEAP for MbedTLS, using HEAP5 to extend heap)

Can anyone tell me :

- Shall I enforce actual data to be on a non-cacheable section (As far as I understood, only the descriptor need that, but that may be where I am wrong) ?
- Is there any option to do this automatically (something like `LWIP_MPU_COMPATIBLE` which seems to have a close enough behavior) ?
- Why does this only happen when adding MBEDTLS module?
- Why only section on RAM\_D2 are enabled on MPU ? Is my MPU configuration OK ? (I can provide precise configuration if required)
- Is it a mistake to use DTCM for additional HEAP? (section not cacheable?)

I’ll be grateful for anny answers 🙂

Regards,

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [August 29, 2023, 4:26pm UTC](https://forums.freertos.org/t/stm32h7-eth-tx-fails-depending-on-buffer-address/18087/2 "2023-08-29T16:26:37Z")

</div>

A number of PODs do not allow DMA to access certain memory regions depending on the internal bus architecture, have you checked that with your MCUs user guide?

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [August 30, 2023, 5:27am UTC](https://forums.freertos.org/t/stm32h7-eth-tx-fails-depending-on-buffer-address/18087/3 "2023-08-30T05:27:10Z")

</div>

This article provides the information you are looking for - [Ethernet not working on STM32H7x3 - STMicroelectronics Community](https://community.st.com/t5/stm32-mcus/ethernet-not-working-on-stm32h7x3/ta-p/49479).

[EDIT] This post also has useful discussion - [FreeRTOS+TCP for STM32H7?](https://forums.freertos.org/t/freertos-tcp-for-stm32h7/7618).

---

<div class="post-metadata">

**Author:** ![jchabod](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@jchabod](https://forums.freertos.org/u/jchabod)\
**Post date:** [August 30, 2023, 4:22pm UTC](https://forums.freertos.org/t/stm32h7-eth-tx-fails-depending-on-buffer-address/18087/4 "2023-08-30T16:22:21Z")

</div>

Ok thanks.

I don’t know where to get this information from H723 user manual… but his make sens.

I also guess that enabling Cache for DCTM in MPU configuration will not miraculously make it Cacheable… ?
