enc28j60 + esp32 Not getting IP

omborse__
Posts: 11
Joined: Tue May 21, 2019 5:30 am

enc28j60 + esp32 Not getting IP

Postby omborse__ » Thu Apr 08, 2021 5:38 am

Hello everyone,
I've been trying to connect an enc28j60 ethernet module with esp32, I am using the sample example code from esp-idf.
I am getting "ethernet link is up" but not able to get IP.
As per README from this example: Quote: "ENC28J60 hasn't burned any valid MAC address in the chip, you need to write an unique MAC address into its internal MAC address register before any traffic happened on TX and RX line."
So as per this I'm entering unique MAC ID but still not getting IP.
Attaching code:

xTaskHandle xEciethernetTaskHandle = NULL;

uint8_t mac_addr[6] = {0x9C, 0x47, 0x83, 0xC1, 0xA7, 0xB5}; // MAC address can't be zero

uint8_t mac_addr_set[6] = {0x02, 0x00, 0x00, 0x12, 0x34, 0x56};



/** Event handler for Ethernet events */
static void eth_event_handler(void *arg, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
//uint8_t mac_addr[6] = {0};
/* we can get the ethernet driver handle from event data */
esp_eth_handle_t eth_handle = *(esp_eth_handle_t *)event_data;

switch (event_id) {
case ETHERNET_EVENT_CONNECTED:
esp_eth_ioctl(eth_handle, ETH_CMD_G_MAC_ADDR, mac_addr);
ESP_LOGI(TAG, "Ethernet Link Up");
ESP_LOGI(TAG, "Ethernet HW Addr %02x:%02x:%02x:%02x:%02x:%02x",
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
break;
case ETHERNET_EVENT_DISCONNECTED:
ESP_LOGI(TAG, "Ethernet Link Down");
break;
case ETHERNET_EVENT_START:
ESP_LOGI(TAG, "Ethernet Started");
break;
case ETHERNET_EVENT_STOP:
ESP_LOGI(TAG, "Ethernet Stopped");
break;
default:
break;
}
}

/** Event handler for IP_EVENT_ETH_GOT_IP */
static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data;
const esp_netif_ip_info_t *ip_info = &event->ip_info;

ESP_LOGI(TAG, "Ethernet Got IP Address");
ESP_LOGI(TAG, "~~~~~~~~~~~");
ESP_LOGI(TAG, "ETHIP:" IPSTR, IP2STR(&ip_info->ip));
ESP_LOGI(TAG, "ETHMASK:" IPSTR, IP2STR(&ip_info->netmask));
ESP_LOGI(TAG, "ETHGW:" IPSTR, IP2STR(&ip_info->gw));
ESP_LOGI(TAG, "~~~~~~~~~~~");
}


Attaching the logs from the,

13:51:37.290 -> [0;32mI (50) enc28j60: revision: 6 [0m
13:51:37.290 -> [0;32mI (60) esp_eth.netif.glue: 02:00:00:12:34:56 [0m
13:51:37.290 -> [0;32mI (60) esp_eth.netif.glue: ethernet attached to netif [0m
13:51:37.290 -> [0;32mI (639) eth_example: Ethernet Started [0m
13:51:37.430 -> Failed to set AO, expect problems
13:51:37.663 -> Error reading API packet. Error code: 0x3
13:51:37.757 -> Error reading API packet. Error code: 0x1 (This is expected)
13:51:39.293 -> [0;32mI (2639) enc28j60: working in 10Mbps [0m
13:51:39.293 -> [0;32mI (2639) enc28j60: working in half duplex [0m
13:51:39.293 -> [0;32mI (2639) eth_example: Ethernet Link Up [0m
13:51:39.293 -> [0;32mI (2639) eth_example: Ethernet HW Addr 02:00:00:12:34:56 [0m

It would be really appreciable if anyone share sample code or at least an idea.
Thank you for your time..

vnjoy0239
Posts: 1
Joined: Wed Jul 21, 2021 5:00 pm

Re: enc28j60 + esp32 Not getting IP

Postby vnjoy0239 » Wed Jul 21, 2021 5:03 pm

did issues got resolved??? even am facing same issues

Below are my logs :

<ESC>[0;32mI (26) boot: ESP-IDF v4.3-dirty 2nd stage bootloader<ESC>[0m<CR><LF>
<ESC>[0;32mI (27) boot: compile time 19:07:20<ESC>[0m<CR><LF>
<ESC>[0;32mI (27) boot: chip revision: 1<ESC>[0m<CR><LF>
<ESC>[0;32mI (30) boot_comm: chip revision: 1, min. bootloader chip revision: 0<ESC>[0m<CR><LF>
<ESC>[0;32mI (37) boot.esp32: SPI Speed : 40MHz<ESC>[0m<CR><LF>
<ESC>[0;32mI (41) boot.esp32: SPI Mode : DIO<ESC>[0m<CR><LF>
<ESC>[0;32mI (46) boot.esp32: SPI Flash Size : 4MB<ESC>[0m<CR><LF>
<ESC>[0;32mI (50) boot: Enabling RNG early entropy source...<ESC>[0m<CR><LF>
<ESC>[0;32mI (56) boot: Partition Table:<ESC>[0m<CR><LF>
<ESC>[0;32mI (59) boot: ## Label Usage Type ST Offset Length<ESC>[0m<CR><LF>
<ESC>[0;32mI (67) boot: 0 nvs WiFi data 01 02 00009000 00006000<ESC>[0m<CR><LF>
<ESC>[0;32mI (74) boot: 1 phy_init RF data 01 01 0000f000 00001000<ESC>[0m<CR><LF>
<ESC>[0;32mI (82) boot: 2 factory factory app 00 00 00010000 00100000<ESC>[0m<CR><LF>
<ESC>[0;32mI (89) boot: End of partition table<ESC>[0m<CR><LF>
<ESC>[0;32mI (93) boot_comm: chip revision: 1, min. application chip revision: 0<ESC>[0m<CR><LF>
<ESC>[0;32mI (100) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1132ch ( 70444) map<ESC>[0m<CR><LF>
<ESC>[0;32mI (136) esp_image: segment 1: paddr=00021354 vaddr=3ffb0000 size=02d34h ( 11572) load<ESC>[0m<CR><LF>
<ESC>[0;32mI (141) esp_image: segment 2: paddr=00024090 vaddr=40080000 size=0bf88h ( 49032) load<ESC>[0m<CR><LF>
<ESC>[0;32mI (162) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=3313ch (209212) map<ESC>[0m<CR><LF>
<ESC>[0;32mI (242) esp_image: segment 4: paddr=00063164 vaddr=4008bf88 size=019d0h ( 6608) load<ESC>[0m<CR><LF>
<ESC>[0;32mI (245) esp_image: segment 5: paddr=00064b3c vaddr=50000000 size=00010h ( 16) load<ESC>[0m<CR><LF>
<ESC>[0;32mI (255) boot: Loaded app from partition at offset 0x10000<ESC>[0m<CR><LF>
<ESC>[0;32mI (255) boot: Disabling RNG early entropy source...<ESC>[0m<CR><LF>
<ESC>[0;32mI (270) cpu_start: Pro cpu up.<ESC>[0m<CR><LF>
<ESC>[0;32mI (270) cpu_start: Starting app cpu, entry point is 0x4008135c<ESC>[0m<CR><LF>
<ESC>[0;32mI (0) cpu_start: App cpu up.<ESC>[0m<CR><LF>
<ESC>[0;32mI (285) cpu_start: Pro cpu start user code<ESC>[0m<CR><LF>
<ESC>[0;32mI (285) cpu_start: cpu freq: 160000000<ESC>[0m<CR><LF>
<ESC>[0;32mI (285) cpu_start: Application information:<ESC>[0m<CR><LF>
<ESC>[0;32mI (289) cpu_start: Project name: enc28j60<ESC>[0m<CR><LF>
<ESC>[0;32mI (294) cpu_start: App version: 1<ESC>[0m<CR><LF>
<ESC>[0;32mI (299) cpu_start: Compile time: Jul 21 2021 19:07:07<ESC>[0m<CR><LF>
<ESC>[0;32mI (305) cpu_start: ELF file SHA256: b6755436d3899be4...<ESC>[0m<CR><LF>
<ESC>[0;32mI (311) cpu_start: ESP-IDF: v4.3-dirty<ESC>[0m<CR><LF>
<ESC>[0;32mI (316) heap_init: Initializing. RAM available for dynamic allocation:<ESC>[0m<CR><LF>
<ESC>[0;32mI (323) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM<ESC>[0m<CR><LF>
<ESC>[0;32mI (329) heap_init: At 3FFB4C00 len 0002B400 (173 KiB): DRAM<ESC>[0m<CR><LF>
<ESC>[0;32mI (335) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM<ESC>[0m<CR><LF>
<ESC>[0;32mI (342) heap_init: At 3FFE4350 len 00013CB0 (79 KiB): D/IRAM<ESC>[0m<CR><LF>
<ESC>[0;32mI (348) heap_init: At 4008D958 len 000126A8 (73 KiB): IRAM<ESC>[0m<CR><LF>
<ESC>[0;32mI (355) esp_apptrace: Initialized TRAX on CPU0<ESC>[0m<CR><LF>
<ESC>[0;32mI (360) spi_flash: detected chip: generic<ESC>[0m<CR><LF>
<ESC>[0;32mI (364) spi_flash: flash io: dio<ESC>[0m<CR><LF>
<ESC>[0;32mI (369) cpu_start: Starting scheduler on PRO CPU.<ESC>[0m<CR><LF>
<ESC>[0;32mI (96) esp_apptrace: Initialized TRAX on CPU1<ESC>[0m<CR><LF>
<ESC>[0;32mI (0) cpu_start: Starting scheduler on APP CPU.<ESC>[0m<CR><LF>
<ESC>[0;32mI (394) gpio: GPIO[32]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 <ESC>[0m<CR><LF>
<ESC>[0;32mI (394) gpio: GPIO[34]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 <ESC>[0m<CR><LF>
<ESC>[0;32mI (414) enc28j60: revision: 6<ESC>[0m<CR><LF>
<ESC>[0;32mI (424) esp_eth.netif.glue: 02:01:25:12:34:56<ESC>[0m<CR><LF>
<ESC>[0;32mI (424) esp_eth.netif.glue: ethernet attached to netif<ESC>[0m<CR><LF>
<ESC>[0;32mI (434) eth_example: Ethernet Started<ESC>[0m<CR><LF>
<ESC>[0;32mI (2434) enc28j60: working in 10Mbps<ESC>[0m<CR><LF>
<ESC>[0;32mI (2434) enc28j60: working in half duplex<ESC>[0m<CR><LF>
<ESC>[0;32mI (2434) eth_example: Ethernet Link Up<ESC>[0m<CR><LF>
<ESC>[0;32mI (2434) eth_example: Ethernet HW Addr 02:01:25:12:34:56<ESC>[0m<CR><LF>

Am not getting IP

Who is online

Users browsing this forum: No registered users and 358 guests