optimize lwip demo and ok1052-c directories

This commit is contained in:
wlyu
2021-12-30 11:20:36 +08:00
parent 8fa0d977a0
commit 62dcbef383
61 changed files with 1006 additions and 470 deletions

View File

@@ -1,5 +1,5 @@
SRC_DIR := third_party_driver
SRC_DIR := third_party_driver
SRC_FILES := board.c clock_config.c pin_mux.c
SRC_FILES := board.c
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -1,6 +0,0 @@
SRC_DIR := drivers
SRC_FILES := system_MIMXRT1052.c
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -1,5 +0,0 @@
SRC_FILES := fsl_cache.c fsl_clock.c fsl_common.c fsl_lpuart.c fsl_enet.c fsl_gpio.c fsl_phy.c
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -1,4 +1,4 @@
SRC_DIR := MIMXRT1052
SRC_DIR := common gpio
ifeq ($(CONFIG_BSP_USING_LPUART),y)
SRC_DIR += uart

View File

@@ -0,0 +1,3 @@
SRC_FILES := system_MIMXRT1052.c fsl_cache.c fsl_clock.c fsl_common.c pin_mux.c clock_config.c
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -1,3 +1,3 @@
SRC_FILES := enet_ethernetif.c enet_ethernetif_kinetis.c
SRC_FILES := enet_ethernetif.c enet_ethernetif_kinetis.c fsl_enet.c
SRC_DIR := ksz8081
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -206,6 +206,7 @@ void ethernetif_phy_init(struct ethernetif *ethernetif,
void ethernetif_input(struct netif *netif)
{
struct pbuf *p;
err_t ret = 0;
LWIP_ASSERT("netif != NULL", (netif != NULL));
@@ -213,9 +214,10 @@ void ethernetif_input(struct netif *netif)
while ((p = ethernetif_linkinput(netif)) != NULL)
{
/* pass all packets to ethernet_input, which decides what packets it supports */
if (netif->input(p, netif) != ERR_OK)
if ((ret = netif->input(p, netif)) != ERR_OK)
{
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
// LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
lw_print("lw: [%s] ret %d p %p\n", __func__, ret, p);
pbuf_free(p);
p = NULL;
}
@@ -287,7 +289,7 @@ err_t ethernetif_init(struct netif *netif, struct ethernetif *ethernetif,
/* Init ethernetif parameters.*/
*ethernetif_enet_ptr(ethernetif) = ethernetif_get_enet_base(enetIdx);
// LWIP_ASSERT("*ethernetif_enet_ptr(ethernetif) != NULL", (*ethernetif_enet_ptr(ethernetif) != NULL));
LWIP_ASSERT("*ethernetif_enet_ptr(ethernetif) != NULL", (*ethernetif_enet_ptr(ethernetif) != NULL));
/* set MAC hardware address length */
netif->hwaddr_len = ETH_HWADDR_LEN;

View File

@@ -70,29 +70,39 @@
#include "lwip/igmp.h"
#include "lwip/mld6.h"
//
//#define USE_RTOS 1
//#define FSL_RTOS_FREE_RTOS
//#define FSL_RTOS_XIUOS
#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS)
#ifdef FSL_RTOS_XIUOS
#include "xs_sem.h"
#else
#include "FreeRTOS.h"
#include "event_groups.h"
#include "list.h"
#endif
typedef uint32_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
typedef TickType_t EventBits_t;
typedef TickType_t EventBits_t;
typedef long BaseType_t;
typedef unsigned long UBaseType_t;
#define portBASE_TYPE long
#define portBASE_TYPE long
#define pdFALSE ( ( BaseType_t ) 0 )
#define pdTRUE ( ( BaseType_t ) 1 )
#define pdPASS ( pdTRUE )
#define pdFAIL ( pdFALSE )
#define pdFALSE ( ( BaseType_t ) 0 )
#define pdTRUE ( ( BaseType_t ) 1 )
#define pdPASS ( pdTRUE )
#define pdFAIL ( pdFALSE )
#ifndef FSL_RTOS_XIUOS
typedef struct EventGroupDef_t
{
EventBits_t uxEventBits;
@@ -109,7 +119,7 @@ typedef struct EventGroupDef_t
struct EventGroupDef_t;
typedef struct EventGroupDef_t * EventGroupHandle_t;
#endif
#endif
@@ -121,6 +131,8 @@ typedef struct EventGroupDef_t * EventGroupHandle_t;
#include "sys_arch.h"
/*******************************************************************************
* Definitions
******************************************************************************/
@@ -136,7 +148,12 @@ struct ethernetif
enet_handle_t handle;
#endif
#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS)
#ifdef FSL_RTOS_XIUOS
int enetSemaphore;
#else
EventGroupHandle_t enetTransmitAccessEvent;
#endif
EventBits_t txFlag;
#endif
enet_rx_bd_struct_t *RxBuffDescrip;
@@ -161,6 +178,8 @@ static void ethernet_callback(ENET_Type *base, enet_handle_t *handle, enet_event
BaseType_t xResult;
lw_print("lw: [%s] input event %#x \n", __func__, event);
switch (event)
{
case kENET_RxEvent:
@@ -170,6 +189,9 @@ static void ethernet_callback(ENET_Type *base, enet_handle_t *handle, enet_event
{
portBASE_TYPE taskToWake = pdFALSE;
#ifdef FSL_RTOS_XIUOS
#else
#ifdef __CA7_REV
if (SystemGetIRQNestingLevel())
#else
@@ -186,11 +208,14 @@ static void ethernet_callback(ENET_Type *base, enet_handle_t *handle, enet_event
{
xEventGroupSetBits(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag);
}
#endif
}
break;
default:
break;
}
KSemaphoreAbandon(ethernetif->enetSemaphore);
}
#endif
@@ -274,6 +299,56 @@ err_t ethernetif_mld_mac_filter(struct netif *netif, const ip6_addr_t *group,
}
#endif
#define netifINTERFACE_TASK_STACK_SIZE ( 4096 )
/**
* This function is the ethernetif_input task, it is processed when a packet
* is ready to be read from the interface. It uses the function low_level_input()
* that should handle the actual reception of bytes from the network
* interface. Then the type of the received packet is determined and
* the appropriate input function is called.
*
* @param netif the lwip network interface structure for this ethernetif
*/
//void eth_input( void * pvParameters )
//{
// struct pbuf *p;
//
// for( ;; )
// {
// if (KSemaphoreObtain( s_xSemaphore, WAITING_FOREVER)==EOK)
// {
// p = low_level_input( s_pxNetIf );
//
// if (ERR_OK != s_pxNetIf->input( p, s_pxNetIf))
// {
// KPrintf("netif input return not OK ! \n");
// pbuf_free(p);
// p=NULL;
// }
// }
// }
//}
//
//void low_level_init()
//{
// /* create the task that handles the ETH_MAC */
// uint32 thr_id = KTaskCreate((signed char*) "eth_input",
// eth_input,
// NULL,
// netifINTERFACE_TASK_STACK_SIZE,
// 15);
// if (thr_id >= 0)
// {
// StartupKTask(thr_id);
// }
// else
// {
// KPrintf("Eth create failed !");
// }
//}
/**
* Initializes ENET driver.
*/
@@ -313,7 +388,14 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif,
#endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
/* Create the Event for transmit busy release trigger. */
#ifdef FSL_RTOS_XIUOS
if(ethernetif->enetSemaphore < 0)
{
ethernetif->enetSemaphore = KSemaphoreCreate(0);
}
#else
ethernetif->enetTransmitAccessEvent = xEventGroupCreate();
#endif
ethernetif->txFlag = 0x1;
config.interrupt |= kENET_RxFrameInterrupt | kENET_TxFrameInterrupt | kENET_TxBufferInterrupt;
@@ -350,6 +432,7 @@ void ethernetif_enet_init(struct netif *netif, struct ethernetif *ethernetif,
#endif
ENET_ActiveRead(ethernetif->base);
// low_level_init();
}
ENET_Type **ethernetif_enet_ptr(struct ethernetif *ethernetif)
@@ -376,17 +459,27 @@ static err_t enet_send_frame(struct ethernetif *ethernetif, unsigned char *data,
{
status_t result;
lw_print("lw: [%s] len %d\n", __func__, length);
do
{
result = ENET_SendFrame(ethernetif->base, &ethernetif->handle, data, length);
if (result == kStatus_ENET_TxFrameBusy)
{
#ifdef FSL_RTOS_XIUOS
// KSemaphoreObtain(ethernetif->enetSemaphore, portMAX_DELAY);
lw_trace();
#else
xEventGroupWaitBits(ethernetif->enetTransmitAccessEvent, ethernetif->txFlag, pdTRUE, (BaseType_t) false,
portMAX_DELAY);
#endif
}
} while (result == kStatus_ENET_TxFrameBusy);
lw_trace();
return ERR_OK;
}
#else

View File

@@ -32,7 +32,6 @@
#endif /* FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL */
#include "lwipopts.h"
unsigned short *lw_enet_ctrl;
/*******************************************************************************
* Definitions
@@ -1564,6 +1563,7 @@ status_t ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, const uint8_t *d
curBuffDescrip = handle->txBdCurrent[0];
if (curBuffDescrip->control & ENET_BUFFDESCRIPTOR_TX_READY_MASK)
{
lw_trace();
return kStatus_ENET_TxFrameBusy;
}
#ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
@@ -1571,6 +1571,9 @@ status_t ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, const uint8_t *d
/* Check PTP message with the PTP header. */
isPtpEventMessage = ENET_Ptp1588ParseFrame(data, NULL, true);
#endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
// lw_print("lw: [%s] size %d len %d\n", __func__, handle->txBuffSizeAlign[0], length);
/* One transmit buffer is enough for one frame. */
if (handle->txBuffSizeAlign[0] >= length)
{
@@ -1613,6 +1616,7 @@ status_t ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, const uint8_t *d
/* Active the transmit buffer descriptor. */
ENET_ActiveSend(base, 0);
// lw_trace();
return kStatus_Success;
}
else
@@ -1620,6 +1624,8 @@ status_t ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, const uint8_t *d
/* One frame requires more than one transmit buffers. */
do
{
lw_trace();
#ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
/* For enable the timestamp. */
if (isPtpEventMessage)

View File

@@ -0,0 +1,2 @@
SRC_FILES := fsl_phy.c
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -0,0 +1,3 @@
SRC_FILES := fsl_gpio.c
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -104,7 +104,7 @@
#endif
#else
#ifndef ENET_PRIORITY
#define ENET_PRIORITY (6U)
#define ENET_PRIORITY (15U)//(6U)
#endif
#ifndef ENET_1588_PRIORITY
#define ENET_1588_PRIORITY (5U)

View File

@@ -1,3 +1,3 @@
SRC_FILES := connect_uart.c
SRC_FILES := connect_uart.c fsl_lpuart.c
include $(KERNEL_ROOT)/compiler.mk

View File

@@ -175,6 +175,7 @@ KERNELPATHS :=-I$(BSP_ROOT) \
-I$(BSP_ROOT)/third_party_driver \
-I$(BSP_ROOT)/third_party_driver/include \
-I$(BSP_ROOT)/third_party_driver/ethernet \
-I$(BSP_ROOT)/third_party_driver/ethernet/ksz8081 \
-I$(BSP_ROOT)/third_party_driver/MIMXRT1052 \
-I$(BSP_ROOT)/third_party_driver/MIMXRT1052/drivers \
-I$(BSP_ROOT)/third_party_driver/CMSIS/Include \
@@ -249,6 +250,11 @@ KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/knowing/tensorflow
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/knowing/tensorflow-lite/tensorflow-lite-for-mcu/source/third_party/ruy #
endif
ifeq ($(CONFIG_SUPPORT_CONTROL_FRAMEWORK), y)
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control #
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control/plc/interoperability/opcua #
endif
ifeq ($(CONFIG_CRYPTO), y)
KERNELPATHS += -I$(KERNEL_ROOT)/framework/security/crypto/include #
endif
@@ -256,10 +262,10 @@ endif
KERNELPATHS += -I$(KERNEL_ROOT)/resources/include #
ifeq ($(CONFIG_RESOURCES_SPI), y)
KERNELPATHS +=-I$(KERNEL_ROOT)/resources/spi #
KERNELPATHS +=-I$(KERNEL_ROOT)/resources/spi #
ifeq ($(CONFIG_RESOURCES_SPI_SFUD),y)
KERNELPATHS += -I$(KERNEL_ROOT)/resources/spi/third_party_spi/SFUD/sfud/inc #
KERNELPATHS += -I$(KERNEL_ROOT)/resources/spi/third_party_spi/SFUD/sfud/inc #
endif
endif