Browse Source

stm32/boards/STM32F769DISC: Add config to use external SPI as filesys.

This board now has the following 3 build configurations:
- mboot + external QSPI in XIP mode + internal filesystem
- mboot + external QSPI with filesystem (the default)
- no mboot + external QSPI with filesystem
pull/5593/head
Damien George 5 years ago
parent
commit
96a4435be1
  1. 7
      ports/stm32/boards/STM32F769DISC/board_init.c
  2. 21
      ports/stm32/boards/STM32F769DISC/mpconfigboard.h
  3. 22
      ports/stm32/boards/STM32F769DISC/mpconfigboard.mk

7
ports/stm32/boards/STM32F769DISC/board_init.c

@ -1,16 +1,19 @@
#include "drivers/memory/spiflash.h"
#include "storage.h"
#include "qspi.h"
// This configuration is needed for mboot to be able to write to the external QSPI flash
STATIC mp_spiflash_cache_t spi_bdev_cache;
const mp_spiflash_config_t spiflash_config = {
.bus_kind = MP_SPIFLASH_BUS_QSPI,
.bus.u_qspi.data = NULL,
.bus.u_qspi.proto = &qspi_proto,
.cache = NULL,
.cache = &spi_bdev_cache,
};
mp_spiflash_t spiflash_instance;
spi_bdev_t spi_bdev;
// This init function is needed to memory map the QSPI flash early in the boot process

21
ports/stm32/boards/STM32F769DISC/mpconfigboard.h

@ -26,7 +26,7 @@ void board_early_init(void);
#define MICROPY_HW_FLASH_LATENCY FLASH_LATENCY_7 // 210-216 MHz needs 7 wait states
// 512MBit external QSPI flash, to be memory mapped
// 512MBit external QSPI flash, used for either the filesystem or XIP memory mapped
#define MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2 (29)
#define MICROPY_HW_QSPIFLASH_CS (pin_B6)
#define MICROPY_HW_QSPIFLASH_SCK (pin_B2)
@ -35,6 +35,21 @@ void board_early_init(void);
#define MICROPY_HW_QSPIFLASH_IO2 (pin_E2)
#define MICROPY_HW_QSPIFLASH_IO3 (pin_D13)
// SPI flash, block device config (when used as the filesystem)
extern const struct _mp_spiflash_config_t spiflash_config;
extern struct _spi_bdev_t spi_bdev;
#if !USE_QSPI_XIP
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (0)
#define MICROPY_HW_BDEV_IOCTL(op, arg) ( \
(op) == BDEV_IOCTL_NUM_BLOCKS ? (64 * 1024 * 1024 / FLASH_BLOCK_SIZE) : \
(op) == BDEV_IOCTL_INIT ? spi_bdev_ioctl(&spi_bdev, (op), (uint32_t)&spiflash_config) : \
spi_bdev_ioctl(&spi_bdev, (op), (arg)) \
)
#define MICROPY_HW_BDEV_READBLOCKS(dest, bl, n) spi_bdev_readblocks(&spi_bdev, (dest), (bl), (n))
#define MICROPY_HW_BDEV_WRITEBLOCKS(src, bl, n) spi_bdev_writeblocks(&spi_bdev, (src), (bl), (n))
#define MICROPY_HW_BDEV_SPIFLASH_EXTENDED (&spi_bdev) // for extended block protocol
#endif
// UART config
#define MICROPY_HW_UART1_TX (pin_A9)
#define MICROPY_HW_UART1_RX (pin_A10)
@ -199,11 +214,9 @@ void board_early_init(void);
// Bootloader configuration
// Give Mboot access to the external QSPI flash
extern const struct _mp_spiflash_config_t spiflash_config;
extern struct _mp_spiflash_t spiflash_instance;
#define MBOOT_SPIFLASH_ADDR (0x90000000)
#define MBOOT_SPIFLASH_BYTE_SIZE (512 * 128 * 1024)
#define MBOOT_SPIFLASH_LAYOUT "/0x90000000/512*128Kg"
#define MBOOT_SPIFLASH_ERASE_BLOCKS_PER_PAGE (128 / 4) // 128k page, 4k erase block
#define MBOOT_SPIFLASH_CONFIG (&spiflash_config)
#define MBOOT_SPIFLASH_SPIFLASH (&spiflash_instance)
#define MBOOT_SPIFLASH_SPIFLASH (&spi_bdev.spiflash)

22
ports/stm32/boards/STM32F769DISC/mpconfigboard.mk

@ -1,9 +1,11 @@
# By default this board is configured to use mboot which must be deployed first
USE_MBOOT ?= 1
# By default this board puts some code into external QSPI flash set in XIP mode
# By default the filesystem is in external QSPI flash. But by setting the
# following option this board puts some code into external flash set in XIP mode.
# USE_MBOOT must be enabled; see f769_qspi.ld for code that goes in QSPI flash
USE_QSPI ?= 1
USE_QSPI_XIP ?= 0
CFLAGS += -DUSE_QSPI_XIP=$(USE_QSPI_XIP)
# MCU settings
MCU_SERIES = f7
@ -12,9 +14,11 @@ MICROPY_FLOAT_IMPL = double
AF_FILE = boards/stm32f767_af.csv
ifeq ($(USE_MBOOT),1)
ifeq ($(USE_QSPI),1)
ifeq ($(USE_QSPI_XIP),1)
# When using Mboot and QSPI the text is split between internal and external flash
# When using Mboot and QSPI-XIP the text is split between internal and external
# QSPI flash, and the filesystem is in internal flash between the bootloader and
# the main program text.
LD_FILES = boards/STM32F769DISC/f769_qspi.ld
TEXT0_ADDR = 0x08020000
TEXT1_ADDR = 0x90000000
@ -23,17 +27,19 @@ TEXT1_SECTIONS = .text_qspi
else
# When using Mboot but not QSPI all the text goes together after the filesystem
# When using Mboot but not QSPI-XIP all the text goes together after the bootloader
# (at same location as when QSPI-XIP is enabled so the same Mboot can be used for
# either configuration) and the filesystem is in external flash.
LD_FILES = boards/stm32f769.ld boards/common_blifs.ld
TEXT0_ADDR = 0x08020000
endif
else
# When not using Mboot the ISR text goes first, then the rest after the filesystem
LD_FILES = boards/stm32f769.ld boards/common_ifs.ld
# When not using Mboot (and so no ability to load text into QSPI) all the text goes
# together at the start of internal flash, and the filesystem is in external flash.
LD_FILES = boards/stm32f769.ld boards/common_basic.ld
TEXT0_ADDR = 0x08000000
TEXT1_ADDR = 0x08020000
endif

Loading…
Cancel
Save