summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/stm32/flashbdev.c4
-rw-r--r--ports/stm32/mpconfigboard_common.h12
-rw-r--r--ports/stm32/storage.c9
3 files changed, 14 insertions, 11 deletions
diff --git a/ports/stm32/flashbdev.c b/ports/stm32/flashbdev.c
index fe7161275..64faf0eac 100644
--- a/ports/stm32/flashbdev.c
+++ b/ports/stm32/flashbdev.c
@@ -34,7 +34,7 @@
#include "flash.h"
#include "storage.h"
-#if !defined(MICROPY_HW_SPIFLASH_SIZE_BITS)
+#if MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
// Here we try to automatically configure the location and size of the flash
// pages to use for the internal storage. We also configure the location of the
@@ -265,4 +265,4 @@ bool flash_bdev_writeblock(const uint8_t *src, uint32_t block) {
return true;
}
-#endif // !defined(MICROPY_HW_SPIFLASH_SIZE_BITS)
+#endif // MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
diff --git a/ports/stm32/mpconfigboard_common.h b/ports/stm32/mpconfigboard_common.h
index 0c57976fb..b876d5884 100644
--- a/ports/stm32/mpconfigboard_common.h
+++ b/ports/stm32/mpconfigboard_common.h
@@ -32,6 +32,11 @@
/*****************************************************************************/
// Feature settings with defaults
+// Whether to enable storage on the internal flash of the MCU
+#ifndef MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
+#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)
+#endif
+
// Whether to enable the RTC, exposed as pyb.RTC
#ifndef MICROPY_HW_ENABLE_RTC
#define MICROPY_HW_ENABLE_RTC (0)
@@ -136,6 +141,13 @@
#error Unsupported MCU series
#endif
+#if MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
+// Provide block device macros if internal flash storage is enabled
+#define MICROPY_HW_BDEV_IOCTL flash_bdev_ioctl
+#define MICROPY_HW_BDEV_READBLOCK flash_bdev_readblock
+#define MICROPY_HW_BDEV_WRITEBLOCK flash_bdev_writeblock
+#endif
+
// Enable hardware I2C if there are any peripherals defined
#if defined(MICROPY_HW_I2C1_SCL) || defined(MICROPY_HW_I2C2_SCL) \
|| defined(MICROPY_HW_I2C3_SCL) || defined(MICROPY_HW_I2C4_SCL)
diff --git a/ports/stm32/storage.c b/ports/stm32/storage.c
index ef583af15..4cf2898b3 100644
--- a/ports/stm32/storage.c
+++ b/ports/stm32/storage.c
@@ -34,15 +34,6 @@
#include "storage.h"
#include "irq.h"
-#if !defined(MICROPY_HW_SPIFLASH_SIZE_BITS)
-
-// Use internal flash as the storage medium
-#define MICROPY_HW_BDEV_IOCTL flash_bdev_ioctl
-#define MICROPY_HW_BDEV_READBLOCK flash_bdev_readblock
-#define MICROPY_HW_BDEV_WRITEBLOCK flash_bdev_writeblock
-
-#endif
-
#define FLASH_PART1_START_BLOCK (0x100)
static bool storage_is_initialised = false;