Giter VIP home page Giter VIP logo

adafruit_spiflash's Introduction

adafruit_spiflash's People

Contributors

apparentlymart avatar attermann avatar bobobo1618 avatar brentru avatar chuckvanzant avatar creativerobotics avatar csc-sendance avatar deanm1278 avatar dhalbert avatar dritanium avatar eugeneanikin avatar evaherrada avatar gdsports avatar gmagician avatar hathach avatar jacobmcollier avatar jepler avatar ladyada avatar lyusupov avatar makermelissa avatar modmatic avatar mrbryonmiller avatar mzero avatar noe-sanchez avatar odaki avatar paintyourdragon avatar siddacious avatar smohekey avatar tdicola avatar tyeth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_spiflash's Issues

GetJEDECID() broken

In Adafruit_SPIFlash.cpp, getJEDECID() does not return proper values. FIX: get rid of 3 dummy writes.

Update: My initial tests were with an 8MB W25Q64FV SPI flash, and getJEDECID() failed with the the 3 dummy spiwrite's, and the data sheet did not indicate dummy write's were required. Having received my Express, I see that getJEDECID() works with or without the 3 dummy writes.

SdFat examples do not compile: Cannot convert 'Adafruit_SPIFlash*' to 'BlockDriver*' {aka 'SdSpiCard*'}

Hello Everyone,

I am trying to setup my QT PY with a external flash chip soldered on the bottom side, and I am running into some compiling problem for all the SdFat Examples in this library. My flash chip is working, and am able to run flash_info and flash_eraser without any issues.

I keep getting this compile error whenever fatfs.begin(&flash) is called in the SdFat example programs

cannot convert 'Adafruit_SPIFlash*' to 'BlockDriver*' {aka 'SdSpiCard*'}

Current Libraries and Boards being used
Adafruit SAMD Boards v1.6.5
Adafruit_SdFat at version 1.2.3
Adafruit_SPIFlash at version 3.4.1

It is as if a typecast is needed, so I tried typecasting to fatfs.begin((BlockDriver*)&flash) which compiles, but causes the code to hang and is not the solution.

Has something fundamentally been changed in the library that needs the examples updated?

Thanks for your help!

Having trouble editing the flash_devices.h to add a new flash memory.

As stated above I have a problem in editing the flash_devices.h file in the library to add a new device that are not listed in this library. Can anybody help me and verify whether what I have edited is correct? and is it possible to add another flash memory excluding the listed one?

//This is the Edited part for new flash device Winbond W25Q512JV
//Datasheet:"https://www.winbond.com/resource-files/W25Q512JV%20SPI%20RevB%2006252019%20KMS.pdf"

#define W25Q512JV
{
.total_size = (1 << 26), /* 64 MiB */
.start_up_time_us = 5000, .manufacturer_id = 0xef,
.memory_type = 0x40, .capacity = 0x20, .max_clock_speed_mhz = 133,
.quad_enable_bit_mask = 0x01, .has_sector_protection = false,
.supports_fast_read = true, .supports_qspi = true,
.supports_qspi_writes = true, .write_status_register_split = false,
}

Adafruit_SPIFlashBase::end prototyped but not implemented.

Describe the bug
There is a prototype for 'Adafruit_SPIFlashBase::end', but it isn't implemented.
see Adafruit_SPIFlashBase.h:51 for the prototype, and notice the lack of implementation in corresponding files.

The reason I wanted it is that the NRF52 automatic clock generator could (depending on hardware implementation details I have not found documentation on) continue to generate clock signals until the underlying SPI peripheral in use is either stopped or suspended, which would increase the power usage in sleep mode generating a clock that is not really required.
The solution would be to stop the driver when the flash is not required for a while and start it before the next operation begins.

Set up (mandatory)

  • PC & IDE : N/A
  • Board : N/A
  • BSP : N/A
  • Sketch: N/A

To Reproduce
Look at file Adafruit_SPIFlashBase.h and notice lack of corresponding implementation in Adafruit_SPIFlashBase.cpp

Don't waste memory if not using SdFat

The class Adafruit_SPIFlash is a fine interface if you want to use SPI flash, but without the FAT file system.

However, it includes both virtual methods for the BaseBlockDriver API, and an instance variable of type Adafruit_FlashCache. The later uses 4k+ of RAM. If you are not using FAT, or the block interface directly - this is just wasted RAM.

I suggest splitting the Adafruit_SPIFlash class like so:

class Adafruit_SPIFlashCore {
	Adafruit_SPIFlashCore(Adafruit_FlashTransport* transport);
	~Adafruit_SPIFlashCore() {}

  ... most of what is in Adafruit_SPIFlash today ...
};

class Adafruit_SPIFlash : public Adafruit_SPIFlash {
	Adafruit_SPIFlash(Adafruit_FlashTransport* transport)
		: Adafruit_SPIFlashCore(transport) {}
	~Adafruit_SPIFlash() {}

	//------------- SdFat BaseBlockDRiver API -------------//
	virtual bool readBlock(uint32_t block, uint8_t* dst);
	virtual bool syncBlocks();
	virtual bool writeBlock(uint32_t block, const uint8_t* src);
	virtual bool readBlocks(uint32_t block, uint8_t* dst, size_t nb);
	virtual bool writeBlocks(uint32_t block, const uint8_t* src, size_t nb);

private:
	Adafruit_FlashCache _cache;
};

Adafruit_SPIFlashCore should be in its own header file, which doesn't #include SdFat.h - so that it works on systems that didn't load that library.

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

You must format before attempting to use with the computer. The Windows 10 computer could not format the device, when trying to format Windows think the W25Q64 has 4GB (would be great if this size were true!).

Formatter:

// Adafruit SPI Flash FatFs Format Example
// Author: Tony DiCola
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!  NOTE: YOU WILL ERASE ALL DATA BY RUNNING THIS SKETCH!  !!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// Usage:
// - Modify the pins and type of fatfs object in the config
//   section below if necessary (usually not necessary).
// - Upload this sketch to your M0 express board.
// - Open the serial monitor at 115200 baud.  You should see a
//   prompt to confirm formatting.  If you don't see the prompt
//   close the serial monitor, press the board reset buttton,
//   wait a few seconds, then open the serial monitor again.
// - Type OK and enter to confirm the format when prompted.
// - Partitioning and formatting will take about 30-60 seconds.
//   Once formatted a message will be printed to notify you that
//   it is finished.
//
#include <SPI.h>
#include <SdFat.h>
#include <Adafruit_SPIFlash.h>

// Since SdFat doesn't fully support FAT12 such as format a new flash
// We will use Elm Cham's fatfs f_mkfs() to format
#include "ff.h"
#include "diskio.h"

// Use second SPI port
SPIClass SPI_2(2);

#define SS2 PB12

#if defined(__SAMD51__) || defined(NRF52840_XXAA)
Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS, PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
#else
//  #if (SPI_INTERFACES_COUNT == 1)
//    Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
//  #else
//    Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
//  #endif

Adafruit_FlashTransport_SPI flashTransport(SS2, &SPI_2);
#endif

Adafruit_SPIFlash flash(&flashTransport);

// file system object from SdFat
FatFileSystem fatfs;


void setup() {
  // Initialize serial port and wait for it to open before continuing.
  Serial.begin(115200);
  while (!Serial) {
    delay(100);
  }
  Serial.println("Adafruit SPI Flash FatFs Format Example");

  // Initialize flash library and check its chip ID.
  if (!flash.begin()) {
    Serial.println("Error, failed to initialize flash chip!");
    while(1);
  }
  Serial.print("Flash chip JEDEC ID: 0x"); Serial.println(flash.getJEDECID(), HEX);

  // Wait for user to send OK to continue.
  Serial.setTimeout(30000);  // Increase timeout to print message less frequently.
  do {
    Serial.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    Serial.println("This sketch will ERASE ALL DATA on the flash chip and format it with a new filesystem!");
    Serial.println("Type OK (all caps) and press enter to continue.");
    Serial.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  }
  while ( !Serial.find("OK"));

  // Call fatfs begin and passed flash object to initialize file system
  Serial.println("Creating and formatting FAT filesystem (this takes ~60 seconds)...");

  // Make filesystem.
  uint8_t buf[512] = {0};          // Working buffer for f_fdisk function.    
  FRESULT r = f_mkfs("", FM_FAT | FM_SFD, 0, buf, sizeof(buf));
  if (r != FR_OK) {
    Serial.print("Error, f_mkfs failed with error code: "); Serial.println(r, DEC);
    while(1);
  }

  // sync to make sure all data is written to flash
  flash.syncBlocks();
  
  Serial.println("Formatted flash!");

  // Check new filesystem
  if (!fatfs.begin(&flash)) {
    Serial.println("Error, failed to mount newly formatted filesystem!");
    while(1) delay(1);
  }

  // Done!
  Serial.println("Flash chip successfully formatted with new empty filesystem!");
}

void loop() {
  // Nothing to be done in the main loop.
}


//--------------------------------------------------------------------+
// fatfs diskio
//--------------------------------------------------------------------+
extern "C"
{

DSTATUS disk_status ( BYTE pdrv )
{
  (void) pdrv;
	return 0;
}

DSTATUS disk_initialize ( BYTE pdrv )
{
  (void) pdrv;
	return 0;
}

DRESULT disk_read (
	BYTE pdrv,		/* Physical drive nmuber to identify the drive */
	BYTE *buff,		/* Data buffer to store read data */
	DWORD sector,	/* Start sector in LBA */
	UINT count		/* Number of sectors to read */
)
{
  (void) pdrv;
	return flash.readBlocks(sector, buff, count) ? RES_OK : RES_ERROR;
}

DRESULT disk_write (
	BYTE pdrv,			/* Physical drive nmuber to identify the drive */
	const BYTE *buff,	/* Data to be written */
	DWORD sector,		/* Start sector in LBA */
	UINT count			/* Number of sectors to write */
)
{
  (void) pdrv;
  return flash.writeBlocks(sector, buff, count) ? RES_OK : RES_ERROR;
}

DRESULT disk_ioctl (
	BYTE pdrv,		/* Physical drive nmuber (0..) */
	BYTE cmd,		/* Control code */
	void *buff		/* Buffer to send/receive control data */
)
{
  (void) pdrv;

  switch ( cmd )
  {
    case CTRL_SYNC:
      flash.syncBlocks();
      return RES_OK;

    case GET_SECTOR_COUNT:
      *((DWORD*) buff) = flash.size()/512;
      return RES_OK;

    case GET_SECTOR_SIZE:
      *((WORD*) buff) = 512;
      return RES_OK;

    case GET_BLOCK_SIZE:
      *((DWORD*) buff) = 8;    // erase block size in units of sector size
      return RES_OK;

    default:
      return RES_PARERR;
  }
}

}

USB Reader:

// This uses the greiman sdfat library.
// To use SdFatEX, set ENABLE_EXTENDED_TRANSFER_CLASS to 1 in the library's
// src/SdFatConfig.h
#include <USBComposite.h>
#include <SPI.h>
#include "SdFat.h"
#include "Adafruit_SPIFlash.h"

USBMassStorage MassStorage;
USBCompositeSerial CompositeSerial;

#define LED_PIN PC13
#define PRODUCT_ID 0x29

// Use first SPI port
//SdFat sd;

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

#define SS2 PB12

Adafruit_FlashTransport_SPI flashTransport(SS2, &SPI_2);

Adafruit_SPIFlash flash(&flashTransport);

//SdFatEX sd;

const uint32_t speed = SPI_CLOCK_DIV2 ;
//const uint8_t SD_CHIP_SELECT = SS2; //PA15; //SS;
bool enabled = false;
uint32 cardSize;

bool write(const uint8_t *writebuff, uint32_t startSector, uint16_t numSectors) {
  //  return sd.card()->writeBlocks(startSector, writebuff, numSectors);
  return flash.writeBlocks(startSector, writebuff, numSectors);
}

bool read(uint8_t *readbuff, uint32_t startSector, uint16_t numSectors) {
  //  return sd.card()->readBlocks(startSector, readbuff, numSectors);
  return flash.readBlocks(startSector, readbuff, numSectors);
}

void setup() {
  //  // Remap SPI 1
  //  // Source: https://community.platformio.org/t/pio-arduino-stm32f103cbt6-remap/6786/5
  //  afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY); // PB3 free
  //  afio_remap(AFIO_REMAP_SPI1);
  //
  //  gpio_set_mode (GPIOB, 3, GPIO_AF_OUTPUT_PP);
  //  gpio_set_mode (GPIOB, 4, GPIO_INPUT_FLOATING);
  //  gpio_set_mode (GPIOB, 5, GPIO_AF_OUTPUT_PP);

  USBComposite.setProductId(PRODUCT_ID);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, 1);
}

void initReader() {
  digitalWrite(LED_PIN, 0);
  //  cardSize = sd.card()->cardSize();
  cardSize = flash.size();
  MassStorage.setDriveData(0, cardSize, read, write);
  MassStorage.registerComponent();
  CompositeSerial.registerComponent();
  USBComposite.begin();
  enabled = true;
}

void loop() {
  if (!enabled) {
    //    if (sd.begin(SD_CHIP_SELECT)) {
    if (flash.begin()) {
      initReader();
    }
    else {
      delay(50);
    }
  }
  else {
    MassStorage.loop();
  }
}

USB SD Card reader source:
[USB Composite library]
https://github.com/arpruss/USBComposite_stm32f1/blob/master/examples/sdreader/sdreader.ino

Fails when using with Feather M0 Express starting with v3.3.0

Describe the bug
When using versions >= 3.3.0 the library silently fails to write to files.

Set up (mandatory)

  • PC & IDE : Arduino 1.8.13 on macOS 10.15.6
  • Board : Feather M0 Express
  • BSP : 1.6.4
  • Sketch: examples/SdFat_full_usage

To Reproduce
Steps to reproduce the behavior:

  1. Install a version of the library >= 3.3.0 <= 3.3.3 (latest)
  2. Connect Feather M0 Express
  3. Open SdFat_full_usage example
  4. Upload to board
  5. See errors in output

Serial Log
Using 3.3.3

Adafruit SPI Flash FatFs Full Usage Example
Flash chip JEDEC ID: 0xC84015
Mounted filesystem!
Test directory not found, creating...
Error, failed to create directory!

Using 3.3.0

Adafruit SPI Flash FatFs Full Usage Example
Flash chip JEDEC ID: 0xC84015
Mounted filesystem!
Test directory not found, creating...
Created directory!
Creating deep folder structure...
Creating /test/foo/bar
Created directory!
Creating /test/foo/baz
Error, failed to create directory!

For reference, when using 3.2.2

Adafruit SPI Flash FatFs Full Usage Example
Flash chip JEDEC ID: 0xC84015
Mounted filesystem!
Test directory not found, creating...
Created directory!
Creating deep folder structure...
Creating /test/foo/bar
Created directory!
Creating /test/foo/baz
Created directory!
Opened file /test/test.txt for writing/appending...
Wrote to file /test/test.txt!
First line of test.txt: Hello world!

Total size of test.txt (bytes): 57
Current position in test.txt: 14
Available data to read in test.txt: 43
File name: use getName()
Is file a directory? No
Entire contents of test.txt:
Hello world!
Hello number: 123
Hello hex number: 0x7B
Listing children of directory /test:
- foo (directory)
- test.txt
Deleting /test/foo/test2.txt...
Deleted file!
Deleting /test directory and everything inside it...
Test directory was deleted!
Finished!

example fatfs_format fails for Adafruit Metro M4

Using an Adafruit Metro M4 and while trying to troubleshoot this Adafruit forum issue https://forums.adafruit.com/viewtopic.php?f=60&t=148446#p733537 I ran into problems when using commit 1.1.0 (commit 1.0.8 worked fine).

To simplify I tried just fatfs_format and found it to fail with the following info :

Adafruit SPI Flash FatFs Format Example
Flash chip JEDEC ID: 0x0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This sketch will ERASE ALL DATA on the flash chip and format it with a new filesystem!
Type OK (all caps) and press enter to continue.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Partitioning flash with 1 primary partition...
Error, f_fdisk failed with error code: 1

Library does not work with Feather M4 Express and Adafruit_SleepyDog-master

I was having trouble localizing a problem before with the SPIFlash library and finally pinned it down to its interaction with the SleepyDog library. I created a minimal example which basically causes SPIFlash writes to corrupt the file system (see attached). This example works when you comment out the Watchdog.sleep(1000); ... to reproduce the error, follow these steps, first with that line commented out:

  1. format the M4 Express using the SdFat_Format example
  2. run the minimal example attached
  3. run the SdFat_OpenNext example to see what was written

Then repeat that with the Watchdog.sleep(1000); line and watch the file system become corrupted. Any ideas what in the SleepyDog library is causing this?

Flash_Memory_Problem_Minimal_Example.txt

Update: this same crash happens when using CircuitPython to create the file system and see what is written.

Full Usage Example fails on Feather M4 Express

On all versions tested from 3.0.0 to 3.1.1 The "Full Usage Example" is failing on a Feather M4 Express. It's failing on line 88 of the .ino and entering the error conditional there.

When this happens I'm getting some instability in 3.1.1 as well, for example the Serial.println on line 89 would not show up in the serial console sometimes. And other times when I set the LED on pin 13 high before/after line 89 it would not illuminate. When this would happen the board would also appear unresponsive the the Arduino IDE could not longer connect to the port or reset it automatically for uploading a new sketch. At this point only option is to double click reset and upload a new sketch via that route. Maybe this is expected from while(1) in the error condition there but I feel like the answer is "no", otherwise why use this as an error catching technique? Either way I'm getting breaking hangs in this part of the code.

A good bit of the library functionality does work, but I've not yet had a chance to go through and test everything.

Useful Info/Assumptions:

  • I tried testing with 3.0.0 -> 3.1.1; same behavior on all
  • I used the format example from this library to format the flash before running the full usage examples sketch
  • I'm assuming this library requires the Adafruit fork of SdFat as the original library wouldn't even build without some changes to SdFatConfig.h, so that's what I used
  • Prior to breaking changes in 3.0.0 I had not yet had trouble working with the QSPI flash on the M4; this is new behavior
  • I'm using Arduino IDE 1.8.9 on Windows 10
  • Arduino SAMD Boards 1.8.3
  • Adafruit SAMD Boards 1.5.3

Here's what I get printed out on the serial console until it hangs:

Adafruit SPI Flash FatFs Full Usage Example
Flash chip JEDEC ID: 0xC84015
Mounted filesystem!
Creating deep folder structure...
Error, couldn't create deep directory structure!

Initially I wasn't even getting that last error line - the stability when it enters the inside of that error checking conditional seems unpredictable for some reason. In some other example .ino files I was testing I was also not getting Serial output but did verify the code was running by setting pin 13 high. However in the full usage example file it definitely dies inside of that error condition trying to create deep directory structure.

I'm going to test more functionality further and I'll add additional comments if I found more related information. Since fatfs.exists() is used in the example code without issue I'm going to assume the error is related to !fatfs.mkdir("/test/foo/bar") - as it seems testing the existing of and create directories without nesting (/test) isn't an issue and it seems to fail when trying to create nested files/folders.

Adding Support for GD25Q16E

Hi Guys,

The GD25Q16C seems almost impossible to find and is stated to be "not recommended for new designs" by multiple sources. I bought myself some GD25Q16E to test out to see if they'd work, the new version of that chip. They are recognized by the flash info example, but the can't be programmed. I tried putting the .max_clock_speed_mhz from 104 to 133, which is the new spec, but it didn't work. Any other ideas of what to try to see if we can get this to work? It is supposed to be just a new generation of the same chip, and there are a lot of them around. The datasheets look so similar:

http://www.gigadevice.com/datasheet/gd25q16c/
http://www.gigadevice.com/datasheet/gd25q16e/

Casey

Supported chip not found

flash_devices.h has device descirptor initializor lists for 20 different flash chips.
But possible_devices, the list that begin() looks through after getting the jedec id, lists only 8 of these. (in Adafruit_SPIFLashBase.cpp).

I have a custom board with one of the non-listed flash chips, S25FL064L. I could create the descriptor myself, initialized from the macro in flash_devices.h, and pass it to begin()... but my code also runs on a standard Feather M0 Express, which uses a different chip, and is listed in possible_devices. And I'd like to do this from the same binary.

So I want the behavior of looking up the descriptor based on the jedec id... but I need my flash chip in the list.

I see three possible fixes for this, and will submit a pull request, but I'm interested to know which way you'd like to spin this:

1: Just add the missing 12 chip descriptors to possible_devices. This will add 12*16 = 192 bytes to the static image size of any user of the library.

2: Make a version of begin() that takes a list of additional possible devices, not just a single device. Have begin() search through the supplied list, and thepossible_devices.

3: Don't change the library, just call begin() and if that fails, call it again with the descriptor of the chip and see if that works. begin() would need to ensure that it is safe to call again if it fails. I'm not sure if the internal transport object supports having its begin() method called twice.

Nano BLE and MbedOS Arduino error

Hi I am test this library with Arduino Nano BLE and Arduino Core Mbed

But I have the error

/Users/xxx/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-g++ -c -w -g -Os -nostdlib @/Users/xx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/variants/bast_ble/defines.txt @/Users/xxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/variants/bast_ble/cxxflags.txt -DARDUINO_ARCH_NRF52840 -MMD -mcpu=cortex-m4 -DARDUINO=10810 -DARDUINO_bast_ble -DARDUINO_ARCH_MBED -I/Users/xxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/cores/arduino -I/Users/xxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/variants/bast_ble -I/Users/xxx/Documents/Arduino/libraries/SdFat_-_Adafruit_Fork/src -I/Users/xxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/libraries/SPI -I/Users/xxx/Documents/Arduino/libraries/Adafruit_SPIFlash/src -I/Users/xxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/cores/arduino/api/deprecated -iprefix/Users/xxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/cores/arduino @/Users/xxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/variants/bast_ble/includes.txt /var/folders/mv/_ygj1fx50f9_sd6zn6fgyt3h0000gn/T/arduino_build_236814/sketch/flash_info.ino.cpp -o /var/folders/mv/_ygj1fx50f9_sd6zn6fgyt3h0000gn/T/arduino_build_236814/sketch/flash_info.ino.cpp.o
In file included from /Users/xxx/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_default_fcntl.h:200:0,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/fcntl.h:4,
                 from /Users/xxx/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/fcntl.h:1,
                 from /Users/xxx/Documents/Arduino/libraries/SdFat_-_Adafruit_Fork/src/FatLib/FatApiConstants.h:30,
                 from /Users/xxx/Documents/Arduino/libraries/SdFat_-_Adafruit_Fork/src/FatLib/FatFile.h:36,
                 from /Users/xxx/Documents/Arduino/libraries/SdFat_-_Adafruit_Fork/src/FatLib/ArduinoFiles.h:33,
                 from /Users/xxx/Documents/Arduino/libraries/SdFat_-_Adafruit_Fork/src/FatLib/FatLib.h:27,
                 from /Users/xxxx/Documents/Arduino/libraries/SdFat_-_Adafruit_Fork/src/SdFat.h:33,
                 from /Users/xxxx/Documents/Arduino/libraries/Adafruit_SPIFlash/examples/flash_info/flash_info.ino:4:
/Users/xxxxx/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/stat.h:27:8: error: redefinition of 'struct stat'
 struct stat
        ^~~~
In file included from /Users/xxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/cores/arduino/mbed/platform/mbed_error.h:21:0,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/cores/arduino/mbed/rtos/Queue.h:28,
                 from /Users/xxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/cores/arduino/mbed/rtos/Mail.h:28,
                 from /Users/xxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/cores/arduino/mbed/rtos/rtos.h:33,
                 from /Users/xxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/cores/arduino/mbed/mbed.h:23,
                 from /Users/xxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/cores/arduino/Arduino.h:32,
                 from /var/folders/mv/_ygj1fx50f9_sd6zn6fgyt3h0000gn/T/arduino_build_236814/sketch/flash_info.ino.cpp:1:
/Users/xxxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/cores/arduino/mbed/platform/mbed_retarget.h:500:8: note: previous definition of 'struct stat'
 struct stat {
        ^~~~
Se encontraron varias bibliotecas para "Adafruit_SPIFlash.h"
Usado: /Users/xxxx/Documents/Arduino/libraries/Adafruit_SPIFlash
Se encontraron varias bibliotecas para "SdFat.h"
Usado: /Users/xxxx/Documents/Arduino/libraries/SdFat_-_Adafruit_Fork
Se encontraron varias bibliotecas para "SPI.h"
Usado: /Users/xxxxx/Library/Arduino15/packages/arduino/hardware/mbed/1.1.4/libraries/SPI

Release 3.0.0 examples fail on Metro M4 Express, but 2.0.2 examples work just fine

As posted on https://forums.adafruit.com/viewtopic.php?f=63&t=154063:

With the latest version 3.0.0 of the Adafruit_SPIFlash library, I am having trouble getting the QSPI flash to work with Arduino on both my Metro M0 Express and Metro M4 Express boards:

  • The flash_info and flash_erase_express examples from the Adafruit_SPIFlash library do work.

  • The SdFat_format example fails like this:
    Adafruit SPI Flash FatFs Format Example
    Flash chip JEDEC ID: 0xC84015
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    This sketch will ERASE ALL DATA on the flash chip and format it with a new filesystem!
    Type OK (all caps) and press enter to continue.
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Failed to wipe

  • The flash_manipulator example fails:
    Adafruit Serial Flash Manipulator example
    JEDEC ID: C84015
    Flash size: 2097152
    Initializing SD card... Card failed, or not present

  • The SdFat_full_usage example fails (of course, because the QSPI flash is not formatted):
    Adafruit SPI Flash FatFs Full Usage Example
    Flash chip JEDEC ID: 0xC84015
    Error, failed to mount newly formatted filesystem!
    Was the flash chip formatted with the fatfs_format example?

It does not seem to be a hardware issue: I can restore the QSPI flash as CIRCUITPY drive for use with CircuitPython by double-clicking the reset button to enter the UF2 boot loader and dragging the appropriate file (today adafruit-circuitpython-metro_m4_express-en_US-4.0.2.uf) onto the METROBOOT drive.

Libraries are up-to-date:

  • Arduino IDE 1.8.9 with standard libraries up-to-date (7/13/19)
  • Adafruit SPIFlash version=3.0.0
  • SdFat version=1.0.16 from the Adafruit fork at https://github.com/adafruit/SdFat

After some further digging ....

With version 2.0.2 from https://github.com/adafruit/Adafruit_SP ... /tag/2.0.2, all the important examples work with my Metro M4 Express board: fatfs_circuitpython, fatfs_datalogging, fatfs_format, fatfs_full_usage, fatfs_print_file, flash_erase, and flash_erase_express. (SPI_Flash_Manipulator fails looking for an SD card, which I don't have; I didn't try circuitpython_backupFiles).

Since 2.0.2 is deprecated, I'd rather get 3.0.0 to work (or help with getting it to work), but I am not sure where to start.

Thanks,

microscope

[F-RAM] Would it be possible to add FRAM memory support?

I am trying to use a model FM25L04G F-RAM as a buffer for a flash memory to avoid unnecessary flash use, the flash being used only when there is definite data to be saved, as the F-RAM theoretically allows unlimited cycles reading and writing.

Based on the flash_devices.h file, I edited a new definition:

// Settings for the RAMTRON FM25L04G 4Kbit SPI F-RAM.
// Datasheet: https://www.dataman.com/media/datasheet/Ramtron/FM25L04.pdf
#define FM25L04  {\
    .total_size = (1 << 9), /* 512 bytes */ \
    .start_up_time_us = 10000, /* 10 ms */ \ 
    .manufacturer_id = 0x00, \
    .memory_type = 0x00, \
    .capacity = 0x09, \
    .max_clock_speed_mhz = 14, \
    .quad_enable_bit_mask = 0x00, \
    .has_sector_protection = false, \
    .supports_fast_read = false, \
    .supports_qspi = false, \
    .supports_qspi_writes = false, \
    .write_status_register_split = false, \
    .single_status_byte = true, \
}

This memory has few commands, and are of the same standard as Flash W25Q64, but has no JEDEC ID, how can I force the parameters described in the flash_devices.h file?

FM25L04G FRAM commands

flash device definition appears to be wrong

I tried using the W25Q80DL in a project and the JDEC ID didn't match the one in flash_devices.h It reports the memory_type as 0x40 not 0x60.

I was using a SAMD21 with the W25Q80DL flash chip from Winbond. I was testing using various spi Flash examples from this library.

I also noticed (unless I missed something) that the max speed is wrong. The datasheed list two device versions, one with a speed of 104MHz and the other with 80MHz. The DL variant has a top speed of 80MHz

W25Q80DV 104MHz
W25Q80DL 80MHz

To fix the problem I changed this definition in flash_devices.h:

#define W25Q80DL                                                               \
  {                                                                            \
    .total_size = (1UL << 20), /* 1 MiB */                                     \
        .start_up_time_us = 5000, .manufacturer_id = 0xef,                     \
    .memory_type = 0x60, .capacity = 0x14, .max_clock_speed_mhz = 104,         \
    .quad_enable_bit_mask = 0x02, .has_sector_protection = false,              \
    .supports_fast_read = true, .supports_qspi = true,                         \
    .supports_qspi_writes = false, .write_status_register_split = false,       \
    .single_status_byte = false, .is_fram = false,                             \
  }

To this:

#define W25Q80DL                                                               \
  {                                                                            \
    .total_size = (1UL << 20), /* 1 MiB */                                     \
        .start_up_time_us = 5000, .manufacturer_id = 0xef,                     \
    .memory_type = 0x40, .capacity = 0x14, .max_clock_speed_mhz = 80,         \
    .quad_enable_bit_mask = 0x02, .has_sector_protection = false,              \
    .supports_fast_read = true, .supports_qspi = true,                         \
    .supports_qspi_writes = false, .write_status_register_split = false,       \
    .single_status_byte = false, .is_fram = false,                             \
  }

Library does not work with Feather M0 Express With No Bootloader

I currently have two Feather M0 Express boards both running without a Boot-Loader as I am programming and debugging via SWD.

1)Original Feather: Uses standard fitted memory.
2)Modified Feather: Original fitted memory removed to use not supported Flash Memory AT25XV041B.

I selected no boot-loader by changing the boards.txt file:
Was: adafruit_feather_m0_express.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
Now: adafruit_feather_m0_express.build.ldscript=linker_scripts/gcc/flash_without_bootloader.ld

Having the No Boot-loader option enabled a can run all I2C code and SPI display code like the adafruit ST7735 library with no issues. As I have no USB connected I am using the Serial1 Hardware UART which is connected to my Digital Discovery Logic Analyser.

When using the example 'flash_info' program I return no results for either 'JEDEC ID:' or 'FLASH Size:' They are both blank. This is on the Original Feather.

When trying the same code on the Modified Feather I get the same blank results.

I did enter the AT25XV041B Flash into the 'flash_devices.h' file as shown below:

#define AT25XV041B \ { \ .total_size = (1 << 22), /* 4 MiB */ \ .start_up_time_us = 10000, .manufacturer_id = 0x1f, \ .memory_type = 0x44, .capacity = 0x01, .max_clock_speed_mhz = 85, \ .quad_enable_bit_mask = 0x00, .has_sector_protection = true, \ .supports_fast_read = true, .supports_qspi = true, \ .supports_qspi_writes = false, .write_status_register_split = false, \ .single_status_byte = false, \ }

I used my Digital Discovery Logic Analyser to spy in the SPI lines and noted that the SPI was reading the Flash chip and returning the following:
Data: h9F | h00, hFF | h1F, hFF | h44, hFF | h02,

This data output matches the datasheet but for some reason the 'JEDEC ID:' or 'FLASH Size:' They are both blank when looking at the serial out. Have I missed something?

I'm surprised that a Original Feather with no Boot-loader would return blank data as it uses the supported SPI Flash Data. Is there a way to get this library to work without a Boot-loader?

Thank you.

Conflict on class "File" definition with SD.h

I've written a M4 Express sketch that reads a file off an SD card and writes it to the onboard flash. I had a conflict between the class "File" which is defined in SD.h as well as Adafruit_SPIFlash_FatFs.h. I saw that SD.h has a namespace wrapper for "File" but Adafruit_SPIFlash_FatFs.h does not. Hence the conflict. I was able to make my sketch work by editing Adafruit_SPIFlash_FatFs, both .h & .cpp, with a replacement for "File". I replaced it with "FlashFile".

Is there a more elegant way these two Libraries to coexist?

W25Q128JV_SQ and W25Q128JV_PM don't work

I've made some boards with the 16 MBit chips: W25Q128JV_SQ, W25Q128JV_PM as well as a new IS25LP128F, which is not included in flash_devices.h but is included in circuitpython devices.h. None of them work out of the box so people should be careful using these larger chips, which I unfortunately need for audio files. I've tested boards with these chips with both circuitpython as well as this library. The code hangs right here for the IS25LP128F, which is the only one that at least appears to be recognized properly through JEDEC ID:

// The write in progress bit should be low. while ( readStatus() & 0x01 ) {} Serial.println("YOU SEE THIS ..."); // The suspended write/erase bit should be low. while ( readStatus2() & 0x80 ) {} Serial.println("BUT DON'T SEE THIS ...");

Adafruit_SPIFlashBase.h:35:28: warning: overflow in constant expression [-fpermissive]

Arduino: 1.8.13 (Windows 7), Board: "Arduino Mega 2560, ATmega2560 (Mega 2560)"
Modules used:

  • DeekRobot 8122 RTC & SDcard module, connected with I2C
  • TFT LCD 128x160 RGB with ST7735 chip, connected on ICSP header

When -not- using SPI but the SDcard on the this error pops up:

F:\Projecten\Arduino\libraries\Adafruit_SPIFlash\src/Adafruit_SPIFlashBase.h:35:26: warning: integer overflow in expression [-Woverflow]
SFLASH_BLOCK_SIZE = 64 * 1024,
~~~^~~~~~
F:\Projecten\Arduino\libraries\Adafruit_SPIFlash\src/Adafruit_SPIFlashBase.h:35:28: warning: overflow in constant expression [-fpermissive]
SFLASH_BLOCK_SIZE = 64 * 1024,
^~~~
F:\Projecten\Arduino\libraries\Adafruit_SPIFlash\src/Adafruit_SPIFlashBase.h:35:28: warning: overflow in constant expression [-fpermissive]

This also happens in the example BreakoutST7735-160x128.

Why is the NeoPixel library included in the dependencies?

NeoPixel is included in "depends" of library.properties.

NeoPixel may depend on SPIFlash, but I don't think SPIFlash depends on NeoPixel.
(I think NeoPixel is high-level and SPIFlash is low-level)

Please let me know if you need to depend on NeoPixel.
If you don't need a dependency, would you like to remove it from "depends"?
(I think simple is preferable for low-level)

Error on formatting SPI flash

Hi,

I'm using a W25Q64 external flash on ESP32.

The following problem occurs when trying to format the flash:

Adafruit SPI Flash FatFs Format Example Flash chip JEDEC ID: 0xEF4017 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! This sketch will ERASE ALL DATA on the flash chip and format it with a new filesystem! Type OK (all caps) and press enter to continue. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Creating and formatting FAT filesystem (this takes ~60 seconds)... Error, f_mount failed with error code: 13

Another person had the same problem, as: #58

read8, read16, and read32 don't work

The read8(), read16(), and read32() convenience routines don't work because they are testing the return value from readBuffer() incorrectly. For example:

uint8_t Adafruit_SPIFlash::read8(uint32_t addr)
{
	uint8_t ret;
	return readBuffer(addr, &ret, sizeof(ret)) ? 0xff : ret;
}

readBuffer() returns a count of bytes read, which will be interpreted as true if != 0, so this will return 0xff.

Adapting Library for different chip

Hi. I would like some help with using this library on the adafruit feather M0 adalogger and S25FL128L flash chip.

I am trying to get the msc_external_flash_sdcard example to work on an adafruit feather M0 adalogger with the flash chip SCK on pin 13, MISO on pin 12, MOSI on pin 11 and CS on pin 6.

The SD card is working perfect. I can use it over usb and in code perfectly. Now I want to get the flash working.

I created the new SPI Class for the pins I am using.

SPIClass flashSPI (&sercom1, 12, 13, 11, SPI_PAD_0_SCK_1, SERCOM_RX_PAD_3);
#define flash_cs 6 //Chip select pin
Adafruit_FlashTransport_SPI flashTransport(flash_cs, flashSPI);
Adafruit_SPIFlash flash(&flashTransport);
FatFileSystem fatfs;

When I read JEDEC ID, I get a value of 00d5h.
When I read page size I get 256.
When I read number of pages I get 0.

With the following:

usb_msc.setMaxLun(2);
usb_msc.setID(0, "Flash Memory", "External Flash", "1.0");
usb_msc.setID(1, "SD Memory", "SD Card", "1.0");
usb_msc.begin();

"SD Memory" and "Flash Memory" are both detected as storage devices over USB in task manager. The SD works perfectly but not the Flash.

Any help will be appreciated.

Thank you.

Using Adafruit_SPIFlash on the Metro M4

Dear All:

I am doing a project for school involving the Metro M4. One of the features of the M4 I am exploiting is its data logging ability with the QSPI flash memory. I actually declared nominal success on this project back in February with the exception of some bugs, mostly an inability to consistently extract the data file from the Flash drive.
I was writing a manual for the operation of my system when I learned that the QSPI library had just been depreciated and that the Adafruit_SPIFlash library had been heavily revised. So I downloaded the newest versions of the Adafruit_SPIFlash (3.1.1) and SDFat (1.1.0) libraries. After some tinkering, I ran the SDFat_Format.ino sketch to re-format my Metro M4's flash memory. At the end, I got this message:

Error, failed to mount newly formatted filesystem!

Are there any configuration settings I have to first change before I run the sketch? I know the sketch was primarily written for the M0. However, the M4 uses a QSPI protocol to communicate with its on-board memory. I see these settings at the beginning of the file.

#if defined(__SAMD51__) || defined(NRF52840_XXAA)
  Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS, PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
#else
  #if (SPI_INTERFACES_COUNT == 1)
    Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
  #else
    Adafruit_FlashTransport_SPI flashTransport(SS1, &SPI1);
  #endif
#endif

Adafruit_SPIFlash flash(&flashTransport);

// file system object from SdFat
FatFileSystem fatfs;

How should I ensure that __SAMD51__ is defined? Do I #define it manually?

In my original data logging code, the flash type is Adafruit_QSPI_GD25Q. The FAT system is Adafruit_W25Q16BV_Fatfs. How can I ensure that these options are set properly in the new libraries?

I got this error from working in the school lab last night. I wasn't allowed a lot of time to attend to this issue. I know that there have been a lot of postings on the Adafruit forum about the M4 and the SPIFlash library so I apologize if my question is already answered. I will try to go to the lab either today or Monday and will post any updates.
I would appreciate it if someone could help me. A big bonus if the data file is no longer corrupted on any write.

Also, I was checking out this website address:

https://learn.adafruit.com/adafruit-fea ... -spi-flash

So this represents the learning website for using the SPIFLASH library. Here is the link to the library.

https://github.com/adafruit/Adafruit_SP ... master.zip

Now, the website gives this list of sketches that I will be able to run:
fatfs_circuitpython
fatfs_datalogging
fatfs_format
fatfs_full_usage
fatfs_print_file
flash_erase

None of the sketches that start with fatfs are in the zip file. Will the SDFat_format sketch really encompass QSPI flash memories and the Metro M4?

I got this error from working in the school lab last night. I wasn't allowed a lot of time to attend to this issue. I know that there have been a lot of postings on the Adafruit forum about the M4 and the SPIFlash library so I apologize if my question is already answered. I will try to go to the lab either today or Monday and will post any updates.
I would appreciate it if someone could help me. A big bonus if the data file is no longer corrupted on any write.

Error : Couldn't write updated sector!

flash :W25Q16BV
Serial Monitor OP:

Adafruit SPI Flash FatFs Format Example
Flash chip JEDEC ID: 0xEF
Partitioning flash with 1 primary partition...
Couldn't write updated sector!
Error, f_fdisk failed with error code: 1

I am getting this error in fatfs format example.

Anyone get file system corruption when using Adafruit_BluefruitLE_nRF51-master?

Hi Guys,

I am having difficulty localizing a file system corruption issue using the Adafruit_SPIFlash library as my program for a Feather M4 Express gets more and more complex. I find when I use Serial.end() after beginning BLE (I'm using Adafruit_BluefruitLE_nRF51-master), I get far greater reliability. But even then I eventually get some file system corruption after multiple (a couple 100) deletes/writes. Has anyone experienced these issues of file syste corruption and how do you deal with it? My program often re-writes files and the way I am doing it is simply erasing the file first and then re-writing it many times. Is that a good way of doing it or could that also be causing issues? For example, to change the number of LEDs used, my function is as follows:

bool changeNumberOfLEDs(byte data) { numberOfLEDs = data; if (!fatfs.remove(MAINSETTINGS)) { //Serial.println("Error, couldn't delete the preset file!"); while(1) yield(); } else { myFile.open(MAINSETTINGS, FILE_READ); if (!myFile) { if(myFile.open(MAINSETTINGS, FILE_WRITE)) { String strToWrite = currentMainSettings.substring(mainSettingsDataLocations[0],mainSettingsDataLocations[5])+String(data)+currentMainSettings.substring(mainSettingsDataLocations[6]-1,currentMainSettings.length()); myFile.write(strToWrite.c_str(), strlen(strToWrite.c_str())); myFile.close(); currentMainSettings = strToWrite; loadMainSettings(MAINSETTINGS); } else { return false; } return true; } else { myFile.close();} } return false; }

Updated to version 3.1.4

I have a small project that was working on a Adafruit Feather HUZZAH ESP8266, I updated my libraries and the project no longer compiles. I stripped away the code to only debug the essential libraries and the following still does not compile.

#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_HX8357.h> // Hardware-specific library
#include <SdFat.h> // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h> // SPI / QSPI flash library

// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}

Im getting this error;

In file included from /Users/manuelgonzalez/Documents/Arduino/debug_sketch/debug_sketch.ino:8:0:
/Users/manuelgonzalez/Documents/Arduino/libraries/Adafruit_SPIFlash/src/Adafruit_SPIFlash.h:39:4: error: #error ENABLE_EXTENDED_TRANSFER_CLASS must be set to 1 in SdFat SdFatConfig.h
#error ENABLE_EXTENDED_TRANSFER_CLASS must be set to 1 in SdFat SdFatConfig.h
^
/Users/manuelgonzalez/Documents/Arduino/libraries/Adafruit_SPIFlash/src/Adafruit_SPIFlash.h:43:4: error: #error FAT12_SUPPORT must be set to 1 in SdFat SdFatConfig.h
#error FAT12_SUPPORT must be set to 1 in SdFat SdFatConfig.h
^
exit status 1
Error compiling for board Adafruit Feather HUZZAH ESP8266.

How do I resolve this issue? Thanks!

File System corruption with 32MB flash after writing ~16MB

I am using W25Q256JV to save wav files. I have it up and running using sdfat and this library and can save files to the flash and read them back out. However once I save enough files to the flash to exceed about half the capacity of the flash (~16MB) the file system becomes corrupt and will no longer mount. See below for the device settings used.

Was this library written for a max flash size of 16MB? Or is this just a potential bug? Any ideas on where to start digging to save me some time would be appreciated!

// Settings for the Winbond W25Q256JV 32MiB SPI flash.
// Datasheet:
// https://www.winbond.com/resource-files/w25q256jv%20spi%20revg%2008032017.pdf
#define W25Q256JV                                                              \
  {                                                                            \
    .total_size = (1 << 25), /* 32 MiB */                                      \
        .start_up_time_us = 5000, .manufacturer_id = 0xef,                     \
    .memory_type = 0x40, .capacity = 0x19, .max_clock_speed_mhz = 133,         \
    .quad_enable_bit_mask = 0x02, .has_sector_protection = false,              \
    .supports_fast_read = true, .supports_qspi = true,                         \
    .supports_qspi_writes = true, .write_status_register_split = false,        \
    .single_status_byte = false,                                               \
  }

Can't format SPI flash on Feather M0 Express

I want to format the onboard flash on the Feather M0 Express and store some files there.
The format example gives the following output:

Adafruit SPI Flash FatFs Format Example
Flash chip JEDEC ID: 0x14015
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This sketch will ERASE ALL DATA on the flash chip and format it with a new filesystem!
Type OK (all caps) and press enter to continue.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Creating and formatting FAT filesystem (this takes ~60 seconds)...
Formatted flash!
Error, failed to mount newly formatted filesystem!

Adafrut_SPIFlash Lib with ESP32-S2 Arduino Core

I've been trying to get some of the examples to compile for the Saola board using external SPI Fram - a configuration which compiles and works well with SAMD21/51 boards as long as DMA spi reads are disabled. (#65)

For the Saola I uncomment the custom spi pin defines but on compile I get:

error: 'esp_partition_t' does not name a type; did you mean 'esp_ptr_internal'?
esp_partition_t const *_partition;
^~~~~~~~~~~~~~~
esp_ptr_internal

I get get the same error if I leave the default defines to target the internal flash partition with FATFS default partition scheme.
Any pointers? (no pun).

In the meantime I'm looking for clues based on this: #78

BTW, Thank you for the terrific library. Using it in combination with TinyUSB to expose my Fram to usb msc is truly liberating!

Nick

Did not work with github.com/stm32duino/Arduino_Core_STM32

If anyone tries to use the SPI2 port (Blue Pill, STM32F103C8T6), only core github.com/rogerclarkmelbourne/Arduino_STM32 worked.

Did not worked (Arduino_Core_STM32):

#define MOSI2 PB15
#define MISO2 PB14
#define SCLK2 PB13
#define SS2 PB12

//SPIClass(uint8_t mosi, uint8_t miso, uint8_t sclk, uint8_t ssel)
SPIClass SPI_2 = SPIClass(MOSI2, MISO2, SCLK2, SS2);

Adafruit_FlashTransport_SPI flashTransport(SS2, &SPI_2);

void setup() {
  SPI_2.begin();
 //  remaining code below
}

It worked (Arduino_STM32):

#define SS2 PB12
SPIClass SPI_2(2);
Adafruit_FlashTransport_SPI flashTransport(SS2, &SPI_2);

Reported here for future research:
stm32duino/Arduino_Core_STM32#669

writeBuffer fails with non-page aligned addresses

The function Adafruit_SPIFlash::writeBuffer takes an address in flash, a pointer to data, and a length. It splits up the write into page sized operations (the largest the underlying chips can program at a time), and continues until the whole buffer is written.

The code correctly handles writes smaller than a page, and writes where the last chunk is less than a full page. Flash chips correctly handle these partial page program operations, leaving the other parts of the page intact.

However, the code in Adafruit_SPIFlash::writeBuffer incorrectly handles the case where the address is not page aligned, and the length is long enough to spill into the next page.

For example:

    flash.writeBuffer(0x0020, mydatabuffer, 320);

In this case, the current code will program two chunks:

  • @ address 0x0020, for 256 bytes
  • @ address 0x0120, for 64 bytes

Flash chips do not support the first operation in the way one might expect: They wrap the data at the page boundary, and so bytes 224 to 255 are written into addresses 0x0000 to 0x0019, that is, on the first page, in front of bytes 0 to 223!

The correct chunking should be:

  • @ address 0x0020, for 224 bytes
  • @ address 0x0100, for 96 bytes

The following function correctly computes the chunking:

  uint32_t writeBuffer (
    Adafruit_SPIFlash& flash,
    uint32_t address, uint8_t const *buffer, uint32_t len)
  {
    uint32_t remain = len;

    // write one page at a time
    while(remain)
    {
      uint32_t const leftOnPage
        = SFLASH_PAGE_SIZE - (address & (SFLASH_PAGE_SIZE - 1));

      uint32_t const toWrite = min(remain, leftOnPage);

      if (flash.writeBuffer(address, buffer, toWrite) != toWrite) break;

      remain -= toWrite;
      buffer += toWrite;
      address += toWrite;
    }

    return len - remain;
  }

The logic of leftOnPage should be incorporated into Adafruit_SPIFlash::writeBuffer.

SAMD SPI Read issue

Describe the bug
When improving spi flash accessing speed, I find out that M0 can perform SPI DMA write without issue, but can only carry out exactly 1 DMA Read (still has issue).

Code that enable DMA write
https://github.com/adafruit/Adafruit_SPIFlash/blob/master/src/spi/Adafruit_FlashTransport_SPI.cpp#L147

Code that eanble DMA read
https://github.com/adafruit/Adafruit_SPIFlash/blob/master/src/spi/Adafruit_FlashTransport_SPI.cpp#L121

Set up (mandatory)

  • PC & IDE : Arduino 1.8.13 on Ubuntu 20.04
  • Board : Feather M0 Express
  • BSP : 1.6.1 (or current github master)
  • Sketch: Adafruit_SPIFlash/examples/flash_speedtest

To Reproduce
Steps to reproduce the behavior:

  1. Uncomment this #elif to enable SPI DMA read https://github.com/adafruit/Adafruit_SPIFlash/blob/master/src/spi/Adafruit_FlashTransport_SPI.cpp#L119 Code should be
#elif defined(ARDUINO_ARCH_SAMD) && defined(_ADAFRUIT_ZERODMA_H_)
  // TODO Could only got the 1st SPI read work, 2nd will failed, maybe we
  // didn't clear thing !!!
  _spi->transfer(NULL, data, len, true);
  1. Run the flash_speedtest example
  2. See error

Context
the example sketch will

  • erase the chip,
  • write 0xAA to the whole chip
  • then read back and compare.

Then it does the second pass with 0x55 pattern. The sketch complete successfully when DMA Read is not used, and failed when it does. In both cases DMA Write is eanbled. Below is the output log.

By my observation, the DMA Read seems to have an error, it does read several hundreds byte before failing. Afterwards, it doesn't seem to be able to execute another Read ( second pass is all zeroes).

@PaintYourDragon @ladyada Since you are expert on SPI DMA on SAMD, would you mind taking a look at the issue. It is probably some condition is not clear, or maybe I didn't understand enough of the DMA API. Thanks in advance.

Serial Log

With DMA Read eanbled

Adafruit Serial Flash Speed Test example
JEDEC ID: C84015
Flash size: 2097152
Erase chip
Write flash with 0xAA
Write 2097152 bytes in 4.63 seconds.
Speed : 452.95 KB/s.

Read flash and compare
Error: flash contents mismatched at address 0x00000000!!!
000: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
010: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
020: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
030: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
040: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
050: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
060: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
070: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
080: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
090: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
0A0: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
0B0: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
.......................
320: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
330: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
340: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
350: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
360: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
370: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
380: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
390: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
3A0: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
3B0: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
3C0: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
3D0: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
3E0: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
3F0: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
400: AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA 
410: AA AA AA AA AA 00 00 00 00 00 00 00 00 00 00 00 
420: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
430: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
.......................
FE0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
FF0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Erase chip
Write flash with 0x55
Write 2097152 bytes in 11.45 seconds.
Speed : 183.22 KB/s.

Read flash and compare
Error: flash contents mismatched at address 0x00000000!!!
000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
.......................
FE0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
FF0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Speed test is completed.

Without DMA Read

Adafruit Serial Flash Speed Test example
JEDEC ID: C84015
Flash size: 2097152
Erase chip
Write flash with 0xAA
Write 2097152 bytes in 4.64 seconds.
Speed : 452.07 KB/s.

Read flash and compare
Read  2097152 bytes in 3.54 seconds.
Speed : 592.08 KB/s.

Erase chip
Write flash with 0x55
Write 2097152 bytes in 4.64 seconds.
Speed : 452.46 KB/s.

Read flash and compare
Read  2097152 bytes in 3.54 seconds.
Speed : 592.42 KB/s.

Speed test is completed.

Unable to compile, missing declarations

Describe the bug
I am compiling a program that uses Adafruit_ImageReader. The latest version requires Adafruit_SPIFlash. When compiling using Adafruit_SPIFlash version 3.2.2, everything compiles properly with no errors or warnings. When I upgrade to Adafruit_SPIFlash version 3.3.0, I receive many errors that state values are not declared in the scope (see below for details). When I revert back to 3.2.2, everything compiles correctly. I wasx able to reproduce this in a very simple program (attached below).

Set up (mandatory)

  • PC & IDE : Arduino 1.8.12 Windows 10
  • Board : NodeMCU-32S
  • Libraries versions
    Adafruit BUSIO 1.50
    Adafruit EPD 2.53
    Adafruit GFX 1.10.1
    Adafruit ILI9341 1.56
    Adafruit ImageReader 2.4.0
    Adafruit SPIFlash 3.3.0
    SdFat 1.1.4 <- with required changes
    // SdFat library, editing the default SdFatConfig.h file
    // #define USE_STANDARD_SPI_LIBRARY 2
    // #define FAT12_SUPPORT 1
    // #define ENABLE_EXTENDED_TRANSFER_CLASS 1

To Reproduce
Steps to reproduce the behavior:
Run the following code using the board NodeMCU-32S

  • Program starts here -
    #include <SdFat.h>
    #include <SPI.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_ILI9341.h>
    #include <Adafruit_ImageReader.h>
    #include <Adafruit_ImageReader_EPD.h>
    Adafruit_ImageReader *reader;
    ImageReturnCode ImageReaderStat;
    void setup() {
    }
    void loop() {
    }
  • Program ends here -

Serial Log
...\Arduino\libraries\Adafruit_SPIFlash\src/spi/Adafruit_FlashTransport_SPI.h:61:50: error: 'MSBFIRST' was not declared in this scope

 _spi->beginTransaction(SPISettings(clock_hz, MSBFIRST, SPI_MODE0));

Arduino\libraries\Adafruit_SPIFlash\src/spi/Adafruit_FlashTransport_SPI.h:62:23: error: 'LOW' was not declared in this scope

 digitalWrite(_ss, LOW);

                   ^

...\Arduino\libraries\Adafruit_SPIFlash\src/spi/Adafruit_FlashTransport_SPI.h:62:26: error: 'digitalWrite' was not declared in this scope

 digitalWrite(_ss, LOW);

                      ^

...\Arduino\libraries\Adafruit_SPIFlash\src/spi/Adafruit_FlashTransport_SPI.h: In member function 'void Adafruit_FlashTransport_SPI::endTransaction()':

...\Arduino\libraries\Adafruit_SPIFlash\src/spi/Adafruit_FlashTransport_SPI.h:66:23: error: 'HIGH' was not declared in this scope

 digitalWrite(_ss, HIGH);

                   ^

...\Arduino\libraries\Adafruit_SPIFlash\src/spi/Adafruit_FlashTransport_SPI.h:66:27: error: 'digitalWrite' was not declared in this scope

 digitalWrite(_ss, HIGH);

                       ^

...\Arduino\libraries\Adafruit_SPIFlash\src/Adafruit_SPIFlashBase.h:89:44: error: 'HIGH' was not declared in this scope

   digitalWrite(_ind_pin, _ind_active ? HIGH : LOW);

                                        ^

and many more ...........

writeBuffer works sometimes?

Been investigating using the flash memory on the IstyBitsy M4 to store some persistent data over resets.
So started with the flash_manipulator.ino code and modified to only use page 0 (for now).
Firstly succeeded in writing some data, great.
Then went to change it, no luck, using the same code.
Found that if I erase the chip before writing to the flash, the data on the flash is altered by the change invoked by writeBuffer otherwise the data remains unchanged.

output from setup

Adafruit Serial Flash Manipulator example
JEDEC ID: C84015
Flash size: 2097152
Page size: 256
Number of pages: 8192

Modified code is in attached file
TestFlashManipulator.ino.txt

Conflict with ESP8266 core

  • ESP8266 BSP = 2.6.2
  • Target Board = "Adafruit Feather HUZZAH ESP8266"

Test sketch:

#include <Adafruit_SPIFlash.h>
#include "ESP8266WiFi.h"

void setup() {
}

void loop() {
}

error:

/home/user/.arduino15/packages/esp8266/hardware/esp8266/2.6.2/cores/esp8266/FS.h:258:11: error: 'File' is already declared in this scope
 using fs::File;

EDIT forgot to add reference thread:
https://forums.adafruit.com/viewtopic.php?f=57&t=159452

eraseChip() not working on ESP32-S2

Operating System

MacOS

IDE version

1.8.13

Board

Adafruit FunHouse ESP32S2

BSP version

Latest

SPIFlash Library version

3.5.2

Sketch

https://github.com/adafruit/Adafruit_SPIFlash/blob/master/examples/flash_erase_express/flash_erase_express.ino

What happened ?

Running flash_erase or calling flash.eraseChip() on an ESP32-S2 does not seem to erase the contents of a pre-existing filesystem

How to reproduce ?

  1. Load CircuitPython onto an ESP32S2 to create the FS + files
  2. Run https://github.com/adafruit/Adafruit_SPIFlash/blob/master/examples/flash_erase_express/flash_erase_express.ino
  3. Open mounted CIRCUITPY drive, files are still there.

Debug Log

No response

Screenshots

No response

Unable to use both SD.h and Adafruit_SPIFlash.h in the same sketch

Describe the bug

I am unable to use the builtin SDCard slot and onboard SPI Flash on my Grand Central M4. I get compilation errors.
Including SD.h and Adafruit_SPIFlash.h yields different compilation errors depending on order of includes (SD.h before or after Adafruit_SPIFlash.h).

For now, I have disabled the SPIFlash code as the sd card is more useful for my purposes.

I have attached the full console output from each run, I don't know how useful they are since they are both quite massive. I made the reduced test cases directly in the sketch where I found the error. Here they are:

SD_h_is_first.txt
SD_h_is_second.txt

Set up (mandatory)

  • PC & IDE : Arduino 1.8.12 on Gentoo Linux amd64
  • Board : Grand Central M4
  • BSP : Adafruit SAMD Boards v 1.6.4 with boards.txt modified to compile in gnu++17 mode
  • Sketch: see Custom Sketches section

To Reproduce
Steps to reproduce the behavior:
Run verify on each custom sketch below to see each error

Compiler Error Output
When SD.h comes after Adafruit_SPIFlash.h:

In file included from /home/jwscoggins/dev/sketches/i960_Prototype_Simulator/i960_Prototype_Simulator.ino:140:
/home/jwscoggins/dev/sketches/libraries/SD/src/SD.h:23: warning: "FILE_READ" redefined
   23 | #define FILE_READ O_READ
      | 
In file included from /home/jwscoggins/dev/sketches/libraries/SdFat_-_Adafruit_Fork/src/FatLib/FatLib.h:27,
                 from /home/jwscoggins/dev/sketches/libraries/SdFat_-_Adafruit_Fork/src/SdFat.h:33,
                 from /home/jwscoggins/dev/sketches/i960_Prototype_Simulator/i960_Prototype_Simulator.ino:138:
/home/jwscoggins/dev/sketches/libraries/SdFat_-_Adafruit_Fork/src/FatLib/ArduinoFiles.h:37: note: this is the location of the previous definition
   37 | #define FILE_READ O_RDONLY
      | 
In file included from /home/jwscoggins/dev/sketches/i960_Prototype_Simulator/i960_Prototype_Simulator.ino:140:
/home/jwscoggins/dev/sketches/libraries/SD/src/SD.h:24: warning: "FILE_WRITE" redefined
   24 | #define FILE_WRITE (O_READ | O_WRITE | O_CREAT | O_APPEND)
      | 
In file included from /home/jwscoggins/dev/sketches/libraries/SdFat_-_Adafruit_Fork/src/FatLib/FatLib.h:27,
                 from /home/jwscoggins/dev/sketches/libraries/SdFat_-_Adafruit_Fork/src/SdFat.h:33,
                 from /home/jwscoggins/dev/sketches/i960_Prototype_Simulator/i960_Prototype_Simulator.ino:138:
/home/jwscoggins/dev/sketches/libraries/SdFat_-_Adafruit_Fork/src/FatLib/ArduinoFiles.h:39: note: this is the location of the previous definition
   39 | #define FILE_WRITE (O_RDWR | O_CREAT | O_AT_END)
      | 
In file included from /home/jwscoggins/dev/sketches/i960_Prototype_Simulator/i960_Prototype_Simulator.ino:140:
/home/jwscoggins/dev/sketches/libraries/SD/src/SD.h:63:7: error: 'SdVolume' does not name a type; did you mean 'FatVolume'?
   63 |       SdVolume volume;
      |       ^~~~~~~~
      |       FatVolume
/home/jwscoggins/dev/sketches/libraries/SD/src/SD.h:71:37: error: 'SD_CHIP_SELECT_PIN' was not declared in this scope
   71 |       boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN);
      |                                     ^~~~~~~~~~~~~~~~~~

And when SD.h comes before Adafruit_SPIFlash.h

In file included from /home/jwscoggins/dev/sketches/i960_Prototype_Simulator/i960_Prototype_Simulator.ino:139:
/home/jwscoggins/dev/sketches/libraries/Adafruit_SPIFlash/src/Adafruit_SPIFlash.h:50:49: error: expected class-name before ',' token
   50 | class Adafruit_SPIFlash : public BaseBlockDriver, public Adafruit_SPIFlashBase {
      |                                                 ^

Custom Sketches

// SD.h after Adafruit_SPIFlash.h
#include <SdFat.h>
#include <Adafruit_SPIFlash.h>
#include <SD.h>
Adafruit_FlashTransport_QSPI flashTransport;
Adafruit_SPIFlash flash(&flashTransport);
void setup() {
    flash.begin();
}
void loop() {
    delay(100);
}

and

// SD.h before Adafruit_SPIFlash.h
#include <SD.h>
#include <SdFat.h>
#include <Adafruit_SPIFlash.h>

Adafruit_FlashTransport_QSPI flashTransport;
Adafruit_SPIFlash flash(&flashTransport);
void setup() {
    flash.begin();
}
void loop() {
    delay(100);
}

nRF52 QSPI transport fails to operate in 1BIT I/O mode

Operating System

Linux

IDE version

Arduino 1.6+

Board

nRF52840

BSP version

1.0.0

SPIFlash Library version

Latest

Sketch

msc_external_flash.ino from Adafruit_TinyUSB_Arduino examples.

What happened ?

Adafruit_FlashTransport_QSPI_NRF.cpp always uses 'hard-coded' 4-bits data R/W transfer:

      .prot_if = {.readoc = NRF_QSPI_READOC_READ4O, // 0x6B read command
                  .writeoc = NRF_QSPI_WRITEOC_PP4O, // 0x32 write command

regardless of the

.supports_qspi = false,

defined in the flash_devices.h

The _supports_qspi _ variable has an effect on STATUS REGISTER value, but not on the R/W COMMANDs data width.

To maintain compatibility with 1BIT data transfer mode I would suggest to initialize the nRF52 QSPI transport as follows:

      .prot_if = {.readoc = NRF_QSPI_READOC_FASTREAD, // 0x0B read command
                  .writeoc = NRF_QSPI_WRITEOC_PP, // 0x02 write command

then update the data transfer method if the .supports_qspi is true for flash IC been detected.

How to reproduce ?

build and run sketch listed above.

Debug Log

No response

Screenshots

No response

Can't format flash - ItsyBitsy M4 Express with onboard flash

For some reason I get an "Error, f_mount failed with error code: 13" when trying to run the SdFat_format example.

I am using the built in flash on the board, and it appears to be communicating correctly and responding 0xC84015 as it should.

Am I doing something wrong, or is this a bug?

  • PC & IDE : Arduino 1.8.13 on Windows 7
  • Board : ItsyBitsy M4 Express
  • BSP : Adafruit SAMD 1.6.0
  • Sketch: SdFat_format

To Reproduce
Steps to reproduce the behavior:

  1. Load example to board, type "OK", hit enter...
Adafruit SPI Flash FatFs Format Example
Flash chip JEDEC ID: 0xC84015
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This sketch will ERASE ALL DATA on the flash chip and format it with a new filesystem!
Type OK (all caps) and press enter to continue.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Creating and formatting FAT filesystem (this takes ~60 seconds)...
Error, f_mount failed with error code: 13

EDIT : Using library 3.2.2 does not work, using library 2.0.2 does work as it's supposed to.

Support for overriding flash type autodetection

It would be nice to be able to specify an explicit flash device, rather than rely on auto-detection. Currently, it seems that not all devices in flash_devices.h are detectable, due to not existing in possible_devices (Adafruit_SPIFlashBase.cpp). Perhaps there could be some simple API for passing in some explicit device (likely from flash_devices.h), such as in the begin() method. Thoughts?

It would be better to point users to your library, rather than maintain a fork.

Great work otherwise! Thanks for the awesome library :)

Library does not compile for RP2040-based boards due to missing F_CPU

Operating System

Linux

IDE version

1.8.16

Board

Raspberry Pi Pico

BSP version

2.4.1

SPIFlash Library version

3.7.0

Sketch

#include <Adafruit_SPIFlash.h>

void setup() {}
void loop() {}

What happened ?

(I'm reporting this for someone else, neither of us is using this library directly, it's getting pulled in through Adafruit_ImageReader)

Compile error:

libraries/Adafruit_SPIFlash/src/Adafruit_SPIFlashBase.cpp:202:71: error: 'F_CPU' was not declared in this scope
       (uint32_t)_flash_dev->max_clock_speed_mhz * 1000000U, (uint32_t)F_CPU);

Likely because of arduino/ArduinoCore-mbed#221.

How to reproduce ?

  1. Try to compile
  2. That's it really

Debug Log

No response

Screenshots

No response

Support to SST26VF064B Flash

Hello,

I try to add support for SST26VF064B with

#define SST_SST26VF064B {\
    .total_size = (1 << 23), /* 8 MiB */ \
    .start_up_time_us = 10000, \
    .manufacturer_id = 0xbf, \
    .memory_type = 0x26, \
    .capacity = 0x43, \
    .max_clock_speed_mhz = 104, \
    .quad_enable_bit_mask = 0x01, \
    .has_sector_protection = false, \
    .supports_fast_read = true, \
    .supports_qspi = true, \
    .supports_qspi_writes = true, \
    .write_status_register_split = false, \
    .single_status_byte = false, \
}

I add the define in: static const external_flash_device possible_devices[]

All seams ok but the MCU freeze in detection.
Any parameter in the flash define is incorrect ?

I the file Adafruit_SPIFlash.cpp if none flash was detect I suggest to change from:
if (_flash_dev == NULL) return false;
to
if (_flash_dev == NULL || jedec_ids[0] == 255 ) return false;

Because the flash begin() init always return true if no device detected.

Thank you

Formatting SPI flash doesn't create a Volume

Hi, I'm using a Feather M0 adalogger, with an external W25Q64.

I have it wired to Hardware SPI and CS = A1.

Using the example, I first run flash_erase which succeeds.

Then when I run SdFat_format I get the following output:

Adafruit SPI Flash FatFs Format Example Flash chip JEDEC ID: 0xEF4017 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! This sketch will ERASE ALL DATA on the flash chip and format it with a new filesystem! Type OK (all caps) and press enter to continue. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Creating and formatting FAT filesystem (this takes ~60 seconds)... Error, f_mount failed with error code: 13

Error 13, meaning no volume exists, but the previous command to create the file system passes without issue.

I'm running the examples as stock except for changing this section:

Adafruit_FlashTransport_SPI flashTransport(A1,SPI); Adafruit_SPIFlash flash(&flashTransport);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.