diff --git a/bsp_z7/lwip/include/arch/cc.h b/bsp_z7/lwip/include/arch/cc.h index 75a584b..803c90b 100644 --- a/bsp_z7/lwip/include/arch/cc.h +++ b/bsp_z7/lwip/include/arch/cc.h @@ -47,6 +47,9 @@ #include #include "cpu.h" +#include "xil_printf.h" + + // errno is a macro. If we define LWIP_ERRNO_INCLUDE to errno.h the preprocessor will replace it, // breaking the include. Instead we supply a helper include which in turn includes errno.h #define LWIP_ERRNO_INCLUDE diff --git a/bsp_z7/lwip/include/lwipopts.h b/bsp_z7/lwip/include/lwipopts.h index f2a5b2c..a92f274 100644 --- a/bsp_z7/lwip/include/lwipopts.h +++ b/bsp_z7/lwip/include/lwipopts.h @@ -78,7 +78,7 @@ #define PPP_DEBUG LWIP_DBG_OFF #define MEM_DEBUG LWIP_DBG_OFF #define MEMP_DEBUG LWIP_DBG_OFF -#define PBUF_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_ON #define API_LIB_DEBUG LWIP_DBG_ON #define API_MSG_DEBUG LWIP_DBG_ON #define TCPIP_DEBUG LWIP_DBG_ON diff --git a/bsp_z7/lwip/include/lwippools.h b/bsp_z7/lwip/include/lwippools.h index 7361272..7b5650e 100644 --- a/bsp_z7/lwip/include/lwippools.h +++ b/bsp_z7/lwip/include/lwippools.h @@ -1,5 +1,5 @@ LWIP_MALLOC_MEMPOOL_START LWIP_MALLOC_MEMPOOL(50, 256) LWIP_MALLOC_MEMPOOL(50, 512) -LWIP_MALLOC_MEMPOOL(50, 1512) +LWIP_MALLOC_MEMPOOL(50, 1550) LWIP_MALLOC_MEMPOOL_END \ No newline at end of file diff --git a/bsp_z7/lwip/netif/xadapter.c b/bsp_z7/lwip/netif/xadapter.c index 0f2d421..2c48d74 100644 --- a/bsp_z7/lwip/netif/xadapter.c +++ b/bsp_z7/lwip/netif/xadapter.c @@ -215,13 +215,11 @@ xemacif_input_thread(struct netif *netif) { struct xemac_s *emac = (struct xemac_s *)netif->state; while (1) { - xil_printf("input started\n"); /* sleep until there are packets to process * This semaphore is set by the packet receive interrupt * routine. */ sys_sem_wait(&emac->sem_rx_data_available); - xil_printf("input received\n"); /* move all received packets to lwIP */ xemacif_input(netif); diff --git a/bsp_z7/testEth.c b/bsp_z7/testEth.c index b4f38f2..ec9a381 100644 --- a/bsp_z7/testEth.c +++ b/bsp_z7/testEth.c @@ -30,6 +30,7 @@ #include "lwip/inet.h" #include "lwip/init.h" #include "lwip/udp.h" +#include "lwip/tcpip.h" #include "lwip/timeouts.h" #include "netif/xadapter.h" #include "xil_printf.h" @@ -135,13 +136,19 @@ void network_thread() { #endif } +void udp_receiver(void *arg, struct udp_pcb *pcb, struct pbuf *p, + const ip_addr_t *addr, u16_t port){ + u32_t now = sys_now(); + xil_printf("%i received len: %i tot_len: %i data: ", now, p->len, p->tot_len); + char * pointer = p->payload; + for(uint8_t i = 0; i < p->len; i++) { + xil_printf(" %c", pointer + i); + } + xil_printf("\n"); +} + int main_thread(void * _) { - - xil_printf("pre check\n"); - vTaskDelay(200 * portTICK_PERIOD_MS); - xil_printf("check\n"); - #if LWIP_DHCP == 1 int mscnt = 0; #endif @@ -153,7 +160,10 @@ int main_thread(void * _) { xil_printf("-----lwIP Socket Mode UDP Client Application------\r\n"); /* initialize lwIP before calling sys_thread_new */ - lwip_init(); + //lwip_init(); + tcpip_init(NULL, NULL); + //give init some time + vTaskDelay(1000 * portTICK_PERIOD_MS); /* any thread using lwIP should be created using sys_thread_new */ network_thread(); @@ -196,15 +206,16 @@ int main_thread(void * _) { struct udp_pcb *udpecho_raw_pcb = udp_new(); - xil_printf("pcb: %p\r\n", udpecho_raw_pcb); + u32_t now = sys_now(); + xil_printf("%i pcb: %p\r\n", now, udpecho_raw_pcb); - udp_sendto(udpecho_raw_pcb, tx, &addr, 1177); + udp_sendto(udpecho_raw_pcb, tx, &addr, 8100); + udp_recv(udpecho_raw_pcb,udp_receiver,NULL); while (1) { sys_check_timeouts(); - xil_printf("pre loop\n"); + vTaskDelay(200 * portTICK_PERIOD_MS); - xil_printf("loop\n"); } pbuf_free(tx);