I'm trying to use the SPIMemory library (GitHub - Marzogh/SPIMemory: Arduino library for Flash Memory Chips (SPI based only). Formerly SPIFlash) to access the on-board 4MB flash memory on an Adafruit ESP32 Feather board (HUZZAH32, built around the WROOM32 module). The library provides a simple interface to the flash memory.
To get started, I have a little sketch that calls the constructor for the library, then the begin command, and then writing a byte and reading it back.
#include <SPIMemory.h>
int8_t flargs[4] = {31,32,33,30}; //sck, miso, mosi, ss
SPIFlash flash;
void setup() {
Serial.begin(115200);
// Initialize SPI Flash
if (!flash.begin(MB(4)))
Serial.printf ("initializing flash failed\n");
else
Serial.printf ("initializing flash capacity %x\n", flash.getCapacity());
if (flash.error())
Serial.println(flash.error(VERBOSE));
// write a byte and then read it back
uint32_t flash_addr = 0x0100;
uint8_t tmpvalin = 0x5c, tmpvalout = 0x00;
flash.writeByte (flash_addr, tmpvalin);
flash.readByte (flash_addr, tmpvalout);
Serial.printf ("after write and readback tmpval = %x\n", tmpvalout);
}
void loop() {
}
I'm getting this error:
"Unable to identify chip. Are you sure this chip is supported?"
From the sparse library documentation, it appears the ESP32 should be supported (though perhaps beta). But it's unclear what the arguments (if any) should be to the SPIFlash constructor. I don't understand this cryptic note: "ESP32 boards usually have an SPI Flash already attached to their default SS pin, so the user has to explicitly declare the ChipSelect pin being used with the constructor". I've tried no argument (as in the above code), and various choices for the chip-select pin. There's also mention of using a 4-element array (containing the SPI pin numbers) as the argument (flargs in my code). But it's unclear if this refers to pin numbers of the ESP32 chip or of the WROOM32 module. But no matter what I try, I keep getting the above error.
There is no response at the github repository or the Adafruit forum. And this extensive document has also not yielded a solution: https://spimemory.readthedocs.io/_/downloads/en/latest/pdf/
There's also quite a bit of discussion in this thread, including where the authors claims to have made it work on ESP32 Feather boards: SPIMemory library - Formerly SPIFlash - now supports SPI FRAM as well! :) - #166 by Marzogh