I am getting an error "util/delay.h not found" for Nano 33 BLE

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.

The readme of the library on GitHub doesn't mention the Nano 33 BLE under supported boards: GitHub - Marzogh/SPIMemory: Arduino library for Flash Memory Chips (SPI based only). Formerly SPIFlash
In fact, I believe the latest commit was before the release of the Nano 33 BLE.

Well then, are there any flash memory libraries that do work with Nano 33 ble?

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'm not really sure why that gives an error, the definition is right here: SPIMemory/SPIFlash.cpp at 1f1e4def16e0e06b033c50578a337bd804c66bd3 · Marzogh/SPIMemory · GitHub

Did you install the library correctly? Did you edit the file in the libraries folder or did you make a copy in you sketch folder?

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.

No, editing it in the libraries folder is the correct thing to do.

Edit: I just tried it myself, and the example compiles correctly for me. I'm using version 2.2.0 of the mbed_nano core.

It also gave an error on line 31

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.

Then this is probably different from the latest version on GitHub, try installing the master version instead.

That fixed it thank you very much.

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.

I'm sorry, I'm not familiar with the library.