Hi so,
Now it looks like an SPI issue?
Any input from the great Hive mind here
// Adafruit Grand Central M4 QSPI Flash and SD Card Setup Example
// Author: Joshua Scoggins
//
// This is an example of how to bring up both the QSPI Flash and SD Card found
// on the Adafruit Grand Central M4. This example will setup both the QSPI
// Flash and SD card (if present) and display information about the QSPI flash.
//
#include <SPI.h>
#include <SdFat.h>
#include <Adafruit_SPIFlash.h>
// for flashTransport definition
#include "flash_config.h"
Adafruit_SPIFlash onboardFlash(&flashTransport);
SdFat onboardSdCard;
SPIClass SPI_2(NRF_SPIM2, D9, D8, D10); // MISO, SCK, MOSI
Adafruit_FlashTransport_SPI expflashTransport(2, &SPI_2);
Adafruit_SPIFlash expFlash(&expflashTransport);
constexpr int getSDCardPin() noexcept {
#ifdef SDCARD_SS_PIN
return SDCARD_SS_PIN;
#else
// modify to fit your needs
// by default, pin 4 is the SD_CS pin used by the Adafruit 1.8" TFT SD Shield
return 4;
#endif
}
void setup() {
pinMode(D1, OUTPUT); // CS
digitalWrite(D1, HIGH);
Serial.begin(9600);
while (!Serial) {
// wait for native usb
delay(2100);
}
Serial.print("Starting up onboard QSPI Flash...");
onboardFlash.begin(&P25Q16H,1);
Serial.println("Done");
Serial.println("Onboard Flash information");
Serial.print("JEDEC ID: 0x");
Serial.println(onboardFlash.getJEDECID(), HEX);
Serial.print("Flash size: ");
Serial.print(onboardFlash.size() / 1024);
Serial.println(" KB");
Serial.print("Starting up Grove Expansion SPI Flash...");
//expFlash.begin(&W25Q80DV,1);
Serial.println("Done");
Serial.println("Expansion board Flash information");
Serial.print("JEDEC ID: 0x");
Serial.println(expFlash.getJEDECID(), HEX);
Serial.print("Flash size: ");
Serial.print(expFlash.size() / 1024);
Serial.println(" KB");
Serial.print("Starting up SD Card...");
if (!onboardSdCard.begin(getSDCardPin())) {
Serial.println("No card found (is one inserted?)");
} else {
Serial.println("Card found!");
}
}
void loop() {
// nothing to do
}
No go? here’s the output.
Adafruit SPI Flash FatFs Format Example
Error, failed to initialize flash chip!
Thank you in advance for your support.
GL PJ
flash_config.h—below—
/*
* The MIT License (MIT)
*
* Copyright (c) 2022 Ha Thach (tinyusb.org) for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef FLASH_CONFIG_H_
#define FLASH_CONFIG_H_
SPIFlash_Device_t const P25Q16H {
.total_size = (1UL << 21), // 2MiB
.start_up_time_us = 10000, // Don't know where to find that value
.manufacturer_id = 0x85,
.memory_type = 0x60,
.capacity = 0x15,
.max_clock_speed_mhz = 55,
.quad_enable_bit_mask = 0x02, // Datasheet p. 27
.has_sector_protection = 1, // Datasheet p. 27
.supports_fast_read = 1, // Datasheet p. 29
.supports_qspi = 1, // Obviously
.supports_qspi_writes = 1, // Datasheet p. 41
.write_status_register_split = 1, // Datasheet p. 28
.single_status_byte = 0, // 2 bytes
.is_fram = 0, // Flash Memory
};
/*SPIFlash_Device_t const W25Q80DV {
.total_size = (1UL << 20), // 2MiB
.start_up_time_us = 5000, // Don't know where to find that value
.manufacturer_id = 0xEF,
.memory_type = 0x40,
.capacity = 0x14,
.max_clock_speed_mhz = 104,
.quad_enable_bit_mask = 0x02, // Datasheet p. 27
.has_sector_protection = 0, // Datasheet p. 27
.supports_fast_read = 1, // Datasheet p. 29
.supports_qspi = 1, // Obviously
.supports_qspi_writes = 0, // Datasheet p. 41
.write_status_register_split = 0, // Datasheet p. 28
.single_status_byte = 0, // 2 bytes
.is_fram = 0, // Flash Memory
};
*/
// Un-comment to run example with custom SPI and SS e.g with FRAM breakout
//#define CUSTOM_CS D1
//#define CUSTOM_SPI SPI
#if defined(CUSTOM_CS) && defined(CUSTOM_SPI)
Adafruit_FlashTransport_SPI expflashTransport(CUSTOM_CS, CUSTOM_SPI);
#elif defined(ARDUINO_ARCH_ESP32)
// ESP32 use same flash device that store code for file system.
// SPIFlash will parse partition.cvs to detect FATFS partition to use
Adafruit_FlashTransport_ESP32 flashTransport;
#elif defined(ARDUINO_ARCH_RP2040)
// RP2040 use same flash device that store code for file system. Therefore we
// only need to specify start address and size (no need SPI or SS)
// By default (start=0, size=0), values that match file system setting in
// 'Tools->Flash Size' menu selection will be used.
Adafruit_FlashTransport_RP2040 flashTransport;
// To be compatible with CircuitPython partition scheme (start_address = 1 MB,
// size = total flash - 1 MB) use const value (CPY_START_ADDR, CPY_SIZE) or
// subclass Adafruit_FlashTransport_RP2040_CPY. Un-comment either of the
// following line:
// Adafruit_FlashTransport_RP2040
// flashTransport(Adafruit_FlashTransport_RP2040::CPY_START_ADDR,
// Adafruit_FlashTransport_RP2040::CPY_SIZE);
// Adafruit_FlashTransport_RP2040_CPY flashTransport;
#else
// On-board external flash (QSPI or SPI) macros should already
// defined in your board variant if supported
//EXTERNAL_FLASH_USE_QSPI
//EXTERNAL_FLASH_USE_CS
//EXTERNAL_FLASH_USE_SPI
#if defined(EXTERNAL_FLASH_USE_QSPI)
Adafruit_FlashTransport_QSPI flashTransport;
#elif defined(EXTERNAL_FLASH_USE_SPI)
Adafruit_FlashTransport_SPI flashTransport(EXTERNAL_FLASH_USE_CS,
EXTERNAL_FLASH_USE_SPI);
#elif defined(__AVR__)
// Use stand SPI/SS for avr port.
// Note cache will be disable due to lack of memory.
Adafruit_FlashTransport_SPI flashTransport(SS, SPI);
#else
#error No (Q)SPI flash are defined for your board !
#endif
#endif
#endif