EthernetENC for ESP8266 and 28J60

Hi

I have an ESP8266 connected to a ENC28J60 MOSI on D7, MISO on D6 and SCLK on D5. The code is set for D2 for CS but I have tried D0, D3 and D4 as well all crash but at different points, microsecondDelay is common.

The ESP8266 resets when I compile and use the following code, I do not get passed the setup stage.

#include <EthernetENC.h>
#include <EthernetUdp.h>
const unsigned int UDP_TX_PACKET_MAX_SIZE = 100;

IPAddress ip( 192, 168, 1, 218 );
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x02, 0x18 };
  
EthernetUDP udpServer;

void setup() {
  
 Serial.begin(9600);  
  while( !Serial ) {
      delay(1);
  } 
  delay(200);    
  Serial.println("\nDebug setup");
  
  Ethernet.init( D2 );
  Ethernet.begin(mac, ip);
}

void loop() { 
 
}

I get the stack trace

Soft WDT reset

>>>stack>>>

ctx: cont
sp: 3ffffc50 end: 3fffffc0 offset: 01a0
3ffffdf0:  00000003 3ffe85cf 3ffee7e2 40100290  
3ffffe00:  3ffe85cf 3ffee7e2 ea000000 40203088  
3ffffe10:  000000ea 3ffe85ce 00000060 3ffffed8  
3ffffe20:  3ffffed0 3ffee7e2 000000ea 4020322c  
3ffffe30:  3ffffed0 3ffee7e2 00000100 402037a6  
3ffffe40:  3ffffed0 3ffee7e2 3ffe85c8 402038e7  
3ffffe50:  feefeffe feef0001 feefeffe 3ffffed8  
3ffffe60:  3ffffed0 3ffffec8 3ffe85c8 40202767  
3ffffe70:  feefeffe feefeffe 3ffffec0 4020282d  
3ffffe80:  feefeffe feefeffe feefeffe feefeffe  
3ffffe90:  feefeffe feefeffe feefeffe feefeffe  
3ffffea0:  feefeffe feefeffe feefeffe 3fffff28  
3ffffeb0:  3fffff20 3ffe85c8 3ffee524 402028c8  
3ffffec0:  40207de8 00ffffff 40207de8 0101a8c0  
3ffffed0:  40207de8 0101a8c0 40207de8 da01a8c0  
3ffffee0:  40207de8 00ffffff feefeffe feefeffe  
3ffffef0:  3fffff30 feefeffe feefeffe 3ffef554  
3fffff00:  4020603d 00000001 00000020 3fffff60  
3fffff10:  3ffe85c8 3ffee524 3fffff68 40202925  
3fffff20:  40207de8 0101a8c0 40207de8 0101a8c0  
3fffff30:  40207de8 da01a8c0 40207de8 0101a8c0  
3fffff40:  40204820 3ffe87ec 3ffee80c 3ffee884  
3fffff50:  3ffe85c8 3ffee524 3fffff90 4020296e  
3fffff60:  40207de8 0101a8c0 40207de8 da01a8c0  
3fffff70:  40207de8 0101a8c0 3ffee884 40204b8c  
3fffff80:  3fffdad0 00000000 3ffee524 40202511  
3fffff90:  40207de8 da01a8c0 feefeffe feefeffe  
3fffffa0:  feefeffe feefeffe 3ffee870 40205188  
3fffffb0:  feefeffe feefeffe 3ffe85e0 40100bc1  
<<<stack<<<

Which when put through the Exception decoder gives


*Decoding stack results* 0x40100290: **__digitalWrite(uint8_t, uint8_t)** at C:\Users\MalcolmJohnson\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\**core_esp8266_wiring_digital.cpp** line **87** 0x40203088: **Enc28J60Network::readOp(unsigned char, unsigned char)** at C:\Users\MalcolmJohnson\Documents\Arduino\libraries\EthernetENC\src\utility\**Enc28J60Network.cpp** line **427** 0x4020322c: **Enc28J60Network::readReg(unsigned char)** at C:\Users\MalcolmJohnson\Documents\Arduino\libraries\EthernetENC\src\utility\**Enc28J60Network.cpp** line **500** 0x402037a6: **Enc28J60Network::phyWrite(unsigned char, unsigned short)** at C:\Users\MalcolmJohnson\Documents\Arduino\libraries\EthernetENC\src\utility\**Enc28J60Network.cpp** line **530** 0x402038e7: **Enc28J60Network::init(unsigned char*)** at C:\Users\MalcolmJohnson\Documents\Arduino\libraries\EthernetENC\src\utility\**Enc28J60Network.cpp** line **128** 0x40202767: **UIPEthernetClass::init(unsigned char const*)** at C:\Users\MalcolmJohnson\Documents\Arduino\libraries\EthernetENC\src\**Ethernet.cpp** line **311** 0x4020282d: **UIPEthernetClass::begin(unsigned char const*, IPAddress, IPAddress, IPAddress, IPAddress)** at C:\Users\MalcolmJohnson\Documents\Arduino\libraries\EthernetENC\src\**Ethernet.cpp** line **105** 0x402028c8: **UIPEthernetClass::begin(unsigned char const*, IPAddress, IPAddress, IPAddress)** at C:\Users\MalcolmJohnson\Documents\Arduino\libraries\EthernetENC\src\**Ethernet.cpp** line **98** 0x4020603d: **uart_flush(uart_t*)** at C:\Users\MalcolmJohnson\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\**uart.cpp** line **586** 0x40202925: **UIPEthernetClass::begin(unsigned char const*, IPAddress, IPAddress)** at C:\Users\MalcolmJohnson\Documents\Arduino\libraries\EthernetENC\src\**Ethernet.cpp** line **91** 0x40204820: **HardwareSerial::write(unsigned char const*, unsigned int)** at C:\Users\MalcolmJohnson\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/**HardwareSerial.h** line **193** 0x4020296e: **UIPEthernetClass::begin(unsigned char const*, IPAddress)** at C:\Users\MalcolmJohnson\Documents\Arduino\libraries\EthernetENC\src\**Ethernet.cpp** line **83** 0x40204b8c: **Print::println(char const*)** at C:\Users\MalcolmJohnson\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\**Print.cpp** line **238** 0x40202511: **setup()** at C:\Users\MalcolmJohnson\Documents\Phasear\Arduino\ESP8266_ENC28J60/**ESP8266_ENC28J60.ino** line **26** 0x40205188: **loop_wrapper()** at C:\Users\MalcolmJohnson\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\**core_esp8266_main.cpp** line **198**

I am trying to work out what I have done missed in the setup to cause the crash.

only you can decode the stack trace. use the stack trace decoder plugin.

but, for the enc28j60 on esp8266 use the lwIP_enc28j60 library which is bundled with the esp8266 core v. 3

Hi Juraj, the trace is for the above code, I would have thought that it may be repeatable, but will give lwIP_enc28j60 a go

the stack decoder uses the elf file of the compiled sketch