Skip to content

Commit

Permalink
drivers: eth: enc28j60: Fix read error when ERDPT < ERXRDPT
Browse files Browse the repository at this point in the history
After read first packet and if ERDPT < ERXRDPT,cause read Rx FIFO error.
The fix is to set ERDPT properly before reading next packet.

Fixed zephyrproject-rtos#9537

Signed-off-by: Frank Li <lgl88911@163.com>
  • Loading branch information
lgl88911 authored and nashif committed Aug 31, 2018
1 parent f2883ec commit 4934323
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions drivers/ethernet/eth_enc28j60.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,19 +520,28 @@ static int eth_enc28j60_rx(struct device *dev)
u8_t info[RSV_SIZE];
struct net_pkt *pkt;
u16_t next_packet;
u8_t rdptl = 0;
u8_t rdpth = 0;

/* remove read fifo address to packet header address */
eth_enc28j60_set_bank(dev, ENC28J60_REG_ERXRDPTL);
eth_enc28j60_read_reg(dev, ENC28J60_REG_ERXRDPTL, &rdptl);
eth_enc28j60_read_reg(dev, ENC28J60_REG_ERXRDPTH, &rdpth);
eth_enc28j60_write_reg(dev, ENC28J60_REG_ERDPTL, rdptl);
eth_enc28j60_write_reg(dev, ENC28J60_REG_ERDPTH, rdpth);

/* Read address for next packet */
eth_enc28j60_read_mem(dev, info, 2);
next_packet = info[0] | (u16_t)info[1] << 8;

/* Errata 14. Even values in ERXRDPT
* may corrupt receive buffer.
*/
No need adjust next packet
if (next_packet == 0) {
next_packet = ENC28J60_RXEND;
} else if (!(next_packet & 0x01)) {
next_packet--;
}
}*/

/* Read reception status vector */
eth_enc28j60_read_mem(dev, info, 4);
Expand Down

0 comments on commit 4934323

Please sign in to comment.