11-14-2024, 07:05 PM
I already have the PCB I tried to upload the example from ESP32 (it compiles correctly), however, in the serial window there is an error related to the MAC address:
Arduino program code:
I must add that the PCB is functional. I have uploaded the latest firmware to it, i.e. KCS_KC868_A16_V2.2.7.bin, and it correctly starts the network card and reports in the browser. Please help me how to start network support in Arduino.
Code:
st: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:1
load:0x3fff0030,len:4832
load:0x40078000,len:16460
load:0x40080400,len:4
load:0x40080404,len:3504
entry 0x400805cc
E (2007) esp.emac: emac_esp32_init(371): reset timeout
E (2007) esp_eth: esp_eth_driver_install(228): init mac failed
Code:
#define ETH_PHY_TYPE ETH_PHY_LAN8720
#define ETH_PHY_ADDR 0
#define ETH_PHY_MDC 23
#define ETH_PHY_MDIO 18
#define ETH_PHY_POWER 16
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN
#include <ETH.h>
//IPAddress myIP(10, 1, 10, 111);
//IPAddress myGW(10, 1, 10, 1);
//IPAddress mySN(255, 255, 255, 0);
//IPAddress myDNS(8, 8, 8, 8);
static bool eth_connected = false;
// WARNING: onEvent is called from a separate FreeRTOS task (thread)!
void onEvent(arduino_event_id_t event) {
switch (event) {
case ARDUINO_EVENT_ETH_START:
Serial.println("ETH Started");
ETH.setHostname("esp32-ethernet");
break;
case ARDUINO_EVENT_ETH_CONNECTED: Serial.println("ETH Connected"); break;
case ARDUINO_EVENT_ETH_GOT_IP:
Serial.println("ETH Got IP");
Serial.println(ETH);
eth_connected = true;
break;
case ARDUINO_EVENT_ETH_LOST_IP:
Serial.println("ETH Lost IP");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_STOP:
Serial.println("ETH Stopped");
eth_connected = false;
break;
default: break;
}
}
void testClient(const char *host, uint16_t port) {
Serial.print("\nconnecting to ");
Serial.println(host);
NetworkClient client;
if (!client.connect(host, port)) {
Serial.println("connection failed");
return;
}
client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
while (client.connected() && !client.available());
while (client.available()) {
Serial.write(client.read());
}
Serial.println("closing connection\n");
client.stop();
}
void setup() {
Serial.begin(115200);
Network.onEvent(onEvent);
delay(1000);
ETH.begin();
}