cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F217 & Ethernet PHY: KSZ8721BL & LwIp1.3.2 - ping trouble

rerayne
Associate II
Posted on March 02, 2012 at 16:28

Hello!

I have a board based on STM32F Ethernet PHY: KSZ8721BL; LwIp 1.3.2. I took [url = ''http://electronix.ru/redirect.php?http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/FIRMWARE/stm32f2x7_eth_lwip.zip'']this[/url] example of LwIp for STM32F2*7 and changed ethernet driver configuration for my board (change are highlighted): stm32f2x7_eth_bsp.c

[b]#define CHECKSUM_BY_HARDWARE 1 [/b]
/*...................*/
void ETH_BSP_Config(void)
{
/* Configure the GPIO ports for ethernet pins */
ETH_GPIO_Config();
/* Config NVIC for Ethernet */
ETH_NVIC_Config();
/* Configure the Ethernet MAC/DMA */
ETH_MACDMA_Config();
[b]
/* if (EthInitStatus == 0)
{
LCD_SetTextColor(Red);
LCD_DisplayStringLine(Line5, (uint8_t*)'' Ethernet Init '');
LCD_DisplayStringLine(Line6, (uint8_t*)'' failed '');
while(1);
}*/
/* Configure the PHY to generate an interrupt on change of link status */
// Eth_Link_PHYITConfig(DP83848_PHY_ADDRESS);
/* Configure the EXTI for Ethernet link status. */
// Eth_Link_EXTIConfig();[/b]
}
void ETH_GPIO_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable GPIOs clocks */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB |
RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOI |
RCC_AHB1Periph_GPIOG | RCC_AHB1Periph_GPIOH |
RCC_AHB1Periph_GPIOF, ENABLE);
/* Enable SYSCFG clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* Configure MCO (PA8) */
[b] GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOA, &GPIO_InitStructure);[/b]
/* MII/RMII Media interface selection --------------------------------------*/
#ifdef MII_MODE /* Mode MII with STM322xG-EVAL */
#ifdef PHY_CLOCK_MCO
/* Output HSE clock (25MHz) on MCO pin (PA8) to clock the PHY */
RCC_MCO1Config(RCC_MCO1Source_HSE, RCC_MCO1Div_1);
#endif /* PHY_CLOCK_MCO */
SYSCFG_ETH_MediaInterfaceConfig(SYSCFG_ETH_MediaInterface_MII);
#elif defined RMII_MODE /* Mode RMII with STM322xG-EVAL *///!
/* Output PLL clock divided by 2 (50MHz) on MCO pin (PA8) to clock the PHY */
[b]RCC_MCO1Config(RCC_MCO1Source_PLLCLK, RCC_MCO1Div_2);[/b]
SYSCFG_ETH_MediaInterfaceConfig(SYSCFG_ETH_MediaInterface_RMII);
[b] SYSCFG_CompensationCellCmd(ENABLE);[/b]
#endif
/* Configure PA1, PA2 and PA7 */
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_ETH);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_ETH);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_ETH);
/* Configure PC1, PC4 and PC5 */
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource4, GPIO_AF_ETH);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource5, GPIO_AF_ETH);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource1, GPIO_AF_ETH); 
/* Configure PG14 and PG13 */
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOG, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOG, GPIO_PinSource13, GPIO_AF_ETH);
GPIO_PinAFConfig(GPIOG, GPIO_PinSource14, GPIO_AF_ETH);
/* Configure PB11 */ 
[b] GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_ETH);[/b]
}

system_stm32f2xx.c:

uint32_t SystemCoreClock = 100000000;

The board started working with this code successfully. After 2-4 hour the board ceased to answer. Interesting fact: At the start of pinging the responce time <= 1 ms. After some time (always random period) pinging changes to 400-2000ms. If I start pinging on a second computer with option -f(flood), pings to board will change to 1-40ms. After stop pinging on the second computer the responce time returns to 400-2000ms again. Somebody met this problem? Regards, Rayne. #lwip-freertos-stm32f2-ping
4 REPLIES 4
amin23
Associate II
Posted on March 02, 2012 at 17:18

Hello,

Is your application based on FreeRTOS or standalone?

rerayne
Associate II
Posted on March 02, 2012 at 19:03

Hello!

FreeRTOS version.

amin23
Associate II
Posted on March 05, 2012 at 07:46

hello,

Try to modify ethernetif_input function as below:

void ethernetif_input(void * pvParameters)

{

  struct pbuf *p;

  for( ;; )

  {

    if(xSemaphoreTake(s_xSemaphore, emacBLOCK_TIME_WAITING_FOR_INPUT)==pdTRUE)

    {

GET_NEXT_FRAGMENT:

      p = low_level_input( s_pxNetIf );

      if (p != NULL)

      {

        if (ERR_OK != s_pxNetIf->input( p, s_pxNetIf))

        {

          pbuf_free(p);

          p=NULL;

        }

        else

        {

          xSemaphoreTake(s_xSemaphore, 0);

          goto GET_NEXT_FRAGMENT;

        }

      }

    }

  }

}

rerayne
Associate II
Posted on March 05, 2012 at 12:04

Work! Thanks!

But I catch next bug: HF on static void

tcpip_thread(void *arg) in call function:

[code]

#if LWIP_ARP

     if (msg->msg.inp.netif->flags & NETIF_FLAG_ETHARP)

{

       ethernet_input(msg->msg.inp.p, msg->msg.inp.netif);

     } 

[/code]

Addr of msg->msg.inp.p = 0x23 => CPU hardfault.