---
title: "W5100 behaving weirdly"
url: "https://maker.wiznet.io/forum/14065"
markdown_url: "https://maker.wiznet.io/forum/14065/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "dev07"
created: "2020-11-10T21:11:30+09:00"
last_activity: "2020-11-16T18:12:54+09:00"
language: "en"
views: 531
replies: 2
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5100 behaving weirdly

## Question

Asked by dev07 on 2020-11-10 in Ethernet Chips.

[I ported the W5100 driver to the ESP32](https://github.com/KaeLL/w5100_esp32), as well as a [PoC app](https://github.com/KaeLL/ESP32-W5100) to test it, and I’m having 2 problems using the chip. But before diving in, I think it’s important to mention that:

1. I’m using the chip in MAC_RAW mode;

2. **These problems happen intermittently, and the 1st problem doesn’t seem to occur if I use the chip’s TCP/IP stack** (use sockets in TCP/UDP mode). This is important to take into consideration in light of the fact that physical/hardware issues could be to blame. I’m assuming hardware/software as well as physical/logical issues would manifest themselves in a consistent fashion, which is not the case here, adding to the argument against this being something physical/hardware related. I could be wrong in assuming this, though.

Let me know if I forgot some other important detail, and I’ll be happy to provide it.

---

The first and foremost issue is the S0_IR_RECV interrupt not triggering **at all** in any [polls](https://github.com/KaeLL/w5100_esp32/blob/master/eth_mac.c#L132-L146), even though Wireshark tells me data has in fact been sent to it. This effectively means data can’t be received through the chip.
[Here’s the Wireshark capture](https://maker.wiznet.io/forum/legacyFile.asp?path=zRNdSl9nrvFSJaIRomBEd7MNdZZ.zip) (1.4 KB) and [here’s the Logic 2 capture](https://maker.wiznet.io/forum/legacyFile.asp?path=wf8g5504ZlRyutstn9SMftevVav.zip) (870.1 KB).

Below is a screenshot of a search for the 0x04 (S0_IR_RECV) value on the MISO line in the capture linked above, in which the only result is a read of the S0_TX_WR register.
![no_recv](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/5/55cddb9dd9255bae18aadfcdf2d4110c73c59813.png)
And here’s a screenshot of part of the Wireshark capture above, showing that data is being received from and sent to the chip (as shown by the DHCPDISCOVER and DHCPOFFER packages).

[![no_recv_ws](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/2/2c1b1ebd877cc13b5e37c32ccb5aab0f8025e242.png) no_recv_ws1071×515 209 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/2/2c1b1ebd877cc13b5e37c32ccb5aab0f8025e242.png)

There is a second variant of this issue in which data is said to be sent by the chip, in which S0_IR_SEND_OK is asserted, but Wireshark shows that nothing has crossed the wire.
[And here’s the capture](https://maker.wiznet.io/forum/legacyFile.asp?path=uUh5sU9tC6TITGiXDyEhlldnZm1.zip) (1.6 KB)
followed by an img of it

[![no_send](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/5/5081ed775df36371494a374fe04df8e7a68b140d.png) no_send942×638 265 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/5/5081ed775df36371494a374fe04df8e7a68b140d.png)

And [here’s a log of a run of the PoC app mentioned above](https://gist.github.com/KaeLL/55acd65ae8224cd14b025552f9718ff9) showing the path of execution of the test firmware, as well as hexdumps of everything passing through the link layer. Both variants of this first issue are identical with regards to the produced log.

---

The second issue is a weird behavior that happens sometimes during initialization, in which the S0_CR_CLOSE command actually doesn’t get executed by the socket at all, and initialization gets stuck in the [close() loop](https://github.com/KaeLL/w5100_esp32/blob/master/w5100_socket.c#L29-L31) routine.

[Here’s the Logic 2 capture](https://maker.wiznet.io/forum/legacyFile.asp?path=vGzr8eTgbZ6NBVT3D4Lg1dGNZni.zip) (873.2 KB) and below is the gist of what I’m talking about

[![sock_close_issue](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/a/abcaed0bdd2457bc0f36c3cec1ccfe8ac4332ddd.png) sock_close_issue1800×234 18.8 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/a/abcaed0bdd2457bc0f36c3cec1ccfe8ac4332ddd.png)

The way I get around this problem is by not calling the socket close function before socket initialization, and go straight to opening the socket in MAC_RAW mode. Since it can be avoided, this is more of a low priority issue, but is still a problem. Here’s a dump of a few registers when the close command fails. To make it easier to follow, the registers being read are MR, IR, IMR, RTR and RCR (I was just curious to see if there was anything relevant in both of them), S0_MR, S0_IR, S0_SR

[![reg_dump_sock_close](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/a/aacac8240963ae5ed989f6e48d485c0bfde8ffe3.png) reg_dump_sock_close1920×1080 60.8 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/a/aacac8240963ae5ed989f6e48d485c0bfde8ffe3.png)

---

Any help is much appreciated.

## Replies

### Reply 1 by dev07, 2020-11-11

Apparently I was wrong regarding the 2nd problem when I said that I could skip closing the socket. It turns out that it doesn’t help.

[![lol](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/1/14c118f1ec01aa63198329a6abc435dbe3309fa6.png) lol1859×309 23.4 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/1/14c118f1ec01aa63198329a6abc435dbe3309fa6.png)

[Logic 2 capture](https://maker.wiznet.io/forum/legacyFile.asp?path=u8umMZ2HNRTA2oXnvV3IPPPKotr.zip) (305.0 KB)

### Reply 2 by dev07, 2020-11-16

**Solved**

/RESET wasn’t being properly pulled.

---

Source: https://maker.wiznet.io/forum/14065
