SPIMemory library - Formerly SPIFlash - now supports SPI FRAM as well! :)

Marzogh you can probably update the compatibility tables. I haven't thoughly tested but it does seem to work just fine with Teensy 3.2 and Teensy LC.
I am also using the Adesto AT25SL641. Which won't be very popular at 1.8v but it passed all checks with the LC and works perfectly.

@jacky4566: Thanks for the heads up. Its good to know its working with the Teensys and with the AT25SL641. Have you had to make any mods to get the library to run on the Teensy?

Marzogh:
@jacky4566: Thanks for the heads up. Its good to know its working with the Teensys and with the AT25SL641. Have you had to make any mods to get the library to run on the Teensy?

No mods. Using default SPI pins since its a custom board I cant really test the alternate pins. CPU clock 48MHz, SPI clock speed 12MHz. Power down works fine as well.

Any chance you will support CY15B104Q 4Mbit FRAM, I have one and have never got it working.

Thanks and Regards

I have been able to run the FlashDiagnostics on the Sparkfun RedBoard Turbo. A M0 processor with W25Q32BV 32M-Bit Winbond memory chip. I had to modify the variant.h and variant.cpp files as Sparkfun had omitted to include Arduino access for the on board SPImemory.

I have posted details of the edits and a copy of the output obtained on the Sparkfun forum:

https://forum.sparkfun.com/viewtopic.php?f=145&t=49805

Thanks for the library
Ted

@tfcroft4 Thank you for the heads up :slight_smile: I'm glad the library works for you :grin:

@BobTrex I add support for ICs based on the ones I can get my hands on. Please raise an 'feature request' issue on Github for support for this chip and I'll put it into the pipeline :slight_smile:

Just pushed an update through to v3.4.0 with the following changes:

Bugs squashed:

  • FastRead works properly now. All previous versions of the library has a FastRead bug that prevent it from doing what it was supposed to.

Enhancements:

-An alternate version of the constructor SPIFlash flash(int8_t *SPIPinsArray); can be used (only with ESP32 boards as of now) to enable the use of custom SPI pins. SPIPinsArray has to be a 4 element array containing the custom SPI pin numbers (as signed integers - int8_t) in the following order - sck, miso, mosi, ss. Refer to the wiki for more information. Resolves issue #113

  • Created new error code NOCHIPSELECTDECLARED for errors with declaring custom SPI pins.

  • Using other SPI ports (HSPI, VSPI, SPI1, SPI2 etc.) is now also supported on ESP32 boards - along with SAMD and STM32 boards (supported since v3.0.0). Resolves issue #177

  • The new version changes the way [setClock()](http://(Library instantiation functions ยท Marzogh/SPIMemory Wiki ยท GitHub) works and allows for the definition of clock speed before the SPI Bus is instantiated. Refer to wiki for further details. Thanks @rambo.(PR #156)

  • Reduce SRAM footprint when running Diagnostics.ino. Thanks @rambo

  • Officially supports the ESP32 (tested on the ESP32 Feather)

  • Now supports FRAM memory chips via the SPIFram constructor

  • Changed Diagnostics output in _chipID() to match situation better.

  • Fixed _chipID() to run more efficiently.

New ยตCs supported:

  • nRF52832 ARM Cortex M4F (Adafruit nRF52 Feather)
  • STM32L0 ARM Cortex M0+ (Nucleo-L031K6)

New flash memory chips supported:

  • MX25L4005 & MX25L4005 from Macronix

Work on proper documentation continues. As polaroi8d pointed out here, the old ReadMe was getting far too unwieldy and the Github Wiki is not the easiest thing to poke around. I hope to have the documentation done soon - (Rst + Sphinx). Check out the progress of the documentation here! Any recommendations are welcome 8)

Hi There
I'm in the process of designing a shield for an Arduino Due. and unfortunately after all our PCBs have been
manufactured I was shocked to find the Due has no EEPROM (I only need 90 bytes). Thats fine I thought, we
have plenty of SPI flash chips in the factory I can use.... only to notice the "4" SPI units the Due is supposed to have. One is connected to a silly header with 5V (instead of 3.3). I have to get my SPI working over some
pins that are actually on the regular pins. and I found the second SPI is only on the BGA version of the micro.
So I asked what about the other 2? Does your library support using the USARTs in SPI mod? and if so how?

Hi,

I didn't manage to make this library work on a NodeMCU v1.0 board, it uses an ESP12 (ESP8266 + 32Mbit Flash)). I don't understand as it's supposed to work with an Adafruit Feather HUZZAH board which is uses an ESP12 too.
I'm using the TestFlash example to test.
First I have to force the SPI to SPI_PINS_HSPI_OVERLAP mode, otherwise I get a watchdog reset.
Why is the SPI frequency set to 104 Mhz by default ? The Winbond-W25Q32 chip is not supposed to work above 80 MHz and the SPI library uses 40 Mhz...
The CS signal set to pin GPIO15 for the ARDUINO_ARCH_ESP8266, which is correct for user SPI, but on an ESP12 the SPI0 must be used (SPI_PINS_HSPI_OVERLAP mode), which has CS on GPIO11. When I try to change CS to 11 I get a watchdog reset.
I tried to access the flash directly without your library by trying to read Jedec ID, I can get all the signals correct (I think) except the SDIO_DATA3 (GPIO10) signal which is kept low, thus disabling the flash (this signal is connected to HOLD pin on the flash chip.
I compared to the signals I have when I call the SDK function spi_flash_get_id() (which works). If I try to force the SDIO_DATA3 (GPIO10) signal high in the code, I get a watchdog reset.
I've tried to post on the Espressif forum to ask for help, but after a few days my message has still not been validated by moderator...

I really don't know what to do now.

Cheetor:
Hi There
I'm in the process of designing a shield for an Arduino Due. and unfortunately after all our PCBs have been
manufactured I was shocked to find the Due has no EEPROM (I only need 90 bytes). Thats fine I thought, we
have plenty of SPI flash chips in the factory I can use.... only to notice the "4" SPI units the Due is supposed to have. One is connected to a silly header with 5V (instead of 3.3). I have to get my SPI working over some
pins that are actually on the regular pins. and I found the second SPI is only on the BGA version of the micro.
So I asked what about the other 2? Does your library support using the USARTs in SPI mod? and if so how?

Hi Cheetor, The short answer is, I'm afraid not. Sorry. :frowning: The latest version (3.4.0) does let you switch between existing SPI interfaces, so perhaps that might be helpful.

Hi Etienne, let me try to answer your questions in order:

  • I can access the built-in flash on the ESP12 module in the Huzzah without any issues.
  • Use FlashDiagnostics to test - its cleaner and runs with less of a memory footprint than TestFlash
  • The SPI frequency is not set to 104 MHz. Its set to operate unto a maximum of 104 MHz.
  • You don't need to force the SPI to SPI0 by any method outside the library. If you look at the ReadMe file that comes with the library, under the usage section, you'll see the following note about how to use a non-default SPI interface.

Every version of the library >= v3.0.0 supports the ability to use any of multiple SPI interfaces (if your micro-controller supports them). Switching to use another SPI interface is done by calling SPIFlash flash(csPin, &SPI1); (or &SPI2 and so on), instead of SPIFlash flash(csPin)[/u]

HI! I'm using SPIMemory to work with board Heltec Wifi Kit 32(pinout WiFi_Kit_series/WIFI Kit 32.pdf at master ยท Heltec-Aaron-Lee/WiFi_Kit_series ยท GitHub) + Winbond w25q128jvsq (installed on board), and allways, in all samples i can't see this flash

Init class:

SPIFlash flash(5);

Output:

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:928
ho 0 tail 12 room 4
load:0x40078000,len:8516
load:0x40080400,len:5816
entry 0x4008069c
Initialising..........

SPIMemory Library version: < 2.5.0

No comms. Check wiring. Is chip supported? If unable to fix, raise an issue on Github

What i'm doing wrong?

P.S. Sorry for my english

Hi,
I'm trying to use SPIMemory with FM25L16-G and get get understanding how to change defines to successfully work with examples. I need a little guide through there. I'm using ATMega 2560.
Thank in advance.

Hi everyone,

first: thank you to everyone for all your great work, I would have given up on so many things if it wasn't for you.

I have a Sparkfun Redboard Turbo, and I can use SPIMemory up until version 3.3, with some changes in the variant.h file and the diagnostics.cpp (all thanks to replies in this thread).
For some reason, it won't work with the newest version of SPIMemory though. If I run FlashDiagnostics, it says the wiring is wrong. Am I doing something wrong?

Also, with the older library versions that I use, when I use flash.writeStr(), and the string is longer than 255 bytes, my code hangs at the write command. I use the readWriteString example.

If I then reset my board after trying to write a much longer string with flash.writeStr(), and just use flash.readStr(), it reads the whole, longer string. So the writeStr command actually does write the longer string to flash, but for some reason it hangs after or when it does it.

I hope someone can help me fix the writeStr :slight_smile: so I can write my long string to flash.

Thanks!

Hi,

Are there any plans to add support for SPI NAND flash chips?

Steve

Hi,

I tried with STM32F103C8T6 SPI port 2, but it didn't work, maybe someone can compare the code with the SdFat library, because SdFat already provides for use with SPI2 port:

// Use second SPI port
SPIClass SPI_2(2);
SdFat sd2(&SPI_2);

Source: https://github.com/greiman/SdFat/blob/master/examples/STM32Test/STM32Test.ino

Hi Marzogh,
great job indeed, Kudos!

I would like to use it with a STM32 Nucleo Board, which would support Dual SPI. Does your library support such a configuration?

Thanks
Best
Mirco

Hello,

This library SPIMemory can be very useful for saving RAM and Flash memory space, but if you want to use a more powerful microcontroller like STM32, and have greater compatibility with an SD card, you might want to look at this other library:

Here is an example of using a W25Q64 Flash being accessed like a USB stick:

[Blue Pill STM32F103C8T6] USB Mass Storage Flash W28Q64 (Like a SD card Reader)

https://forum.arduino.cc/index.php?topic=637442.0

"P.S. Example above uses second SPI port, but you can use another port"

Thanks a lot @rtek1000, i will look into this new possibility.

Regards

is it possible to write files on an spi flash module with an W25Q64 ?