W5500 and mbed-os 5

hello,
I’m trying to use W5500 with Mbed. have tried the examples from

and

The 2nd does not compile with W5500, event include path are wrong. After fixing, the init with MAC failed. The MAC is set and the a hardware reset is called. After fixing this, the IP is delivered by DHCP, but then init is called and a hardware reset is performed again.
It looks like this was never tested and is not maintained, the Issue button is also disabled for this repo.
I was able to fix this woes, but now the SPI communication is stopping after about 7-8 s. There are also a lot of polling loops that do not yield. Is there some better code for working with multitasking OS?
thanks, Johannes

hello
I will update that’s code.
please, see this code.

Or you create mbed-os-example-sockets.
Import WIZnetInterface library to the project.

and modify file ‘mbed_app.json’
{

"config": {
    "network-interface":{
        "help": "options are ETHERNET, ETHERNET_WIZNET",
        "value": "ETHERNET_WIZNET"
    }
},
"target_overrides": {
    "*": {
        "platform.stdio-baud-rate": 115200,
        "platform.stdio-convert-newlines": true,
        "mbed-trace.enable": 0
    }
}

}

and check file ‘mbed_lib.json’ in WIZnetInterface
{

"name": "WIZNET",
"config": {
    "sck": {
        "help": "sck pin for spi connection. defaults to SPI_SCK",
        "value": "SPI_SCK"
    },
    "cs": {
        "help": "cs pin for spi connection. defaults to SPI_CS",
        "value": "SPI_CS"
    },
    "miso": {
        "help": "miso pin for spi connection. defaults to SPI_MISO",
        "value": "SPI_MISO"
    },
    "mosi": {
        "help": "mosi pin for spi connection. defaults to SPI_MOSI",
        "value": "SPI_MOSI"
    },
    "rst": {
        "help": "RESET pin for spi connection. defaults to D15",
        "value": "D15"
    },
    "debug": {
        "help": "Enable debug logs. [true/false]",
        "value": flase
    },
    "interface": {
        "help": "Set the wiznet module interface [W5500/W6100]",
        "value": "W5500"
    },
    "socket-bufsize": {
        "help": "Max socket data heap usage",
        "value": 8192
    },
    "default-network": {
        "help": "Set the default network interface",
        "options" : [true,false],
        "value": true
    }
},
"target_overrides": {
}

}

Hello Teddy,
tanks for your fast reply and your support.
The recommended Wiznet Library contains the same problems, f.e. that init first sets the mac address and then calls reset. This deletes the mac and dhcp will fail:

In the meantime, I was able to fix a numer of problems by myself:

  • the easy_connect does a dhcp call when used init with mac, but then calls init and reset again, ip is lost
  • there is a WIZNET_ACCEPT_TIMEOUT, but why? In non blocking, it should never timeout. When it is running into timeout, in mbed5 it is hanging at an event in TCPSocket.
  • the socket callbacks are not thread safe, the callback can be set to 0 and then the system is running into hardfault
  • there are some functions deprecated, f.e. const char* get_ip_address(). The newer functions that make use of SocketAddress are not defined yet.
  • there is a Sock Status enumeration which interferes with a mbed definition, I have use a namespace to fix this.

I also don’t want to use easy_connect because it is deprecated with current Mbed mechanism to get default EthernetInterface. I’m checking how to integrate it to existing Mbed classes to use also Mbed dhcp and bring_up/down interface. The existing code works only when the ethernet is plugged in at system start.
I can publish this on github if you want to adopt or review my changes.

hello

Now we checked after MBED-OS version updated our code did not execute.

I’m checking. please wait.

I always welcome your opinion. And there is a thought to change.

And here WIZNET_ACCEPT_TIMEOUT is that can’t wait indefinitely before connecting, so we’ve set a timeout.

Thank you.

Thanks again for your support.
This timeout I have already modified:

#define WIZNET_TIMEOUT_INFINITE (-1)
#define WIZNET_ACCEPT_TIMEOUT   WIZNET_TIMEOUT_INFINITE 

        if ((t.read_ms() > WIZNET_ACCEPT_TIMEOUT) && (WIZNET_ACCEPT_TIMEOUT != WIZNET_TIMEOUT_INFINITE)) {
            debug("WIZnetInterface::socket_accept, timed out\r\n");
            return NSAPI_ERROR_WOULD_BLOCK;
        }

with WIZNET_ACCEPT_TIMEOUT=WIZNET_TIMEOUT_INFINITE is infinite waiting.
But I’ve checked the generic ioLibrary, maybe it is better to start from scratch with this library?
And instead of using polling, the interrupt and using Mbed Events sounds like a smarter solution?

I have checked also if I can use TCPsocket.set_blocking(false), but the blocking or timeout for reading is not used in the recv/send function.

Hello

your code is dangerous. if It is not connected, maybe Your program is stuck in an infinite loop and can do nothing.
If timeouts are frequent, it is recommended to increase the timeout time.

And I don’t understand this question.

I think the interrupt or Mbed Event method is more efficient.

TCPsocket.set_blocking(false) is not WIZNET Function.
now our send/recv Function is not used.
but I will check mbed-os internal Functions with WizInterface Function.
I’ll find a way to be compatible with MBED-OS internal functions and WIZInterface functions.

Thank you

yes, you’re right. The code should handle events when the interface is coming up/down, f.e. when the network cable is pulled out and plugged in.

about ioLibrary: the mbed-os related code is a few years old, the ioLibrary is newer. So my question was if it is better to add mbed features to ioLibrary.

Hello

Yes. I think so that.
I will also consider the IOLibrary to add the MBED structure.

Thank you.

hi teddy,

i also found out that its impossible to use the w5500@mbed at the moment. So i also appreciate your work and help, teddy. Looking forwar to your fixes :slight_smile:

Thank you so much mr. wiznet wizzard :slight_smile:

M.

hello teddy,

Hope you are well. We desperately waiting for some help here with this issue, since mbed and w5500 is no longer working together.

Happy new year to you.
Mike.

hello.
I’m sorry.
The schedule is getting late.
We will support you as soon as possible.
Please waits for more.
Thank you

Hello Teddy, do you have some news for us, when do you think you can start with fixing the issues?

Mike.

@teddy Sorry to say, but we are waiting for help since almost 3 month now. Please Wiznet Team, help us!

MIke.

Sorry.
We are currently working.
Please wait a little longer

Hello wiznet Team. Another 3 month later? Many people running into the same big. Arguing about wiznet on Facebook. But I cant help them. I am stuck in the same support case. Can you tell us if this will be fixed? How many month longer do we have to wait? We just need support…

Mike.

Hahaha… Now there is mbed os6… And still no help from wiznet… Not even a message… Nothing… great company, great support!

Hello Mike.
Sorry for the delay in response.
We updated WIZnetInterface for mbed-os 6.

It is the using method but language is Korean.

we will translate language later.

thanks.