Porting to a custom STM32 board with SPI Flash #18377
Replies: 3 comments 1 reply
-
|
Have you read working with filesystems (official doc). It is normally possible to create FAT or littlefs filesystems on internal and external devices. The latter can be mounted on mountpoints of your choosing. This approach (with a suitable device driver) can be used to mount various devices (Flash, EEPROM, FRAM etc.). |
Beta Was this translation helpful? Give feedback.
-
|
I believe, I might have found the reason of why the board fails to execute mpremote commands. The problem is as follows. In main.c it executes
Then it starts "main.py". If mpremote cp/reset/soft-reset command is called, a RAW-REPL mode is triggered. The board enters soft-reset mode and deinitializes all peripherials including SPI. It calls
Then it goes to
and then tried to initialize the storage device
But the SPI is deinitialized at this point and inside of the SPI communication HAL functions the "status" variable is "HAL_BUSY" instead of "HAL_OK". I don't quite understand what's going on on soft-reset. It seems, it de-initializes all peripherals and then calls "goto soft_reset" to the point below peripheral initialization. I.e. all the peripherals de-initialized on soft-reset remain de-initialized forever? |
Beta Was this translation helpful? Give feedback.
-
|
Just in case, if anybody finds this useful, the problem is that any mpremote operation which under the hood uses soft-reset deactivates SPI bus. Then the board tries using deactivated SPI to re-initialize Flash filesystem and fails. I've created a pull request for this problem #18400 suggesting instead of
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I've made a board with my preferences https://github.com/z80/cuckoo/tree/master/schematics/mp_board. It Uses STM32F405RGT6 and an SPI Flash chip W25Q128JVS connected to SPI2 peripheral.
The configuration is a copy-paste from similar boards adjusted to specific pins used for SPI Flash memory and LEDs https://github.com/z80/micropython/tree/master/ports/stm32/boards/F405_SERGEY_V2.
I have 2 problems.
No matter how I configure the board, it keeps using FAT. I seem to unable to switch to LittleFS even though I see it building and linking LittleFS-related files.
When the board is configured to use flash memory of the microcontroller for storage, everything works: both REPL access and mass storage device mode. (https://github.com/z80/micropython/tree/master/ports/stm32/boards/F405_SERGEY)
But if configured to use the external SPI flash for storage, terminal access using mpremote works only partially. I only can run python terminal commands. Copying files or executing source files makes the board fail. On the other hand, copying arbitrarily large files over Mass Storage device works perfectly fine. (https://github.com/z80/micropython/tree/master/ports/stm32/boards/F405_SERGEY_V2) It must be REPL does something what mass storage device mode does not do when running or copying files.
It must be, I'm missing something obvious. But I don't see it. I'd appreciate any advice!
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions