cancel
Showing results for 
Search instead for 
Did you mean: 

LwIP problems from code generated via STM32CubeMX (SMT32H7)

KR1
Associate III

Hello,

I seem to be having some problems with the code generated via STM32CubeMX on the NUCLEO-H743ZI development board. I want to configure it to run on LwIP/RAW API. I can create such a configuration for its close relative: the NUCLEO F767ZI development board. In the latter case I take the following steps:

  1.  Set the HCLK to 216 MHz (clocked from the HSI);
  2. Enable the ETH peripheral, set it to RMII mode, and set ETH_TXD0 and ETH_TX_EN pins to PG13 and PG11 (others are mapped appropriately);
  3.  Set the PHY address to 0 in ETH Configuration>General: Ethernet Configuration
  4.  Enable the LwIP middleware;
  5. Enable ICMP (LWIP_BROADCAST_PING and LWIP_MULTICAST_PING in LwIP Key Options>IPMP Options). This step is not necessary, although it helps to determine if all is well with the device.

After I generate the code, I add an extern variable to my main.c to be able to track whether the device has obtained an IP address:

/* USER CODE BEGIN PV */
 
/* Private variables ---------------------------------------------------------*/
 
extern struct netif gnetif;
 
/* USER CODE END PV */

Moreover, I add the standard LwIP/RAW IP callbacks t the main loop:

/* Infinite loop */
 
 /* USER CODE BEGIN WHILE */
 
 while (1)
 
 {
 
 
 
 /* USER CODE END WHILE */
 
 
 
 /* USER CODE BEGIN 3 */
 
 ethernetif_input(&gnetif);
 
 sys_check_timeouts();
 
 }
 
 /* USER CODE END 3 */

This code works well and I am able to get an IP address (I can determine it frome the gnetif->ip_addr field), I can see all the proper ARP request in WireShark and I am able to ping the device:

0690X000006C7VhQAK.png

Herein, I am filtering only the traffic from/to the appropriate (STM32) MAC address 00:80:E1:00:00:00.

For the NUCLEO-H7432ZI board, I essentially follow the same steps, with a couple of minor deviations:

  1.  Set the HCLK to 400 MHz (clocked from the HSI);
  2. Enable the ETH peripheral, set it to RMII mode, and set ETH_TXD0 and ETH_TX_EN pins to PG13 and PG11 (others are mapped appropriately);
  3. Enable the CPU DCache (under Cortex_M7 Configuration)
  4. Enable the LWIP middleware
  5. Select LAN8742/LAN8742 as the Driver_PHY (under LwIP>Platform Settings)
  6. Enable ICMP (LWIP_BROADCAST_PING and LWIP_MULTICAST_PING in LwIP Key Options>IPMP Options).

I change the code in main.c appropriately as for the F7 example. Moreover, I edit the linker file to partition the RAM from 0x24000000 to 0x2407FFFF (there is an instruction in ETH>Parameter Setting to do so in order to get the ETH peripheral working).

If I upload this (nearly identical) build to the NUCLEAO-H743ZI board, I get no network activity (No ARP requests to get an IP address.

Now I know that the issue is somewhere in the STM32CubeMX generated configuration. The hardware itself is good. There is an example of a LwIP HTTP server in STM32Cube_FW_H7_V1.1.0 which works just fine if I upload it to the board. The LwIP_HTTP_Server_Netconn_RTOS example in STM32Cube_FW_H7_V1.1.0 is somewhat different: it uses a RTOS and the Netconn API. For my application I want to stick with Raw API (and no RTOS). So my question would be, what am I missing in my microcontroller configuration?

23 REPLIES 23
clock.1166
Senior

Hi Pavel,

Thanks. I have built without errors and it runs OK.

At least I am a bit further on in my understanding of how to build an HTTP webserver. but

I do wish that there was a working H743 project to investigate!

Chris

clock.1166
Senior

FINALLY!!!!!!! Now there is.

I imported the STM32Cube_FW_H7_V1.5.0\Projects\NUCLEO-H743ZI\Applications\LwIP\LwIP_HTTP_Server_Netconn_RTOS\SW4STM32\STM32H743ZI_Nucleo into cubeide v1.7.0

and the H743ZI2 nucleo - worked first time no mods at all.

Now at least I can study the operation. Hope this helps someone!

Chris

Hello,

can you please tell me, how did you activate the ETH_IRQHandler(), because i cant call this unless I use Lwip with RTOS

regards

Enable the necessary interrupts in ETH peripheral, enable the ETH peripheral in NVIC and set up the DMA descriptors correctly.

About that "perfectly working solution"... It's running the whole IP stack from interrupts, which also means you have to disable interrupts to call any lwIP function from non-interrupt code. And disabling/enabling I-cache is just a complete nonsense.