cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F439ZI + Eth + LwIP; no ping response

florian.morsch
Associate II

Hello,

i have a Nucleo-144 board, where i replaced the STM32F429ZI for a STM32F439ZI.

I used CubeMX 5.2.0 to create a ethernet test project just to ping the board and go further from there, but i cant get it to work.

Ethernet is enabled

0690X000008B5dmQAC.png

Ethernet interrupt is enabled.

The parameter settings:

0690X000008B5euQAC.pngAnd the advanced parameter settings:

0690X000008B5f4QAC.png

The clock configuration:

0690X000008B5fOQAS.png

LwIP is enabled, general settings (Ive tested with bot static and dynamic IP, both wont work):

0690X000008B5fiQAC.png

I left most of the LwIP options at standart, except i set

LWIP_BROADCAST_PING (Respond to Broadcast Pings) Enabled

LWIP_MULTICAST_PING (Respond to Multicast Pings) Enabled

Also CHECKSUM_BY_HARDWARE is enabled, as well as all the CHEKSUM_GEN_*** and CHECKSUM_CHECK_***

Ive build the source code with Minimum Heap Size 0x2000 and Minimum Stack Size 0x4000.

In Atollic TrueSTUDIO 9.0.1 ive build the project, where i needed to copy fsdata.c to Middlewares/Third_Party/LwIP/src/apps/httpd/ and exclude it from build, so the file would build properly.

I added MX_LWIP_Process(); to the while(1) in main.c, compiled and flashed the board.

At this point i should be able to ping it already, but i get no response whatsoever.

It doesnt matter if i use a crossed or straight ethernet cable, connect it to the network or directly to the PC and if i give a static or dynamic IP, i cant ping the board at all.

Im in a dead end with this, i suspect that the F439ZI MCU on a F429ZI nucleo board wont work, but at this point i dont know what could be wrong. Any tipps/help would be appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi

you didn't mention that you called MX_LWIP_Init() before the while loop to initialize LWIP

When use HTTPD , httpd_init(); must be called also.

In LWIP-> "Debug" tab ->advanced options can activate some debug options to help solve the issue.

You can retarget these messages to Atollic's SWV console or to a serial port .

View solution in original post

11 REPLIES 11

Hi

you didn't mention that you called MX_LWIP_Init() before the while loop to initialize LWIP

When use HTTPD , httpd_init(); must be called also.

In LWIP-> "Debug" tab ->advanced options can activate some debug options to help solve the issue.

You can retarget these messages to Atollic's SWV console or to a serial port .

Hello and sorry for the late reply.

The MX_LWIP_Init(); is automatically called in the CubeMX generated code:

int main(void)
{
  /* USER CODE BEGIN 1 */
 
  /* USER CODE END 1 */
  
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_LWIP_Init();
  /* USER CODE BEGIN 2 */
 
  /* USER CODE END 2 */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
	  //Read a received packet from the Ethernet buffers and send it to the LwIP stack for handling
	  MX_LWIP_Process();
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

Thanks for the hint with the debug options, going to check on that.

EDIT: I deactivated the HTTPD and enabled LWIP_NETIF_LINK_CALLBACK and LWIP_NETIF_REMOVE_CALLBACK, after that the board responds to pings, now i can proceed.

Thanks for the hint with httpd_init();

I searched for that command, but in the whole project i could not find it, so i disabled it in CubeMX.

After i enabled LWIP_HTTPD, LWIP_HTTPD_CGI and LWIP_HTTPD_SSI and added httpd_init(); to main.c,i get the compiler error:

(i use this https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjAvbSJrf_hAhVQKFAKHQ60BYUQFjAAegQIBRAC&url=http%3A%2F%2Fwww.openstm32.org%2Fdl410&usg=AOvVaw2WTGcQg8_S_ei2oJLzipwb as guide)

"undefined reference to 'httpd_cgi_handler'

in path /EthernetTest/Middlewares/Third_Party/LwIP/src/apps/httpd

The problem: httpd.h, where httpd_cgi_handler is defined, is called with #include "lwip/apps/httpd.h".

The compiler always searches in the wrong place, the httpd.h is located at /EthernetTest/Middlewares/Third_Party/LwIP/src/include/lwip/apps/

but the compiler wont take that path.

The path is given in Properties -> c/c++ Build -> Settings -> Directories -> Include Path

and also in Properties -> C/C++ General -> Paths and Symbols -> Includes

Any idea why the compiler wont take the .h file with the definition of httpd_cgi_handler in the given location?

If You have #include "lwip/apps/httpd.h" in file, then configure directory search path to /EthernetTest/Middlewares/Third_Party/LwIP/src/include/ so that concatenated together they form the needed full path.

The problem with this is, i already have the search patch .../Middlewares/Third_Party/LwIP/src/include/ enabled, also set it at a higher priority then .../Middlewares/Third_Party/LwIP/src/apps/httpd, but the compiler still gives this error.

I found the source of the problem though: The function httpd_cgi_handler(); is called

httpd_cgi_handler(uri, count, http_cgi_params, http_cgi_param_vals
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
         , hs->handle->state
#endif
);

and also declared in the header httpd.h

extern void httpd_cgi_handler(const char* uri, int iNumParams, char **pcParam, char **pcValue
#if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE
                                     , void *connection_state
#endif
);

but there is no function definition. Its simply missing. So i put the function call into comments and the code compiled as it should.

I guess thats a bug with the generated code from CubeMX.

Hi.

httpd_cgi_handler(..) must be defined by the user.

In general, when the user wants to install one or more CGI callbacks , must use http_set_cgi_handlers(CGI_arr, x);

CGI_arr is an array of tCGI type, "x" is the number of handlers contained in the array

Install one callback func like this "tCGI CGI_arr[1]={{"/config.cgi", usrCGIHandler}}; //usrCGIHandler is the user handler

So you can call http_set_cgi_handlers(CGI_arr, 1); to install this handler.

A "workaround" not to have this link error is to disable

this "HTTP CGI NEW STYLE"

Here are some data from LWIP site

0690X000008BIrIQAW.jpg

Thank you for the great help, i see now where i made my mistakes. Not the answer to the original question, but perfect answer to the followup.

Thanks again.

Hello,

How did you solve this issue. I'm having a same problem  with httpd_cgi_handler();?

Thank you!