cancel
Showing results for 
Search instead for 
Did you mean: 

Use Ethernet on nucleo STM32F767zi without RTOS

Wai Siang
Associate III

Objective:
Use ethernet cable to talk to MCU.
Don't want RTOS, just want to use simple CAT5e cable to link to PC server and can ping and can send some messages to and from server via JSON format messages.

I have swept through nearly all available thread from buggy ETH matters collected by Piranha (since ~2019) to 2022 by Adam (https://community.st.com/t5/stm32-mcus/how-to-create-a-project-for-stm32h7-with-ethernet-and-lwip-stack/ta-p/49308#fn:2)
I've tried to follow, but failed, not every thing is true on F767zi.
Some experts suggested that ST should automate the IDE in MCU specific settings. Agree.
Because all the references to make it works is not well combed for beginner. It is very messy compared to other suppliers.
For example, set memory address here and there, enable this disable that... I dont know why, not much explanation, very little cited documents, but somehow the Guru Experts knew it. Amazing. I followed, but no luck.
I cannot even ping the nucleo MCU from PC. I saw some who could...
https://community.st.com/t5/stm32-mcus-embedded-software/stm32f767zi-lwip-freertos-no-ping-response-can-not-compile-lwip/td-p/171121/page/2
========
Now it is late mid of 2024. 
I still cannot get a new references to make ETH work. AI's example also not working. The official bugs are too powerful, like many community mates have commented. hahahaha

Question:
Has anyone know how to get on-board ETH works on nucleo-F767zi?
Or is this F7 onboard ETH really buggy, should I just shift to H7 series better?
Or just forget about onboard ETH, better get an external ETH module to interface directly?

Here is some of my setting
A:Connectivity TAB
1. ETH enabled, LWIP driver DP83848 selected (only this is available. Some used another LANXXXX driver,  never seen in my IDE)

WaiSiang_0-1723088639234.png

2. corrected ETH TXD1 after referring to Nucleo's user guide pdf, it was previously automatically set to another pin. What a *** bug...

WaiSiang_1-1723088685492.png

3. NVIC global interrupt Ticked. (many example use it, so I followed)

B: LWIP setting:

1. Set IP. The rest Default.

WaiSiang_2-1723088799078.png

2.  Key Option: I followed Adam's setting. I don't understand these here, I just followed Adam (URL above).

WaiSiang_4-1723088965768.png

WaiSiang_3-1723088907066.png

Many experts shared to set LwIP heap Pointer address. F767zi does not have that setting available even "show advance parameter" is checked. So I didn't set as shown by Adam's post.

C: Cortex M7 setting

WaiSiang_5-1723089259850.png

WaiSiang_6-1723089270066.png

I don't know why these is needed, just follow and adjust linearly from Adam post.

Clock to 400MHz

Adam set the SysClk to 400. 
I cannot get it to 400 in F767zi, it is RED in the maximum available divider and multiplier.
I tried to maximize it to 200. I wonder if this is critical.

WaiSiang_0-1723091091437.png

E: Main.c
In the main.c, I saw a few new lines added by system:
MX_LWIP_Init(); // system added
inside while(1), first line, I added
MX_LWIP_Process(); // many ppl who ping MCU successfully, use this function in the while loop, so I followed.

But I cannot get a successful ping. I got these:
------------
Pinging 192.168.1.111 with 32 bytes of data:

Reply from 192.168.1.89: Destination host unreachable.
Reply from 192.168.1.89: Destination host unreachable.
Reply from 192.168.1.89: Destination host unreachable.
Reply from 192.168.1.89: Destination host unreachable.

Ping statistics for 192.168.1.111:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
------------

Lastly, I did not do the Modification in

  • Placement of the RX_POOL buffers (although we configured the address in CubeMX) in ethernetif.c2:
  • and Modification in Linkerscript

because it looks exotic to me, I am not sure how and where and why.


Please correct me if you really know where goes wrong and reason behinds.
If there is new references available in 2024, please share with me.
If you know better chipset, external ETH module that is easier to use, do share with me please. 

1 ACCEPTED SOLUTION

Accepted Solutions
STea
ST Employee

Hello @Wai Siang ,

I'll try to give you a quick guide on how to make it work on the Nucleof767 here is the steps I followed to make it work: 
1- configuration of ethernet and pin assignment 

2- configuration of Lwip with the correct Network interface (PHY) LAN8742 (you will find all configuration in the .ioc file) 
3- disabled DHCP to assign a static IP address
4- make sure ICMP is activated in order for the ping command to get a response 
5-genrated project using CubeIDE 
6-added the following section in the flash.ld file to place the DMA descriptors of Ethernet in a specific memory location as they are sensitive to segmentation and unaligned access.

  .lwip_sec (NOLOAD) : {
    . = ABSOLUTE(0x2007c000);
    *(.RxDecripSection) 
    
    . = ABSOLUTE(0x2007c0a0);
    *(.TxDecripSection)
    
  } >RAM AT> FLASH

7-in the while(1) of the main.c file add 

	  MX_LWIP_Process();
	      HAL_Delay(1);

for periodic handling
8- download the Firmware and test the application by ping 192.168.1.x(15 in the shared working example)
Hope this helps.
Regards

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
STea
ST Employee

Hello @Wai Siang ,

I'll try to give you a quick guide on how to make it work on the Nucleof767 here is the steps I followed to make it work: 
1- configuration of ethernet and pin assignment 

2- configuration of Lwip with the correct Network interface (PHY) LAN8742 (you will find all configuration in the .ioc file) 
3- disabled DHCP to assign a static IP address
4- make sure ICMP is activated in order for the ping command to get a response 
5-genrated project using CubeIDE 
6-added the following section in the flash.ld file to place the DMA descriptors of Ethernet in a specific memory location as they are sensitive to segmentation and unaligned access.

  .lwip_sec (NOLOAD) : {
    . = ABSOLUTE(0x2007c000);
    *(.RxDecripSection) 
    
    . = ABSOLUTE(0x2007c0a0);
    *(.TxDecripSection)
    
  } >RAM AT> FLASH

7-in the while(1) of the main.c file add 

	  MX_LWIP_Process();
	      HAL_Delay(1);

for periodic handling
8- download the Firmware and test the application by ping 192.168.1.x(15 in the shared working example)
Hope this helps.
Regards

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Thanks.
After I connect to router and ping it, it can ping. I can use UDP scanner to see the Echo from MCU IP which look healthy.
but I failed to send UDP message sending.

void udp_send_message(const char *data2, size_t length, const ip_addr_t *dest_ip, u16_t port) {

struct pbuf *p;

err_t err;

 

// Allocate pbuf for the UDP message

p = pbuf_alloc(PBUF_TRANSPORT, length, PBUF_POOL);

if (p == NULL) {

// Handle memory allocation failure

strcpy(data, "pbuf_alloc failed\r\n");

HAL_UART_Transmit_IT(&huart2, (uint8_t *)data, strlen(data)); // Send error message to terminal

HAL_Delay(5);

Error_Handler();

return;

}

 

// Copy the message data into the pbuf

memcpy(p->payload, data2, length);

 

// Send the UDP message

err = udp_sendto(udp_connection, p, dest_ip, port);

if (err != ERR_OK) {

// Handle send error

snprintf(data, sizeof(data), "udp_sendto failed %d\r\n", err);

HAL_UART_Transmit_IT(&huart2, (uint8_t *)data, strlen(data)); // Send error code to terminal

HAL_GPIO_WritePin(GPIOB, LD2_Pin, GPIO_PIN_SET); // Turn on blue LED

HAL_Delay(5);

Error_Handler();

}

 

// Free the pbuf

pbuf_free(p);

}

 


My PC UDP listener in MobaXterm no longer see anything coming from MCU IP...

Should I open another thread or ask here about UDP so people know how my setting is?

Hello @Wai Siang ,

I'll proceed by closing this thread and recommend you open another thread to treat the UDP sending problem.
Regards 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.