tobozo / ESP32-ENC28J60

ENC28J60 Ethernet driver for ESP32-Arduino 2.0.x / 3.0.x, lwip compliant
MIT License
26 stars 8 forks source link

Update for arduino-esp32 v3.0 #14

Closed webspiderteam closed 3 months ago

webspiderteam commented 3 months ago

I have done all update changes but I am getting these errors: /appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-12.2.0_20230208/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: /ESP32-ENC28J60.cpp:114: undefined reference to enc28j60_begin' /appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-12.2.0_20230208/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: Documents\Arduino\ETH_ENC28J60/ESP32-ENC28J60.cpp:121: undefined reference toesp_eth_phy_new_enc28j60' /appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/esp-12.2.0_20230208/bin/../lib/gcc/xtensa-esp32-elf/12.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: Documents\Arduino\ETH_ENC28J60/ESP32-ENC28J60.cpp:135: undefined reference to `emac_enc28j60_get_chip_info' may be you can fix these issues. I not pro in C coding.

tobozo commented 3 months ago

hi,

thanks for your PR :+1:

I cloned your fork and got a totally different linker error (complaining about missing tcpipInit()), tried to solve that instead until I got a successful compilation, but I don't have an ENC28J60 to test with, I hope this will solve your linker error too.

diff --git a/src/ESP32-ENC28J60.cpp b/src/ESP32-ENC28J60.cpp
index 55a9d9a..95a006b 100644
--- a/src/ESP32-ENC28J60.cpp
+++ b/src/ESP32-ENC28J60.cpp
@@ -76,7 +76,8 @@ ENC28J60Class::~ENC28J60Class() {}
 esp_netif_t *eth_netif{nullptr};
 //bool ENC28J60Class::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_type_t type, eth_clock_mode_t clock_mode, bool use_mac_from_efuse)
 bool ENC28J60Class::begin(int MISO_GPIO, int MOSI_GPIO, int SCLK_GPIO, int CS_GPIO, int INT_GPIO, int SPI_CLOCK_MHZ, int SPI_HOST, uint8_t* ENC28J60_Mac) {
-  tcpipInit();
+  //tcpipInit();
+  Network.begin();

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

diff --git a/src/ESP32-ENC28J60.h b/src/ESP32-ENC28J60.h
index 1ddb53a..d71cd4b 100644
--- a/src/ESP32-ENC28J60.h
+++ b/src/ESP32-ENC28J60.h
@@ -20,6 +20,7 @@
 #ifndef _ENC28J60_ESP32_ETH_H_
 #define _ENC28J60_ESP32_ETH_H_

+#include "Network.h"
 #include "WiFi.h"
 #include "esp_system.h"
 #include "esp_eth.h"
@@ -73,8 +74,8 @@ public:
     uint8_t* macAddress(uint8_t* mac);
     String macAddress();

-    friend class WiFiClient;
-    friend class WiFiServer;
+    friend class NetworkClient;
+    friend class NetworkServer;
 };

 extern ENC28J60Class ETH;
diff --git a/src/extmod/esp_eth_spi_enc28j60.c b/src/extmod/esp_eth_spi_enc28j60.c
index bea3be1..e6ae598 100644
--- a/src/extmod/esp_eth_spi_enc28j60.c
+++ b/src/extmod/esp_eth_spi_enc28j60.c
@@ -14,7 +14,7 @@

 esp_eth_mac_t* enc28j60_new_mac(int SPI_HOST, spi_device_interface_config_t* spi_devcfg, int INT_GPIO )
 {
-    eth_enc28j60_config_t enc28j60_config = ETH_ENC28J60_DEFAULT_CONFIG(SPI_HOST, *spi_devcfg);
+    eth_enc28j60_config_t enc28j60_config = ETH_ENC28J60_DEFAULT_CONFIG(SPI_HOST, spi_devcfg);
     enc28j60_config.int_gpio_num = INT_GPIO;

     eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
webspiderteam commented 3 months ago

I think there was an file encoding issue. Because I downloaded all files back and put them in workspace manually. Now all files shows there is changes but no difference.

Thanks for fixing Tcpipinit issue. I haven't testted with hardware yet but I don't think there will be an issue.