Batch differences in product. Bootloader changes and code trouple

Hi there,

Yes, A lot to unpack here…
The test code above can be made to Pass/Fail with the delay’s shortened. (no Serial)You can’t read and write the flash that way either., Well not with any expectation of data integrity.
Loose all the serial output stuff. Use the RGB-LED to indicate a mismatch…
Greeen for good , RED for stop. :grin: :ok_hand:

Did you actually look at the flash read and write examples from the fruit folks, Under the examples tab ? :lying_face: It’s there. The lib your using.? I choose Ver. Adafruit [email protected] and tested with that. The timing is key with flash chips so each is different
you’ll need to hold the CS or SS and then Go again or flush the serial port first then Do it, Look into the flash test code and adapt it.:+1: then test again.

use the Flash test code examples and post it up the output you get. in a New Thread, This is Off course for the OP of this one.

The second code won’t compile with the Wvariant.h
Keep in mind the PIN numbers may be different in the BSP. I used the read or print to see what it was and if they are what I thought they were , as you see turns out its different if its “SPI” or “QSPI” as to the internal peripheral to port Interface. (PPI) or the macro the LIB uses.?? YMMV

take a look at the Technical reference Guide to get more incite to the SPM

You can try this SFUD example tweak it to your QSPI and see how that works.

//
// This tests and Identifies the Onboard Xiao QSPI Flash Chip 
// and Expansion Flash Chip on Grove Board Hardwired to A1/D1 (pin 1) on Xiao 
// for the Flash chipSelect CS or SS 
#include <sfud.h>

#define SFUD_DEMO_TEST_BUFFER_SIZE                     2048
static uint8_t sfud_demo_test_buf[SFUD_DEMO_TEST_BUFFER_SIZE] = {0};
static void sfud_demo(uint32_t addr, size_t size, uint8_t *data);
	
#define SERIAL Serial
#define SS 1
void setup()
{
    SERIAL.begin(9600);
    delay (2000);
   // while(!SERIAL) {};
  SERIAL.println();
  SERIAL.println("Program " __FILE__ " compiled on " __DATE__ " at " __TIME__);
  SERIAL.println();
  SERIAL.println("Processor came out of reset.");
  SERIAL.println();
    pinMode(D1, OUTPUT); // set CS as output in lew of DNP on board, teting with and with out.
  digitalWrite(D1, HIGH);
  SERIAL.println("--------------");
  Serial.println(SS); // chip select
  Serial.println(MOSI); // master out, slave in
  Serial.println(MISO); // master in, slave out
  Serial.println(SCK); // clock
  Serial.println("--------------");
    while(!(sfud_init() == SFUD_SUCCESS));
    #ifdef SFUD_USING_QSPI
   sfud_qspi_fast_read_enable(sfud_get_device(SFUD_w25q80_DEVICE_INDEX), 2); // Chip name is in Lower Case ***
   //sfud_qspi_fast_read_enable(sfud_get_device(SFUD_gd25q64c_DEVICE_INDEX), 2); // Chip name is in Lower Case ***
    #endif
    const sfud_flash *flash = sfud_get_device_table() + 0;
    uint32_t addr = 0;
    size_t size = sizeof(sfud_demo_test_buf);
    uint8_t result = sfud_read(flash, addr, size, sfud_demo_test_buf);
    if (result == SFUD_SUCCESS) {
        SERIAL.println("Read the flash data success.");
        SERIAL.println("Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\r\n");
        for (int i = 0; i < size; i++) {
            if (i % 16 == 0) {
                SERIAL.print("0x");
                SERIAL.print(addr + i,HEX);
                SERIAL.print("\t");
            }
            SERIAL.print(sfud_demo_test_buf[i],HEX);
            SERIAL.print("\t");
            if (((i + 1) % 16 == 0) || i == size - 1) {
                SERIAL.println("");
            }
        }
        SERIAL.println(" ");
    } else {
        SERIAL.println("Read the flash data failed.");
    }
}

void loop()
{     
}

I use this to test the expansion board add-on flash chip.

HTH
GL :slight_smile: PJ :v: