Closed ecosky closed 2 years ago
HI @ecosky
Can you try again using the new WiFiWebServer releases v1.4.1 ?
It's possible there is some bug or settings not correct in PIO because there is no issue with Arduino IDE in compiling at all.
The default lib_compat_mode = soft
is really bad for multi-platform code, especially for new PIO users. Wrong libraries could be included and creating compile errors.
lib_compat_mode
from default soft
to strict
to minimize compile error in cross-platformPackages' Patches
for many boardsThanks for the suggestion. I updated to 1.4.1 and get the same error unless I add the && !defined(ARDUINO_NANO_RP2040_CONNECT)
I'm admittedly new to PlatformIO so could easily be doing something wrong, however this line of code appears to be including the avr/pgmspace.h if some defines are not present, which may be intentional but from what I can tell so far the avr/pgmspace.h I think is part of the AVR LIBC library that is not used by the RP2040? I could be wrong there. All I know is that by not including this on the RP2040 connect, it works for me. I started with an empty project and the WebServer example, so I'm not sure where I might have gone wrong to trigger this if it is something I did.
I added some warnings to test which one of these were triggering the #include, and any of them would trigger that condition.
#if !(ESP32)
#warning MATCHING: ESP32
#endif
#if !(ESP8266)
#warning MATCHING: ESP8266
#endif
#if !(defined(ARDUINO_PORTENTA_H7_M7))
#warning MATCHING: defined(ARDUINO_PORTENTA_H7_M7)
#endif
#if !(defined(ARDUINO_PORTENTA_H7_M4))
#warning MATCHING: defined(ARDUINO_PORTENTA_H7_M4)
#endif
// KH, For PROGMEM commands
// ESP32/ESP8266 includes <pgmspace.h> by default, and memccpy_P was already defined there
#if !(ESP32 || ESP8266 || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)) && !defined(ARDUINO_NANO_RP2040_CONNECT)
#include <avr/pgmspace.h>
#define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n))
#endif
Here's the output:
In file included from src\defines.h:372, from src\main.cpp:18: .pio\libdeps\nanorp2040connect\WiFiWebServer\src/WiFiWebServer.h:149:2: warning: #warning MATCHING: ESP32 [-Wcpp] 149 | #warning MATCHING: ESP32 | ^~~~~~~ .pio\libdeps\nanorp2040connect\WiFiWebServer\src/WiFiWebServer.h:152:2: warning: #warning MATCHING: ESP8266 [-Wcpp] 152 | #warning MATCHING: ESP8266 | ^~~~~~~ .pio\libdeps\nanorp2040connect\WiFiWebServer\src/WiFiWebServer.h:155:2: warning: #warning MATCHING: defined(ARDUINO_PORTENTA_H7_M7) [-Wcpp] 155 | #warning MATCHING: defined(ARDUINO_PORTENTA_H7_M7) | ^~~~~~~ .pio\libdeps\nanorp2040connect\WiFiWebServer\src/WiFiWebServer.h:158:2: warning: #warning MATCHING: defined(ARDUINO_PORTENTA_H7_M4) [-Wcpp] 158 | #warning MATCHING: defined(ARDUINO_PORTENTA_H7_M4) | ^~~~~~~
Hi @ecosky
Thanks for testing and publish the results. I still don't see the compile error in your post
The actual pgmspace.h
file of mbed_rp2040 core is in the deprecated section of the core, for example, if the core is v.2.5.2,
2.5.2/cores/arduino/api/deprecated-avr-comp/avr/pgmspace.h
Somehow, PIO, by using some wrong settings, you have to find out where, and not include that deprecated directory, therefore, compile error happens.
It's easy to add the && !defined(ARDUINO_NANO_RP2040_CONNECT), but I'm reluctant to do that kind of kludge, without knowing and fixing the real cause, which can create many more issues in the future.
I suggest you discuss in PIO forum, to understand then fix the real PIO issue => why it's OK with Arduino IDE, but not with PIO.
Good Luck,
Hi,
Just noted that you're still using mbed_rp2040 core v2.4.1. Can you try to update to latest ArduinoCore-mbed core v2.5.2 to see any better ?
Hi @ecosky
I guess I can see the real issue now
It's possible that PIO, when installing ArduinoCore-mbed core, just installs from the GitHub (or something similar to that), and the whole directory 2.5.2/cores/arduino/api
is missing.
Could you check if you have that directory 2.5.2/cores/arduino/api
in PIO ArduinoCore-mbed core?
I guess that directory is added only by Arduino IDE, running some installation script.
Without that, you'll get the compile error such as ???
defines.h:372:10: fatal error: avr/pgmspace.h: No such file or directory
#include <avr/pgmspace.h>
Yep, that's the exact error I have been getting. I've been trying to figure out how to get ArduinoCore-mbed 2.5.2 installed but it seems to be unavailable to me for some reason, and the update feature isn't aware of it yet.
I don't see that directory - could you please provide a more complete path? Perhaps I'm looking in the wrong place. Thanks!
Check in your Arduino IDE core directory, such as in Linux
~/.arduino15/packages/arduino/hardware/mbed_rp2040/2.5.2/cores/arduino/api
In Windows, something similar to that
It's wrong if you add the core just by doing as suggested in PIO Raspberry Pi RP2040
platform = https://github.com/platformio/platform-raspberrypi.git
Doing that way, you are possibly missing many requested directories and tools
PIO is missing this package_full.sh#L15-L17
# Clone ArduinoCore-api in parent folder and create symlinks
git clone git@github.com:arduino/ArduinoCore-API.git ../api/
ln -s ../../../api/api cores/arduino/api
That script must be used / run to install the core correctly
This is the location of the missing directory
You have to post an issue in PIO to fix once-and-for-all, because who knows this can happen to any other cores?
I've been trying to figure out how to get ArduinoCore-mbed 2.5.2 installed but it seems to be unavailable to me for some reason, and the update feature isn't aware of it yet.
Using v2.4.2 is still OK as we already know the culprit. Don't need to wait for v2.5.2.
The issue will happen to all core and/or versions of ArduinoCore-mbed core, such as mbed_nano, mbed_portanta, mbed_rp2040
For example
From Nordic nRF52
[env:upstream_develop]
platform = https://github.com/platformio/platform-nordicnrf52.git
On Windows here, and down in C:\Users\accountName\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano I only have a 2.4.1 folder.
I see when I look at the boards manager in the Arduino IDE there is an update to 2.5.2. Updating it there didn't fix the PIO build, it still finds v2.4.2. I haven't run the Arduino IDE in a while so I'm not surprised it's stale there. I suspect it's not even relevant to this discussion?
Unfortunately, Windows doesn't support the symlink but I can shuffle things around. Can you please share the full path I need to be in when running the above script? Thanks
I see when I look at the boards manager in the Arduino IDE there is an update to 2.5.2. Updating it there didn't fix the PIO build, it still finds v2.4.2.
I see when I look at the boards manager in the Arduino IDE there is an update to 2.5.2. Updating it there didn't fix the PIO build, it still finds v2.4.2.
PIO packages is at different location from Arduino IDE.
You just locate your mbed_rp2040 core, then copy the whole core directory to PIO core directory
C:\Users\accountName\AppData\Local\Arduino15\packages\arduino\hardware\mbed_rp2040\2.4.1\cores\arduino\api
Just find where is the PIO platforms directory, then copy to overwrite all or just copy the api
directory only
Just check my Windows machine and the api
is there (I don't know which script the Arduino IDE uses to install the ArduinoCore-API, will find later as I don't use Windows at all, just in some other place to check when necessary)
C:\Users\accountName\AppData\Local\Arduino15\packages\arduino\hardware\mbed_rp2040\2.5.2\cores\arduino\api
That's why you have to follow the instructions in ArduinoCore-mbed Installation
$sketchbook/hardware/arduino-git
mkdir -p $sketchbook/hardware/arduino-git
cd $sketchbook/hardware/arduino-git
git clone git@github.com:arduino/ArduinoCore-mbed mbed
git clone git@github.com:arduino/ArduinoCore-API
api
symlinkCreate a symlink to ArduinoCore-API/api
in $sketchbook/hardware/arduino/mbed/cores/arduino
.
@ivankravets, @maxgerhardt
Please have a look and give your opinion.
Thanks,
Could you check if you have that directory 2.5.2/cores/arduino/api in PIO ArduinoCore-mbed core?
The cores/arduino/api
folder exists in the PlatformIO package. framework-arduino-mbed
of version 2.4.1 is used in platform-rasperrypi. PlatformIO has got a proper copy of the 2.4.1 version of the core.
If the probklem is that the library needs ArduinoCore-mbed version 2.5.2, that's a problem that has to be solved in platform-raspberrypi. The latest version in the package repo is 2.4.1. I've opened issue https://github.com/platformio/platform-raspberrypi/issues/19 regarding this.
@maxgerhardt
Thanks, I still wonder why @ecosky doesn't have api
directory when he's using mbed_rp2040 core v2.4.1
Is it possible some more installation steps necessary to follow to get the Complete framework-arduino-mbed-2.4.1.tar.gz, with included api
to get the Complete framework-arduino-mbed-2.4.1.tar.gz, with included api
The file you linked to literally has the api
folder.
Yes, I know, that's why I wonder how can a normal user misses it in the PIO installation. Any special step users have to take?
Anyway, this is not my issue anymore.
When he said
I don't see that directory - could you please provide a more complete path? Perhaps I'm looking in the wrong place. Thanks!
He was probably looking for the Arduino IDE path, not the PlatformIO path C:\Users\<user>\.platformio\packages\framework-arduino-mbed\cores\arduino\api
. The folder should be there.
If so, he couldn't get compile error, such as
defines.h:372:10: fatal error: avr/pgmspace.h: No such file or directory
#include <avr/pgmspace.h>
Yes he can still get that compile error while having that file. I have that file too
but since the PlatformIO Arduino-mbed builder script does not add the folder to the include path in
the include error is presented.
I opened https://github.com/platformio/builder-framework-arduino-core-mbed/pull/1 to have that fixed.
This is the real solution, I think, which will finally fix for many other Arduino mbed cores (mbed_nano, mbed_portenta, mbed_rp2040)
Thanks.
With the PR merged and https://github.com/platformio/platform-raspberrypi/issues/20 closed I can now use the upstream version to compile the HelloServer example with
[env:nanorp2040connect]
platform = https://github.com/platformio/platform-raspberrypi.git
board = nanorp2040connect
framework = arduino
lib_deps =
khoih-prog/WiFiWebServer @ ^1.4.2
lib_ignore =
WiFi101
WiFiEspAT
WiFi
ESP_AT_Lib
and that works fine, no having to modify source code.
Linking .pio\build\nanorp2040connect\firmware.elf
Generating UF2 image
elf2uf2 ".pio\build\nanorp2040connect\firmware.elf" ".pio\build\nanorp2040connect\firmware.uf2"
Checking size .pio\build\nanorp2040connect\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [== ] 19.0% (used 51440 bytes from 270336 bytes)
Flash: [ ] 4.6% (used 96912 bytes from 2097152 bytes)
Building .pio\build\nanorp2040connect\firmware.bin
=================== [SUCCESS] Took 124.70 seconds ===================
I still have to lib_ignore
incorrect libraries which PlatformIO detects are "included" though, that's not so nice and also doesn't go away with lib_ldf_mode = chain+
. Not exactly sure why -- but at least compilation works with these extra options.
That's good news.
I still have to lib_ignore incorrect libraries which PlatformIO detects are "included" though, that's not so nice and also doesn't go away with lib_ldf_mode = chain+. Not exactly sure why -- but at least compilation works with these extra options.
Did you use the strict
in lib_compat_mode
?
; Checks for the compatibility with frameworks and dev/platforms
lib_compat_mode = strict
The library selection also must be enforced by checking WiFiWebServer.h#L128-L142 as this library is designed for many platforms and boards, there are too many WiFi libraries users can choose
// Modify to use new WiFiNINA_Generic library to support boards besides Nano-33 IoT, MKRWiFi1010, Adafruit MetroM4, etc.
#if USE_WIFI_NINA
#include <WiFiNINA_Generic.h>
//#include <WiFiNINA.h>
#warning Use WiFiNINA from WiFiWebServer
#elif USE_WIFI101
#include <WiFi101.h>
#warning Use WiFi101 from WiFiWebServer
#else
#if USE_WIFI_CUSTOM
#warning Use Custom WiFi for WiFiWebServer
#else
#include <WiFi.h>
#warning Use WiFi.h from WiFiWebServer
#endif
I guess if you can use the USE_WIFI_???
definition ( => #include <WiFi???.h>) into compiler script, it'll be better.
Line 149 of WiFiWebServer.h doesn't work with RP2040 Connect on PlatformIO, fix is simple, just add the !defined as shown below:
// KH, For PROGMEM commands // ESP32/ESP8266 includes by default, and memccpy_P was already defined there
if !(ESP32 || ESP8266) && !defined(ARDUINO_NANO_RP2040_CONNECT)
include <avr/pgmspace.h>
define memccpy_P(dest, src, c, n) memccpy((dest), (src), (c), (n))
endif
Thanks to maxgerhardt for the fix. More details on this over here, https://community.platformio.org/t/rp2040-connect-wifiwebserver-build-issues/23801/2