summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/ChangeLog3
-rw-r--r--nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c60
-rw-r--r--nuttx/configs/pic32-starterkit/nsh/defconfig2
-rw-r--r--nuttx/configs/pic32-starterkit/ostest/defconfig2
-rw-r--r--nuttx/net/uip/uip_icmpinput.c4
-rw-r--r--nuttx/net/uip/uip_icmpping.c9
-rw-r--r--nuttx/net/uip/uip_icmpsend.c4
-rw-r--r--nuttx/net/uip/uip_input.c1
8 files changed, 53 insertions, 32 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 99554146d..29f57e369 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -2542,4 +2542,7 @@
basic port to this board.
* configs/pic32-startkit/nsh/up_usbdev, up_nsh.c, and up_usbterm.c: Verified
the USB (device) driver on the PIC32 Ethernet Starter Kit.
+ * arch/mips/src/pic32mx/pic32mx_ethernet.c: Verifed the PIC32 Ethernet
+ driver on the PIC32 Starter Kit. Status: It is occasionally functional
+ but no stable enough for use.
diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c b/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c
index 210a85bbf..8bbd62906 100644
--- a/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c
+++ b/nuttx/arch/mips/src/pic32mx/pic32mx-ethernet.c
@@ -49,6 +49,7 @@
#include <debug.h>
#include <wdog.h>
#include <errno.h>
+#include <assert.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
@@ -469,7 +470,7 @@ static void pic32mx_ethreset(struct pic32mx_driver_s *priv);
#ifdef CONFIG_NET_REGDEBUG
static void pic32mx_printreg(uint32_t addr, uint32_t val, bool iswrite)
{
- dbg("%08x%s%08x\n", addr, iswrite ? "<-" : "->", val);
+ lldbg("%08x%s%08x\n", addr, iswrite ? "<-" : "->", val);
}
#endif
@@ -519,7 +520,7 @@ static void pic32mx_checkreg(uint32_t addr, uint32_t val, bool iswrite)
{
/* No.. More than one. */
- dbg("[repeats %d more times]\n", count);
+ lldbg("[repeats %d more times]\n", count);
}
}
@@ -598,12 +599,12 @@ static void pic32mx_putreg(uint32_t val, uint32_t addr)
#ifdef CONFIG_NET_DESCDEBUG
static void pic32mx_dumptxdesc(struct pic32mx_txdesc_s *txdesc, const char *msg)
{
- dbg("TX Descriptor [%p]: %s\n", txdesc, msg);
- dbg(" status: %08x\n", txdesc->status);
- dbg(" address: %08x [%08x]\n", txdesc->address, VIRT_ADDR(txdesc->address));
- dbg(" tsv1: %08x\n", txdesc->tsv1);
- dbg(" tsv2: %08x\n", txdesc->tsv2);
- dbg(" nexted: %08x [%08x]\n", txdesc->nexted, VIRT_ADDR(txdesc->nexted));
+ lldbg("TX Descriptor [%p]: %s\n", txdesc, msg);
+ lldbg(" status: %08x\n", txdesc->status);
+ lldbg(" address: %08x [%08x]\n", txdesc->address, VIRT_ADDR(txdesc->address));
+ lldbg(" tsv1: %08x\n", txdesc->tsv1);
+ lldbg(" tsv2: %08x\n", txdesc->tsv2);
+ lldbg(" nexted: %08x [%08x]\n", txdesc->nexted, VIRT_ADDR(txdesc->nexted));
}
#endif
@@ -625,12 +626,12 @@ static void pic32mx_dumptxdesc(struct pic32mx_txdesc_s *txdesc, const char *msg)
#ifdef CONFIG_NET_DESCDEBUG
static void pic32mx_dumprxdesc(struct pic32mx_rxdesc_s *rxdesc, const char *msg)
{
- dbg("RX Descriptor [%p]: %s\n", rxdesc, msg);
- dbg(" status: %08x\n", rxdesc->status);
- dbg(" address: %08x [%08x]\n", rxdesc->address, VIRT_ADDR(rxdesc->address));
- dbg(" rsv1: %08x\n", rxdesc->rsv1);
- dbg(" rsv2: %08x\n", rxdesc->rsv2);
- dbg(" nexted: %08x [%08x]\n", rxdesc->nexted, VIRT_ADDR(rxdesc->nexted));
+ lldbg("RX Descriptor [%p]: %s\n", rxdesc, msg);
+ lldbg(" status: %08x\n", rxdesc->status);
+ lldbg(" address: %08x [%08x]\n", rxdesc->address, VIRT_ADDR(rxdesc->address));
+ lldbg(" rsv1: %08x\n", rxdesc->rsv1);
+ lldbg(" rsv2: %08x\n", rxdesc->rsv2);
+ lldbg(" nexted: %08x [%08x]\n", rxdesc->nexted, VIRT_ADDR(rxdesc->nexted));
}
#endif
@@ -655,7 +656,12 @@ static inline void pic32mx_bufferinit(struct pic32mx_driver_s *priv)
for (i = 0, buffer = priv->pd_buffers; i < PIC32MX_NBUFFERS; i++)
{
+ /* Add the buffer to the end of the list of free buffers */
+
sq_addlast((sq_entry_t*)buffer, &priv->pd_freebuffers);
+
+ /* Get the address of the next buffer */
+
buffer += PIC32MX_ALIGNED_BUFSIZE;
}
}
@@ -676,6 +682,8 @@ static inline void pic32mx_bufferinit(struct pic32mx_driver_s *priv)
static uint8_t *pic32mx_allocbuffer(struct pic32mx_driver_s *priv)
{
+ /* Return the next free buffer from the head of the free buffer list */
+
return (uint8_t*)sq_remfirst(&priv->pd_freebuffers);
}
@@ -695,6 +703,8 @@ static uint8_t *pic32mx_allocbuffer(struct pic32mx_driver_s *priv)
static void pic32mx_freebuffer(struct pic32mx_driver_s *priv, uint8_t *buffer)
{
+ /* Add the buffer to the end of the free buffer list */
+
sq_addlast((sq_entry_t*)buffer, &priv->pd_freebuffers);
}
@@ -978,7 +988,8 @@ static int pic32mx_transmit(struct pic32mx_driver_s *priv)
* must have assured that there is no transmission in progress.
*/
- DEBUGASSERT(priv->pd_dev.d_buf && priv->pd_dev.d_len < CONFIG_NET_BUFSIZE);
+ DEBUGASSERT(priv->pd_dev.d_buf != NULL &&
+ priv->pd_dev.d_len < CONFIG_NET_BUFSIZE);
/* Increment statistics and dump the packet (if so configured) */
@@ -1144,7 +1155,7 @@ static void pic32mx_response(struct pic32mx_driver_s *priv)
}
else
{
- /* No.. mark the Tx as pending and halt further Tx interrupts */
+ /* No.. mark the Tx as pending and halt further Rx interrupts */
DEBUGASSERT((priv->pd_inten & ETH_INT_TXDONE) != 0);
@@ -1243,6 +1254,7 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv)
/* Get the Rx buffer address from the Rx descriptor */
priv->pd_dev.d_buf = (uint8_t*)VIRT_ADDR(rxdesc->address);
+ DEBUGASSERT(priv->pd_dev.d_buf != NULL);
/* Replace the buffer in the RX descriptor with a new one */
@@ -1264,14 +1276,14 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv)
if (BUF->type == HTONS(UIP_ETHTYPE_IP))
#endif
{
- /* Handle the incoming Rx packet */
+ /* Handle the incoming IP packet */
EMAC_STAT(priv, rx_ip);
uip_arp_ipin(&priv->pd_dev);
uip_input(&priv->pd_dev);
/* If the above function invocation resulted in data that
- * should be sent out on the network, the field d_len will
+ * should be sent out on the network, the field d_len will
* set to a value > 0.
*/
@@ -1283,6 +1295,8 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv)
}
else if (BUF->type == htons(UIP_ETHTYPE_ARP))
{
+ /* Handle the incoming ARP packet */
+
EMAC_STAT(priv, rx_arp);
uip_arp_arpin(&priv->pd_dev);
@@ -1300,6 +1314,7 @@ static void pic32mx_rxdone(struct pic32mx_driver_s *priv)
{
/* Unrecognized... drop it. */
+ nlldbg("Unrecognized packet type dropped: %04x\n", ntohs(BUF->type));
EMAC_STAT(priv, rx_dropped);
}
@@ -1388,8 +1403,9 @@ static void pic32mx_txdone(struct pic32mx_driver_s *priv)
}
}
- /* Check if there is a pending Tx transfer that was scheduled by Rx handling
- * while the Tx logic was busy. If so, processing that pending Tx now.
+ /* Check if there is a pending Tx transfer that was deferred by Rx handling
+ * because there were no available Tx descriptors. If so, process that
+ * pending Tx now.
*/
if (priv->pd_txpending)
@@ -1925,9 +1941,9 @@ static int pic32mx_ifup(struct uip_driver_s *dev)
* inside of the stack.
*/
- regval = ETH_RXFC_BCEN | ETH_RXFC_PMMODE_DISABLED;
+ regval = ETH_RXFC_BCEN | ETH_RXFC_UCEN | ETH_RXFC_PMMODE_DISABLED;
#ifdef CONFIG_NET_MULTICAST
- regval |= (ETH_RXFC_MCEN | ETH_RXFC_UCEN);
+ regval |= ETH_RXFC_MCEN;
#endif
pic32mx_putreg(regval, PIC32MX_ETH_RXFC);
diff --git a/nuttx/configs/pic32-starterkit/nsh/defconfig b/nuttx/configs/pic32-starterkit/nsh/defconfig
index 24c909824..337c96bfd 100644
--- a/nuttx/configs/pic32-starterkit/nsh/defconfig
+++ b/nuttx/configs/pic32-starterkit/nsh/defconfig
@@ -88,7 +88,7 @@ CONFIG_ARCH_CHIP=pic32mx
CONFIG_ARCH_CHIP_PIC32MX795F512L=y
CONFIG_ARCH_BOARD=pic32-starterkit
CONFIG_ARCH_BOARD_PIC32_STARTERKIT=y
-CONFIG_BOARD_LOOPSPERMSEC=5560
+CONFIG_BOARD_LOOPSPERMSEC=7245
CONFIG_DRAM_SIZE=(128*1024)
CONFIG_DRAM_START=0xa0000000
CONFIG_DRAM_END=(CONFIG_DRAM_START+CONFIG_DRAM_SIZE)
diff --git a/nuttx/configs/pic32-starterkit/ostest/defconfig b/nuttx/configs/pic32-starterkit/ostest/defconfig
index 941408745..fae414269 100644
--- a/nuttx/configs/pic32-starterkit/ostest/defconfig
+++ b/nuttx/configs/pic32-starterkit/ostest/defconfig
@@ -88,7 +88,7 @@ CONFIG_ARCH_CHIP=pic32mx
CONFIG_ARCH_CHIP_PIC32MX795F512L=y
CONFIG_ARCH_BOARD=pic32-starterkit
CONFIG_ARCH_BOARD_PIC32_STARTERKIT=y
-CONFIG_BOARD_LOOPSPERMSEC=5560
+CONFIG_BOARD_LOOPSPERMSEC=7245
CONFIG_DRAM_SIZE=(128*1024)
CONFIG_DRAM_START=0xa0000000
CONFIG_DRAM_END=(CONFIG_DRAM_START+CONFIG_DRAM_SIZE)
diff --git a/nuttx/net/uip/uip_icmpinput.c b/nuttx/net/uip/uip_icmpinput.c
index 60ff75ea8..cea2ae4fc 100644
--- a/nuttx/net/uip/uip_icmpinput.c
+++ b/nuttx/net/uip/uip_icmpinput.c
@@ -2,8 +2,8 @@
* net/uip/uip_icmpinput.c
* Handling incoming ICMP/ICMP6 input
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Adapted for NuttX from logic in uIP which also has a BSD-like license:
*
diff --git a/nuttx/net/uip/uip_icmpping.c b/nuttx/net/uip/uip_icmpping.c
index 5627b148a..356187d09 100644
--- a/nuttx/net/uip/uip_icmpping.c
+++ b/nuttx/net/uip/uip_icmpping.c
@@ -1,8 +1,8 @@
/****************************************************************************
* net/uip/uip_icmpping.c
*
- * Copyright (C) 2008-2011 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2008-2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -214,7 +214,7 @@ static uint16_t ping_interrupt(struct uip_driver_s *dev, void *conn,
if (dev->d_sndlen <= 0 && /* Packet available */
(flags & UIP_NEWDATA) == 0 && /* No incoming data */
!pstate->png_sent) /* Request not sent */
- {
+ {
struct uip_icmpip_hdr *picmp = ICMPBUF;
/* We can send the ECHO request now.
@@ -243,7 +243,8 @@ static uint16_t ping_interrupt(struct uip_driver_s *dev, void *conn,
*/
nlldbg("Send ECHO request: seqno=%d\n", pstate->png_seqno);
- dev->d_sndlen= pstate->png_datlen + 4;
+
+ dev->d_sndlen = pstate->png_datlen + 4;
uip_icmpsend(dev, &pstate->png_addr);
pstate->png_sent = true;
return flags;
diff --git a/nuttx/net/uip/uip_icmpsend.c b/nuttx/net/uip/uip_icmpsend.c
index 0167ee9c4..00c5bb9de 100644
--- a/nuttx/net/uip/uip_icmpsend.c
+++ b/nuttx/net/uip/uip_icmpsend.c
@@ -1,8 +1,8 @@
/****************************************************************************
* net/uip/uip_icmpsend.c
*
- * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved.
- * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ * Copyright (C) 2008-2010, 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/nuttx/net/uip/uip_input.c b/nuttx/net/uip/uip_input.c
index 7ae2f2739..83fb7df33 100644
--- a/nuttx/net/uip/uip_input.c
+++ b/nuttx/net/uip/uip_input.c
@@ -161,6 +161,7 @@ static uint8_t uip_reass(void)
uip_reassflags = 0;
/* Clear the bitmap. */
+
memset(uip_reassbitmap, 0, sizeof(uip_reassbitmap));
}