6 years, 3 months ago.

Ethernet not working for K64F

Hello, I am trying to make the Ethernet interface working on K64F FRDM board, but it won't work. Either if DHCP or static IP, it doesn't work. The example code, related to the latest mbed version, is minimalist and it doesn't work. Is there perhaps some other initialisation one has to do in order to bring the interface up? Please note, the library hangs on the function below:

LWIPInterface: add_ethernet_interface():

if (!netif_add(&interface->netif,

  1. if LWIP_IPV4 0, 0, 0,
  2. endif interface, &LWIP::Interface::emac_if_init, tcpip_input)) { return NSAPI_ERROR_DEVICE_ERROR; }

Alternatively, is there any way to debug the mbed code? Any suggestion is appreciated. Thank you

Davide

1 Answer

6 years, 3 months ago.

Hi,

do you have to use LWIPInterface? If not, try seeing this sample program: http://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-sockets/

Hi, thanks for the suggestion, but that code is not working as well. It still hangs on the connect() function. Does someone know how to enable debug on mbed? If it is ever possible. Thanks

posted by Davide Longo 06 Aug 2018

I tested this program on K64F and it worked... Hmm... I used online compiler. Ethernet cable is connected to my board.

On debug, for example, see this page: https://os.mbed.com/docs/latest/tutorials/visual-studio-code.html

posted by Osamu Koizumi 06 Aug 2018

I compiled via CLI, using the latest mbed os version. My K64f board is connected to a router. It hangs on connect(), either if cable is plugged or it is not. I will try to compile online. Are you connected to a router or to a PC? Thanks

posted by Davide Longo 06 Aug 2018

I tried CLI too. It's working. My K64F board is connected to a router with Ethernet cable. Can you provide your Mbed OS version? mbed ls

My output: mbed-os-example-sockets (#0f5a9685585e, tag: tip) `- mbed-os (#485bdeee150e, tags: latest, mbed-os-5.9.4)

posted by Osamu Koizumi 06 Aug 2018

It hangs to me. My output:

- mbed-os (#485bdeee150e, tags: latest, mbed-os-5.9.4)

However, the board I am using currently uses also two UARTS and one ADC for signal acquisition. Not sure if this is relevant. Also, if I call "get_mac_address()" I get NULL. It looks like the interface is not brought up.

posted by Davide Longo 06 Aug 2018

Could you try to run the example program mbed-os-example-sockets without any modification?

posted by Osamu Koizumi 06 Aug 2018

I just tried it. The example program hangs for around 1 minute and then returns error. This is the output:

Mbed OS Socket example Mbed OS version: 5.9.4

Error! net->connect() returned: -3010 IP address: None Netmask: None Gateway: None Error! socket.connect() returned: -3009 Error! socket.connect() returned: -3004 Done

The fact the example program at least returns when instead the same code in a bigger program hangs forever is not comforting. There must be conflicts in the drivers, I guess.

posted by Davide Longo 06 Aug 2018

The error code -3010 from connect() means DHCP error. Is DHCP available in your environment? Any security setting?

https://github.com/ARMmbed/mbed-os/blob/485bdeee150e2bc8ed75e27d936060fb63a7a7d1/features/netsocket/nsapi_types.h#L48

posted by Osamu Koizumi 06 Aug 2018

Right that, I found it, I routed the board to a switch which had security settings. When connected to another switch, the example program worked. However, same code put in a bigger context, it still hangs. I will investigate why. Thank you for your support, appreciated!

Davide

posted by Davide Longo 06 Aug 2018

Issue Fixed. The problem was in a conflict between Ethernet and UART3. They can't be use at the same moment in the K64f frdm board. Changing UART to another one fixed the issue. The connect() functions works fine now. Thanks a lot!

Davide

posted by Davide Longo 06 Aug 2018

Great! Thank you for sharing your fix.

posted by Osamu Koizumi 06 Aug 2018