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

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

Enhancements:

  • The library now gathers sfdp information through _chipID(). SFDP information is collected when available, otherwise the library defaults to using code from v3.1.0 to ID the chip.
  • The library now does the following - if the flash memory chip is compatible with the SFDP standard
  • Identifies the flash memory chip using the Serial Flash Discoverable Parameters standard. (JESD216B)
  • Identifies the following opcodes from the SFDP tables and uses them to read/write data:
  • eraseSector, eraseBlock32K, eraseBlock64K
  • Reads timing information from SFDP to accurately time the following operations:
  • eraseSector, eraseBlock32K, eraseBlock64K

New flash memory chips supported:

  • All flash memories compatible with the SFDP standard (as at JESD216B) should be compatible with the library

  • LE25U40CMC from ON Semiconductor

  • A25L512A0 from AMIC

  • M25P40 from Micron

  • AT25SF041 from Adesto

  • S25FL032P from Cypress/Spansion

New Microcontrollers supported:

  • ATSAMD51J19 ARM Cortex M4 (Adafruit Metro M4)

I've started work on proper documentation. 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. By the time the next release rolls around I hope to have the documentation done - (Rst + Sphinx). Check out the progress of the documentation here! Any recommendations are welcome 8)

Hi Marzogh

Did you received your JV series.
I am using W25Q64JV and i updated the library 3.2.0.
But library gives Error code: 0x0B

Thanks
Ergun

Marzogh:
Hi mate,

Thanks for the heads up. I've got some JV series coming in from AliExpress, but this being AliExpress, they're probably a month or so away form getting to me in Australia. :confused:

I'll see if I can figure out what's going wrong (in theory) by looking at the timing on the datasheet and get back to you as soon as I can.

The current release version is v3.0.1 and that's what is available from the library manager. I'm still testing v3.1.0 is all platforms that library supports and should hopefully have it out before this week ends.

Feel free to pull down a zip of the development branch to test with your hardware. The code is pretty much good to go and just needs some battle testing before I sign off on a release.

If you are looking at using filesystems, Adafruit's SPI Flash library has quite good filesystem support with the ability to mount the chip up as a mass storage device. However, this is something I've only ever played around with on the M0 Express line of boards and I don't know how it works (or if it does) outside of the M0 / SAMD21 line.

I would like to - someday incorporate a filesystem into my library, but I have two problems with that:

  • I have no idea how filesystems work, much less how to implement one on the Arduino platform :stuck_out_tongue:
  • My main aim with this library has been to get it to work as fast as it can while maintaining read/write integrity. AFAIK, putting a filesystem in there reduces this speed enormously.

I use the library with my environmental sensor units as a way of storing lots of data as (byte arrays) on an SPI Flash chip. When it fills up I write all of that data to an SD card in one go. This saves a ton of power when you have a low-power environmental sensing / logging system deployed in remote areas for extended periods of time. I borrowed this idea from EKMallon's fantastic Cave Pearl project. He uses EEPROMs to buffer data but I've found that using SPI Flash in combination with an SD card works equally well - especially when I use a TPL5110 timer to cut power to the entire system when it doesn't need to be operational. :slight_smile:

Hi Ergun,

As I replied on your bug report on Github, I have received my W25Q64JV and tested it with v3.1.0 & with v3.2.0 and they work fine - no errors thrown at all. Could you please respond to my reply there?

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

Bugs squashed:

  • Fixes issue #135 : The addition of the SFDP checking to _chipID resulted in a sudden (very large) increase in compiled code size. As of the current version (v3.2.1), SFDP checking is an user controlled option. To get the library to work with SFDP compatible flash memory (that might not be officially supported), the user must uncomment '//#define USES_SFDP' in 'SPIMemory.h'.

  • Moved bool _loopedOver from being a local variable in getAddress() to a global one. Now it actually does what it was meant to do - i.e. prevent looping over data a second time.

Enhancements:

  • As of v3.2.1, SFDP parameter discovery is an user controlled option. To get the library to work with SFDP compatible flash memory chips that are not officially supported by the library, the user must uncomment '//#define USES_SFDP' in 'SPIMemory.h'.
  • The way the basic functions execute has been modified to keep the function runtime the same (or improved) while reducing their memory footprint.

Test sketch - FlashDiagnostics.ino from v3.2.0 with #RUNDIAGNOSTIC commented out
Test platform - Arduino Pro Mini 8MHz 3.3V

Library version Compiled code size SFDP discovery % Difference from v3.1.0
v3.1.0 17652 bytes Not supported 0%
v3.2.0 20104 bytes Supported & enabled by default +13.9%
v3.2.1 17854 bytes Supported & enabled +1.1%
v3.2.1 15316 bytes Supported & disabled -13.75%

(Low-priority / Feature request)

Not sure if this has been entertained before and dismissed for some reason, but: It would be cool if the library API explicitly supported sequential access. E.g. readNextByte() or similar. It seems that most (all?) of these devices auto-increment addresses following accesses, meaning that they're optimized for sequential access. Meanwhile, the library steers you toward random access, which is kind of worst-case scenario. Supporting random access is fine, of course, but supporting and documenting the access pattern that the hardware is actually designed for seems important too. Otherwise, people who need to stream bytes from memory are going to do things like readByte(addr++) and be severely punished for it when the library does 4x as many transfers as necessary.

Hi Marzogh,

I've problems with reading and writing to SST26VF064B from Microchip.

I'm using a SAMD21 sparkfun mini breakout.

If I run the sketch "FlashDiagnostics" the chip is recognized and I get the following output:
SPIMemory Library version: 3.2.1

JEDEC ID: 0xBE5237
Man ID: 0xBE
Memory ID: 0x52
Capacity: 0
Max Pages: 0


Testing library code

Function Test result Runtime

Power Down FAIL Not all chips support power down. Check your datasheet.
Power Up PASS 0 us

Erase Chip PASS 0 us
Erase 72KB FAIL
Erase 64KB FAIL
Erase 32KB FAIL
Erase 4KB FAIL

Data type I/O Result Write time Read time

Byte FAIL 0 us
Char FAIL 0 us
Word FAIL 0 us
Short FAIL 0 us
ULong FAIL 0 us
Long FAIL 0 us
Float FAIL 0 us
Struct FAIL 0 us
Byte Array FAIL 0, FAIL 1, FAIL 2, FAIL 3, FAIL 4, FAIL 5, FAIL 6, FAIL 7, FAIL 8, FAIL 9, FAIL 10, FAIL 11, FAIL 13, FAIL 14, FAIL 15, FAIL 16, FAIL 17, FAIL 18, FAIL 19, FAIL 20, FAIL 21, FAIL 22, FAIL 23, FAIL 24, FAIL 25, FAIL 26, FAIL 27, FAIL 28, FAIL 29, FAIL 30, FAIL 31, FAIL 32, FAIL 33, FAIL 34, FAIL 35, FAIL 36, FAIL 37, FAIL 38, FAIL 39, FAIL 40, FAIL 41, FAIL 42, FAIL 43, FAIL 44, FAIL 45, FAIL 46, FAIL 47, FAIL 48, FAIL 49, FAIL 50, FAIL 51, FAIL 52, FAIL 53, FAIL 54, FAIL 55, FAIL 56, FAIL 57, FAIL 58, FAIL 59, FAIL 60, FAIL 61, FAIL 62, FAIL 63, FAIL 64, FAIL 65, FAIL 66, FAIL 67, FAIL 68, FAIL 69, FAIL 70, FAIL 71, FAIL 72, FAIL 73, FAIL 74, FAIL 75, FAIL 76, FAIL 77, FAIL 78, FAIL 79, FAIL 80, FAIL 81, FAIL 82, FAIL 83, FAIL 84, FAIL 85, FAIL 86, FAIL 87, FAIL 88, FAIL 89, FAIL 90, FAIL 91, FAIL 92, FAIL 93, FAIL 94, FAIL 95, FAIL 96, FAIL 97, FAIL 98, FAIL 99, FAIL 100, FAIL 101, FAIL 102, FAIL 103, FAIL 104, FAIL 105, FAIL 106, FAIL 107, FAIL 108, FAIL 109, FAIL 110, FAIL 111, FAIL 112, FAIL 113, FAIL 114, FAIL 115, FAIL 116, FAIL 117, FAIL 118, FAIL 119, FAIL 120, FAIL 121, FAIL 122, FAIL 123, FAIL 124, FAIL 125, FAIL 126, FAIL 127, FAIL 128, FAIL 129, FAIL 130, FAIL 131, FAIL 132, FAIL 133, FAIL 134, FAIL 135, FAIL 136, FAIL 137, FAIL 138, FAIL 139, FAIL 140, FAIL 141, FAIL 142, FAIL 143, FAIL 144, FAIL 145, FAIL 146, FAIL 147, FAIL 148, FAIL 149, FAIL 150, FAIL 151, FAIL 152, FAIL 153, FAIL 154, FAIL 155, FAIL 156, FAIL 157, FAIL 158, FAIL 159, FAIL 160, FAIL 161, FAIL 162, FAIL 163, FAIL 164, FAIL 165, FAIL 166, FAIL 167, FAIL 168, FAIL 169, FAIL 170, FAIL 171, FAIL 172, FAIL 173, FAIL 174, FAIL 175, FAIL 176, FAIL 177, FAIL 178, FAIL 179, FAIL 180, FAIL 181, FAIL 182, FAIL 183, FAIL 184, FAIL 185, FAIL 186, FAIL 187, FAIL 188, FAIL 189, FAIL 190, FAIL 191, FAIL 192, FAIL 193, FAIL 194, FAIL 195, FAIL 196, FAIL 197, FAIL 198, FAIL 199, FAIL 200, FAIL 201, FAIL 202, FAIL 203, FAIL 204, FAIL 205, FAIL 206, FAIL 207, FAIL 208, FAIL 209, FAIL 210, FAIL 211, FAIL 212, FAIL 213, FAIL 214, FAIL 215, FAIL 216, FAIL 217, FAIL 218, FAIL 219, FAIL 220, FAIL 221, FAIL 222, FAIL 223, FAIL 224, FAIL 225, FAIL 226, FAIL 227, FAIL 228, FAIL 229, FAIL 230, FAIL 231, FAIL 232, FAIL 233, FAIL 234, FAIL 235, FAIL 236, FAIL 237, FAIL 238, FAIL 239, FAIL 240, FAIL 241, FAIL 242, FAIL 243, FAIL 244, FAIL 245, FAIL 246, FAIL 247, FAIL 248, FAIL 249, FAIL 250, FAIL 251, FAIL 252, FAIL 253, FAIL 254, FAIL 255, PASS 0 us
String FAIL 0 us

Could you give me a hint, what to do/test?

Getting a similar result with the Adafruit feather SAMD and a 16MB Microchip SST26. Seems like it can erase and read, but not write. Any suggestions?

I also swapped to another 16MB Microchip SST26 with the same result.

Initialising..........

SPIMemory Library version: 3.2.1

JEDEC ID: 0xBF2641
Man ID: 0xBF
Memory ID: 0x26
Capacity: 16777216
Max Pages: 4294967295

-----------------------------------------------------------------------------------------------------------------------------
Testing library code
-----------------------------------------------------------------------------------------------------------------------------
Function Test result     Runtime
-----------------------------------------------------------------------------------------------------------------------------
Power Down   FAIL Not all chips support power down. Check your datasheet.
Power Up   PASS      0 us

Erase Chip   PASS      0 us
Erase 72KB   PASS      0 us
Erase 64KB   PASS      0 us
Erase 32KB   PASS      0 us
Erase 4KB   PASS      0 us
-----------------------------------------------------------------------------------------------------------------------------
Data type I/O Result      Write time      Read time
-----------------------------------------------------------------------------------------------------------------------------
Byte   FAIL      0 us
Char   FAIL      0 us
Word   FAIL      0 us
Short   FAIL      0 us
ULong   FAIL      0 us
Long   FAIL      0 us
Float   FAIL      0 us
Struct   FAIL      0 us
Byte Array   FAIL 0,   FAIL 1,   FAIL 2,   FAIL 3,   FAIL 4,   FAIL 5,   FAIL 6,   FAIL 7,   FAIL 8,   FAIL 9,   FAIL 10,   FAIL 11,   FAIL 12,   FAIL 13,   FAIL 14,   FAIL 15,   FAIL 16,   FAIL 17,   FAIL 18,   FAIL 19,   FAIL 20,   FAIL 21,   FAIL 22,   FAIL 23,   FAIL 24,   FAIL 25,   FAIL 26,   FAIL 27,   FAIL 28,   FAIL 29,   FAIL 30,   FAIL 31,   FAIL 32,   FAIL 33,   FAIL 34,   FAIL 35,   FAIL 36,   FAIL 37,   FAIL 38,   FAIL 39,   FAIL 40,   FAIL 41,   FAIL 42,   FAIL 43,   FAIL 44,   FAIL 45,   FAIL 46,   FAIL 47,   FAIL 48,   FAIL 49,   FAIL 50,   FAIL 51,   FAIL 52,   FAIL 53,   FAIL 54,   FAIL 55,   FAIL 56,   FAIL 57,   FAIL 58,   FAIL 59,   FAIL 60,   FAIL 61,   FAIL 62,   FAIL 63,   FAIL 64,   FAIL 65,   FAIL 66,   FAIL 67,   FAIL 68,   FAIL 69,   FAIL 70,   FAIL 71,   FAIL 72,   FAIL 73,   FAIL 74,   FAIL 75,   FAIL 76,   FAIL 77,   FAIL 78,   FAIL 79,   FAIL 80,   FAIL 81,   FAIL 82,   FAIL 83,   FAIL 84,   FAIL 85,   FAIL 86,   FAIL 87,   FAIL 88,   FAIL 89,   FAIL 90,   FAIL 91,   FAIL 92,   FAIL 93,   FAIL 94,   FAIL 95,   FAIL 96,   FAIL 97,   FAIL 98,   FAIL 99,   FAIL 100,   FAIL 101,   FAIL 102,   FAIL 103,   FAIL 104,   FAIL 105,   FAIL 106,   FAIL 107,   FAIL 108,   FAIL 109,   FAIL 110,   FAIL 111,   FAIL 112,   FAIL 113,   FAIL 114,   FAIL 115,   FAIL 116,   FAIL 117,   FAIL 118,   FAIL 119,   FAIL 120,   FAIL 121,   FAIL 122,   FAIL 123,   FAIL 124,   FAIL 125,   FAIL 126,   FAIL 127,   FAIL 128,   FAIL 129,   FAIL 130,   FAIL 131,   FAIL 132,   FAIL 133,   FAIL 134,   FAIL 135,   FAIL 136,   FAIL 137,   FAIL 138,   FAIL 139,   FAIL 140,   FAIL 141,   FAIL 142,   FAIL 143,   FAIL 144,   FAIL 145,   FAIL 146,   FAIL 147,   FAIL 148,   FAIL 149,   FAIL 150,   FAIL 151,   FAIL 152,   FAIL 153,   FAIL 154,   FAIL 155,   FAIL 156,   FAIL 157,   FAIL 158,   FAIL 159,   FAIL 160,   FAIL 161,   FAIL 162,   FAIL 163,   FAIL 164,   FAIL 165,   FAIL 166,   FAIL 167,   FAIL 168,   FAIL 169,   FAIL 170,   FAIL 171,   FAIL 172,   FAIL 173,   FAIL 174,   FAIL 175,   FAIL 176,   FAIL 177,   FAIL 178,   FAIL 179,   FAIL 180,   FAIL 181,   FAIL 182,   FAIL 183,   FAIL 184,   FAIL 185,   FAIL 186,   FAIL 187,   FAIL 188,   FAIL 189,   FAIL 190,   FAIL 191,   FAIL 192,   FAIL 193,   FAIL 194,   FAIL 195,   FAIL 196,   FAIL 197,   FAIL 198,   FAIL 199,   FAIL 200,   FAIL 201,   FAIL 202,   FAIL 203,   FAIL 204,   FAIL 205,   FAIL 206,   FAIL 207,   FAIL 208,   FAIL 209,   FAIL 210,   FAIL 211,   FAIL 212,   FAIL 213,   FAIL 214,   FAIL 215,   FAIL 216,   FAIL 217,   FAIL 218,   FAIL 219,   FAIL 220,   FAIL 221,   FAIL 222,   FAIL 223,   FAIL 224,   FAIL 225,   FAIL 226,   FAIL 227,   FAIL 228,   FAIL 229,   FAIL 230,   FAIL 231,   FAIL 232,   FAIL 233,   FAIL 234,   FAIL 235,   FAIL 236,   FAIL 237,   FAIL 238,   FAIL 239,   FAIL 240,   FAIL 241,   FAIL 242,   FAIL 243,   FAIL 244,   FAIL 245,   FAIL 246,   FAIL 247,   FAIL 248,   FAIL 249,   FAIL 250,   FAIL 251,   FAIL 252,   FAIL 253,   FAIL 254,   PASS      0 us
String   FAIL      0 us

Im using this library for ESP8266 nodemcu with winbond external flash w25q32f but im frequently faced WDT reset. what should i do..? please help me

Hi guys,

My apologies for the long delay in replying. I was away for health reasons and am slowly transitioning back into normality.

@walterpre & @BigEyetuna The problem with the SST26 series is top priority and I will try and get this sorted within a week and keep you posted here.

@siva_iot I find that WDT reset usually happens when your code does not allow the ESP8266 to carry out essential background functions. make sure you have enough delay() statements at the right places in your code. the delay() function in the ESP8266 is different to the normal one used for ATmega or ARM boards and lets background processes run while waiting for user code to execute.

@jaholmes The simplest way would be to use the built in readByteArray()/writeByteArray() or readCharArray()/writeCharArray() functions. They let you define the size of the block of data you want read/written - sequentially - and are very fast.

@walterpre & @BigEyetuna This issue has been addressed with the code in the development branch on GitHub. I will roll these changes into the next release of the library

hello @Marzogh.

Im having some issues with the SPImemory library, specifically it doesn't work.

Hardware:
Adafruit Feather adalogger
W25Q64JV

Wiring:
1cs ----> pin11
2DO ----> MISO
3WP ----> VCC 3.3v
4GND ----> GND
5DI ----> MOSI
6CLK ----> SCK
7HOLD ----> VCC 3.3v
8VCC ----> VCC 3.3v

FlashDiagnostics line 40 has been changed to:
SPIFlash flash(11);

I have some very basic code which works fine to manually handle reading and writing to the flash chip so I know it is not a hardware or wiring issue, but I would like to implement your library since it seems to work so well for others. I have tried version 3.2.1 and 3.2.0 to no avail.

Obviosuly it thinks the chip is not powered on so all of the other tests will fail.

getAddressex only returns the serial.print lines with blank spaces (0s?)where values should be.

Any help is appreciated.

The output is below

Initialising..........
Chip Diagnostics initiated.

Unable to identify chip. Are you sure this chip is supported?
Chip details:
If this does not help resolve/clarify this issue, please raise an issue at http://www.github.com/Marzogh/SPIMemory/issues with the details of what your were doing when this error occurred

SPIMemory Library version: 3.2.1

JEDEC ID: 0x8FFF8F
Man ID: 0x8F
Memory ID: 0xFF
Capacity: 0
Max Pages: 0

-----------------------------------------------------------------------------------------------------------------------------
 Testing library code
-----------------------------------------------------------------------------------------------------------------------------
 Function Test result     Runtime
-----------------------------------------------------------------------------------------------------------------------------
 Power Down   PASS      66 us
 Power Up   FAIL 

 Erase Chip The Flash chip is currently powered down.
   FAIL 
 Erase 72KB The Flash chip is currently powered down.
   FAIL 
 Erase 64KB The Flash chip is currently powered down.
   FAIL 
 Erase 32KB The Flash chip is currently powered down.
   FAIL 
 Erase 4KB The Flash chip is currently powered down.
   FAIL 
-----------------------------------------------------------------------------------------------------------------------------
 Data type I/O Result      Write time      Read time
-----------------------------------------------------------------------------------------------------------------------------
The Flash chip is currently powered down.
The Flash chip is currently powered down.
 Byte   FAIL 0 us 4.251 s
The Flash chip is currently powered down.
The Flash chip is currently powered down.
 Char   FAIL 0 us 4.292 s
The Flash chip is currently powered down.
The Flash chip is currently powered down.
 Word   FAIL 0 us 4.333 s
The Flash chip is currently powered down.
The Flash chip is currently powered down.
 Short   FAIL 0 us 4.374 s
The Flash chip is currently powered down.
The Flash chip is currently powered down.
 ULong   FAIL 0 us 4.415 s
The Flash chip is currently powered down.
The Flash chip is currently powered down.
 Long   FAIL 0 us 4.456 s
The Flash chip is currently powered down.
The Flash chip is currently powered down.
 Float   FAIL 0 us 4.497 s
The Flash chip is currently powered down.
The Flash chip is currently powered down.
 Struct   FAIL 0 us 4.539 s
The Flash chip is currently powered down.
The Flash chip is currently powered down.
 Byte Array   FAIL 0,   FAIL 1,   FAIL 2,   FAIL 3,   FAIL 4,   FAIL 5,   FAIL 6,   FAIL 7,   FAIL 8,   FAIL 9,   FAIL 10,   FAIL 11,   FAIL 12,   FAIL 13,   FAIL 14,   FAIL 15,   FAIL 16,   FAIL 17,   FAIL 18,   FAIL 19,   FAIL 20,   FAIL 21,   FAIL 22,   FAIL 23,   FAIL 24,   FAIL 25,   FAIL 26,   FAIL 27,   FAIL 28,   FAIL 29,   FAIL 30,   FAIL 31,   FAIL 32,   FAIL 33,   FAIL 34,   FAIL 35,   FAIL 36,   FAIL 37,   FAIL 38,   FAIL 39,   FAIL 40,   FAIL 41,   FAIL 42,   FAIL 43,   FAIL 44,   FAIL 45,   FAIL 46,   FAIL 47,   FAIL 48,   FAIL 49,   FAIL 50,   FAIL 51,   FAIL 52,   FAIL 53,   FAIL 54,   FAIL 55,   FAIL 56,   FAIL 57,   FAIL 58,   FAIL 59,   FAIL 60,   FAIL 61,   FAIL 62,   FAIL 63,   FAIL 64,   FAIL 65,   FAIL 66,   FAIL 67,   FAIL 68,   FAIL 69,   FAIL 70,   FAIL 71,   FAIL 72,   FAIL 73,   FAIL 74,   FAIL 75,   FAIL 76,   FAIL 77,   FAIL 78,   FAIL 79,   FAIL 80,   FAIL 81,   FAIL 82,   FAIL 83,   FAIL 84,   FAIL 85,   FAIL 86,   FAIL 87,   FAIL 88,   FAIL 89,   FAIL 90,   FAIL 91,   FAIL 92,   FAIL 93,   FAIL 94,   FAIL 95,   FAIL 96,   FAIL 97,   FAIL 98,   FAIL 99,   FAIL 100,   FAIL 101,   FAIL 102,   FAIL 103,   FAIL 104,   FAIL 105,   FAIL 106,   FAIL 107,   FAIL 108,   FAIL 109,   FAIL 110,   FAIL 111,   FAIL 112,   FAIL 113,   FAIL 114,   FAIL 115,   FAIL 116,   FAIL 117,   FAIL 118,   FAIL 119,   FAIL 120,   FAIL 121,   FAIL 122,   FAIL 123,   FAIL 124,   FAIL 125,   FAIL 126,   FAIL 127,   FAIL 128,   FAIL 129,   FAIL 130,   FAIL 131,   FAIL 132,   FAIL 133,   FAIL 134,   FAIL 135,   FAIL 136,   FAIL 137,   FAIL 138,   FAIL 139,   FAIL 140,   FAIL 141,   FAIL 142,   FAIL 143,   FAIL 144,   FAIL 145,   FAIL 146,   FAIL 147,   FAIL 148,   FAIL 149,   FAIL 150,   FAIL 151,   FAIL 152,   FAIL 153,   FAIL 154,   FAIL 155,   FAIL 156,   FAIL 157,   FAIL 158,   FAIL 159,   FAIL 160,   FAIL 161,   FAIL 162,   FAIL 163,   FAIL 164,   FAIL 165,   FAIL 166,   FAIL 167,   FAIL 168,   FAIL 169,   FAIL 170,   FAIL 171,   FAIL 172,   FAIL 173,   FAIL 174,   FAIL 175,   FAIL 176,   FAIL 177,   FAIL 178,   FAIL 179,   FAIL 180,   FAIL 181,   FAIL 182,   FAIL 183,   FAIL 184,   FAIL 185,   FAIL 186,   FAIL 187,   FAIL 188,   FAIL 189,   FAIL 190,   FAIL 191,   FAIL 192,   FAIL 193,   FAIL 194,   FAIL 195,   FAIL 196,   FAIL 197,   FAIL 198,   FAIL 199,   FAIL 200,   FAIL 201,   FAIL 202,   FAIL 203,   FAIL 204,   FAIL 205,   FAIL 206,   FAIL 207,   FAIL 208,   FAIL 209,   FAIL 210,   FAIL 211,   FAIL 212,   FAIL 213,   FAIL 214,   FAIL 215,   FAIL 216,   FAIL 217,   FAIL 218,   FAIL 219,   FAIL 220,   FAIL 221,   FAIL 222,   FAIL 223,   FAIL 224,   FAIL 225,   FAIL 226,   FAIL 227,   FAIL 228,   FAIL 229,   FAIL 230,   FAIL 231,   FAIL 232,   FAIL 233,   FAIL 234,   FAIL 235,   FAIL 236,   FAIL 237,   FAIL 238,   FAIL 239,   FAIL 240,   FAIL 241,   FAIL 242,   FAIL 243,   FAIL 244,   FAIL 245,   FAIL 246,   FAIL 247,   FAIL 248,   FAIL 249,   FAIL 250,   FAIL 251,   FAIL 252,   FAIL 253,   FAIL 254,   FAIL 255,   PASS 0 us 4.581 s
The Flash chip is currently powered down.
The Flash chip is currently powered down.
 String   FAIL 0 us 4.719 s
-----------------------------------------------------------------------------------------------------------------------------

Hello Srmojo,

Did you had any luck with your board?
I do have one also and would like to implement the library.
Thanks.

Tim

OK ive am at my wits end and come to the masters for help.

I have a Teensy LC and trying to communicate with a SST26VF064B Flash chip.

Using only raw SPI commands I can communicate with the chip. Get ID and read the status regs. But I cant write! Whey do they make it so damn hard to write!

Marzogh perhaps you can lend some insight into my SST26 chip.

Starting factory fresh with SPIMemory Library this is the result of the test code:

Initialising..........
Chip Diagnostics initiated.

No Chip size defined by user. Automated identification initiated.
Chip identified. This chip is fully supported by the library.

SPIMemory Library version: 3.2.1

JEDEC ID: 0xBF2643
Man ID: 0xBF
Memory ID: 0x26
Capacity: 8388608
Max Pages: 0
Unique ID: 04294967040, 0xFFFFFFFFFFFFFF00
-----------------------------------------------------------------------------------------------------------------------------
							Testing library code
-----------------------------------------------------------------------------------------------------------------------------
			Function		Test result			     Runtime
-----------------------------------------------------------------------------------------------------------------------------
			Power Down	This function is not supported by the flash memory hardware.
	   FAIL			Not all chips support power down. Check your datasheet.
			Power Up		   PASS				      44 us

			Erase Chip		   PASS				      60 us
			Erase 72KB		   PASS				      176 us
			Erase 64KB		   PASS				      68 us
			Erase 32KB		   PASS				      76 us
			Erase 4KB		   PASS				      76 us
-----------------------------------------------------------------------------------------------------------------------------
			Data type		I/O Result	      Write time	      Read time
-----------------------------------------------------------------------------------------------------------------------------
			Byte			   FAIL			0 us			40 us
			Char			   FAIL			0 us			40 us
			Word			   FAIL			0 us			44 us
			Short			   FAIL			0 us			40 us
			ULong			   FAIL			0 us			44 us
			Long			   FAIL			0 us			48 us
			Float			   FAIL			0 us			48 us
Write Function has failed errorcheck.
If this does not help resolve/clarify this issue, please raise an issue at http://www.github.com/Marzogh/SPIMemory/issues with the details of what your were doing when this error occurred
			Struct			   FAIL			0 us			112 us
			Byte Array		   FAIL	0, 	   FAIL	1, 	   FAIL	2, 	   FAIL	3, 	   FAIL	4, 	   FAIL	5, 	   FAIL	6, 	   FAIL	7, 	   FAIL	8, 	   FAIL	9, 	   FAIL	10, 	   FAIL	11, 	   FAIL	12, 	   FAIL	13, 	   FAIL	14, 	   FAIL	15, 	   FAIL	16, 	   FAIL	17, 	   FAIL	18, 	   FAIL	19, 	   FAIL	20, 	   FAIL	21, 	   FAIL	22, 	   FAIL	23, 	   FAIL	24, 	   FAIL	25, 	   FAIL	26, 	   FAIL	27, 	   FAIL	28, 	   FAIL	29, 	   FAIL	30, 	   FAIL	31, 	   FAIL	32, 	   FAIL	33, 	   FAIL	34, 	   FAIL	35, 	   FAIL	36, 	   FAIL	37, 	   FAIL	38, 	   FAIL	39, 	   FAIL	40, 	   FAIL	41, 	   FAIL	42, 	   FAIL	43, 	   FAIL	44, 	   FAIL	45, 	   FAIL	46, 	   FAIL	47, 	   FAIL	48, 	   FAIL	49, 	   FAIL	50, 	   FAIL	51, 	   FAIL	52, 	   FAIL	53, 	   FAIL	54, 	   FAIL	55, 	   FAIL	56, 	   FAIL	57, 	   FAIL	58, 	   FAIL	59, 	   FAIL	60, 	   FAIL	61, 	   FAIL	62, 	   FAIL	63, 	   FAIL	64, 	   FAIL	65, 	   FAIL	66, 	   FAIL	67, 	   FAIL	68, 	   FAIL	69, 	   FAIL	70, 	   FAIL	71, 	   FAIL	72, 	   FAIL	73, 	   FAIL	74, 	   FAIL	75, 	   FAIL	76, 	   FAIL	77, 	   FAIL	78, 	   FAIL	79, 	   FAIL	80, 	   FAIL	81, 	   FAIL	82, 	   FAIL	83, 	   FAIL	84, 	   FAIL	85, 	   FAIL	86, 	   FAIL	87, 	   FAIL	88, 	   FAIL	89, 	   FAIL	90, 	   FAIL	91, 	   FAIL	92, 	   FAIL	93, 	   FAIL	94, 	   FAIL	95, 	   FAIL	96, 	   FAIL	97, 	   FAIL	98, 	   FAIL	99, 	   FAIL	100, 	   FAIL	101, 	   FAIL	102, 	   FAIL	103, 	   FAIL	104, 	   FAIL	105, 	   FAIL	106, 	   FAIL	107, 	   FAIL	108, 	   FAIL	109, 	   FAIL	110, 	   FAIL	111, 	   FAIL	112, 	   FAIL	113, 	   FAIL	114, 	   FAIL	115, 	   FAIL	116, 	   FAIL	117, 	   FAIL	118, 	   FAIL	119, 	   FAIL	120, 	   FAIL	121, 	   FAIL	122, 	   FAIL	123, 	   FAIL	124, 	   FAIL	125, 	   FAIL	126, 	   FAIL	127, 	   FAIL	128, 	   FAIL	129, 	   FAIL	130, 	   FAIL	131, 	   FAIL	132, 	   FAIL	133, 	   FAIL	134, 	   FAIL	135, 	   FAIL	136, 	   FAIL	137, 	   FAIL	138, 	   FAIL	139, 	   FAIL	140, 	   FAIL	141, 	   FAIL	142, 	   FAIL	143, 	   FAIL	144, 	   FAIL	145, 	   FAIL	146, 	   FAIL	147, 	   FAIL	148, 	   FAIL	149, 	   FAIL	150, 	   FAIL	151, 	   FAIL	152, 	   FAIL	153, 	   FAIL	154, 	   FAIL	155, 	   FAIL	156, 	   FAIL	157, 	   FAIL	158, 	   FAIL	159, 	   FAIL	160, 	   FAIL	161, 	   FAIL	162, 	   FAIL	163, 	   FAIL	164, 	   FAIL	165, 	   FAIL	166, 	   FAIL	167, 	   FAIL	168, 	   FAIL	169, 	   FAIL	170, 	   FAIL	171, 	   FAIL	172, 	   FAIL	173, 	   FAIL	174, 	   FAIL	175, 	   FAIL	176, 	   FAIL	177, 	   FAIL	178, 	   FAIL	179, 	   FAIL	180, 	   FAIL	181, 	   FAIL	182, 	   FAIL	183, 	   FAIL	184, 	   FAIL	185, 	   FAIL	186, 	   FAIL	187, 	   FAIL	188, 	   FAIL	189, 	   FAIL	190, 	   FAIL	191, 	   FAIL	192, 	   FAIL	193, 	   FAIL	194, 	   FAIL	195, 	   FAIL	196, 	   FAIL	197, 	   FAIL	198, 	   FAIL	199, 	   FAIL	200, 	   FAIL	201, 	   FAIL	202, 	   FAIL	203, 	   FAIL	204, 	   FAIL	205, 	   FAIL	206, 	   FAIL	207, 	   FAIL	208, 	   FAIL	209, 	   FAIL	210, 	   FAIL	211, 	   FAIL	212, 	   FAIL	213, 	   FAIL	214, 	   FAIL	215, 	   FAIL	216, 	   FAIL	217, 	   FAIL	218, 	   FAIL	219, 	   FAIL	220, 	   FAIL	221, 	   FAIL	222, 	   FAIL	223, 	   FAIL	224, 	   FAIL	225, 	   FAIL	226, 	   FAIL	227, 	   FAIL	228, 	   FAIL	229, 	   FAIL	230, 	   FAIL	231, 	   FAIL	232, 	   FAIL	233, 	   FAIL	234, 	   FAIL	235, 	   FAIL	236, 	   FAIL	237, 	   FAIL	238, 	   FAIL	239, 	   FAIL	240, 	   FAIL	241, 	   FAIL	242, 	   FAIL	243, 	   FAIL	244, 	   FAIL	245, 	   FAIL	246, 	   FAIL	247, 	   FAIL	248, 	   FAIL	249, 	   FAIL	250, 	   FAIL	251, 	   FAIL	252, 	   FAIL	253, 	   FAIL	254, 	   PASS			0 us			512 us
Write Function has failed errorcheck.
If this does not help resolve/clarify this issue, please raise an issue at http://www.github.com/Marzogh/SPIMemory/issues with the details of what your were doing when this error occurred
			String			   FAIL			0 us			84 us

I have disable the WP and HOLD pins with the IOC Register but still not getting anywhere. What is next to investigate?
Thank you!

hello thanks for your great work

are that library support sst25vf010a or LE25U40CMDTWG cause those are the parts i have

i also try to use sst25vf010a but it return 00h as chip id and manufacture id

thanks in advance

hello @Marzogh.

Im having some issues with the SPImemory library, specifically it doesn't work for the writing operations.

Hardware:
Arduino UNO
W25Q80BV

Wiring:
1cs ----> pin10
2DO ----> MISO
3WP ----> 3.3v
4GND ----> GND
5DI ----> MOSI
6CLK ----> SCK
7HOLD ----> 3.3v
8VCC ----> 3.3v

I interfaced the Arduino and Flash using the level shifter.
and FlashDiagnostics line 40 has been changed to:
SPIFlash flash(10);

The library version 3.2.1 and 3.2.0 both do not work.

Any help is appreciated.

The output is below

Initialising..........

SPIMemory Library version: 3.2.1

JEDEC ID: 0xEF4014
Man ID: 0xEF
Memory ID: 0x40
Capacity: 1048576
Max Pages: 4294967295
Unique ID: 2815588997737984, 0x60A88003660B2E00
-----------------------------------------------------------------------------------------------------------------------------
							Testing library code
-----------------------------------------------------------------------------------------------------------------------------
			Function		Test result			     Runtime
-----------------------------------------------------------------------------------------------------------------------------
			Power Down		   FAIL			Not all chips support power down. Check your datasheet.
			Power Up		   PASS				      0 us

			Erase Chip		   PASS				      0 us
			Erase 72KB		   PASS				      0 us
			Erase 64KB		   PASS				      0 us
			Erase 32KB		   PASS				      0 us
			Erase 4KB		   PASS				      0 us
-----------------------------------------------------------------------------------------------------------------------------
			Data type		I/O Result	      Write time	      Read time
-----------------------------------------------------------------------------------------------------------------------------
			Byte			   FAIL				      0 us
			Char			   FAIL				      0 us
			Word			   FAIL				      0 us
			Short			   FAIL				      0 us
			ULong			   FAIL				      0 us
			Long			   FAIL				      0 us
			Float			   FAIL				      0 us
			Struct			   FAIL				      0 us
			Byte Array		   FAIL	1, 	   FAIL	2, 	   FAIL	3, 	   FAIL	4, 	   FAIL	5, 	   FAIL	6, 	   FAIL	7, 	   FAIL	8, 	   FAIL	9, 	   FAIL	10, 	   FAIL	11, 	   FAIL	12, 	   FAIL	13, 	   FAIL	14, 	   FAIL	15, 	   FAIL	16, 	   FAIL	17, 	   FAIL	18, 	   FAIL	19, 	   FAIL	20, 	   FAIL	21, 	   FAIL	22, 	   FAIL	23, 	   FAIL	24, 	   FAIL	25, 	   FAIL	26, 	   FAIL	27, 	   FAIL	28, 	   FAIL	29, 	   FAIL	30, 	   FAIL	31, 	   FAIL	32, 	   FAIL	33, 	   FAIL	34, 	   FAIL	35, 	   FAIL	36, 	   FAIL	37, 	   FAIL	38, 	   FAIL	39, 	   FAIL	40, 	   FAIL	41, 	   FAIL	42, 	   FAIL	43, 	   FAIL	44, 	   FAIL	45, 	   FAIL	46, 	   FAIL	47, 	   FAIL	48, 	   FAIL	49, 	   FAIL	50, 	   FAIL	51, 	   FAIL	52, 	   FAIL	53, 	   FAIL	54, 	   FAIL	55, 	   FAIL	56, 	   FAIL	57, 	   FAIL	58, 	   FAIL	59, 	   FAIL	60, 	   FAIL	61, 	   FAIL	62, 	   FAIL	63, 	   FAIL	64, 	   FAIL	65, 	   FAIL	66, 	   FAIL	67, 	   FAIL	68, 	   FAIL	69, 	   FAIL	70, 	   FAIL	71, 	   FAIL	72, 	   FAIL	73, 	   FAIL	74, 	   FAIL	75, 	   FAIL	76, 	   FAIL	77, 	   FAIL	78, 	   FAIL	79, 	   FAIL	80, 	   FAIL	81, 	   FAIL	82, 	   FAIL	83, 	   FAIL	84, 	   FAIL	85, 	   FAIL	86, 	   FAIL	87, 	   FAIL	88, 	   FAIL	89, 	   FAIL	90, 	   FAIL	91, 	   FAIL	92, 	   FAIL	93, 	   FAIL	94, 	   FAIL	95, 	   FAIL	96, 	   FAIL	97, 	   FAIL	98, 	   FAIL	99, 	   FAIL	100, 	   FAIL	101, 	   FAIL	102, 	   FAIL	103, 	   FAIL	104, 	   FAIL	105, 	   FAIL	106, 	   FAIL	107, 	   FAIL	108, 	   FAIL	109, 	   FAIL	110, 	   FAIL	111, 	   FAIL	112, 	   FAIL	113, 	   FAIL	114, 	   FAIL	115, 	   FAIL	116, 	   FAIL	117, 	   FAIL	118, 	   FAIL	119, 	   FAIL	120, 	   FAIL	121, 	   FAIL	122, 	   FAIL	123, 	   FAIL	124, 	   FAIL	125, 	   FAIL	126, 	   FAIL	127, 	   FAIL	128, 	   FAIL	129, 	   FAIL	130, 	   FAIL	131, 	   FAIL	132, 	   FAIL	133, 	   FAIL	134, 	   FAIL	135, 	   FAIL	136, 	   FAIL	137, 	   FAIL	138, 	   FAIL	139, 	   FAIL	140, 	   FAIL	141, 	   FAIL	142, 	   FAIL	143, 	   FAIL	144, 	   FAIL	145, 	   FAIL	146, 	   FAIL	147, 	   FAIL	148, 	   FAIL	149, 	   FAIL	150, 	   FAIL	151, 	   FAIL	152, 	   FAIL	153, 	   FAIL	154, 	   FAIL	155, 	   FAIL	156, 	   FAIL	157, 	   FAIL	158, 	   FAIL	159, 	   FAIL	160, 	   FAIL	161, 	   FAIL	162, 	   FAIL	163, 	   FAIL	164, 	   FAIL	165, 	   FAIL	166, 	   FAIL	167, 	   FAIL	168, 	   FAIL	169, 	   FAIL	170, 	   FAIL	171, 	   FAIL	172, 	   FAIL	173, 	   FAIL	174, 	   FAIL	175, 	   FAIL	176, 	   FAIL	177, 	   FAIL	178, 	   FAIL	179, 	   FAIL	180, 	   FAIL	181, 	   FAIL	182, 	   FAIL	183, 	   FAIL	184, 	   FAIL	185, 	   FAIL	186, 	   FAIL	187, 	   FAIL	188, 	   FAIL	189, 	   FAIL	190, 	   FAIL	191, 	   FAIL	192, 	   FAIL	193, 	   FAIL	194, 	   FAIL	195, 	   FAIL	196, 	   FAIL	197, 	   FAIL	198, 	   FAIL	199, 	   FAIL	200, 	   FAIL	201, 	   FAIL	202, 	   FAIL	203, 	   FAIL	204, 	   FAIL	205, 	   FAIL	206, 	   FAIL	207, 	   FAIL	208, 	   FAIL	209, 	   FAIL	210, 	   FAIL	211, 	   FAIL	212, 	   FAIL	213, 	   FAIL	214, 	   FAIL	215, 	   FAIL	216, 	   FAIL	217, 	   FAIL	218, 	   FAIL	219, 	   FAIL	220, 	   FAIL	221, 	   FAIL	222, 	   FAIL	223, 	   FAIL	224, 	   FAIL	225, 	   FAIL	226, 	   FAIL	227, 	   FAIL	228, 	   FAIL	229, 	   FAIL	230, 	   FAIL	231, 	   FAIL	232, 	   FAIL	233, 	   FAIL	234, 	   FAIL	235, 	   FAIL	236, 	   FAIL	237, 	   FAIL	238, 	   FAIL	239, 	   FAIL	240, 	   FAIL	241, 	   FAIL	242, 	   FAIL	243, 	   FAIL	244, 	   FAIL	245, 	   FAIL	246, 	   FAIL	247, 	   FAIL	248, 	   FAIL	249, 	   FAIL	250, 	   FAIL	251, 	   FAIL	252, 	   FAIL	253, 	   FAIL	254, 	   FAIL	255, 	   PASS				      0 us
			String			   FAIL				      0 us
-----------------------------------------------------------------------------------------------------------------------------
To see function runtimes ncomment RUNDIAGNOSTIC in SPIMemory.h.

Hi, Im using ESP8266, then executing flash.begin() and without spi flash connected ... >> getting WDT reset. I cant add delay(0) ... is in your library ...

... with spi flash inserted (connected) - all ok.

  ESP.wdtDisable();
  ESP.wdtFeed();

  if (!flash.begin()) {
    Serial.println(flash.error(VERBOSE));
  }

  ESP.wdtEnable(1000);

same with wdtDisable() after ~10 seconds WDT reset .... your library stack in infinite loop on flash.begin() .... any help ?

OK ... find the bug, in defines.h change ... for esp8266 BUSY_TIMEOUT set ~2 seconds (was 1000 seconds)

// #define BUSY_TIMEOUT  1000000000L
#if defined (ARDUINO_ARCH_ESP8266)
#define BUSY_TIMEOUT  2000000L
#else
#define BUSY_TIMEOUT  1000000000L
#endif

... now work ok

and may be in this code must be done some fixes:

// Polls the status register 1 until busy flag is cleared or timeout
 bool SPIFlash::_notBusy(uint32_t timeout) {
   _delay_us(WINBOND_WRITE_DELAY);
   uint32_t _time = micros();

   do {
     #if defined (ARDUINO_ARCH_ESP8266)
     delay(0);
     #endif
     _readStat1();
     if (!(stat1 & BUSY))
     {
       return true;
     }

   } while ((micros() - _time) < timeout);
   if (timeout <= (micros() - _time)) {
     _troubleshoot(CHIPBUSY);
     return false;
   }
   return true;
 }

change code >

do {
** #if defined (ARDUINO_ARCH_ESP8266)**
** delay(0);**
** #endif**
** _readStat1();**

same with cheapErase() fix

//Erases whole chip. Think twice before using.
bool SPIFlash::eraseChip(void) {
  #ifdef RUNDIAGNOSTIC
    _spifuncruntime = micros();
  #endif
 if(_isChipPoweredDown() || !_notBusy() || !_writeEnable()) {
    return false;
  }

 _beginSPI(chipErase.opcode);
  _endSPI();

 while(_readStat1() & BUSY) {
  #if defined (ARDUINO_ARCH_ESP8266)
     delay(0);
  #endif
    //_delay_us(30000L);
  }
  _endSPI();

  #ifdef RUNDIAGNOSTIC
    _spifuncruntime = micros() - _spifuncruntime;
  #endif
 return true;

}

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

  • The SPIMemory now supports SPI FRAM (one chip for now, but the list is going to grow. :slight_smile: )

Bugs squashed:

  • Fixed a major bug causing issues with page boundaries in writeAnything and writeStr. Thanks for your help @jacky4566 (Issue #151)
  • Fixed a major bug with reading Strings (Issue #143)
  • Fixes a bug by initialising the SPIBusState to false
  • Fixes bug that causes ballooning of pagesize when SFDP is not read. This is because no default _pageSize value was set in this scenario. This has now been fixed.
  • Fixes a major bug in how SFDP data is used to calculate chip capacity. The previous version of the library returned a wrong value. This has now been fixed. Refer to comments in _getSFDPFlashParam(void) for further details.

Enhancements:

  • Reduce SRAM footprint when running Diagnostics.ino. Thanks @rambo (PR #157)
  • 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 flash memory chips supported:

  • GD25Q16C from Giga devices (Used on the Adafruit ItsyBitsy M0 Express)
  • W25Q64JV from Winbond
  • SST26VF016B & SST26VF032B from Microchip.

New Fram memory chips supported:

  • FM25W256 from Cypress

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)

@walterpre, @BigEyetuna & @jacky4566 : jetty840 identified the issue with the SST26 series and its been fixed with v3.3.0.

@Srmojo & @timoteo_mendes: I've just tested the latest version of the library - v3.3.0 - with the W25Q64JV on the Adafruit 328p feather and it works fine. I do not have an Adalogger handy, but AFAIK, the both of them use the same µC - hope it helps!

@amirezz: There was a bug in v3.2.1 that prevented the library from writing to the SST25 and SST26 series. This has been fixed in v3.3.0. Also, the library supports the LE25U40C.

@zhliao: Could you check and confirm that v3.3.0 also causes the same issue? If it does, please let me know and I will take a look at it right away.

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?