Skip to content

Commit 939945d

Browse files
committed
stm32/WEACT_F411: Keep internal flash storage enabled alongside any external spiflash.
Signed-off-by: Andrew Leech <[email protected]>
1 parent 2b7cd31 commit 939945d

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

ports/stm32/boards/WEACT_F411_BLACKPILL/bdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "spi.h"
33
#include "py/mpconfig.h"
44

5-
#if !MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
5+
#if MICROPY_HW_SPIFLASH_SIZE_BYTES
66

77
#if WEACT_F411_V20
88
// External SPI flash uses SPI interface, but not on all HW spi pins.

ports/stm32/boards/WEACT_F411_BLACKPILL/mpconfigboard.h

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,10 @@
7979
#define MICROPY_HW_SPI3_MISO (pin_B4)
8080
#define MICROPY_HW_SPI3_MOSI (pin_B5)
8181

82-
// External SPI Flash configuration
83-
84-
#if !MICROPY_HW_SPIFLASH_SIZE_BYTES
85-
// Use internal filesystem if spiflash not enabled.
8682
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)
8783

88-
#else
89-
// Disable internal filesystem to use spiflash.
90-
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
84+
// External SPI Flash configuration
85+
#if MICROPY_HW_SPIFLASH_SIZE_BYTES
9186

9287
// SPI flash pins
9388
#define MICROPY_HW_SPIFLASH_CS (pyb_pin_FLASH_CS)
@@ -103,10 +98,24 @@
10398

10499
extern const struct _mp_spiflash_config_t spiflash_config;
105100
extern struct _spi_bdev_t spi_bdev;
101+
102+
// This configures the spiflash storage logically directly
103+
// after the internal flash as accessed via pyb.Flash
104+
// If start/length variables are not passed to pyb.Flash
105+
// both internal and external flash will be used merged into one
106+
// larger filesystem.
107+
106108
#define MICROPY_HW_SPIFLASH_ENABLE_CACHE (1)
107-
#define MICROPY_HW_BDEV_SPIFLASH (&spi_bdev)
108-
#define MICROPY_HW_BDEV_SPIFLASH_CONFIG (&spiflash_config)
109-
#define MICROPY_HW_BDEV_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
110-
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
111109
#define MICROPY_HW_SPIFLASH_SIZE_BITS (MICROPY_HW_SPIFLASH_SIZE_BYTES * 8)
110+
#define MICROPY_HW_BDEV2_SPIFLASH (&spi_bdev)
111+
#define MICROPY_HW_BDEV2_SPIFLASH_CONFIG (&spiflash_config)
112+
#define MICROPY_HW_BDEV2_SPIFLASH_SIZE_BYTES (MICROPY_HW_SPIFLASH_SIZE_BITS / 8)
113+
#define MICROPY_HW_BDEV2_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
114+
#define MICROPY_HW_BDEV2_READBLOCKS(dest, bl, n) spi_bdev_readblocks(MICROPY_HW_BDEV2_SPIFLASH, (dest), (bl), (n))
115+
#define MICROPY_HW_BDEV2_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(MICROPY_HW_BDEV2_SPIFLASH, (src), (bl), (n))
116+
#define MICROPY_HW_BDEV2_IOCTL(op, arg) ( \
117+
(op) == BDEV_IOCTL_NUM_BLOCKS ? (MICROPY_HW_BDEV2_SPIFLASH_SIZE_BYTES / FLASH_BLOCK_SIZE) : \
118+
(op) == BDEV_IOCTL_INIT ? spi_bdev_ioctl(MICROPY_HW_BDEV2_SPIFLASH, (op), (uint32_t)MICROPY_HW_BDEV2_SPIFLASH_CONFIG) : \
119+
spi_bdev_ioctl(MICROPY_HW_BDEV2_SPIFLASH, (op), (arg)) \
120+
)
112121
#endif

0 commit comments

Comments
 (0)