cancel
Showing results for 
Search instead for 
Did you mean: 

LwIP + FreeRTOS not working on STM32F746

RCont.1
Associate II

Hello folks!

I have a STM32F746 MCU on my custom board and I'm trying to get the LwIP + FreeRTOS stack to work, especially the netconn tcp_echo_server example.

It's not a hardware related problem, because the same HW has been used on another board (STM32F2 and STM32F3) and everything works fine. It must be a software problem but I can't figure out what it is.

I simply generated the code with the STM32CubeIDE, copied the example from the repository and started the application. This worked on the other board (STM33F2 and STM33F3) but not in this one (STM32F746).

Looking at the example of the repository, there are some differences compared to the generated code, especially regarding the addressing of the DMA buffers as follow.

...._RAM.ld
 
/* GENERATED CODE */
 
MEMORY
{
  RAM      (xrw)   : ORIGIN = 0x20000000, LENGTH = 320K  
  FLASH    (rx)    : ORIGIN = 0x08000000, LENGTH = 512K
}
 
/* EXAMPLE CODE */
 
MEMORY
{
  RAM      (xrw)   : ORIGIN = 0x20000000, LENGTH = 307K
  FLASH    (rx)    : ORIGIN = 0x08000000, LENGTH = 512K
  Memory_B1(xrw)   : ORIGIN = 0x2004C000, LENGTH = 0x80
  Memory_B2(xrw)   : ORIGIN = 0x2004C080, LENGTH = 0x80
  Memory_B3(xrw)   : ORIGIN = 0x2004C100, LENGTH = 0x17D0 
  Memory_B4(xrw)   : ORIGIN = 0x2004D8D0, LENGTH = 0x17D0 
}
 
  .RxDescripSection (NOLOAD) : { *(.RxDescripSection) } >Memory_B1
  .TxDescripSection (NOLOAD) : { *(.TxDescripSection) } >Memory_B2
  .RxarraySection   (NOLOAD) : { *(.RxBUF) } >Memory_B3
  .TxarraySection   (NOLOAD) : { *(.TxBUF) } >Memory_B4

ethernetif.c
 
/* GENERATED CODE */
 
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
  #pragma data_alignment=4
#endif
__ALIGN_BEGIN ETH_DMADescTypeDef  DMARxDscrTab[ETH_RXBUFNB] __ALIGN_END;/* Ethernet Rx MA Descriptor */
 
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
  #pragma data_alignment=4
#endif
__ALIGN_BEGIN ETH_DMADescTypeDef  DMATxDscrTab[ETH_TXBUFNB] __ALIGN_END;/* Ethernet Tx DMA Descriptor */
 
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
  #pragma data_alignment=4
#endif
__ALIGN_BEGIN uint8_t Rx_Buff[ETH_RXBUFNB][ETH_RX_BUF_SIZE] __ALIGN_END; /* Ethernet Receive Buffer */
 
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
  #pragma data_alignment=4
#endif
__ALIGN_BEGIN uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE] __ALIGN_END; /* Ethernet Transmit Buffer */
 
****************************************************************
 
/* EXAMPLE CODE */
 
ETH_DMADescTypeDef  DMARxDscrTab[ETH_RXBUFNB] __attribute__((section(".RxDescripSection")));/* Ethernet Rx DMA Descriptors */
 
ETH_DMADescTypeDef  DMATxDscrTab[ETH_TXBUFNB] __attribute__((section(".TxDescripSection")));/* Ethernet Tx DMA Descriptors */
 
uint8_t Rx_Buff[ETH_RXBUFNB][ETH_RX_BUF_SIZE] __attribute__((section(".RxarraySection"))); /* Ethernet Receive Buffers */
 
uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE] __attribute__((section(".TxarraySection"))); /* Ethernet Transmit Buffers */

The "application" code, is exactly the same as in the netconn tcp_echo_server example

Is there anyone who managed to use the LwIP stack on this MCU STM32F746?

Tnx.

11 REPLIES 11
Nimit Vachhani
Associate III

Hi,

Have you found the solution ? I have implemented LWIP with STM32F103VE and ENC28J60 module. If you want to have a look let me know.

FYI : I have also implemented it using Nucleo-144 board for STM32F207ZG

RCont.1
Associate II

Hi Nimit,

No, no working solution for now.

I've implemented a working solution with other 2 custom boards with the same hardware but different MCUs: STM32F2 and STM32F3, and a couple of Discovery boards. The problem I have is only with this MCU STM32F746, when the STM32CubeIDE generates the code.

I'm not understanding where I'm going wrong or if there is anything particular to configure.

Nimit Vachhani
Associate III

Its simple... I have working solution let me know if you need some help.

RCont.1
Associate II

Yes, of course, otherwise I wouldn't have written here on the forum. Please, share here your solution, or contact me in direct.

I've struggled on my STM32F767 and it seems the most common bear trap is that the DTCM doesn't play nicely with the DMA controller. I believe you need to make sure the Ethernet buffers are nailed in place (I use SRAM2 block) and then you make the cache for that region 'write through'.

RCont.1
Associate II

Hi Oliver,

How to do that?

RCont.1
Associate II

I've copied the example by editing the linker descriptor file FLASH.ld, then assigning the right addresses to the Ethernet buffers, as I wrote in my first post.

Moreover, I've configured the MPU as follow

  /* Configure the MPU as Normal Non Cacheable for Ethernet Buffers in the SRAM2 */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.BaseAddress = 0x2004C000;
  MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;
  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER0;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
  MPU_InitStruct.SubRegionDisable = 0x00;
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
 
  HAL_MPU_ConfigRegion(&MPU_InitStruct);
  
  /* Configure the MPU as Device for Ethernet Descriptors in the SRAM2 */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.BaseAddress = 0x2004C000;
  MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER1;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
  MPU_InitStruct.SubRegionDisable = 0x00;
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
 
  HAL_MPU_ConfigRegion(&MPU_InitStruct);

But it's still not working for me....

Can you share with us?

Thanks

Hello Nimit Sir

 

Please guide me how to make tcp working on stm32f746 discovery, even I am struggling to make it work for days.
Any inputs are highly appreciated, I am a beginner in embedded systems.

 

Thankyou.