Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access onboard flash on STM32 Feather Express #179

Open
dakotahorstman opened this issue Oct 31, 2024 · 0 comments
Open

Unable to access onboard flash on STM32 Feather Express #179

dakotahorstman opened this issue Oct 31, 2024 · 0 comments
Labels

Comments

@dakotahorstman
Copy link

Operating System

Linux

IDE version

PlatformIO 3.3.3/VSCode

Board

Adafruit STM32 Feather Express

BSP version

Unknown

SPIFlash Library version

5.0.0

Sketch as attached file if not stock example

// Header file

#ifndef __ONBOARD_FLASH_H
#define __ONBOARD_FLASH_H

#include <Arduino.h>
#include <Adafruit_SPIFlash.h>

extern Adafruit_SPIFlash onboardFlash;
void setupFlash();

#endif // __ONBOARD_FLASH_H


// Implementation file

#include "onboardflash.h"

Adafruit_FlashTransport_SPI flashTransport(PIN_SPI3_SS, SPI);
// Also tried
// SPIClass SPI_FLASH(PIN_SPI3_MOSI, PIN_SPI3_MISO, PIN_SPI3_SCK, PIN_SPI3_SS);
// Adafruit_FlashTransport_SPI flashTransport(PIN_SPI3_SS, &SPI_FLASH);
Adafruit_SPIFlash onboardFlash(&flashTransport);


void setupFlash() {
  SPI.setMISO(PIN_SPI3_MISO);
  SPI.setMOSI(PIN_SPI3_MOSI);
  SPI.setSCLK(PIN_SPI3_SCK);
  SPI.setSSEL(PIN_SPI3_SS);
}
// main.cpp

#include <Arduino.h>
#include "onboardflash.h"

void setup() {
  Serial.begin(115200);

  setupFlash();
  Serial.println(onboardFlash.begin());  // Hangs here, never prints
}

void loop() {
  Serial.println("Running");  // Never prints
  delay(1000);
}
// platformio.ini

[env]
framework = arduino
lib_deps = 
	adafruit/Adafruit SPIFlash@^5.0.0
monitor_speed = 115200

[adafruit_feather_f405]
extends = env
board = adafruit_feather_f405
platform = ststm32
lib_ldf_mode = deep
build_flags = 
	-DHAL_CAN_MODULE_ENABLED
	-DUSBCON
	-DUSBD_VID=0
	-DUSBD_PID=0
	-DHAL_PCD_MODULE_ENABLED
	-DUSBD_USE_CDC
	-DHAL_UART_MODULE_ENABLED
	-D__PROGVERSION__='"0.0.0"'
	-DDEVICE_ID=0
upload_protocol = dfu

[env:adafruit_feather_debug]
extends = adafruit_feather_f405
build_flags = 
	${adafruit_feather_f405.build_flags}

What happened ?

First, I would like to state the documentation for the Feather is out of date, or out of sync with actual implementation.

Near the bottom of the page, the guide states

The SPI Flash is connected to SPI bus 1 pins that are not brought out on the GPIO pads. This way you don't have to worry about the SPI flash colliding with other devices on the main SPI connection.

We give the SPI Flash the 'faster' SPI port 1 because there is no QSPI support, and reading fast from the SPI is important if you want to stream audio clips or GIFs.

In CircuitPython the SPI flash is automatically used as the filesystem exposed over USB.

In Arduino you can access SPI flash with our library and adding this definition to the top of your sketch to instantiate the SPI flash.
SPIClass SPI_FLASH(PIN_SPI1_MOSI, PIN_SPI1_MISO, PIN_SPI1_SCK, PIN_SPI1_SS);
Adafruit_FlashTransport_SPI flashTransport(PIN_SPI1_SS, &SPI_FLASH);
Note that our SPI flash library cannot be used at the same time as the SDIO library because they have colliding File definitions.

PIN_SPI1_MOSI, PIN_SPI1_MISO, PIN_SPI1_SCK, and PIN_SPI1_SS do not exist in the pin definitions, their PIN_SPI3_* variants do, so that needs to be updated and/or corrected. The PIN_SPI3_* variants do match what is outlined on the schematic.

Now, onto the actual issue, I cannot seem to access the onboard flash at all. Perhaps something I have setup is wrong, but the sketch hangs at begin() and doesn't continue on. I tested this against two Feathers and get the same result.

My Feather is communicating with other devices via CAN bus, but that is the only majorly unique thing about my setup. I wouldn't think that would affect SPI, but I could be wrong.

How to reproduce ?

Upload the sketch and see for yourself.

Debug Log as attached txt file

No output. Again, the sketch hangs.

Screenshots

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant