diff --git a/bsp/ls2kdev/drivers/net/synopGMAC.c b/bsp/ls2kdev/drivers/net/synopGMAC.c index 0d4d603901..38a6345236 100644 --- a/bsp/ls2kdev/drivers/net/synopGMAC.c +++ b/bsp/ls2kdev/drivers/net/synopGMAC.c @@ -807,7 +807,7 @@ void eth_rx_irq(int irqno, void *param) if (dma_status_reg & GmacLineIntfIntr) { - rt_kprintf("%s:: Interrupt due to GMAC LINE module\n", __FUNCTION__); + //rt_kprintf("%s:: Interrupt due to GMAC LINE module\n", __FUNCTION__); } interrupt = synopGMAC_get_interrupt_type(gmacdev); diff --git a/components/net/Kconfig b/components/net/Kconfig index 45bc8d101c..3a4f39ed49 100644 --- a/components/net/Kconfig +++ b/components/net/Kconfig @@ -118,7 +118,7 @@ config RT_USING_LWIP config RT_USING_LWIP202 bool "lwIP v2.0.2" - config RT_USING_LWIP212 + config RT_USING_LWIP212 bool "lwIP v2.1.2" endchoice @@ -131,6 +131,10 @@ config RT_USING_LWIP select NETDEV_IPV6_SCOPES if RT_USING_LWIP212 endif + config RT_LWIP_MEM_ALIGNMENT + int "Memory alignment" + default 4 + config RT_LWIP_IGMP bool "IGMP protocol" default y diff --git a/components/net/lwip-2.0.2/src/arch/sys_arch.c b/components/net/lwip-2.0.2/src/arch/sys_arch.c index f7ed6eedec..40c79011ec 100644 --- a/components/net/lwip-2.0.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.0.2/src/arch/sys_arch.c @@ -460,7 +460,7 @@ void sys_mbox_post(sys_mbox_t *mbox, void *msg) { RT_DEBUG_NOT_IN_INTERRUPT; - rt_mb_send_wait(*mbox, (rt_uint32_t)msg, RT_WAITING_FOREVER); + rt_mb_send_wait(*mbox, (rt_ubase_t)msg, RT_WAITING_FOREVER); return; } @@ -472,7 +472,7 @@ void sys_mbox_post(sys_mbox_t *mbox, void *msg) */ err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg) { - if (rt_mb_send(*mbox, (rt_uint32_t)msg) == RT_EOK) + if (rt_mb_send(*mbox, (rt_ubase_t)msg) == RT_EOK) return ERR_OK; return ERR_MEM; diff --git a/components/net/lwip-2.0.2/src/lwipopts.h b/components/net/lwip-2.0.2/src/lwipopts.h index c53863e1ab..09bd223aa4 100644 --- a/components/net/lwip-2.0.2/src/lwipopts.h +++ b/components/net/lwip-2.0.2/src/lwipopts.h @@ -230,7 +230,12 @@ #define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT) /* ---------- Memory options ---------- */ +#ifdef RT_LWIP_MEM_ALIGNMENT +#define MEM_ALIGNMENT RT_LWIP_MEM_ALIGNMENT +#else #define MEM_ALIGNMENT 4 +#endif + #define MEMP_OVERFLOW_CHECK 1 //// #define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1 //// //#define MEM_LIBC_MALLOC 1 diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c index 2fa528aa0d..b93acb1fcf 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -38,6 +38,7 @@ * after lwIP initialization. * 2013-02-28 aozima fixed list_tcps bug: ipaddr_ntoa isn't reentrant. * 2016-08-18 Bernard port to lwIP 2.0.0 + * 2020-08-10 lizhirui fixed some problems when this is running on 64-bit cpu */ #include "lwip/opt.h" @@ -85,10 +86,10 @@ struct eth_tx_msg static struct rt_mailbox eth_tx_thread_mb; static struct rt_thread eth_tx_thread; #ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE -static char eth_tx_thread_mb_pool[32 * 4]; +static char eth_tx_thread_mb_pool[32 * sizeof(rt_ubase_t)]; static char eth_tx_thread_stack[512]; #else -static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4]; +static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)]; static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; #endif #endif @@ -97,10 +98,10 @@ static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; static struct rt_mailbox eth_rx_thread_mb; static struct rt_thread eth_rx_thread; #ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE -static char eth_rx_thread_mb_pool[48 * 4]; +static char eth_rx_thread_mb_pool[48 * sizeof(rt_ubase_t)]; static char eth_rx_thread_stack[1024]; #else -static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4]; +static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)]; static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; #endif #endif @@ -395,7 +396,7 @@ static err_t ethernetif_linkoutput(struct netif *netif, struct pbuf *p) /* send a message to eth tx thread */ msg.netif = netif; msg.buf = p; - if (rt_mb_send(ð_tx_thread_mb, (rt_uint32_t) &msg) == RT_EOK) + if (rt_mb_send(ð_tx_thread_mb, (rt_ubase_t) &msg) == RT_EOK) { /* waiting for ack */ rt_sem_take(&(enetif->tx_ack), RT_WAITING_FOREVER); @@ -599,7 +600,7 @@ rt_err_t eth_device_ready(struct eth_device* dev) { if (dev->netif) /* post message to Ethernet thread */ - return rt_mb_send(ð_rx_thread_mb, (rt_uint32_t)dev); + return rt_mb_send(ð_rx_thread_mb, (rt_ubase_t)dev); else return ERR_OK; /* netif is not initialized yet, just return. */ } @@ -619,7 +620,7 @@ rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up) rt_hw_interrupt_enable(level); /* post message to ethernet thread */ - return rt_mb_send(ð_rx_thread_mb, (rt_uint32_t)dev); + return rt_mb_send(ð_rx_thread_mb, (rt_ubase_t)dev); } #else /* NOTE: please not use it in interrupt when no RxThread exist */ @@ -739,7 +740,7 @@ int eth_system_device_init_private(void) #ifndef LWIP_NO_RX_THREAD /* initialize mailbox and create Ethernet Rx thread */ result = rt_mb_init(ð_rx_thread_mb, "erxmb", - ð_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/4, + ð_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/sizeof(rt_ubase_t), RT_IPC_FLAG_FIFO); RT_ASSERT(result == RT_EOK); @@ -755,7 +756,7 @@ int eth_system_device_init_private(void) #ifndef LWIP_NO_TX_THREAD /* initialize mailbox and create Ethernet Tx thread */ result = rt_mb_init(ð_tx_thread_mb, "etxmb", - ð_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/4, + ð_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/sizeof(rt_ubase_t), RT_IPC_FLAG_FIFO); RT_ASSERT(result == RT_EOK); diff --git a/components/net/uip/rt-thread/uip_ethernetif.c b/components/net/uip/rt-thread/uip_ethernetif.c index fa4e52461e..4fef184f4a 100644 --- a/components/net/uip/rt-thread/uip_ethernetif.c +++ b/components/net/uip/rt-thread/uip_ethernetif.c @@ -63,11 +63,11 @@ static struct rt_mailbox eth_rx_thread_mb; static struct rt_thread eth_rx_thread; #ifndef RT_LWIP_ETHTHREAD_PRIORITY #define RT_ETHERNETIF_THREAD_PREORITY 0x90 -static char eth_rx_thread_mb_pool[48 * 4]; +static char eth_rx_thread_mb_pool[48 * sizeof(rt_ubase_t)]; static char eth_rx_thread_stack[1024]; #else #define RT_ETHERNETIF_THREAD_PREORITY RT_LWIP_ETHTHREAD_PRIORITY -static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4]; +static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)]; static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; #endif @@ -79,10 +79,10 @@ struct eth_tx_msg static struct rt_mailbox eth_tx_thread_mb; static struct rt_thread eth_tx_thread; #ifndef RT_LWIP_ETHTHREAD_PRIORITY -static char eth_tx_thread_mb_pool[32 * 4]; +static char eth_tx_thread_mb_pool[32 * sizeof(rt_ubase_t)]; static char eth_tx_thread_stack[512]; #else -static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4]; +static char eth_tx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * sizeof(rt_ubase_t)]; static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE]; #endif @@ -281,7 +281,7 @@ rt_err_t eth_system_device_init() /* init rx thread */ /* init mailbox and create ethernet thread */ result = rt_mb_init(ð_rx_thread_mb, "erxmb", - ð_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/4, + ð_rx_thread_mb_pool[0], sizeof(eth_rx_thread_mb_pool)/sizeof(rt_ubase_t), RT_IPC_FLAG_FIFO); RT_ASSERT(result == RT_EOK); @@ -297,7 +297,7 @@ rt_err_t eth_system_device_init() /* init mailbox and create ethernet thread */ result = rt_mb_init(ð_tx_thread_mb, "etxmb", - ð_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/4, + ð_tx_thread_mb_pool[0], sizeof(eth_tx_thread_mb_pool)/sizeof(rt_ubase_t), RT_IPC_FLAG_FIFO); RT_ASSERT(result == RT_EOK);