Skip to main content
kens0o
Associate II
June 30, 2022
Question

Problems with TouchGFX generated Project and LWIP/Ethernet

  • June 30, 2022
  • 5 replies
  • 5154 views

Hi,

i am having problems with TouchGFX generated Project and LWIP/Ethernet

My Software setup:

STMCubeIDE Version: 1.9.0

TouchGFX Version: 4.19.1

STM32Cube_FW_H7_V1.10.0

My Hardware setup:

STM32H747I-DISCO

I have followed the steps in the ST-article How-to-create-project-for-STM32H7-with-Ethernet-and-LwIP-stack-working (can't add link) but can't ping the board. There is no Ethernet interrupt or RX callback, but GPIOs are set to high speed and ETH global interrupt is enabled and set to priorty 5 - preemption and 0 - subpriority.

Ping works in the attached example from the article, even when I migrate to the new H7-FW (after using the steps under 10. STM32Cube_FW_H7_V1.10.0 (and newer) specific issues).

I think there might be a problem with the MPU region, since I read somewhere that the M4 core is accessing the 0x30040000 with 0x10040000 and I have setup the same address there (sorry i am new to dualcore and mpu configs - see region 4 to 7 in my config). here is my config:

void MPU_Config(void)
 
{ 
 MPU_Region_InitTypeDef MPU_InitStruct = {0}; 
 
 /* Disables the MPU */
  HAL_MPU_Disable();
 
  /** Initializes and configures the Region and the memory to be protected
 
 */
 
 MPU_InitStruct.Enable = MPU_REGION_ENABLE;
 
 MPU_InitStruct.Number = MPU_REGION_NUMBER0; 
 MPU_InitStruct.BaseAddress = 0x90000000; 
 MPU_InitStruct.Size = MPU_REGION_SIZE_256MB; 
 MPU_InitStruct.SubRegionDisable = 0x0; 
 MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; 
 MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS; 
 MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE; 
 MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE; 
 MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; 
 MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; 
 
 HAL_MPU_ConfigRegion(&MPU_InitStruct);
 
 
 /** Initializes and configures the Region and the memory to be protected
 */ 
 MPU_InitStruct.Number = MPU_REGION_NUMBER1; 
 MPU_InitStruct.Size = MPU_REGION_SIZE_128MB; 
 HAL_MPU_ConfigRegion(&MPU_InitStruct);
  
 /** Initializes and configures the Region and the memory to be protected
 */
  MPU_InitStruct.Number = MPU_REGION_NUMBER2; 
 MPU_InitStruct.BaseAddress = 0xD0000000; 
 MPU_InitStruct.Size = MPU_REGION_SIZE_32MB; 
 MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;  
 HAL_MPU_ConfigRegion(&MPU_InitStruct);
 
 /** Initializes and configures the Region and the memory to be protected 
 */
 
 MPU_InitStruct.Number = MPU_REGION_NUMBER3; 
 MPU_InitStruct.BaseAddress = 0x24000000; 
 MPU_InitStruct.Size = MPU_REGION_SIZE_512KB; 
 MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE; 
 HAL_MPU_ConfigRegion(&MPU_InitStruct);
 
 /** Initializes and configures the Region and the memory to be protected 
 */ 
 MPU_InitStruct.Number = MPU_REGION_NUMBER4; 
 MPU_InitStruct.BaseAddress = 0x10000000; 
 MPU_InitStruct.Size = MPU_REGION_SIZE_256KB; 
 HAL_MPU_ConfigRegion(&MPU_InitStruct); 
 
 /** Initializes and configures the Region and the memory to be protected 
 */
 
 MPU_InitStruct.Number = MPU_REGION_NUMBER5; 
 MPU_InitStruct.BaseAddress = 0x10040000; 
 MPU_InitStruct.Size = MPU_REGION_SIZE_32KB; 
 MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE; 
 HAL_MPU_ConfigRegion(&MPU_InitStruct);
 
  /** Initializes and configures the Region and the memory to be protected 
 */
  MPU_InitStruct.Number = MPU_REGION_NUMBER6; 
 MPU_InitStruct.BaseAddress = 0x30040000; 
 MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1; 
 MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS; 
 MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; 
 HAL_MPU_ConfigRegion(&MPU_InitStruct); 
 
 /** Initializes and configures the Region and the memory to be protected 
 */
 
 MPU_InitStruct.Number = MPU_REGION_NUMBER7; 
 MPU_InitStruct.Size = MPU_REGION_SIZE_256B; 
 MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; 
 MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE; 
 MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE; 
 HAL_MPU_ConfigRegion(&MPU_InitStruct);
 
 /* Enables the MPU */ 
 HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); 
}

Another clue I got is this: in the ethernetif.h there is this complete section grayes out, but i am using the GNU Compiler:

#if defined ( __ICCARM__ ) /*!< IAR Compiler */ 
#pragma location = 0x30000260 
extern u8_t memp_memory_RX_POOL_base[]; 
 
#elif defined ( __CC_ARM ) /* MDK ARM Compiler */ 
__attribute__((at(0x30000260)) extern u8_t memp_memory_RX_POOL_base[]; 
 
#elif defined ( __GNUC__ ) /* GNU Compiler */ 
__attribute__((section(".Rx_PoolSection"))) extern u8_t memp_memory_RX_POOL_base[];
 
#endif

So I think the problem could be the structure of the TouchGFX generated Project.

On the left is the TouchGFX generated Project, which links only some files to the CM7 Subproject and on the right is the example project which has the files directly included in the CM7 subproject

0693W00000QKCpFQAX.png 

Thank you for any help and hints!

This topic has been closed for replies.

5 replies

ktrofimo
Senior III
July 1, 2022

Regarding MPU: It is important to set correct parameters for TX and RX DMA descriptors:

1. in linker LD file check .lwip_sec section for addresses in use

2. in ethernetif.c you should check corresponding __attribute__((section(".XxDescripSection"))); at DMARxDscrTab[] and DMATxDscrTab[]​ arrays

3. in main.c check that region set for DMA descriptors in linker LD file have:

  • MPU_TEX_LEVEL0
  • BUFFERABLE
  • NOT_CACHEABLE
  • SHAREABLE
  • INSTRUCTION_ACCESS_DISABLE

attributes. CubeIDE can set single attribute in the beginning of function and then use it for many sections. So check what is set in sections above 4 and if you are going to change it manually, then also think about sections below you have just changed.

kens0o
kens0oAuthor
Associate II
July 1, 2022

0693W00000QKG2vQAH.pngThanks for the fast answer!

1. In the linker file .._FLASH.ld I already had added the .lwip section:

.lwip_sec (NOLOAD):
 {
 . = ABSOLUTE(0x30040000);
 *(.RxDescripSection)
 
 . = ABSOLUTE(0x30040060);
 *(.TxDescripSection)
 
 . = ABSOLUTE(0x30040200);
 *(.Rx_PoolSection)
 } > RAM_D2

2. in ethernetif.c DMARxDscrTab[] and DMATxDscrTab[]​ arrays also seem to be inactive. So I think this could be the error. I noticed before that some defines can't be found because only c files are linked into the project.

0693W00000QKFxlQAH.png 

3. in main.c these are the regions I had added. Access Permission was set to ALL ACCESS NOT PERMITTED. I changed it, but still can't ping the board.

0693W00000QKFzmQAH.png 

ktrofimo
Senior III
July 1, 2022

Check what is with your DMA descriptor tables. (Probably you just need to rebuild index - sometimes CubeIDE doesn't highlight code properly until index is rebuilt)

Last section (for __GNUC__) should be enabled. Otherwise your will have compilation errors.

kens0o
kens0oAuthor
Associate II
July 1, 2022

Rebuilding the index does not solve the problem. I checked the comiler flag: it is set to __GNUC__ in the project, but the ethernetif.h and .c files are not linked in the project. They are located in the CM7/LWIP/Target/ folder and the STM32H747I-DISCO_CM7 Project has only linked the LwIP files from the Middlewares/Third_Party/LwIP/ folder.

Any advice whats the best way to handle the TouchGFX generated Project? I think it is very unhandy that only some files get linked to the project. For example defines in main.h are not known to files in the project which include main.h. Do I have to add new .c and .h files in the CM7/Core/ folder and link them to the project?

0693W00000QKGIPQA5.png

ktrofimo
Senior III
July 1, 2022

Here is my project structure:

0693W00000QKGNeQAP.pngBoth lwip.c and ethernetif.c are located in LWIP\Target folder and linked to the project:

0693W00000QKGP6QAP.png

kens0o
kens0oAuthor
Associate II
July 1, 2022

Thanks, now I see it, too! It's the same link in my project and when I open ethernetif.c with the link, the compiler flag for __GNUC__ is recognized.

kens0o
kens0oAuthor
Associate II
July 6, 2022

I already found your post and read the links, but it is hard for me to figure out if they all concern the FW_H7_1.10 and which of these points could be the reason for the link failing after 5 to 30 minutes.

It would be nice if you could lead me in the right direction.

Piranha
Principal III
July 6, 2022

All of the lwIP related issues are definitely still broken and causing problems.

Piranha
Principal III
July 20, 2022

So, continuing from this topic...

> But I can't figure out where the DMA transfers are resumed.

The DMA transfers are resumed by issuing a poll demand. On H7 this is done by a write to the respective descriptor tail pointer register.

Read the following from RM0399 Rev 3:

61.9.4 Performing normal receive and transmit operation

61.4.1 DMA controller; DMA transmission in default mode, DMA reception

There is an issue with inconsistent naming and wrong and misleading documentation for these registers on H7. This is described/reported there:

https://community.st.com/s/question/0D53W00000EGsnUSAT/how-does-ethernet-rx-descriptor-wrapping-work-on-stm32h7