1
votes

Hope all is going well. I'm trying to ping STM32H743ZI NUCLEO 144 using LWIP middle-ware. Code generated by CubeMX.

  • Configurations:

    1. Set the HCLK to 400 MHz
    2. Enabled the CPU ICache and DCache (under Cortex_M7 Configuration)
    3. Enabled MPU (Region0, Region1 & Region2)
    4. Enabled LWIP
    5. Selected LAN8742 as the Driver_PHY (under LwIP>Platform Settings)
    6. DHCP disabled (IP, MASK: 255,255,255,000 , Gateway: Modem IP)
    7. RTOS disabled
    8. LWIP_HTTPD, LWIP_HTTPD_CGI enabled
    9. LWIP_HTTPD_SSI enabled
    10. LWIP_HTTPD_MAX_TAG_NAME_LEN set to 16
    11. ICMP enabled (LWIP_BROADCAST_PING and LWIP_MULTICAST_PING in LwIP Key Options>IPMP Options).
    12. Code Generated for Keil V5
    13. MX_LWIP_Process added to the main function in While loop.

      while(1)
      {

      MX_LWIP_Process();

      }

I don't know how should I configure the CubeMX or change the generated code to be able to ping my board.

My_File

1

1 Answers

0
votes

this will probably help you (it did for me): Information about this issue can be found here. https://community.st.com/s/article/FAQ-Ethernet-not-working-on-STM32H7x3

Memory buffers need to be assigned to RAM that can be accessed by the Ethernet peripheral. You may need to adjust the tour stack/heap size. The default Ethernet GPIOs speed may be too low. You may need to configure the MPU.

You may likely need to change your linker script.

On this page you will find good information: https://github.com/MX-Master/STM32H7_Nucleo-H743ZI_Ethernet_LwIP

The HAL_Delay mentioned may not be required, though.

In the file lan8742.c (driver), I added an extra line for the LAN8742_Init function, around line 190, to set auto-negotiation:

// Link did not come up after HW reset.
pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, LAN8742_BCR_AUTONEGO_EN);

So that function looks like:

// Used in ethernetif.c, 363, static void low_level_init(struct netif *netif)
int32_t LAN8742_Init(lan8742_Object_t *pObj)
{
   uint32_t tickstart = 0, regvalue = 0, addr = 0;
   int32_t status = LAN8742_STATUS_OK;

   if(pObj->Is_Initialized == 0)
   {
     if(pObj->IO.Init != 0)
     {
       /* GPIO and Clocks initialization */
       pObj->IO.Init();
     }

     /* for later check */
     pObj->DevAddr = LAN8742_MAX_DEV_ADDR + 1;

     /* Get the device address from special mode register */  
     for(addr = 0; addr <= LAN8742_MAX_DEV_ADDR; addr ++)
     {
       if(pObj->IO.ReadReg(addr, LAN8742_SMR, &regvalue) < 0)
       { 
         status = LAN8742_STATUS_READ_ERROR;
         /* Can't read from this device address 
            continue with next address */
         continue;
       }

       if((regvalue & LAN8742_SMR_PHY_ADDR) == addr)
       {
         pObj->DevAddr = addr;
         status = LAN8742_STATUS_OK;
         break;
       }
     }

     if(pObj->DevAddr > LAN8742_MAX_DEV_ADDR)
     {
       status = LAN8742_STATUS_ADDRESS_ERROR;
     }

     /* if device address is matched */
     if(status == LAN8742_STATUS_OK)
     {
       /* set a software reset  */
       if(pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, LAN8742_BCR_SOFT_RESET) >= 0)
       { 
         /* get software reset status */
         if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &regvalue) >= 0)
         { 
           tickstart = pObj->IO.GetTick();

           /* wait until software reset is done or timeout occurred  */
           while(regvalue & LAN8742_BCR_SOFT_RESET)
           {
             if((pObj->IO.GetTick() - tickstart) <= LAN8742_SW_RESET_TO)
             {
               if(pObj->IO.ReadReg(pObj->DevAddr, LAN8742_BCR, &regvalue) < 0)
               { 
                 status = LAN8742_STATUS_READ_ERROR;
                 break;
               }
             }
             else
             {
               status = LAN8742_STATUS_RESET_TIMEOUT;
             }
           } 
         }
         else
         {
           status = LAN8742_STATUS_READ_ERROR;
         }
       }
       else
       {
         status = LAN8742_STATUS_WRITE_ERROR;
       }
     }
   }


   // Jack 2019-03-25, Link did not come up after HW reset.
   pObj->IO.WriteReg(pObj->DevAddr, LAN8742_BCR, LAN8742_BCR_AUTONEGO_EN);



   if(status == LAN8742_STATUS_OK)
   {
     tickstart =  pObj->IO.GetTick();

     /* Wait for 2s to perform initialization */
     while((pObj->IO.GetTick() - tickstart) <= LAN8742_INIT_TO)
     {
     }
     pObj->Is_Initialized = 1;
   }

   return status;
}