Portenta H7 DHCP fails but static IP works fine

Hi all,

having trouble with getting the the DHCP working with the Arduino Portenta H7.

We have a custom daughter board but have same issues if I’m using the Portenta Breakout Board.

Packages I’m using are:

and

I’ve just used the code from some provided Arduino examples but even if I use the Ethernet library from Mbed OS, it returns a DHCP failed error.

https:// os.mbed .com/docs/mbed-os/v6.16/apis/ethernet.html

(sorry for formatting, apparently I can only have 2 links as a new user)

Statically assigning an IP works completely fine. I can open a UDP socket, send and receive packets just fine.

 // initialize the ethernet device
  Ethernet.begin(mac);

  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet was not found.  Sorry, can't run without hardware. :(");
    while (true) {
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }
  if (Ethernet.hardwareStatus() == EthernetMbed) {
    Serial.println("Ethernet found. :)");
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  }
  if (Ethernet.linkStatus() == LinkON) {
    Serial.println("Ethernet cable IS connected.");
  }

Hardware set-up is Arduino connected to a custom daughter board, which connects to an embedded switch. RJ45 connection into a USB-C hub (bloody work laptop doesn’t have a NIC with RJ45).

I might be missing something obvious, I haven’t written firmware for over a decade and I’ve never done any OOP so C++ is fairly new to me.

Any help would be greatly appreciated.

Please show or upload your complete mbed project which fails to obtain a dynamic IP address. All I see is Arduino code and no platformio.ini.

Hi Max,

Please find the project files here.

So, both environments have framework = arduino setup (and not framework = mbed), yet both of them are trying to import the direct framework-mbed package…

You either chose directly framework = mbed without any platform_packages or use framework = arduino. The latter one, being based on mbed-os, still gives you access to select mbed-os functionality and classes, without the need to import any mbed-os package, because it’s already precompiled in the core. So the platform_packages line is effect-less.

In any case, does the same code also not work in the Arduino IDE? If yes, it’s not PlatformIO related and you should open an issue in https://github.com/arduino/ArduinoCore-mbed/issues.

1 Like

Thank you Max. That has cleaned up my project significantly.

No, it doesn’t work with the Arduino IDE and I’ve also changed my network interface to go directly into a NIC instead of through a USB C hub. Still no dice so I’ll open an issue where you linked.

Cheers.

Just an update for this if anyone else runs into this issue.

I was running this on Windows 11 and had assumed that (like Linux), it can act like a de-facto DHCP server and share IP addresses. I was wrong.

If I connect the Arduino to a switch that is directly connected to the modem, the DHCP works fine.