Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2022-08-04 20:08:23 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-08-04 20:08:23 +0300
commita3ad9ff6413acb93658d2c0a46572f76c8b4f0b4 (patch)
treeb160b4764b02fdc7f526958ff2cfebf35f8fa83b
parent4a01d83e309200d6f7a6a6d2e8cabf62e983a396 (diff)
Minor improvements to LWIP config and associated code
-rw-r--r--src/Hardware/SAME5x/Ethernet/GmacInterface.cpp35
-rw-r--r--src/Hardware/SAME70/Ethernet/GmacInterface.cpp217
-rw-r--r--src/Networking/LwipEthernet/Lwip/lwipopts.h4
-rw-r--r--src/Networking/LwipEthernet/Lwip/src/include/arch/cc.h8
-rw-r--r--src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h2
5 files changed, 132 insertions, 134 deletions
diff --git a/src/Hardware/SAME5x/Ethernet/GmacInterface.cpp b/src/Hardware/SAME5x/Ethernet/GmacInterface.cpp
index be29a86f..2f6a5988 100644
--- a/src/Hardware/SAME5x/Ethernet/GmacInterface.cpp
+++ b/src/Hardware/SAME5x/Ethernet/GmacInterface.cpp
@@ -33,7 +33,7 @@ extern Mutex lwipMutex;
#if defined(LWIP_DEBUG)
constexpr size_t EthernetTaskStackWords = 700;
#else
-constexpr size_t EthernetTaskStackWords = 250;
+constexpr size_t EthernetTaskStackWords = 300;
#endif
static Task<EthernetTaskStackWords> ethernetTask;
@@ -84,27 +84,27 @@ struct alignas(8) gmac_device {
/** Pointer to Tx descriptor list (must be 8-byte aligned). */
volatile gmac_tx_descriptor_t tx_desc[GMAC_TX_BUFFERS];
+ /** RX pbuf pointer list. */
+ struct pbuf *rx_pbuf[GMAC_RX_BUFFERS];
+
+ /** TX buffers. */
+ alignas(8) uint8_t tx_buf[GMAC_TX_BUFFERS][(GMAC_TX_UNITSIZE + 3u) & (~3u)];
+
/** RX index for current processing TD. */
uint32_t us_rx_idx;
/** Circular buffer head pointer by upper layer (buffer to be sent). */
uint32_t us_tx_idx;
- bool rxPbufsFullyPopulated = false;
-
/** Reference to lwIP netif structure. */
struct netif *netif;
- /** RX pbuf pointer list. */
- struct pbuf *rx_pbuf[GMAC_RX_BUFFERS];
-
- /** TX buffers. */
- alignas(8) uint8_t tx_buf[GMAC_TX_BUFFERS][(GMAC_TX_UNITSIZE + 3u) & (~3u)];
+ bool rxPbufsFullyPopulated = false;
};
/**
* GMAC driver instance.
*/
-__nocache static struct gmac_device gs_gmac_dev;
+__nocache alignas(8) static struct gmac_device gs_gmac_dev;
/**
* MAC address to use.
@@ -524,7 +524,7 @@ bool ethernetif_input(struct netif *netif) noexcept
/* Points to packet payload, which starts with an Ethernet header. */
ethhdr = static_cast<struct eth_hdr*>(p->payload);
- switch (htons(ethhdr->type)) {
+ switch (lwip_htons(ethhdr->type)) {
case ETHTYPE_IP:
case ETHTYPE_ARP:
#if defined(PPPOE_SUPPORT) && PPPOE_SUPPORT
@@ -720,6 +720,20 @@ void ethernetif_hardware_init() noexcept
/* Disable TX & RX and more. */
gmac_disable_interrupt(GMAC, ~0u);
+ /* Enable the copy of data into the buffers ignore broadcasts, and not copy FCS. */
+ gmac_enable_copy_all(GMAC, false);
+ gmac_disable_broadcast(GMAC, false);
+
+#if SUPPORT_MULTICAST_DISCOVERY
+ // Without this code, we don't receive any multicast packets
+ GMAC->GMAC_NCFGR |= GMAC_NCFGR_MTIHEN; // enable multicast hash reception
+ GMAC->GMAC_HRB = 0xFFFFFFFF; // enable reception of all multicast frames
+ GMAC->GMAC_HRT = 0xFFFFFFFF;
+#endif
+
+ /* Set RX buffer size to 1536. */
+ gmac_set_rx_bufsize(GMAC, 0x18);
+
/* Clear all status bits in the receive status register. */
gmac_clear_rx_status(GMAC, GMAC_RSR_BNA | GMAC_RSR_REC | GMAC_RSR_RXOVR | GMAC_RSR_HNO);
@@ -735,6 +749,7 @@ void ethernetif_hardware_init() noexcept
/* Enable Rx, Tx and the statistics register. */
gmac_enable_transmit(GMAC, true);
gmac_enable_receive(GMAC, true);
+ gmac_enable_statistics_write(GMAC, true);
/* Set GMAC address. */
gmac_set_address(GMAC, 0, gs_uc_mac_address);
diff --git a/src/Hardware/SAME70/Ethernet/GmacInterface.cpp b/src/Hardware/SAME70/Ethernet/GmacInterface.cpp
index abf2e0a0..018bdad4 100644
--- a/src/Hardware/SAME70/Ethernet/GmacInterface.cpp
+++ b/src/Hardware/SAME70/Ethernet/GmacInterface.cpp
@@ -31,6 +31,8 @@
*
*/
+#include <Core.h>
+#include <Cache.h>
#include "GmacInterface.h"
#include <pmc/pmc.h>
@@ -57,7 +59,12 @@ extern "C" {
extern Mutex lwipMutex;
+#if defined(LWIP_DEBUG)
+constexpr size_t EthernetTaskStackWords = 700;
+#else
constexpr size_t EthernetTaskStackWords = 300;
+#endif
+
static Task<EthernetTaskStackWords> ethernetTask;
// Error counters
@@ -97,7 +104,7 @@ alignas(8) static gmac_rx_descriptor_t gs_rx_desc_null;
/**
* GMAC driver structure.
*/
-struct gmac_device {
+struct alignas(8) gmac_device {
/**
* Pointer to allocated TX buffer.
* Section 3.6 of AMBA 2.0 spec states that burst should not cross
@@ -109,10 +116,12 @@ struct gmac_device {
volatile gmac_rx_descriptor_t rx_desc[GMAC_RX_BUFFERS];
/** Pointer to Tx descriptor list (must be 8-byte aligned). */
volatile gmac_tx_descriptor_t tx_desc[GMAC_TX_BUFFERS];
+
/** RX pbuf pointer list. */
struct pbuf *rx_pbuf[GMAC_RX_BUFFERS];
+
/** TX buffers. */
- uint8_t tx_buf[GMAC_TX_BUFFERS][GMAC_TX_UNITSIZE];
+ alignas(8) uint8_t tx_buf[GMAC_TX_BUFFERS][(GMAC_TX_UNITSIZE + 3u) & (~3u)];
/** RX index for current processing TD. */
uint32_t us_rx_idx;
@@ -121,12 +130,14 @@ struct gmac_device {
/** Reference to lwIP netif structure. */
struct netif *netif;
+
+ bool rxPbufsFullyPopulated = false;
};
/**
* GMAC driver instance.
*/
-__nocache __aligned(8) static struct gmac_device gs_gmac_dev;
+__nocache alignas(8) static struct gmac_device gs_gmac_dev;
/**
* MAC address to use.
@@ -141,8 +152,6 @@ static uint8_t gs_uc_mac_address[] =
ETHERNET_CONF_ETHADDR5
};
-static bool rxPbufsFullyPopulated = false;
-
#if LWIP_STATS
/** Used to compute lwIP bandwidth. */
uint32_t lwip_tx_count = 0;
@@ -189,7 +198,7 @@ static void gmac_rx_populate_queue(struct gmac_device *p_gmac_dev, uint32_t star
if (p == nullptr)
{
LWIP_DEBUGF(NETIF_DEBUG, ("gmac_rx_populate_queue: pbuf allocation failure\n"));
- rxPbufsFullyPopulated = false;
+ p_gmac_dev->rxPbufsFullyPopulated = false;
++rxBuffersNotFullyPopulatedCount;
return;
}
@@ -216,7 +225,7 @@ static void gmac_rx_populate_queue(struct gmac_device *p_gmac_dev, uint32_t star
{
p_gmac_dev->rx_desc[ul_index].addr.val = (u32_t) p->payload;
}
-
+ Cache::FlushBeforeDMASend(&p_gmac_dev->rx_desc[ul_index], sizeof(p_gmac_dev->rx_desc[ul_index]));
LWIP_DEBUGF(NETIF_DEBUG,
("gmac_rx_populate_queue: new pbuf allocated: %p [idx=%u]\n",
p, (unsigned int)ul_index));
@@ -229,7 +238,7 @@ static void gmac_rx_populate_queue(struct gmac_device *p_gmac_dev, uint32_t star
}
} while (ul_index != startAt);
- rxPbufsFullyPopulated = true;
+ p_gmac_dev->rxPbufsFullyPopulated = true;
}
/**
@@ -297,10 +306,6 @@ static void gmac_tx_init(struct gmac_device *ps_gmac_dev) noexcept
*/
static void gmac_low_level_init(struct netif *netif) noexcept
{
-#if 0 // chrishamm
- volatile uint32_t ul_delay;
-#endif
-
/* Set MAC hardware address length. */
netif->hwaddr_len = sizeof(gs_uc_mac_address);
/* Set MAC hardware address. */
@@ -315,41 +320,14 @@ static void gmac_low_level_init(struct netif *netif) noexcept
netif->mtu = NET_MTU;
/* Device capabilities. */
- netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP
-#if LWIP_IGMP // chrishamm
- | NETIF_FLAG_IGMP
-#endif
- ;
-
-#if 0 // chrishamm: Just like with the EMAC on the Duet, we initialise the GMAC step-by-step to avoid blocking
- /* Wait for PHY to be ready (CAT811: Max400ms). */
- ul_delay = sysclk_get_cpu_hz() / 1000 / 3 * 400;
- while (ul_delay--) {
- }
-#endif
+ netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_IGMP;
/* Init MAC PHY driver. */
- if (ethernet_phy_init(GMAC, BOARD_GMAC_PHY_ADDR, SystemCoreClock) != GMAC_OK) {
+ if (ethernet_phy_init(GMAC, BOARD_GMAC_PHY_ADDR, SystemCoreClock) != GMAC_OK)
+ {
LWIP_DEBUGF(NETIF_DEBUG, ("gmac_low_level_init: PHY init ERROR!\n"));
return;
}
-
-#if 0 // chrishamm: See ethernetif_establish_link()
- /* Auto Negotiate, work in RMII mode. */
- if (ethernet_phy_auto_negotiate(GMAC, BOARD_GMAC_PHY_ADDR) != GMAC_OK) {
- LWIP_DEBUGF(NETIF_DEBUG, ("gmac_low_level_init: auto negotiate ERROR!\n"));
- return;
- }
-
- /* Establish ethernet link. */
- while (ethernet_phy_set_link(GMAC, BOARD_GMAC_PHY_ADDR, 1) != GMAC_OK) {
- LWIP_DEBUGF(NETIF_DEBUG, ("gmac_low_level_init: set link ERROR!\n"));
- return;
- }
-
- /* Set link up*/
- netif->flags |= NETIF_FLAG_LINK_UP;
-#endif
}
/**
@@ -367,72 +345,76 @@ static err_t gmac_low_level_output(netif *p_netif, struct pbuf *p) noexcept
{
gmac_device *const ps_gmac_dev = static_cast<gmac_device *>(p_netif->state);
- /* Handle GMAC underrun or AHB errors. */
- if (gmac_get_tx_status(GMAC) & GMAC_TX_ERRORS)
+ while (true)
{
- ++txErrorCount;
- LWIP_DEBUGF(NETIF_DEBUG, ("gmac_low_level_output: GMAC ERROR, reinit TX...\n"));
-
- gmac_enable_transmit(GMAC, false);
+ // Handle GMAC underrun or AHB errors
+ if (gmac_get_tx_status(GMAC) & GMAC_TX_ERRORS)
+ {
+ ++txErrorCount;
+ LWIP_DEBUGF(NETIF_DEBUG, ("gmac_low_level_output: GMAC ERROR, reinit TX...\n"));
- LINK_STATS_INC(link.err);
- LINK_STATS_INC(link.drop);
+ gmac_enable_transmit(GMAC, false);
- /* Reinit TX descriptors. */
- gmac_tx_init(ps_gmac_dev);
+ LINK_STATS_INC(link.err);
+ LINK_STATS_INC(link.drop);
- /* Clear error status. */
- gmac_clear_tx_status(GMAC, GMAC_TX_ERRORS);
+ /* Reinit TX descriptors. */
+ gmac_tx_init(ps_gmac_dev);
- gmac_enable_transmit(GMAC, true);
- }
+ /* Clear error status. */
+ gmac_clear_tx_status(GMAC, GMAC_TX_ERRORS);
- while ((ps_gmac_dev->tx_desc[ps_gmac_dev->us_tx_idx].status.val & GMAC_TXD_USED) == 0)
- {
- ++txBufferNotFreeCount;
- delay(1);
- }
+ gmac_enable_transmit(GMAC, true);
+ }
- // Copy pbuf chain into TX buffer
- {
- uint8_t *buffer = reinterpret_cast<uint8_t*>(ps_gmac_dev->tx_desc[ps_gmac_dev->us_tx_idx].addr);
- size_t totalLength = 0;
- for (const pbuf *q = p; q != nullptr; q = q->next)
+ volatile gmac_tx_descriptor_t& txDescriptor = ps_gmac_dev->tx_desc[ps_gmac_dev->us_tx_idx];
+ Cache::InvalidateAfterDMAReceive(&txDescriptor, sizeof(gmac_tx_descriptor_t));
+ if ((txDescriptor.status.val & GMAC_TXD_USED) != 0)
{
- totalLength += q->len;
- if (totalLength > GMAC_TX_UNITSIZE)
+ // Copy pbuf chain into TX buffer
+ uint8_t *buffer = reinterpret_cast<uint8_t*>(txDescriptor.addr);
+ size_t totalLength = 0;
+ for (const pbuf *q = p; q != nullptr; q = q->next)
{
- ++txBufferTooShortCount;
- return ERR_BUF;
+ totalLength += q->len;
+ if (totalLength > GMAC_TX_UNITSIZE)
+ {
+ ++txBufferTooShortCount;
+ return ERR_BUF;
+ }
+ memcpy(buffer, q->payload, q->len);
+ buffer += q->len;
}
- memcpy(buffer, q->payload, q->len);
- buffer += q->len;
- }
- }
+ Cache::FlushBeforeDMASend(reinterpret_cast<const uint8_t*>(txDescriptor.addr), totalLength);
- // Set length and mark the buffer to be sent by GMAC
- uint32_t txStat = p->tot_len | GMAC_TXD_LAST;
- if (ps_gmac_dev->us_tx_idx == GMAC_TX_BUFFERS - 1)
- {
- txStat |= GMAC_TXD_WRAP;
- }
- ps_gmac_dev->tx_desc[ps_gmac_dev->us_tx_idx].status.val = txStat;
-
- LWIP_DEBUGF(NETIF_DEBUG,
- ("gmac_low_level_output: DMA buffer sent, size=%d [idx=%u]\n",
- p->tot_len, (unsigned int)ps_gmac_dev->us_tx_idx));
+ // Set length and mark the buffer to be sent by GMAC
+ uint32_t txStat = totalLength | GMAC_TXD_LAST;
+ if (ps_gmac_dev->us_tx_idx == GMAC_TX_BUFFERS - 1)
+ {
+ txStat |= GMAC_TXD_WRAP;
+ }
+ txDescriptor.status.val = txStat;
+ Cache::FlushBeforeDMASend(&txDescriptor, sizeof(gmac_tx_descriptor_t));
+ LWIP_DEBUGF(NETIF_DEBUG,
+ ("gmac_low_level_output: DMA buffer sent, size=%d [idx=%u]\n",
+ p->tot_len, (unsigned int)ps_gmac_dev->us_tx_idx));
- ps_gmac_dev->us_tx_idx = (ps_gmac_dev->us_tx_idx + 1) % GMAC_TX_BUFFERS;
+ ps_gmac_dev->us_tx_idx = (ps_gmac_dev->us_tx_idx + 1) % GMAC_TX_BUFFERS;
- /* Now start to transmission. */
- gmac_start_transmission(GMAC);
+ /* Now start to transmission. */
+ gmac_start_transmission(GMAC);
#if LWIP_STATS
- lwip_tx_count += p->tot_len;
+ lwip_tx_count += p->tot_len;
#endif
- LINK_STATS_INC(link.xmit);
+ LINK_STATS_INC(link.xmit);
- return ERR_OK;
+ return ERR_OK;
+ }
+
+ ++txBufferNotFreeCount;
+ delay(2); //TODO use an interrupt instead
+ }
}
/**
@@ -477,6 +459,7 @@ static pbuf *gmac_low_level_input(struct netif *netif) noexcept
}
volatile gmac_rx_descriptor_t * const p_rx = &ps_gmac_dev->rx_desc[ps_gmac_dev->us_rx_idx];
+ Cache::InvalidateAfterDMAReceive(p_rx, sizeof(gmac_rx_descriptor_t));
pbuf * const p = ((p_rx->addr.val & GMAC_RXD_OWNERSHIP) == GMAC_RXD_OWNERSHIP)
? ps_gmac_dev->rx_pbuf[ps_gmac_dev->us_rx_idx]
: nullptr;
@@ -488,11 +471,12 @@ static pbuf *gmac_low_level_input(struct netif *netif) noexcept
const uint32_t length = p_rx->status.val & GMAC_RXD_LEN_MASK;
/* Fetch pre-allocated pbuf. */
+ Cache::InvalidateAfterDMAReceive(p->payload, length);
p->len = length;
/* Remove this pbuf from its descriptor. */
ps_gmac_dev->rx_pbuf[ps_gmac_dev->us_rx_idx] = nullptr;
- rxPbufsFullyPopulated = false;
+ ps_gmac_dev->rxPbufsFullyPopulated = false;
LWIP_DEBUGF(NETIF_DEBUG,
("gmac_low_level_input: DMA buffer %p received, size=%u [idx=%u]\n",
@@ -510,7 +494,7 @@ static pbuf *gmac_low_level_input(struct netif *netif) noexcept
}
/* Fill empty descriptors with new pbufs. */
- if (!rxPbufsFullyPopulated)
+ if (!ps_gmac_dev->rxPbufsFullyPopulated)
{
gmac_rx_populate_queue(ps_gmac_dev, ps_gmac_dev->us_rx_idx);
}
@@ -539,7 +523,7 @@ extern "C" [[noreturn]] void gmac_task(void *pvParameters) noexcept
}
// Wait for the RX notification from the ISR
- TaskBase::Take((rxPbufsFullyPopulated) ? 1000 : 20);
+ TaskBase::Take((ps_gmac_dev->rxPbufsFullyPopulated) ? 1000 : 20);
}
}
@@ -567,7 +551,7 @@ bool ethernetif_input(struct netif *netif) noexcept
/* Points to packet payload, which starts with an Ethernet header. */
ethhdr = static_cast<struct eth_hdr*>(p->payload);
- switch (htons(ethhdr->type)) {
+ switch (lwip_htons(ethhdr->type)) {
case ETHTYPE_IP:
case ETHTYPE_ARP:
#if defined(PPPOE_SUPPORT) && PPPOE_SUPPORT
@@ -636,6 +620,14 @@ err_t ethernetif_init(struct netif *netif) noexcept
gmac_low_level_init(netif);
ethernetTask.Create(gmac_task, "ETHERNET", &gs_gmac_dev, TaskPriority::EthernetPriority);
+
+ /* Set up the interrupts for transmission and errors. */
+ gmac_enable_interrupt(GMAC, GMAC_INT_GROUP);
+
+ /* Enable NVIC GMAC interrupt. */
+ NVIC_ClearPendingIRQ(GMAC_IRQn);
+ NVIC_EnableIRQ(GMAC_IRQn);
+
return ERR_OK;
}
@@ -651,19 +643,15 @@ void ethernetif_hardware_init() noexcept
gmac_clear_statistics(GMAC);
/* Clear all status bits in the receive status register. */
- gmac_clear_rx_status(GMAC, GMAC_RSR_BNA | GMAC_RSR_REC | GMAC_RSR_RXOVR
- | GMAC_RSR_HNO);
+ gmac_clear_rx_status(GMAC, GMAC_RSR_BNA | GMAC_RSR_REC | GMAC_RSR_RXOVR | GMAC_RSR_HNO);
/* Clear all status bits in the transmit status register. */
- gmac_clear_tx_status(GMAC, GMAC_TSR_UBR | GMAC_TSR_COL | GMAC_TSR_RLE
- | GMAC_TSR_TXGO | GMAC_TSR_TFC | GMAC_TSR_TXCOMP
- | GMAC_TSR_HRESP);
+ gmac_clear_tx_status(GMAC, GMAC_TSR_UBR | GMAC_TSR_COL | GMAC_TSR_RLE | GMAC_TSR_TXGO | GMAC_TSR_TFC | GMAC_TSR_TXCOMP | GMAC_TSR_HRESP);
/* Clear interrupts. */
gmac_get_interrupt_status(GMAC);
- /* Enable the copy of data into the buffers
- ignore broadcasts, and not copy FCS. */
+ /* Enable the copy of data into the buffers ignore broadcasts, and not copy FCS. */
gmac_enable_copy_all(GMAC, false);
gmac_disable_broadcast(GMAC, false);
@@ -717,24 +705,16 @@ void ethernetif_hardware_init() noexcept
gmac_enable_receive(GMAC, true);
gmac_enable_statistics_write(GMAC, true);
- /* Set up the interrupts for transmission and errors. */
- gmac_enable_interrupt(GMAC, GMAC_INT_GROUP);
-
/* Set GMAC address. */
gmac_set_address(GMAC, 0, gs_uc_mac_address);
-
- /* Enable NVIC GMAC interrupt. */
-#if 0 // chrishamm: NVIC priorities are assigned by RepRapFirmware
- NVIC_SetPriority(GMAC_IRQn, INT_PRIORITY_GMAC);
-#endif
- NVIC_EnableIRQ(GMAC_IRQn);
}
bool ethernetif_establish_link() noexcept
{
/* Auto Negotiate, work in RMII mode. */
uint8_t result = ethernet_phy_auto_negotiate(GMAC, BOARD_GMAC_PHY_ADDR);
- if (result != GMAC_OK) {
+ if (result != GMAC_OK)
+ {
if (result != GMAC_TIMEOUT)
{
// chrishamm: It is expected that the function above will return ERR_TIMEOUT a few times
@@ -744,7 +724,8 @@ bool ethernetif_establish_link() noexcept
}
/* Establish ethernet link. */
- if (ethernet_phy_set_link(GMAC, BOARD_GMAC_PHY_ADDR, 1) != GMAC_OK) {
+ if (ethernet_phy_set_link(GMAC, BOARD_GMAC_PHY_ADDR, 1) != GMAC_OK)
+ {
LWIP_DEBUGF(NETIF_DEBUG, ("gmac_low_level_init: set link ERROR!\n"));
return false;
}
@@ -758,12 +739,14 @@ bool ethernetif_link_established() noexcept
gmac_enable_management(GMAC, true);
uint32_t ul_stat1;
- if (gmac_phy_read(GMAC, BOARD_GMAC_PHY_ADDR, GMII_BMSR, &ul_stat1) != GMAC_OK) {
+ if (gmac_phy_read(GMAC, BOARD_GMAC_PHY_ADDR, GMII_BMSR, &ul_stat1) != GMAC_OK)
+ {
gmac_enable_management(GMAC, false);
return false;
}
- if ((ul_stat1 & GMII_LINK_STATUS) == 0) {
+ if ((ul_stat1 & GMII_LINK_STATUS) == 0)
+ {
gmac_enable_management(GMAC, false);
return false;
}
@@ -785,11 +768,13 @@ void ethernetif_set_mac_address(const uint8_t macAddress[]) noexcept
// This is called when we shut down
void ethernetif_terminate() noexcept
{
+ gmac_enable_transmit(GMAC, false);
+ gmac_enable_receive(GMAC, false);
NVIC_DisableIRQ(GMAC_IRQn);
ethernetTask.TerminateAndUnlink();
}
-extern "C" u32_t sys_now() noexcept
+extern "C" uint32_t sys_now() noexcept
{
return millis();
}
diff --git a/src/Networking/LwipEthernet/Lwip/lwipopts.h b/src/Networking/LwipEthernet/Lwip/lwipopts.h
index ec45aee7..e67dcc6c 100644
--- a/src/Networking/LwipEthernet/Lwip/lwipopts.h
+++ b/src/Networking/LwipEthernet/Lwip/lwipopts.h
@@ -89,6 +89,10 @@
#define LWIP_CHKSUM_ALGORITHM 3 // use fastest checksum algorithm (does 8 bytes at a time)
+#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 1
+#define lwip_htons(_x) __builtin_bswap16(_x)
+#define lwip_htonl(_x) __builtin_bswap32(_x)
+
/*
------------------------------------
---------- Memory options ----------
diff --git a/src/Networking/LwipEthernet/Lwip/src/include/arch/cc.h b/src/Networking/LwipEthernet/Lwip/src/include/arch/cc.h
index 9ebd7424..24bbe495 100644
--- a/src/Networking/LwipEthernet/Lwip/src/include/arch/cc.h
+++ b/src/Networking/LwipEthernet/Lwip/src/include/arch/cc.h
@@ -104,15 +104,9 @@ typedef uintptr_t mem_ptr_t;
/* Make lwip/arch.h define the codes which are used throughout */
#define LWIP_PROVIDE_ERRNO
-#ifdef __cplusplus
-# define NOEXCEPT noexcept
-#else
-# define NOEXCEPT
-#endif
-
/* Debug facilities. LWIP_DEBUG must be defined to read output */
#ifdef LWIP_DEBUG
-extern void debugPrintf(const char *, ...) NOEXCEPT;
+extern void debugPrintf(const char *, ...) noexcept;
#define LWIP_PLATFORM_DIAG(x) {debugPrintf x;}
#define LWIP_PLATFORM_ASSERT(x) {debugPrintf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); while(1);}
#else
diff --git a/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h b/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h
index 7fff2de0..b5f83c7e 100644
--- a/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h
+++ b/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h
@@ -446,7 +446,7 @@ u32_t sys_jiffies(void);
* Not implementing this function means you cannot use some modules (e.g. TCP
* timestamps, internal timeouts for NO_SYS==1).
*/
-u32_t sys_now(void) NOEXCEPT;
+u32_t sys_now(void) noexcept;
/* Critical Region Protection */
/* These functions must be implemented in the sys_arch.c file.