Ethernet ENC28j60 github example - Error: enc28j60_init: wrong chip ID

KeshavThosar
Posts: 3
Joined: Thu Jul 29, 2021 7:14 am

Ethernet ENC28j60 github example - Error: enc28j60_init: wrong chip ID

Postby KeshavThosar » Thu Jul 29, 2021 8:07 am

After running idf.py menuconfig and flashing the code, I am getting a “Wrong Chip ID” error. I explored the code and I think the problem seems to be occurring while reading the PHY register PHCON1 (ETH_PHY_IDR1_REG_ADDR) and PHCON2 (ETH_PHY_IDR1_REG_ADDR). My wiring is functioning properly but the issue is persistent.

As a check I tried printing out the id1.val and id2.val but both ended up being 0 (hence my assumption). Any help would be appreciated. Thanks

The pins set up in sdkconfig

CONFIG_EXAMPLE_ENC28J60_SPI_HOST=1
CONFIG_EXAMPLE_ENC28J60_SCLK_GPIO=21
CONFIG_EXAMPLE_ENC28J60_MOSI_GPIO=23
CONFIG_EXAMPLE_ENC28J60_MISO_GPIO=22
CONFIG_EXAMPLE_ENC28J60_CS_GPIO=25
CONFIG_EXAMPLE_ENC28J60_SPI_CLOCK_MHZ=10
CONFIG_EXAMPLE_ENC28J60_INT_GPIO=4

Here are the logs
Executing action: monitor
Running idf_monitor in directory c:\Projects\esp32-projects\enc28j60-demo
Executing "C:\Users\Keshav\.espressif\python_env\idf4.2_py3.7_env\Scripts\python.exe C:\esp32\esp-idf\tools/idf_monitor.py -p COM5 -b 115200 --toolchain-prefix xtensa-esp32-elf- c:\Projects\esp32-projects\enc28j60-demo\build\enc28j60.elf -m 'C:\Users\Keshav\.espressif\python_env\idf4.2_py3.7_env\Scripts\python.exe' 'C:\esp32\esp-idf\tools\idf.py' '-p' 'COM5'"...
--- WARNING: GDB cannot open serial ports accessed as COMx
--- Using \\.\COM5 instead...
--- idf_monitor on \\.\COM5 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun 8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:7096
load:0x40078000,len:13212
load:0x40080400,len:4568
0x40080400: _init at ??:?

entry 0x400806f4
I (28) boot: ESP-IDF v4.2-dirty 2nd stage bootloader
I (28) boot: compile time 22:43:36
I (29) boot: chip revision: 1
I (32) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot.esp32: SPI Speed : 40MHz
I (43) boot.esp32: SPI Mode : DIO
I (48) boot.esp32: SPI Flash Size : 2MB
I (52) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (61) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (76) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (84) boot: 2 factory factory app 00 00 00010000 00100000
I (91) boot: End of partition table
I (95) boot_comm: chip revision: 1, min. application chip revision: 0
I (102) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x11274 ( 70260) map
I (138) esp_image: segment 1: paddr=0x0002129c vaddr=0x3ffb0000 size=0x021a4 ( 8612) load
I (142) esp_image: segment 2: paddr=0x00023448 vaddr=0x40080000 size=0x00404 ( 1028) load
0x40080000: _WindowOverflow4 at c:/esp32/esp-idf/components/freertos/xtensa/xtensa_vectors.S:1730

I (145) esp_image: segment 3: paddr=0x00023854 vaddr=0x40080404 size=0x0bc44 ( 48196) load
I (175) esp_image: segment 4: paddr=0x0002f4a0 vaddr=0x00000000 size=0x00b78 ( 2936)
I (176) esp_image: segment 5: paddr=0x00030020 vaddr=0x400d0020 size=0x31570 (202096) map
0x400d0020: _stext at ??:?

I (265) boot: Loaded app from partition at offset 0x10000
I (265) boot: Disabling RNG early entropy source...
I (265) cpu_start: Pro cpu up.
I (269) cpu_start: Application information:
I (274) cpu_start: Project name: enc28j60
I (279) cpu_start: App version: 1
I (283) cpu_start: Compile time: Jul 28 2021 20:37:02
I (289) cpu_start: ELF file SHA256: e3509b72c43cccfc...
I (295) cpu_start: ESP-IDF: v4.2-dirty
I (301) cpu_start: Starting app cpu, entry point is 0x4008192c
0x4008192c: call_start_cpu1 at c:/esp32/esp-idf/components/esp32/cpu_start.c:287

I (0) cpu_start: App cpu up.
I (311) heap_init: Initializing. RAM available for dynamic allocation:
I (318) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (324) heap_init: At 3FFB3928 len 0002C6D8 (177 KiB): DRAM
I (330) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (337) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (343) heap_init: At 4008C048 len 00013FB8 (79 KiB): IRAM
I (349) cpu_start: Pro cpu start user code
I (368) spi_flash: detected chip: generic
I (368) spi_flash: flash io: dio
W (368) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (379) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (6389) enc28j60: revision: 6
E (6399) enc28j60: enc28j60_init(270): wrong chip ID
E (6399) esp_eth: esp_eth_driver_install(199): init phy failed
I (6409) gpio: GPIO[4]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
ESP_ERROR_CHECK failed: esp_err_t 0xffffffff (ESP_FAIL) at 0x40084d38
0x40084d38: _esp_error_check_failed at c:/esp32/esp-idf/components/esp_common/src/esp_err.c:45

file: "../main/enc28j60_example_main.c" line 118
func: app_main
expression: esp_eth_driver_install(&eth_config, &eth_handle)

abort() was called at PC 0x40084d3b on core 0
0x40084d3b: _esp_error_check_failed at c:/esp32/esp-idf/components/esp_common/src/esp_err.c:46


Backtrace:0x400851ab:0x3ffb5640 0x40085849:0x3ffb5660 0x400892a6:0x3ffb5680 0x40084d3b:0x3ffb56f0 0x400d48d3:0x3ffb5710 0x400d31de:0x3ffb57e0 0x40085851:0x3ffb5810
0x400851ab: panic_abort at c:/esp32/esp-idf/components/esp_system/panic.c:330

0x40085849: esp_system_abort at c:/esp32/esp-idf/components/esp_system/system_api.c:106

0x400892a6: abort at c:/esp32/esp-idf/components/newlib/abort.c:46

0x40084d3b: _esp_error_check_failed at c:/esp32/esp-idf/components/esp_common/src/esp_err.c:46

0x400d48d3: app_main at c:\Projects\esp32-projects\enc28j60-demo\build/../main/enc28j60_example_main.c:118 (discriminator 1)

0x400d31de: main_task at c:/esp32/esp-idf/components/esp32/cpu_start.c:600 (discriminator 2)

0x40085851: vPortTaskWrapper at c:/esp32/esp-idf/components/freertos/xtensa/port.c:143
ELF file SHA256: e3509b72c43cccfc
Rebooting...

ESP_Sprite
Posts: 5156
Joined: Thu Nov 26, 2015 4:08 am

Re: Ethernet ENC28j60 github example - Error: enc28j60_init: wrong chip ID

Postby ESP_Sprite » Thu Jul 29, 2021 10:01 am

My wiring is functioning properly
Just curious: what makes you so sure about that?

KeshavThosar
Posts: 3
Joined: Thu Jul 29, 2021 7:14 am

Re: Ethernet ENC28j60 github example - Error: enc28j60_init: wrong chip ID

Postby KeshavThosar » Thu Jul 29, 2021 10:09 am

ESP_Sprite wrote:
Thu Jul 29, 2021 10:01 am
My wiring is functioning properly
Just curious: what makes you so sure about that?
It is because when I tested it initially, it failed to retrieve the revision ID (so it was just assigned 0) so I re-did the wiring, and then it worked out (Later it gave me a value of 6 and kept doing so).

KeshavThosar
Posts: 3
Joined: Thu Jul 29, 2021 7:14 am

Re: Ethernet ENC28j60 github example - Error: enc28j60_init: wrong chip ID

Postby KeshavThosar » Thu Jul 29, 2021 6:28 pm

So it seems I messed up the wiring and the clock speed. I reduced the length of the jumper wires and reduced the SCK speed to 6MHz and it is functioning now. Hope this helps. Thanks to ESP-Sprite for bringing in the thought.

ESP_Sprite
Posts: 5156
Joined: Thu Nov 26, 2015 4:08 am

Re: Ethernet ENC28j60 github example - Error: enc28j60_init: wrong chip ID

Postby ESP_Sprite » Fri Jul 30, 2021 12:51 am

Heh, you're welcome, glad you got it working.

Ankit24011995
Posts: 2
Joined: Tue Aug 10, 2021 1:42 pm

Re: Ethernet ENC28j60 github example - Error: enc28j60_init: wrong chip ID

Postby Ankit24011995 » Wed Sep 15, 2021 5:41 am

I am also having the same issue.
I made a PCB of ESP32 and ENC28J60 which is working with Arduino IDE. But on the same PCB its not working with idf.
Please help.

David64
Posts: 1
Joined: Thu Sep 16, 2021 5:22 am

Re: Ethernet ENC28j60 github example - Error: enc28j60_init: wrong chip ID

Postby David64 » Thu Sep 16, 2021 5:30 am

I faced similar kind of issue last time, I am still searching for some proper solution!!

Who is online

Users browsing this forum: No registered users and 37 guests