platform-atmelsam icon indicating copy to clipboard operation
platform-atmelsam copied to clipboard

Nano 33 IOT Compilation Error "Missing SNU.h" using ArduinoIoTCloud

Open sankara opened this issue 3 years ago • 6 comments

I'm getting the following error while trying to compile my sketch which has a dependency on ArduinoIoTCloud. The library SNU is part of the core files at ArduinoCore-samd. I was able to workaround it by manually copying the library files to my local lib folder. I'm more than happy to help fix this if you could point me in the general direction of the issue.

[env:nano_33_iot]
platform = atmelsam
board = nano_33_iot
framework = arduino
In file included from .pio/libdeps/nano_33_iot/ArduinoIoTCloud/src/ArduinoIoTCloudTCP.cpp:31:0:
.pio/libdeps/nano_33_iot/ArduinoIoTCloud/src/utility/ota/OTA.h:29:12: fatal error: SNU.h: No such file or directory

*************************************************************
* Looking for SNU.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:SNU.h"
* Web  > https://platformio.org/lib/search?query=header:SNU.h
*
*************************************************************

   #include <SNU.h>
            ^~~~~~~
compilation terminated.
*** [.pio/build/nano_33_iot/libff9/ArduinoIoTCloud/ArduinoIoTCloudTCP.cpp.o] Error 1

sankara avatar Aug 31 '20 17:08 sankara

I just added ArduinoIoTCloud to my project and I am getting the same error when compiling from IDE. Library manager downloaded all deps required. I'll try doing what @sankara did to see if it would work.

nciric avatar Sep 13 '20 22:09 nciric

Actually, you need to update/install this target "Arduino SAMD Boards (32-bit ARM Cortex-M0+)" through "Board Manager..." menu in IDE. Once you do SNU.h will be where expected.

nciric avatar Sep 13 '20 22:09 nciric

Just had a very similar issue when working with the ArduinoMQQTClient and WiFiNINA libraries on the Nano33IoT. Wasn't able find Print.h for example.

In the PIO Home go to Platforms -> Updates and the make sure to update Arduino SAM libraries (and the others while you're at it).

chrisinabox avatar Apr 29 '21 14:04 chrisinabox

I'm using Arduino MKR Wifi 1010 and I'm having the same problem after using #include <ArduinoIoTCloud.h>. All platforms and libraries have been updated. I was able to fix this by adding #include <SNU.h> to my main.cpp.

As mentioned by @sankara, the SNU.h part of the core files at ArduinoCore-samd and I suspect that the problem is the way how SNU.h is included in OTA-samd.cpp:

#if OTA_STORAGE_SNU
#  include <SNU.h>
#  include <WiFiNINA.h> /* WiFiStorage */
#endif

According to the PIO docs for the Library Dependency Finder (LDF), by default #include statements inside .cpp files are not registered as a dependency, only in .h header files.

If the code above is moved to, for example, OTA.h, then the LDF picks it up and there are no missing dependencies.

What I'm wondering: if not inside OTA-samd.cpp, where should the code above be included? What are the best practices for declaring an #if X... #include Y.h statement like that in this context?

ghost avatar Aug 09 '21 15:08 ghost

i can confirm that compiling any code witch includes ArduinoIoTCloud inside of vsCode (using LDF) gives an error not finding SNU.h

hard work around is cuting out

#if OTA_STORAGE_SNU
#  include <SNU.h>
#  include <WiFiNINA.h> /* WiFiStorage */
#endif

and insering it inside of OTH.h in the include section

workheart avatar Nov 17 '21 20:11 workheart

I faced the same problem with an Arduino WiFi1010 when building my code: .pio\libdeps\mkrwifi1010\ArduinoIoTCloud\src\utility\ota\OTA-samd.cpp:31:12: fatal error: SNU.h: No such file or directory All platforms and libraries were updated and the error did not get solved. I followed what @mauedu wrote (i.e., by adding #include <SNU.h> to my main.cpp. ) and it worked.

alvarin32 avatar Aug 25 '22 16:08 alvarin32