-
Notifications
You must be signed in to change notification settings - Fork 11
Arduino esp8266 build fails #3
Comments
Same issue here (minimal sample project referenced there). David, you probably have a working project. Would you mind sharing the code with us? Thank you and kind regards, |
Will answer later today. Thanks for your interest. |
Fix pushed |
Thank you. I confirm successful compilation. Still need to test with actual hardware. Benefits of library being in the core:
Thus yes, library should be moved to core. |
Hi David, thanks for fixing! Can you give us a short example code? Please share also the wire connection with us, especially the CS pin. Regards |
I use the same board ethernet board and wemos D1 mini lite. Here's a stripped example.
|
Hi David, thanks for your simpleCode, your code works well with the W5500....... #include <Arduino.h>
#include "ESP8266WiFi.h"
#include <w5500-lwIP.h>
// Arduino Pin 4 = Wemos Pin D2
#define CSPIN 4
Wiznet5500lwIP eth(CSPIN);
byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02};
void setup() {
Serial.begin(115200);
Serial.println("");
Serial.println("start");
eth.setDefault(); // use ethernet for default route
int present = eth.begin(mac);
Serial.println("");
Serial.println("present= " + String(present, HEX));
while (!eth.connected()) {
eth.loop();
Serial.print(".");
delay(1000);
}
}
void loop() {
eth.loop();
Serial.println(eth.localIP());
delay(1000);
} |
Hi David, we are not able to bring a simple NTPClient or WebServer to work. We get an IP address but the NTPClient or WebServer do not connect/cannot be contacted as if the did not bind to the interface. Would you mind providing a simple example for that, please? Regards, |
I guess the issue is that either the services do not bind to the interface (although they bind to IPANY in their code) or that some additional define is missing besides PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY |
There are number of small issues to solve.
So we should be using some sort of timer to call Before that, we do what we can, NTPClient example could then be:
|
Thank you very much, David, for looking into this and for providing the example. I still have to look at it in detail. My W5500 arrived by mail order. Thus, yesterday night, I extended my example code. The AsyncWebserver example worked right out of the box and is reachable both via WiFi and Ethernet. NTP client example did not work right away and now does only with the IP address of the NTP server, not with its FQDN. I will rewrite it according to your example, though. I monitored network traffic with wireshark yesterday. It looks like I am missing some packets in wireshark (I see no name resolution). At least I see issues with ARP. Ethernet has difficulties to get the MAC address of the gateway, sending ARP requests 5 times but receiving no response. I particular, the overall process hangs for seconds, which coincides with 4 to 5 seconds latencies of ping. This is compatible with your reasoning that eth.loop() is not called as often as required. This is like fishing in murky waters. What can I do to foster integration of the library into the core? Is it instead reasonable to do it in a minimal fork of the relevant Arduino Iibrary if the integration into the core does not happen or takes too much time? Cheers |
@d-a-v We created a full real-world example with AsyncWebserver, NTP Client and MQTT Client. Observations:
This is likely due to Ethernet getting stuck if the MQTT Client tries to connect without calling We now have a real-world example for testing a future version of the Arduino library with integrated W5500 ethernet. We are keen to support the integration into the core with testing. @Pfannex is experienced with low-level device programming and could support the addition of status functions and the like into the W5500 device class. @d-a-v How do you like to proceed and how can we help? |
Here's what I propose for a try: Add this inside
Change
to
And somewhere in your sketch, code
The Thanks for your reports and for helping this project ! |
Hi David, thanks for your quick response!
Unfortunately this got no effect. What does extern "C" void eth_loop ()
{
// first, check if ethernet is initialized,
// then call your eth.loop()
} mean? You can find our PlatformIO repo here: |
@Pfannex Just start with
and put
somewhere in your sketch such that it get linked into the executable and gets called from |
@Pfannex Is this now working ? |
@d-a-v , sorry, we can't give you a positive response......but we have some questions.
platformIO home - coredecls.h #ifndef __COREDECLS_H
#define __COREDECLS_H
#ifdef __cplusplus
extern "C" {
#endif
// TODO: put declarations here, get rid of -Wno-implicit-function-declaration
extern bool timeshift64_is_set;
void tune_timeshift64 (uint64_t now_us);
void settimeofday_cb (void (*cb)(void));
void eth_loop (void);
#ifdef __cplusplus
}
#endif
#endif // __COREDECLS_H platformIO Sketch repository - coredecls.h #ifndef __COREDECLS_H
#define __COREDECLS_H
#ifdef __cplusplus
extern "C" {
#endif
// TODO: put declarations here, get rid of -Wno-implicit-function-declaration
#include <stdint.h>
#include <cont.h> // g_pcont declaration
extern bool timeshift64_is_set;
void esp_yield();
void esp_schedule();
void tune_timeshift64 (uint64_t now_us);
void settimeofday_cb (void (*cb)(void));
void disable_extra4k_at_link_time (void) __attribute__((noinline));
uint32_t sqrt32 (uint32_t n);
#ifdef __cplusplus
}
#endif
#endif // __COREDECLS_H
So far the code is compilable but does not work as expected. Finally we need to find out why we got different versions of the core files and why |
While showering I knew why we have two core directories. The sketch internal core is loaded by platformIO because we listed it in the
Thus it looks our Arduino ESP8266-core platformIO core is not up to date. I try to update the core and test it again. So stay tuned..... |
This one is more up to date than the first. I went to watch PubSubCLient sources that you use. Whereas there is a There is no Maybe you can try and add that call there and see what happens. |
For the record, the second loop calls You can also add a |
Hi David, after installing the latest core I add extern "C" void call_user_start();
extern void loop();
extern void setup();
extern void (*__init_array_start)(void);
extern void (*__init_array_end)(void);
extern "C" void eth_loop (void); I also add a "print" into the eth_loop(). extern "C" void eth_loop (){
// first, check if ethernet is initialized,
// then call your eth.loop()
//Serial.println("eth.connected()");
//eth.loop();
if (present){
Serial.println("eth.loop()");
eth.loop();
}
} For the moment MQTT is still disabled and all Printing the "eth.loop()" occurs still very sporadically. I think we need to find a way to call the eth.loop() as quite often as possible. |
While testing the "plug-flag" I noticed that a few seconds after disconnecting the eth plug |
Then we would use a timer like in this example datasheet:
(note: |
After implementing the timer and adding the So far a step into the right direction....! But the MQTT.client doesn`t work clean. At all this can not be the final solution. For me, it looks like the TCP-connection to the MQTT-Broker is disconnecting after 3 seconds. Can we run further tests? |
I experimented with the timer variant as well but was not so bold as to call Increasing the frequency up to one call every millisecond yielded the following results:
Polling the ethernet every millisecond seems excessive to me. I wonder if one was not better off with using the hardwired IP stack in the Wiznet W5500 module and the TX and RX buffers to offload the work to the chip. There is a wealth of information at the Wiznet W5500 web page, including the official library at github and a Wiki. |
The Ethernet (edit:+TCP/IP) driver is also already in the esp8266/arduino core, for the W5100. It is possibly compatible with W5500.
Calling the loop too often is not good - I agree - but at least would make everything work, so I need to run tests myself too, so I can watch what's hapenning. There's also the interrupt pin that could be used (wired + software-honored). |
Thank you, David. For starters, the repository W5500-example contains the latest sketch from our experiments in the MQTT branch, corresponding to previous report. |
If needed please use our MQTT-branch |
Maybe we are looking in the wrong place anyway? Our use case is to have built-in WiFi adapter and external W5500 LAN adapter sitting in the same TCP/IP stack such that higher-level services and protocols (FTP, NTP, MQTT, HTTP) can be accessed via both interfaces. We had the experience that the Arduino libraries allow to either use WiFi or Ethernet as two completely separate TCP/IP stacks. But I might be mistaken. |
How is lwip currently integrated into the Arduino core - I'm guessing its not the one coming with the NONOSSDK so if not then we can add to it not so? |
Please see last commit |
Hi,
I'm using the Arduino IDE 1.8.7 with the latest esp8266 Version 2.4.2 including lwIP2.
Board: WeMos D1 R1
I tried to compile this minimal sketch:
build fails with:
How can I compile with lwip2?
regards
Pf@nne
The text was updated successfully, but these errors were encountered: