Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
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,
- if LWIP_IPV4 0, 0, 0,
- 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 06 Aug 2018I 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 06 Aug 2018I 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 06 Aug 2018I 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 06 Aug 2018It 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 06 Aug 2018Could you try to run the example program mbed-os-example-sockets without any modification?
posted by 06 Aug 2018I 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 06 Aug 2018The error code -3010 from connect() means DHCP error. Is DHCP available in your environment? Any security setting?
posted by 06 Aug 2018Right 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 06 Aug 2018