ST example code has corrupted ETH RX Buffers
HI,
I’m working on ETH and FreeRTOS on the STM32H745 Nucleo-144. I’ve read about various problems on this forum about using the ethernet as detailed below
- https://community.st.com/s/question/0D53W00000rZ8ZvSAK/corrupted-eth-rx-buffer-in-stm32h7?t=1629194187536
- https://community.st.com/s/question/0D50X0000C6eNNSSQ2/bug-fixes-stm32h7-ethernet
So when I saw this article from ST employees detailing how to use ETH and FreeRTOS, with examples I was really excited.
I took their STM32H745_Nucleo_M4_ETH example and added a very simple web site. It just said hello and displayed two large images
<!DOCTYPE HTML>
<html>
<head>
<title>STM32h745 TCP error</title>
</head>
<body>
hello
<img src="image1.jpg">
<img src="image2.jpg">
</body>
</html>Here’s my code changes
\CM4\Core\Src\main.c
/* USER CODE BEGIN 4 */
extern void http_server_netconn_thread(void);
/* USER CODE END 4 */
/* USER CODE BEGIN 5 */
http_server_netconn_thread();
/* USER CODE END 5 */\CM4\LWIP\App\lwip.c – changed the static IP address to 192.168.0.130 (to suite my network)
void MX_LWIP_Init(void)
{
/* IP addresses initialization */
IP_ADDRESS[0] = 192;
IP_ADDRESS[1] = 168;
IP_ADDRESS[2] = 0;
IP_ADDRESS[3] = 130;New Files
- \CM4\Core\Src\website\favicon.jpg – small icon from web page tab
- \CM4\Core\Src\website\image1.jpg – medium size image
- \CM4\Core\Src\website\image2.jpg – large size image
- \CM4\Core\Src\website\index.html – main web page
- \CM4\Core\Src\makefsfile.exe – convert files in website into “C�? code
- \CM4\Core\Src\makefsfile.bat – batch file to call makefsfile with correct arguments
- \CM4\Core\Src\server.c – simple HTTP server based on ST other example code
- \CM4\Core\Src\fsdata.h – website in “C�? code
But when the code below was called for “image2.jpg�? I found “buf�? is normally corrupted with leading zeros.
netbuf_data(inbuf, (void**)&buf, &buflen);Looking at the “buf�? I can see the original HTTP request, but the ETH driver/DMA/?? has overwritten the start with zeros.
Looking at the web browser I can see the actual request is valid.
When the web server sees an empty string it returns back with 501, and the image is not loaded.
I had come across this problem in my actual code last year, but couldn’t release it and maybe my code was at fault. So I was hoping using ST new example code would prove if I was doing something wrong or they had fixed it.
But now I have a small test project using a ST example that demonstrates the problem (99% of the time). So I’m hoping somebody (eg @Laura C, @Camilo LEMOS, @Brian Kling, who was involved in generating the ETH example code) can look at the code, see the problem and fix it.
I’ve included the whole project as a zip file. If you debug it you need to change one of the debug configurations to use a different GDB port number, eg 61238, otherwise it will clash.
Cheers
Chris
