fixed LWIP bugs on stm32f407-st-discovery board
This commit is contained in:
parent
ad84a842b0
commit
8483f08271
|
@ -50,7 +50,7 @@
|
|||
#include "lwip/sys.h"
|
||||
#include "netif/etharp.h"
|
||||
#include "err.h"
|
||||
#include "ethernetif.h"
|
||||
#include "enet_ethernetif.h"
|
||||
|
||||
#include "main.h"
|
||||
#include <string.h>
|
||||
|
@ -140,11 +140,10 @@ void LwIP_Pkt_Handle(struct netif *netif)
|
|||
|
||||
void Time_Update_LwIP(void)
|
||||
{
|
||||
LocalTime += MS_PER_SYSTICK_F407;
|
||||
LocalTime += MS_PER_SYSTICK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* In this function, the hardware should be initialized.
|
||||
* Called from ethernetif_init().
|
||||
|
@ -413,7 +412,7 @@ void LoopGetMacPkg(void * pvParameters)
|
|||
* ERR_MEM if private data couldn't be allocated
|
||||
* any other err_t on error
|
||||
*/
|
||||
err_t ethernetif_init(struct netif *netif)
|
||||
err_t ethernetif0_init(struct netif *netif)
|
||||
{
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* File Name : ethernetif.h
|
||||
* Description : This file provides initialization code for LWIP
|
||||
* middleWare.
|
||||
******************************************************************************
|
||||
* This notice applies to any and all portions of this file
|
||||
* that are not between comment pairs USER CODE BEGIN and
|
||||
* USER CODE END. Other portions of this file, whether
|
||||
* inserted by the user or by software development tools
|
||||
* are owned by their respective copyright owners.
|
||||
*
|
||||
* Copyright (c) 2018 STMicroelectronics International N.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted, provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistribution of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of other
|
||||
* contributors to this software may be used to endorse or promote products
|
||||
* derived from this software without specific written permission.
|
||||
* 4. This software, including modifications and/or derivative works of this
|
||||
* software, must execute solely and exclusively on microcontroller or
|
||||
* microprocessor devices manufactured by or for STMicroelectronics.
|
||||
* 5. Redistribution and use of this software other than as permitted under
|
||||
* this license is void and will automatically terminate your rights under
|
||||
* this license.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
|
||||
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
|
||||
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __ETHERNETIF_H__
|
||||
#define __ETHERNETIF_H__
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
/* Within 'USER CODE' section, code will be kept by default at each generation */
|
||||
/* USER CODE BEGIN 0 */
|
||||
#define NETIF_MTU ( 1500 )
|
||||
|
||||
#define NETIF_IN_TASK_STACK_SIZE ( 1024 )
|
||||
#define NETIF_IN_TASK_PRIORITY ( 3 )
|
||||
|
||||
#define NETIF_OUT_TASK_STACK_SIZE ( 1024 )
|
||||
#define NETIF_OUT_TASK_PRIORITY ( 3 )
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
err_t ethernetif0_init(struct netif *netif);
|
||||
|
||||
void ethernetif_input( void *argument );
|
||||
void ethernetif_output( void *argument );
|
||||
void ethernetif_update_config(struct netif *netif);
|
||||
void ethernetif_notify_conn_changed(struct netif *netif);
|
||||
|
||||
u32_t sys_jiffies(void);
|
||||
u32_t sys_now(void);
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
#endif
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -69,6 +69,8 @@
|
|||
#include "ethernet.h"
|
||||
#include "enet_ethernetif.h"
|
||||
#include <transform.h>
|
||||
#include "connect_ethernet.h"
|
||||
|
||||
|
||||
char lwip_ipaddr[] = {192, 168, 250, 253};
|
||||
char lwip_netmask[] = {255, 255, 255, 0};
|
||||
|
@ -469,14 +471,16 @@ void lwip_config_net(char *ip, char *mask, char *gw)
|
|||
mem_range_t non_dma_memory[] = NON_DMA_MEMORY_ARRAY;
|
||||
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
||||
ip4_addr_t net_ipaddr, net_netmask, net_gw;
|
||||
ethernetif_config_t cfg = {
|
||||
.phyAddress = BOARD_ENET0_PHY_ADDRESS,
|
||||
.clockName = kCLOCK_CoreSysClk,
|
||||
.macAddress = configMAC_ADDR,
|
||||
#if defined(FSL_FEATURE_SOC_LPC_ENET_COUNT) && (FSL_FEATURE_SOC_LPC_ENET_COUNT > 0)
|
||||
.non_dma_memory = non_dma_memory,
|
||||
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
||||
};
|
||||
|
||||
#if defined(ethernetif_config_t)
|
||||
ethernetif_config_t cfg = {
|
||||
.phyAddress = BOARD_ENET0_PHY_ADDRESS,
|
||||
.clockName = kCLOCK_CoreSysClk,
|
||||
.macAddress = configMAC_ADDR,
|
||||
};
|
||||
#else
|
||||
void *cfg = NULL;
|
||||
#endif
|
||||
|
||||
ETH_BSP_Config();
|
||||
|
||||
|
@ -508,6 +512,7 @@ void lwip_config_net(char *ip, char *mask, char *gw)
|
|||
|
||||
netif_add(&gnetif, &net_ipaddr, &net_netmask, &net_gw, &cfg, ethernetif0_init,
|
||||
ethernet_input);
|
||||
|
||||
netif_set_default(&gnetif);
|
||||
netif_set_up(&gnetif);
|
||||
|
||||
|
@ -533,15 +538,16 @@ void lwip_config_tcp(char *ip, char *mask, char *gw)
|
|||
mem_range_t non_dma_memory[] = NON_DMA_MEMORY_ARRAY;
|
||||
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
||||
ip4_addr_t net_ipaddr, net_netmask, net_gw;
|
||||
|
||||
#if defined(ethernetif_config_t)
|
||||
ethernetif_config_t cfg = {
|
||||
.phyAddress = BOARD_ENET0_PHY_ADDRESS,
|
||||
.clockName = kCLOCK_CoreSysClk,
|
||||
.macAddress = configMAC_ADDR,
|
||||
#if defined(FSL_FEATURE_SOC_LPC_ENET_COUNT) && (FSL_FEATURE_SOC_LPC_ENET_COUNT > 0)
|
||||
.non_dma_memory = non_dma_memory,
|
||||
#endif /* FSL_FEATURE_SOC_LPC_ENET_COUNT */
|
||||
};
|
||||
|
||||
#else
|
||||
void *cfg = NULL;
|
||||
#endif
|
||||
ETH_BSP_Config();
|
||||
|
||||
if(chk_lwip_bit(LWIP_INIT_FLAG))
|
||||
|
|
|
@ -45,6 +45,12 @@
|
|||
#include <lwip/arch.h>
|
||||
#include <lwip/netif.h>
|
||||
|
||||
typedef int32 sys_sem_t;
|
||||
typedef int32 sys_mutex_t;
|
||||
typedef int32 sys_mbox_t;
|
||||
typedef int32 sys_thread_t;
|
||||
typedef x_base sys_prot_t;
|
||||
|
||||
#include "tcpip.h"
|
||||
|
||||
#include <xs_base.h>
|
||||
|
@ -65,12 +71,6 @@
|
|||
#define SYS_SEM_NULL -1
|
||||
#define SYS_MRTEX_NULL SYS_SEM_NULL
|
||||
|
||||
typedef int32 sys_sem_t;
|
||||
typedef int32 sys_mutex_t;
|
||||
typedef int32 sys_mbox_t;
|
||||
typedef int32 sys_thread_t;
|
||||
typedef x_base sys_prot_t;
|
||||
|
||||
#define MS_PER_SYSTICK (1000 / TICK_PER_SECOND)
|
||||
|
||||
//debug rtos with IRQ
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "shell.h"
|
||||
#include "sys_arch.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -23,20 +23,12 @@
|
|||
|
||||
#if LWIP_IPV4 && LWIP_DHCP
|
||||
|
||||
#include "lwip/timeouts.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/init.h"
|
||||
#include "lwip/dhcp.h"
|
||||
#include "lwip/prot/dhcp.h"
|
||||
#include "netif/ethernet.h"
|
||||
#include "enet_ethernetif.h"
|
||||
|
||||
#include "board.h"
|
||||
|
||||
#include "pin_mux.h"
|
||||
#include "clock_config.h"
|
||||
#include "fsl_gpio.h"
|
||||
#include "fsl_iomuxc.h"
|
||||
#include "shell.h"
|
||||
#include "sys_arch.h"
|
||||
|
||||
#define LWIP_DHCP_TIME 10000 // 10s
|
||||
|
@ -99,7 +91,6 @@ int LwipPrintDHCP(struct netif *netif)
|
|||
break;
|
||||
default:
|
||||
lw_notice("%u", dhcp_last_state);
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
lw_notice("\r\n");
|
||||
|
|
|
@ -24,15 +24,13 @@
|
|||
|
||||
#include "ping.h"
|
||||
|
||||
#include "lwip/timeouts.h"
|
||||
#include "lwip/init.h"
|
||||
#include "netif/ethernet.h"
|
||||
//#include "lwip/timeouts.h"
|
||||
//#include "lwip/init.h"
|
||||
//#include "netif/ethernet.h"
|
||||
|
||||
#include "board.h"
|
||||
#include "pin_mux.h"
|
||||
#include "clock_config.h"
|
||||
|
||||
#include <sys_arch.h>
|
||||
#include "shell.h"
|
||||
#include "sys_arch.h"
|
||||
#include "connect_ethernet.h"
|
||||
|
||||
char test_ip_addr[] = {192, 168, 250, 253};
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "shell.h"
|
||||
#include "lwip_demo.h"
|
||||
#include "sys_arch.h"
|
||||
#include "lwip/sockets.h"
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "sys_arch.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "shell.h"
|
||||
|
||||
|
||||
#define PBUF_SIZE 27
|
||||
|
|
Loading…
Reference in New Issue