Waveshare RP2040-ETH - Getting Ethernet working

I have been using a Waveshare RP2040-ETH with the Arduino IDE.
RP2040-ETH

Does anyone else here have experience with them and been able to make the Ethernet port work? After adding the board in as per the instructions towards the bottom of the wiki, some Raspberry Pi Pico examples are available in the Arduino IDE. The Ethernet examples don't work for this board.

The DCHP printer example fails. I assumed that the RP2040-ETH is given the MAC address in the software because it doesn't come with one noted on it. Maybe that is not the case?

Running this code, the link / speed LEDs on the RJ45 port turn off.

Maybe I need to configure the CS pin but I have tried various and there isn't anything in the wiki that I can find relating to this.

Apologies if this is wrong category!

/*
  DHCP-based IP printer

  This sketch uses the DHCP extensions to the Ethernet library
  to get an IP address via DHCP and print the address obtained.
  using an Arduino WIZnet Ethernet shield.

  Circuit:
   Ethernet shield attached to pins 10, 11, 12, 13

  created 12 April 2011
  modified 9 Apr 2012
  by Tom Igoe
  modified 02 Sept 2015
  by Arturo Guadalupi

 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};

void setup() {
  // You can use Ethernet.init(pin) to configure the CS pin
  //Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH Shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit FeatherWing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit FeatherWing Ethernet

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  Serial.println("Initialize Ethernet with DHCP:");
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    if (Ethernet.hardwareStatus() == EthernetNoHardware) {
      Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    } else if (Ethernet.linkStatus() == LinkOFF) {
      Serial.println("Ethernet cable is not connected.");
    }
    // no point in carrying on, so do nothing forevermore:
    while (true) {
      delay(1);
    }
  }
  // print your local IP address:
  Serial.print("My IP address: ");
  Serial.println(Ethernet.localIP());
}

void loop() {
  switch (Ethernet.maintain()) {
    case 1:
      //renewed fail
      Serial.println("Error: renewed fail");
      break;

    case 2:
      //renewed success
      Serial.println("Renewed success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    case 3:
      //rebind fail
      Serial.println("Error: rebind fail");
      break;

    case 4:
      //rebind success
      Serial.println("Rebind success");
      //print your local IP address:
      Serial.print("My IP address: ");
      Serial.println(Ethernet.localIP());
      break;

    default:
      //nothing happened
      break;
  }
}

It uses the CH9120 chip for Ethernet. Arduino Ethernet library is for Wiznet W5000 series.

I figured that but assumed that there was some kind of support as their wiki decries how to set it up for use with the Arduino IDE.

I asked the same question of Waveshare support and got this:

You do not need to set the MAC, the MAC is not setable.

You can directly configure the IP and setup TCP/UDP connecting according to the provided examples.

I got it to work as a UDP Client . as a server it can only send after it as received some data. That is how it gets the port to send data to. I did not try TCP modes

you need to copy the CH9120.h and the CH9120.cpp files in the same folder as you arduino .ino file.

I used a program called packet sender https://packetsender.com/ to do my testing.
make sure you go to File - setting - UDP server ports and set it to the Arduinos target port "I used 2000"
I hope this helps


#include "CH9120.h"


char DataChar[508];     //used to send data
String DataString;      // string to receive and send data
unsigned int Datalen=508;   // max len of a data packet

void setup() {
    CH9120_init();                                      //starts ethernet connection. set connection details at the top CH9120.cpp
                                                        // the connection mode needs to be set in 2 places in the 
                                                        // 3rd line of CH9120.cpp and line 40 of CH9120.h (the choices are listed on line 39)
    Serial.println("READY");                           // let me know init is finished. connection still takes a few sec to start. 
                                                      // you can ping the IP of the device to know when it is ready
}



void loop() {



while (Serial.available())                              // only executes if data is available at serial port
  {
    DataString = Serial.readString();                   // get data from serial port
    DataString.toCharArray(DataChar, Datalen);          // convert to an array of Chars
    Serial.println("Sending");                          // print to know that while loop executed
    UART_ID1.write(DataChar);                           // send data 
    
  }

while (UART_ID1.available())                            // only executes if data is available at ethernet port
  {
    DataString = UART_ID1.readString();                 // read data from ethernet port
    if (DataString == "Ping") {                         // send an Ack if the string Ping is sent
      UART_ID1.write("Ack");
    }
    Serial.println(DataString);                           // print out data received
    
  
  }
  



}