[SparkFun Thing Plus - SAMD51] Using its FLASH SPI memory

Ladies and Gentleman,

I have a [SparkFun Thing Plus - SAMD51 and recently I needed a bigger memory to work as a kind of small datalogger. After a while a remembered that it has 4Mb (external) flash memory that communicates through SPI.

So I decided to test it with the [Adafruit_SPIFlash and the [SerialFlash. However, this Thing Plus has two sets of SPI pins and I don’t know how to use the FLASH_SPI facepalm, the other ones I’ve used without any problem. Could anyone give help on how to communicate with this flash memory?

- “NORMAL” SPI

  // 22..24 - SPI pins (MISO,MOSI,SCK)
  // ----------------------
  { PORTB, 11, PIO_SERCOM_ALT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_11 }, // MISO: SERCOM4/PAD[3]
  { PORTB, 12, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_12 }, // MOSI: SERCOM4/PAD[0]
  { PORTB, 13, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_13 }, // SCK: SERCOM4/PAD[1]

- FLASH SPI

  // ----------------------
  // 33..36 SPI for Flash (SCK, CS, MISO, MOSI)
  { PORTA, 9, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, //SCK
  { PORTA, 10, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, //CS
  { PORTA, 11, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, //MISO
  { PORTA, 8, PIO_COM, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, //MOSI

](GitHub - PaulStoffregen/SerialFlash: Library for using SPI Flash memory with a filesystem-like interface)](GitHub - adafruit/Adafruit_SPIFlash: Arduino library for external (Q)SPI flash device)](https://www.sparkfun.com/products/14713)

I guess i could just do:

SPIClass SPI (&sercom4, 22, 24, 23, SPI_PAD_2_SCK_3, SERCOM_RX_PAD_0);

… I will test asap

So, this is already done in the SPI.cpp file:

#endif // PERIPH_SPI
  SPIClass SPI (&PERIPH_SPI,  PIN_SPI_MISO,  PIN_SPI_SCK,  PIN_SPI_MOSI,  PAD_SPI_TX,  PAD_SPI_RX);
#endif
#if SPI_INTERFACES_COUNT > 1
  SPIClass SPI1(&PERIPH_SPI1, PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_MOSI, PAD_SPI1_TX, PAD_SPI1_RX);
#endif

So I already have the SPI1 class defined.

Next step was to change the code to use SPI1 instead of SPI and FLASH_SS in the [ RawHardwareTest from PaulStoffregen.

- Old:

  Serial.println("Raw SerialFlash Hardware Test");
  SerialFlash.begin(FlashChipSelect);

- New:

   Serial.println("Raw SerialFlash Hardware Test");
  SerialFlash.begin(SPI1, FLASH_SS);

The code didn’t work and I think that it won’t even if I change something else, because SparkFun used the AT25SF041 and looking [here it isn’t supported. What libraries should I use to make this communication between the SPI Memory Chip?](SerialFlash/tests.txt at master · PaulStoffregen/SerialFlash · GitHub)](SerialFlash/examples/RawHardwareTest/RawHardwareTest.ino at master · PaulStoffregen/SerialFlash · GitHub)

I’ve jus tried the [ SPIMemory lib form Marzogh but it also didn’t work.

Initialising..........

SPIMemory Library version: < 2.5.0

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

](GitHub - Marzogh/SPIMemory: Arduino library for Flash Memory Chips (SPI based only). Formerly SPIFlash)

The bootloader on this board has control over the on board flash memory and it’s not really available for use unless you remove the bootloader from the board.

If you need additional storage space you’re going to need to attach your own SPI (or I2C) flash. Depending on how much space you need to store data, it might be easier to use a SD card along with a SD socket like BOB-00544.

I see, thank for the update!

BTW, nice profile picture hahah loved it.