From 8c529f3b9b4538e307c67a2170c6a1fdd2e32934 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Fri, 27 Aug 2021 02:29:43 +0200 Subject: net driver fixed --- fw/fe310/eos/net.c | 17 +++++++++-------- fw/fe310/eos/net.h | 3 ++- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'fw') diff --git a/fw/fe310/eos/net.c b/fw/fe310/eos/net.c index 197c2b1..d42686d 100644 --- a/fw/fe310/eos/net.c +++ b/fw/fe310/eos/net.c @@ -19,6 +19,7 @@ #include "net.h" +#define NET_SIZE_HDR 3 #define NET_STATE_FLAG_RUN 0x01 #define NET_STATE_FLAG_INIT 0x02 #define NET_STATE_FLAG_XCHG 0x04 @@ -166,20 +167,20 @@ static void net_handle_xchg(void) { net_state_len_rx |= (r3 & 0xFF); len = MAX(net_state_len_tx, net_state_len_rx); - // esp32 bug workaraund - if (len < 5) { - len = 5; - } else if ((len + 3) % 4 != 0) { - len = ((len + 3)/4 + 1) * 4 - 3; - } - - if (len > EOS_NET_SIZE_BUF) { + if (len > EOS_NET_MTU) { net_state_flags &= ~NET_STATE_FLAG_XCHG; SPI1_REG(SPI_REG_CSMODE) = SPI_CSMODE_AUTO; SPI1_REG(SPI_REG_IE) = 0x0; return; } + // esp32 dma workaraund + if (len < 8 - NET_SIZE_HDR) { + len = 8 - NET_SIZE_HDR; + } else if ((len + NET_SIZE_HDR) % 4 != 0) { + len = ((len + NET_SIZE_HDR)/4 + 1) * 4 - NET_SIZE_HDR; + } + _eos_spi_xchg_init(net_state_buf, len, 0); SPI1_REG(SPI_REG_TXCTRL) = SPI_TXWM(SPI_SIZE_WM); SPI1_REG(SPI_REG_IE) = SPI_IP_TXWM; diff --git a/fw/fe310/eos/net.h b/fw/fe310/eos/net.h index ecefbec..574d179 100644 --- a/fw/fe310/eos/net.h +++ b/fw/fe310/eos/net.h @@ -2,7 +2,8 @@ #include "event.h" /* common */ -#define EOS_NET_SIZE_BUF 1500 +#define EOS_NET_MTU 1500 +#define EOS_NET_SIZE_BUF (EOS_NET_MTU + 4) #define EOS_NET_MTYPE_SOCK 1 #define EOS_NET_MTYPE_POWER 4 -- cgit v1.2.3