I am trying to run the FlashDiagnostics.ino sketch from the SPIMemory library version 3.4.0 on an Arduino Nano 33 BLE Sense. However, I encounter the error below. The Nano 33 BLE uses an nRF52 chip, but util/delay.h only works for AVR boards. However, SPIMemory says it supports the Nano 33 BLE.
Can I go into SPIMemory.h and comment out this #include or is there something else I can do? There is no util/delay.h file in SPIMemory. I would have expected it to install there.
On a side note, I intend to use the SPI IS25LP064A-JBLE flash chip. I am unsure whether this library supports that.
Thank you for any help.
C:\Users\Documents\Arduino\libraries\SPIMemory\examples\FlashDiagnostics\FlashDiagnostics.ino:18:0:
C:\Users\Documents\Arduino\libraries\SPIMemory\src/SPIMemory.h:114:12: fatal error: util/delay.h: No such file or directory
#include <util/delay.h>
^~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Nano 33 BLE.
I suspect that the table on SPIMemory - Arduino Reference is automatically generated based on the values in the libraries.properties file, it doesn't tell you much.
If you add || defined(ARDUINO_ARCH_NRF52840) to this line
it should no longer complain about the missing header.
In fact, it might be a better idea to just invert the logic and use #ifndef __AVR__ ...
There could be other issues, of course, but given that the library supports so many platforms, I don't think it's going to be too hard to port this to the Nano 33 BLE.
I added that line to the header file, and it no longer complains about util/delay.h. However, I am getting an error for this:
C:\Users\User\AppData\Local\Temp\arduino_modified_sketch_859549/FlashDiagnostics.ino:42: undefined reference to `SPIFlash::SPIFlash(unsigned char)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Nano 33 BLE.
SPIFlash flash;
//SPIFlash flash(SPIPins);
//SPIFlash flash(33);
//SPIFlash flash(SS1, &SPI1); //Use this constructor if using an SPI bus other than the default SPI. Only works with chips with more than one hardware SPI bus
Here is the code from line 42 which I believe the error is referring to.
I downloaded the library from arduino's library manager. The SPIFlash.cpp line 42 is correct, and I did not edit it. I did edit the SPIMemory.h in the libraries folder. Should I undo that and make a copy for the sketch folder? Although the sketch FlashDiagnostics.ino is also in the libraries folder as an example sketch.
C:\Users\User\AppData\Local\Temp\arduino_modified_sketch_657669\FlashDiagnostics.ino: In function 'void setup()':
FlashDiagnostics:31:17: error: 'PA0' was not declared in this scope
#define RANDPIN PA0
^
C:\Users\User\AppData\Local\Temp\arduino_modified_sketch_657669\FlashDiagnostics.ino:61:25: note: in expansion of macro 'RANDPIN'
randomSeed(analogRead(RANDPIN));
^~~~~~~
C:\Users\User\AppData\Local\Temp\arduino_modified_sketch_657669\FlashDiagnostics.ino:31:17: note: suggested alternative: 'A0'
#define RANDPIN PA0
^
C:\Users\User\AppData\Local\Temp\arduino_modified_sketch_657669\FlashDiagnostics.ino:61:25: note: in expansion of macro 'RANDPIN'
randomSeed(analogRead(RANDPIN));
^~~~~~~
exit status 1
'PA0' was not declared in this scope
The error suggests switching it to A0, and that does get rid of the issue. Not sure if this is what is leading to the error on line 42.
Sorry to bother you again, but the sketch runs an error in the serial monitor telling me that the nano and flash chip failed to communicate. I am not sure what this could be other than the library not being able to work with the nano. The flash chip is supported by the library.