Skip to content

Commit

Permalink
stm32/WEACT_F411: Keep internal flash storage enabled alongside any e…
Browse files Browse the repository at this point in the history
…xternal spiflash.

Signed-off-by: Andrew Leech <[email protected]>
  • Loading branch information
pi-anl committed Dec 13, 2024
1 parent 2b7cd31 commit 939945d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ports/stm32/boards/WEACT_F411_BLACKPILL/bdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "spi.h"
#include "py/mpconfig.h"

#if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
#if MICROPY_HW_SPIFLASH_SIZE_BYTES

#if WEACT_F411_V20
// External SPI flash uses SPI interface, but not on all HW spi pins.
Expand Down
31 changes: 20 additions & 11 deletions ports/stm32/boards/WEACT_F411_BLACKPILL/mpconfigboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,10 @@
#define MICROPY_HW_SPI3_MISO (pin_B4)
#define MICROPY_HW_SPI3_MOSI (pin_B5)

// External SPI Flash configuration

#if !MICROPY_HW_SPIFLASH_SIZE_BYTES
// Use internal filesystem if spiflash not enabled.
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)

#else
// Disable internal filesystem to use spiflash.
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
// External SPI Flash configuration
#if MICROPY_HW_SPIFLASH_SIZE_BYTES

// SPI flash pins
#define MICROPY_HW_SPIFLASH_CS (pyb_pin_FLASH_CS)
Expand All @@ -103,10 +98,24 @@

extern const struct _mp_spiflash_config_t spiflash_config;
extern struct _spi_bdev_t spi_bdev;

// This configures the spiflash storage logically directly
// after the internal flash as accessed via pyb.Flash
// If start/length variables are not passed to pyb.Flash
// both internal and external flash will be used merged into one
// larger filesystem.

#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
#define MICROPY_HW_SPIFLASH_SIZE_BITS (MICROPY_HW_SPIFLASH_SIZE_BYTES * 8)
#define MICROPY_HW_BDEV2_SPIFLASH (&spi_bdev)
#define MICROPY_HW_BDEV2_SPIFLASH_CONFIG (&spiflash_config)
#define MICROPY_HW_BDEV2_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
#define MICROPY_HW_BDEV2_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
#define MICROPY_HW_BDEV2_READBLOCKS(dest, bl, n) spi_bdev_readblocks(MICROPY_HW_BDEV2_SPIFLASH, (dest), (bl), (n))
#define MICROPY_HW_BDEV2_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(MICROPY_HW_BDEV2_SPIFLASH, (src), (bl), (n))
#define MICROPY_HW_BDEV2_IOCTL(op, arg) ( \
(op) == BDEV_IOCTL_NUM_BLOCKS ? (MICROPY_HW_BDEV2_SPIFLASH_SIZE_BYTES / FLASH_BLOCK_SIZE) : \
(op) == BDEV_IOCTL_INIT ? spi_bdev_ioctl(MICROPY_HW_BDEV2_SPIFLASH, (op), (uint32_t)MICROPY_HW_BDEV2_SPIFLASH_CONFIG) : \
spi_bdev_ioctl(MICROPY_HW_BDEV2_SPIFLASH, (op), (arg)) \
)
#endif

0 comments on commit 939945d

Please sign in to comment.