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.
7 years, 1 month ago.
Problem of Ether (RJ 45) interface of EVK_ODIN_W 2. (mbed os 5.7)
I tried to operate the example below with EVK_ODIN_W2.
https://os.mbed.com/docs/v5.7/reference/ethernet.html
Do not proceed after the message. "Ethernet socket example"
Replying is ant if you ping EVK_ODIN_W2 from the network side.
"net.connect();"
I think that "net.connect ();" is bad, but I do not know the details.
Ether net example
#include "mbed.h" #include "EthernetInterface.h" // Network interface EthernetInterface net; // Socket demo int main() { // Bring up the ethernet interface printf("Ethernet socket example\r\n"); net.connect(); printf("net.connect\r\n"); // Show the network address const char *ip = net.get_ip_address(); printf("IP address is: %s\n", ip ? ip : "No IP"); // Open a socket on the network interface, and create a TCP connection to mbed.org TCPSocket socket; socket.open(&net); socket.connect("developer.mbed.org", 80); // Send a simple http request char sbuffer[] = "GET / HTTP/1.1\r\nHost: developer.mbed.org\r\n\r\n"; int scount = socket.send(sbuffer, sizeof sbuffer); printf("sent %d [%.*s]\n", scount, strstr(sbuffer, "\r\n")-sbuffer, sbuffer); // Recieve a simple http response and print out the response line char rbuffer[64]; int rcount = socket.recv(rbuffer, sizeof rbuffer); printf("recv %d [%.*s]\n", rcount, strstr(rbuffer, "\r\n")-rbuffer, rbuffer); // Close the socket to return its memory and bring down the network interface socket.close(); // Bring down the ethernet interface net.disconnect(); printf("Done\n"); }
Ping Log
C:\L\src\mbed\mbed-os-example-wifi>ping 192.168.137.1 Pinging 192.168.137.1 with 32 bytes of data: Reply from 192.168.137.1: bytes=32 time<1ms TTL=128 Reply from 192.168.137.1: bytes=32 time<1ms TTL=128 Reply from 192.168.137.1: bytes=32 time<1ms TTL=128 Reply from 192.168.137.1: bytes=32 time<1ms TTL=128 Ping statistics for 192.168.137.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms C:\L\src\mbed\mbed-os-example-wifi>
1 Answer
7 years, 1 month ago.
To use the Ethernet port on the ODIN-W2 you need to:
Quote:
Only possible to use either Wi-Fi or Ethernet as MAC-interface, not both at the same time. This is a limitation in mbed-os currently. Wi-Fi is enabled by default. To use Ethernet please remove "EMAC" from the UBLOX_EVK_ODIN_W2 target's "device_has" field in mbed-os/targets/targets.json.
From the ODIN-W2 page.
Pretty annoying.
I missed official information and I was disappointed.
However, as I was correcting the information (as described below), I tried clean build, but the situation did not change. It stops with net.connect () ;.
Also, it is very troublesome if you can not use wifi and eth at the same time, so please wish to function simultaneously in the future.
json(Modified)
"MODULE_UBLOX_ODIN_W2": { "inherits": ["FAMILY_STM32"], "core": "Cortex-M4F", "extra_labels_add": ["STM32F4", "STM32F439", "STM32F439ZI","STM32F439xx", "STM32F439xI"], "macros": ["MBEDTLS_CONFIG_HW_SUPPORT", "HSE_VALUE=24000000", "HSE_STARTUP_TIMEOUT=5000", "CB_INTERFACE_SDIO","CB_CHIP_WL18XX","SUPPORT_80211D_ALWAYS","WLAN_ENABLED","MBEDTLS_ARC4_C","MBEDTLS_DES_C","MBEDTLS_MD4_C","MBEDTLS_MD5_C","MBEDTLS_SHA1_C"], "device_has_add": ["CAN", "TRNG", "FLASH"], "device_has_remove": ["RTC", "SLEEP"], "features": ["LWIP"], "device_name": "STM32F439ZI", "bootloader_supported": true },
I've tested this with https://os.mbed.com/teams/sandbox/code/http-example/ on the ODIN-W2. Add the following to mbed_app.json under 'target_overrides':
"UBLOX_EVK_ODIN_W2": { "target.device_has_remove": ["EMAC"] }
And just compile and run it on the board, this successfully connects to Ethernet and makes HTTP requests.
Not being able to use both Ethernet and WiFi seems to be an ODIN specific thing, perhaps the network stack is shared.
posted by 12 Jan 2018I succeeded in using the RJ45. It was a simple cause. I deleted the following from the loca json file.
"UBLOX_EVK_ODIN_W2": { "target.device_has": ["EMAC"] },
The following is the result.
Ethernet socket example net.connect IP address is: 10.5.10.28 sent 45 [GET / HTTP/1.1] recv 64 [HTTP/1.1 200 OK] Done
Thank you very much, everyone.
posted by 16 Jan 2018