summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/stm32/sdram.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/ports/stm32/sdram.c b/ports/stm32/sdram.c
index b0a3ef215..1e1a08e4c 100644
--- a/ports/stm32/sdram.c
+++ b/ports/stm32/sdram.c
@@ -34,12 +34,20 @@
#if defined(MICROPY_HW_FMC_SDCKE0) && defined(MICROPY_HW_FMC_SDNE0)
#define FMC_SDRAM_BANK FMC_SDRAM_BANK1
#define FMC_SDRAM_CMD_TARGET_BANK FMC_SDRAM_CMD_TARGET_BANK1
+#if MICROPY_HW_FMC_SWAP_BANKS
+#define SDRAM_START_ADDRESS 0x60000000
+#else
#define SDRAM_START_ADDRESS 0xC0000000
+#endif
#elif defined(MICROPY_HW_FMC_SDCKE1) && defined(MICROPY_HW_FMC_SDNE1)
#define FMC_SDRAM_BANK FMC_SDRAM_BANK2
#define FMC_SDRAM_CMD_TARGET_BANK FMC_SDRAM_CMD_TARGET_BANK2
+#if MICROPY_HW_FMC_SWAP_BANKS
+#define SDRAM_START_ADDRESS 0x70000000
+#else
#define SDRAM_START_ADDRESS 0xD0000000
#endif
+#endif
// Provides the MPU_REGION_SIZE_X value when passed the size of region in bytes
// "m" must be a power of 2 between 32 and 4G (2**5 and 2**32) and this formula
@@ -59,6 +67,10 @@ bool sdram_init(void) {
__HAL_RCC_FMC_CLK_ENABLE();
+ #if MICROPY_HW_FMC_SWAP_BANKS
+ HAL_SetFMCMemorySwappingConfig(FMC_SWAPBMAP_SDRAM_SRAM);
+ #endif
+
#if defined(MICROPY_HW_FMC_SDCKE0)
mp_hal_pin_config_alt_static_speed(MICROPY_HW_FMC_SDCKE0, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, MP_HAL_PIN_SPEED_VERY_HIGH, STATIC_AF_FMC_SDCKE0);
mp_hal_pin_config_alt_static_speed(MICROPY_HW_FMC_SDNE0, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_NONE, MP_HAL_PIN_SPEED_VERY_HIGH, STATIC_AF_FMC_SDNE0);