lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Problems with DHCP/IP/Ping


From: Christoph Ziegler
Subject: [lwip-users] Problems with DHCP/IP/Ping
Date: Thu, 3 Apr 2014 09:28:24 +0200

Hallo,

 

i have a big problem with my DHCP/IP and ping.

 

When i start my STM32F4xx system and wait for IP from DHCP, i get successfully a IP.

But when I then try to ping my system, I get no response.

 

BUT…

When I start the ping cmd "ping -n 999 x.x.x.x" before I start the system, the ping is ever successfully when the system is started.

 

What am I doing wrong?

 

 

 

 

Here are fragments from my src:

 

MY lwipopts.h :

===============================================================================================================================

#ifndef __LWIPOPTS_H__

#define __LWIPOPTS_H__

 

/**

* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain

* critical regions during buffer allocation, deallocation and memory

* allocation and deallocation.

*/

#define SYS_LIGHTWEIGHT_PROT    1

 

#define ETHARP_TRUST_IP_MAC     1

#define IP_REASSEMBLY           0

#define IP_FRAG                 0

#define ARP_QUEUEING            1

 

//#define LWIP_AUTOIP             1

 

#define LWIP_NETIF_API                1

 

#define LWIP_ARP                1

 

#define IP_FORWARD              1

 

 

/**

* NO_SYS==1: Provides VERY minimal functionality. Otherwise,

* use lwIP facilities.

*/

#define NO_SYS                  0

 

/* ---------- Memory options ---------- */

/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which

   lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2

   byte alignment -> define MEM_ALIGNMENT to 2. */

#define MEM_ALIGNMENT           4

 

/* MEM_SIZE: the size of the heap memory. If the application will send

a lot of data that needs to be copied, this should be set high. */

#define MEM_SIZE                (5*1024)

 

/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application

   sends a lot of data out of ROM (or other static memory), this

   should be set high. */

#define MEMP_NUM_PBUF           100

/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One

   per active UDP "connection". */

#define MEMP_NUM_UDP_PCB        6

/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP

   connections. */

#define MEMP_NUM_TCP_PCB        10

/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP

   connections. */

#define MEMP_NUM_TCP_PCB_LISTEN 5

/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP

   segments. */

#define MEMP_NUM_TCP_SEG        20

/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active

   timeouts. */

#define MEMP_NUM_SYS_TIMEOUT    10

 

 

/* ---------- Pbuf options ---------- */

/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */

#define PBUF_POOL_SIZE          20

 

/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */

#define PBUF_POOL_BUFSIZE       500

 

 

/* ---------- TCP options ---------- */

#define LWIP_TCP                1

#define TCP_TTL                 255

 

/* Controls if TCP should queue segments that arrive out of

   order. Define to 0 if your device is low on memory. */

#define TCP_QUEUE_OOSEQ         0

 

/* TCP Maximum segment size. */

#define TCP_MSS                 (1500 - 40)   /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */

 

/* TCP sender buffer space (bytes). */

#define TCP_SND_BUF             (5*TCP_MSS)

 

/*  TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least

  as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */

 

#define TCP_SND_QUEUELEN        (4* TCP_SND_BUF/TCP_MSS)

 

/* TCP receive window. */

#define TCP_WND                 (2*TCP_MSS)

 

 

/* ---------- ICMP options ---------- */

#define LWIP_ICMP                       1

 

 

/* ---------- DHCP options ---------- */

/* Define LWIP_DHCP to 1 if you want DHCP configuration of

   interfaces. DHCP is not implemented in lwIP 0.5.1, however, so

   turning this on does currently not work. */

#define LWIP_DHCP                       1

#define DHCP_DOES_ARP_CHECK             1 /* 1 if you want to do an ARP check on the offered address (recommended). */

#define LWIP_NETIF_HOSTNAME             1

 

/* ---------- UDP options ---------- */

#define LWIP_UDP                        1

#define UDP_TTL                         255

 

 

/* ---------- Statistics options ---------- */

#define LWIP_STATS                      1

#define LWIP_PROVIDE_ERRNO              1

 

/* ---------- link callback options ---------- */

/* LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface

* whenever the link changes (i.e., link down)

*/

#define LWIP_NETIF_LINK_CALLBACK        0

 

/*

   --------------------------------------

   ---------- Checksum options ----------

   --------------------------------------

*/

 

/*

The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware:

- To use this feature let the following define uncommented.

- To disable it and process by CPU comment the  the checksum.

*/

//#define CHECKSUM_BY_HARDWARE

 

#ifdef CHECKSUM_BY_HARDWARE

/* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/

#define CHECKSUM_GEN_IP                 0

/* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/

#define CHECKSUM_GEN_UDP                0

/* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/

#define CHECKSUM_GEN_TCP                0

/* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/

#define CHECKSUM_CHECK_IP               0

/* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/

#define CHECKSUM_CHECK_UDP              0

/* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/

#define CHECKSUM_CHECK_TCP              0

/* CHECKSUM_CHECK_ICMP==0: Check checksums by hardware for incoming ICMP packets.*/

#define CHECKSUM_GEN_ICMP               0

#else

/* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/

#define CHECKSUM_GEN_IP                 1

/* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/

#define CHECKSUM_GEN_UDP                1

/* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/

#define CHECKSUM_GEN_TCP                1

/* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/

#define CHECKSUM_CHECK_IP               1

/* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/

#define CHECKSUM_CHECK_UDP              1

/* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/

#define CHECKSUM_CHECK_TCP              1

/* CHECKSUM_CHECK_ICMP==1: Check checksums by hardware for incoming ICMP packets.*/

#define CHECKSUM_GEN_ICMP               1

#endif

 

 

/*

   ----------------------------------------------

   ---------- Sequential layer options ----------

   ----------------------------------------------

*/

/**

* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)

*/

#define LWIP_NETCONN                    1

 

/*

   ------------------------------------

   ---------- Socket options ----------

   ------------------------------------

*/

/**

* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)

*/

#define LWIP_SOCKET                     1

 

 

 

/*

   -----------------------------------

   ---------- DEBUG options ----------

   -----------------------------------

*/

 

#define LWIP_DEBUG                      1

 

#if LWIP_DEBUG

/**

* LWIP_DBG_TYPES_ON: A mask that can be used to globally enable/disable

* debug messages of certain types.

*/

#define LWIP_DBG_TYPES_ON               LWIP_DBG_ON

/**

* ETHARP_DEBUG: Enable debugging in etharp.c.

*/

#define ETHARP_DEBUG                    LWIP_DBG_ON

/**

* NETIF_DEBUG: Enable debugging in netif.c.

*/

#define NETIF_DEBUG                     LWIP_DBG_ON

/**

* PBUF_DEBUG: Enable debugging in pbuf.c.

*/

#define PBUF_DEBUG                      LWIP_DBG_ON

/**

* API_LIB_DEBUG: Enable debugging in api_lib.c.

*/

#define API_LIB_DEBUG                   LWIP_DBG_ON

/**

* API_MSG_DEBUG: Enable debugging in api_msg.c.

*/

#define API_MSG_DEBUG                   LWIP_DBG_ON

/**

* SOCKETS_DEBUG: Enable debugging in sockets.c.

*/

#define SOCKETS_DEBUG                   LWIP_DBG_ON

/**

* ICMP_DEBUG: Enable debugging in icmp.c.

*/

#define ICMP_DEBUG                      LWIP_DBG_ON

/**

* IGMP_DEBUG: Enable debugging in igmp.c.

*/

#define IGMP_DEBUG                      LWIP_DBG_OFF

/**

* INET_DEBUG: Enable debugging in inet.c.

*/

#define INET_DEBUG                      LWIP_DBG_ON

/**

* IP_DEBUG: Enable debugging for IP.

*/

#define IP_DEBUG                        LWIP_DBG_ON

/**

* IP_REASS_DEBUG: Enable debugging in ip_frag.c for both frag & reass.

*/

#define IP_REASS_DEBUG                  LWIP_DBG_ON

/**

* RAW_DEBUG: Enable debugging in raw.c.

*/

#define RAW_DEBUG                       LWIP_DBG_ON

/**

* MEM_DEBUG: Enable debugging in mem.c.

*/

#define MEM_DEBUG                       LWIP_DBG_ON

/**

* MEMP_DEBUG: Enable debugging in memp.c.

*/

#define MEMP_DEBUG                      LWIP_DBG_ON

/**

* SYS_DEBUG: Enable debugging in sys.c.

*/

#define SYS_DEBUG                       LWIP_DBG_ON

/**

* TIMERS_DEBUG: Enable debugging in timers.c.

*/

#define TIMERS_DEBUG                    LWIP_DBG_ON

/**

* TCP_DEBUG: Enable debugging for TCP.

*/

#define TCP_DEBUG                       LWIP_DBG_ON

/**

* TCP_INPUT_DEBUG: Enable debugging in tcp_in.c for incoming debug.

*/

#define TCP_INPUT_DEBUG                 LWIP_DBG_ON

/**

* TCP_FR_DEBUG: Enable debugging in tcp_in.c for fast retransmit.

*/

#define TCP_FR_DEBUG                    LWIP_DBG_ON

/**

* TCP_RTO_DEBUG: Enable debugging in TCP for retransmit

* timeout.

*/

#define TCP_RTO_DEBUG                   LWIP_DBG_ON

/**

* TCP_CWND_DEBUG: Enable debugging for TCP congestion window.

*/

#define TCP_CWND_DEBUG                  LWIP_DBG_ON

/**

* TCP_WND_DEBUG: Enable debugging in tcp_in.c for window updating.

*/

#define TCP_WND_DEBUG                   LWIP_DBG_ON

/**

* TCP_OUTPUT_DEBUG: Enable debugging in tcp_out.c output functions.

*/

#define TCP_OUTPUT_DEBUG                LWIP_DBG_ON

/**

* TCP_RST_DEBUG: Enable debugging for TCP with the RST message.

*/

#define TCP_RST_DEBUG                   LWIP_DBG_ON

/**

* TCP_QLEN_DEBUG: Enable debugging for TCP queue lengths.

*/

#define TCP_QLEN_DEBUG                  LWIP_DBG_OFF

/**

* UDP_DEBUG: Enable debugging in UDP.

*/

#define UDP_DEBUG                       LWIP_DBG_ON

/**

* TCPIP_DEBUG: Enable debugging in tcpip.c.

*/

#define TCPIP_DEBUG                     LWIP_DBG_ON

/**

* PPP_DEBUG: Enable debugging for PPP.

*/

#define PPP_DEBUG                       LWIP_DBG_OFF

/**

* SLIP_DEBUG: Enable debugging in slipif.c.

*/

#define SLIP_DEBUG                      LWIP_DBG_OFF

/**

* DHCP_DEBUG: Enable debugging in dhcp.c.

*/

#define DHCP_DEBUG                      LWIP_DBG_ON

/**

* AUTOIP_DEBUG: Enable debugging in autoip.c.

*/

#define AUTOIP_DEBUG                    LWIP_DBG_OFF

/**

* SNMP_MSG_DEBUG: Enable debugging for SNMP messages.

*/

#define SNMP_MSG_DEBUG                  LWIP_DBG_OFF

/**

* SNMP_MIB_DEBUG: Enable debugging for SNMP MIBs.

*/

#define SNMP_MIB_DEBUG                  LWIP_DBG_OFF

/**

* DNS_DEBUG: Enable debugging for DNS.

*/

#define DNS_DEBUG                       LWIP_DBG_OFF

#endif /* LWIP_DEBUG */

 

 

 

/*

   ---------------------------------

   ---------- OS options ----------

   ---------------------------------

*/

 

#define TCPIP_THREAD_NAME              "TCP/IP"

#define TCPIP_THREAD_STACKSIZE          1000

#define TCPIP_MBOX_SIZE                 5

#define DEFAULT_UDP_RECVMBOX_SIZE       2000

#define DEFAULT_TCP_RECVMBOX_SIZE       2000

#define DEFAULT_ACCEPTMBOX_SIZE         2000

#define DEFAULT_THREAD_STACKSIZE        500

#define TCPIP_THREAD_PRIO               (configMAX_PRIORITIES - 2)

 

#define LWIP_COMPAT_MUTEX               1

 

#endif /* __LWIPOPTS_H__ */

 

=========================================================================================================================================

 

 

AND HERE IS MY dhcp-func and eth conf:

=========================================================================================================================================

 

/* Includes ------------------------------------------------------------------*/

 

/* C includes */

#include <stdio.h>

 

/* STM includes */

#include "stm32f4xx.h"                  /* STM32F4xx Definitions              */

#include "stm32f4x7_eth.h"

 

/* FreeRTOS includes */

#include "FreeRTOS.h"

#include "task.h"

#include "semphr.h"

 

/* LwIP includes */

#include "lwip/opt.h"

#include "netif.h"

#include "lwip/netifapi.h"

#include "lwip/dhcp.h"

#include "lwip/mem.h"

#include "lwip/memp.h"

#include "ethernetif.h"

#include "tcpip.h"

 

/* RM includes */

#include "eth.h"

#include "main.h"

 

/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

#define eth_DHCP_START                  1

#define eth_DHCP_WAIT_ADDRESS           2

#define eth_DHCP_ADDRESS_ASSIGNED       3

#define eth_DHCP_TIMEOUT                4

#define eth_DHCP_LINK_DOWN              5

 

#define eth_MAX_DHCP_TRIES              5

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

 

#define DHCP_TASK_PRIO   ( tskIDLE_PRIORITY + 4 )

 

static struct ip_addr ipaddr;

static struct ip_addr netmask;

static struct ip_addr gw;

ETH_InitTypeDef eth_InitStructure;

__IO uint32_t  EthStatus = 0;

#ifdef USE_DHCP

__IO uint8_t DHCP_state;

#endif /* LWIP_DHCP */

 

/* Private function prototypes -----------------------------------------------*/

static void eth_HwConfig_GPIO(void);

static void eth_HwConfig_NVIC(void);

static void eth_HwConfig_MACDMA(void);

void eth_LwIP_SetStaticIP (void);

void eth_LwIP_Init(void);

 

/* Private functions ---------------------------------------------------------*/

/**

  * @brief  ETH_BSP_Config

  * @param  None

  * @retval None

  */

void RM_ETH_Init(void)

{

  #ifdef RM_DEBUG_PRINTF

  printf("exec eth_HwConfig_GPIO()\n");

  #endif /* RM_DEBUG_PRINTF */

  /* Configure the GPIO ports for ethernet pins */

  eth_HwConfig_GPIO();

 

  #ifdef RM_DEBUG_PRINTF

  printf("exec eth_HwConfig_NVIC()\n");

  #endif /* RM_DEBUG_PRINTF */

  /* Config NVIC for Ethernet */

  eth_HwConfig_NVIC();

 

  #ifdef RM_DEBUG_PRINTF

  printf("exec eth_HwConfig_MACDMA()\n");

  #endif /* RM_DEBUG_PRINTF */

  /* Configure the Ethernet MAC/DMA */

  eth_HwConfig_MACDMA();

 

  #ifdef RM_DEBUG_PRINTF

  printf("exec eth_LwIP_Init()\n");

  #endif /* RM_DEBUG_PRINTF */

    /* Initilaize the LwIP stack */

  eth_LwIP_Init();

}

 

/* Private functions ---------------------------------------------------------*/

/**

  * @brief  Initializes the lwIP stack

  * @param  None

 * @retval None

  */

void eth_LwIP_Init(void)

{

  /* Create tcp_ip stack thread */

  tcpip_init( NULL, NULL );

 

  /* IP address setting */

  ipaddr.addr = 0;

  netmask.addr = 0;

  gw.addr = 0;

 

  netif_add(

    &ETH_EthInterface,

    NULL,

    NULL,

    NULL,

    NULL,

    &ethernetif_init,

    &tcpip_input

  );

 

  /*  Registers the default network interface.*/

  netif_set_default(&ETH_EthInterface);

 

  ETH_EthInterface.flags |= NETIF_FLAG_LINK_UP;

 

  netif_set_down(&ETH_EthInterface);

 

  #ifdef USE_DHCP

    #ifdef RM_DEBUG_PRINTF

      printf("start ETH_LwIP_DHCP_task\n");

    #endif /* RM_DEBUG_PRINTF */

    /* Start DHCPClient */

    xTaskCreate(ETH_LwIP_DHCP_task, (int8_t *)"DHCP", configMINIMAL_STACK_SIZE * 2, NULL, DHCP_TASK_PRIO, NULL);

    DHCP_state = eth_DHCP_START;

  #else

    eth_LwIP_SetStaticIP ();

  #endif /* USE_DHCP */

}

 

void eth_LwIP_SetStaticIP (void)

{

  /* Static address used */

  IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );

  IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);

  IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);

  netif_set_addr(&ETH_EthInterface, &ipaddr , &netmask, &gw);

 

  #ifdef RM_DEBUG_PRINTF

  printf("Static IP eingestellt: %d.%d.%d.%d\r\n",

         ip4_addr1(&ETH_EthInterface.ip_addr),

         ip4_addr2(&ETH_EthInterface.ip_addr),

         ip4_addr3(&ETH_EthInterface.ip_addr),

         ip4_addr4(&ETH_EthInterface.ip_addr) );

  #endif /* RM_DEBUG_PRINTF */

 

  /* When the netif is fully configured this function must be called.*/

  netif_set_up(&ETH_EthInterface);

}

 

#ifdef USE_DHCP

/**

  * @brief  LwIP_DHCP_Process_Handle

  * @param  None

  * @retval None

  */

void ETH_LwIP_DHCP_task(void * pvParameters)

{

  uint32_t IPaddress;

 

  for (;;)

  {

    switch (DHCP_state)

    {

    case eth_DHCP_START:

    {

      netifapi_dhcp_start(&ETH_EthInterface);

      /* IP address should be set to 0

         every time we want to assign a new DHCP address*/

      IPaddress = 0;

      DHCP_state = eth_DHCP_WAIT_ADDRESS;

    }

    break;

 

    case eth_DHCP_WAIT_ADDRESS:

    {

      /* Read the new IP address */

      IPaddress = ETH_EthInterface.ip_addr.addr;

 

      if (IPaddress!=0)

      {

        DHCP_state = eth_DHCP_ADDRESS_ASSIGNED;

 

        #ifdef    RM_DEBUG_PRINTF

        printf("IP von DHCP erhalten: %d.%d.%d.%d\r\n",

               ip4_addr1(&ETH_EthInterface.ip_addr),

               ip4_addr2(&ETH_EthInterface.ip_addr),

               ip4_addr3(&ETH_EthInterface.ip_addr),

               ip4_addr4(&ETH_EthInterface.ip_addr) );

        #endif /* RM_DEBUG_PRINTF */

 

//        netifapi_dhcp_release(&ETH_EthInterface);

 

        /* Stop DHCP */

        netifapi_dhcp_stop(&ETH_EthInterface);

      }

      else

      {

        /* DHCP timeout */

        if (ETH_EthInterface.dhcp->tries > eth_MAX_DHCP_TRIES)

        {

          DHCP_state = eth_DHCP_TIMEOUT;

 

          /* Stop DHCP */

          netifapi_dhcp_stop(&ETH_EthInterface);

 

          eth_LwIP_SetStaticIP ();

 

          for( ;; )

          {

            vTaskDelete(NULL);

          }

 

        }

      }

    }

    break;

 

    default:

      break;

    }

 

    /* wait 250 ms */

    vTaskDelay(250);

  }

}

#endif  /* USE_DHCP */

 

 

/**

  * @brief  Configures the different GPIO ports.

  * @param  None

  * @retval None

  */

void eth_HwConfig_GPIO(void)

{

  GPIO_InitTypeDef GPIO_InitStructure;

 

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Enable SYSCFG clock */

  RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_ETH_MAC, ENABLE); /* Reset Ethernet MAC */

  SYSCFG_ETH_MediaInterfaceConfig(SYSCFG_ETH_MediaInterface_MII);

  RCC_AHB1PeriphResetCmd(RCC_AHB1Periph_ETH_MAC, DISABLE); /* Reset Ethernet MAC */

 

  /* Enable GPIOs clocks */

  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA |

                          RCC_AHB1Periph_GPIOB |

                          RCC_AHB1Periph_GPIOC, ENABLE); /* Enable GPIOA, GPIOB, GPIOC  clocks */

 

  /* Configure Port A ethernet pins (PA.0, PA.1, PA.3, PA.7) */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_3 | GPIO_Pin_7;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

 

  // Connect Ethernet pins to AF11

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource0, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_ETH);

 

  /* Configure Port B ethernet pins (PB.0, PB.1, PB.8, PB.10, PB.11, PB.12, PB.13) */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

  GPIO_Init(GPIOB, &GPIO_InitStructure);

 

  // Connect Ethernet pins to AF11

  GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOB, GPIO_PinSource12, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOB, GPIO_PinSource13, GPIO_AF_ETH);

 

  /* Configure Port C ethernet pins (PC.2, PC.3, PC.4, PC.5) */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3| GPIO_Pin_4 | GPIO_Pin_5;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

  GPIO_Init(GPIOC, &GPIO_InitStructure);

 

// Connect Ethernet pins to AF11

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource2, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource3, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource4, GPIO_AF_ETH);

  GPIO_PinAFConfig(GPIOC, GPIO_PinSource5, GPIO_AF_ETH);

}

 

/**

  * @brief  Configures and enable the Ethernet global interrupt.

  * @param  None

  * @retval None

  */

void eth_HwConfig_NVIC(void)

{

  NVIC_InitTypeDef   NVIC_InitStructure;

 

  /* Enable the Ethernet global Interrupt */

  NVIC_InitStructure.NVIC_IRQChannel = ETH_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 10 ;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

}

 

/**

  * @brief  Configures the Ethernet Interface

  * @param  None

  * @retval None

  */

static void eth_HwConfig_MACDMA(void)

{

  /* Enable ETHERNET clock  */

  RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_ETH_MAC |

                          RCC_AHB1Periph_ETH_MAC_Tx |

                          RCC_AHB1Periph_ETH_MAC_Rx |

                          RCC_AHB1Periph_ETH_MAC_PTP, ENABLE); /* Enable Ethernet clocks */

 

  /* Software reset */

  ETH_SoftwareReset();

 

  /* Wait for software reset */

  while (ETH_GetSoftwareResetStatus() == SET);

 

  /* ETHERNET Configuration --------------------------------------------------*/

  /* Call ETH_StructInit if you don't like to configure all eth_InitStructure parameter */

  ETH_StructInit(&eth_InitStructure);

 

  // Setup ETH->MACMIIAR : //Default passt

 

  // Setup ETH->MACCR :

  eth_InitStructure.ETH_ReceiveOwn = ETH_ReceiveOwn_Disable;

  eth_InitStructure.ETH_AutoNegotiation = ETH_AutoNegotiation_Disable;

 

  // Setup ETH->MACFFR :

  //eth_InitStructure.ETH_MulticastFramesFilter = 0x410;

 

  // Setup ETH->MACFCR : //Default passt

 

  // Setup ETH->MACVLANTR : //Default passt

 

  // Setup ETH->DMAOMR :

  eth_InitStructure.ETH_DropTCPIPChecksumErrorFrame = ETH_DropTCPIPChecksumErrorFrame_Enable;

  eth_InitStructure.ETH_ReceiveStoreForward = ETH_ReceiveStoreForward_Disable;

  eth_InitStructure.ETH_TransmitStoreForward = ETH_TransmitStoreForward_Disable;

 

  // Setup ETH->DMABMR :

  eth_InitStructure.ETH_AddressAlignedBeats = ETH_AddressAlignedBeats_Disable;

  eth_InitStructure.ETH_FixedBurst = ETH_FixedBurst_Disable;

 

#ifdef CHECKSUM_BY_HARDWARE

  eth_InitStructure.ETH_ChecksumOffload = ETH_ChecksumOffload_Enable;

#endif

 

  /* Configure Ethernet */

  EthStatus = ETH_Init(&eth_InitStructure, 1);

 

  /* Enable the Ethernet Rx Interrupt */

  ETH->DMASR  = 0xFFFFFFFF;  // Reset all interrupts

  ETH_DMAITConfig(ETH_DMAIER_NISE | ETH_DMAIER_RIE, ENABLE);

}

=========================================================================================================================================

 

 

 

Can everyone help me?

 

 

 

 

 



Christoph Ziegler
Research & Development (R&D)

RM MICHAELIDES
SOFTWARE & ELEKTRONIK GMBH
Donaustr. 14 | 36043 Fulda | Germany
Phone

Fax     +49 661 9490-333
www.rmcan.com


Management: Dipl. Ing. Robert Michaelides | Register court: Amtsgericht Fulda 5 HRB 1332

E-mail and any attachments may be confidential. If you have received this E-mail and you are not a named addressee, please inform the sender immediately by E-mail and then delete this E-mail from your system. If you are not a named addressee, you may not use, disclose, distribute, copy or print this E-mail. Addressees should scan this E-mail and any attachments for viruses. No representation or warranty is made as to the absence of viruses in this email or any of its attachments.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]