This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push: new 7f48c185c8 sama5d2-xult: add support for QSPI flash and nxffs 7f48c185c8 is described below commit 7f48c185c851b471d707ca9a51db299e540bc984 Author: Janne Rosberg <janne.rosb...@offcode.fi> AuthorDate: Tue Nov 7 18:07:41 2023 +0200 sama5d2-xult: add support for QSPI flash and nxffs Add support for onboard qspi flash with nxffs fs Signed-off-by: Janne Rosberg <janne.rosb...@offcode.fi> --- boards/arm/sama5/sama5d2-xult/Kconfig | 14 +++++++ boards/arm/sama5/sama5d2-xult/src/sam_bringup.c | 50 ++++++++++++++++++++++++ boards/arm/sama5/sama5d2-xult/src/sama5d2-xult.h | 27 +++++++++---- 3 files changed, 84 insertions(+), 7 deletions(-) diff --git a/boards/arm/sama5/sama5d2-xult/Kconfig b/boards/arm/sama5/sama5d2-xult/Kconfig index 83f06e1e28..77fb047c6f 100644 --- a/boards/arm/sama5/sama5d2-xult/Kconfig +++ b/boards/arm/sama5/sama5d2-xult/Kconfig @@ -127,4 +127,18 @@ config SAMA5_SDMMC1_WIDTH_D1_D4 default y depends on SAMA5_SDMMC1 +config SAMA5_QSPI0_SIZE + int "QSPI0 memory size in bytes" + default 1073741824 + depends on SAMA5_QSPI0 + ---help--- + Size of QSPI0 memory mapped area in bytes. Default: 1GB + +config SAMA5_QSPI1_SIZE + int "QSPI1 memory size in bytes" + default 1073741824 + depends on SAMA5_QSPI1 + ---help--- + Size of QSPI1 memory mapped area in bytes. Default: 1GB + endif # ARCH_BOARD_SAMA5D2_XULT diff --git a/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c b/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c index 3bb43e5686..bab347a7af 100644 --- a/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c +++ b/boards/arm/sama5/sama5d2-xult/src/sam_bringup.c @@ -36,6 +36,7 @@ #include <nuttx/usb/usbdev.h> #include <nuttx/usb/usbhost.h> #include <nuttx/usb/usbdev_trace.h> +#include <nuttx/drivers/drivers.h> #include "sama5d2-xult.h" @@ -61,6 +62,15 @@ # include "sam_sdmmc.h" #endif +#ifdef HAVE_MX25RXX +# include "sam_qspi.h" +# include <nuttx/mtd/mtd.h> +#endif + +#ifdef HAVE_MX25RXX_NXFFS +# include <nuttx/fs/nxffs.h> +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -242,6 +252,10 @@ static int nsh_sdmmc_initialize(void) int sam_bringup(void) { +#ifdef HAVE_MX25RXX + struct qspi_dev_s *qspi; + struct mtd_dev_s *mtd; +#endif int ret; /* Register I2C drivers on behalf of the I2C tool */ @@ -458,6 +472,42 @@ int sam_bringup(void) } #endif +#ifdef HAVE_MX25RXX + qspi = sam_qspi_initialize(0); + if (!qspi) + { + syslog(LOG_ERR, "ERROR: sam_qspi_initialize failed\n"); + } + else + { + mtd = mx25rxx_initialize(qspi, true); + if (!mtd) + { + syslog(LOG_ERR, "ERROR: mx25rxx_initialize failed\n"); + } + +#if HAVE_MX25RXX_NXFFS + /* Initialize to provide NXFFS on the mx25rxx MTD interface */ + + ret = nxffs_initialize(mtd); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: NXFFS initialization failed: %d\n", ret); + } + + /* Mount the file system at /mnt/mx25 */ + + ret = nx_mount(NULL, "/mnt/mx25", "nxffs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount the NXFFS volume: %d\n", + ret); + return ret; + } +#endif + } +#endif /* HAVE_MX25RXX */ + /* If we got here then perhaps not all initialization was successful, but * at least enough succeeded to bring-up NSH with perhaps reduced * capabilities. diff --git a/boards/arm/sama5/sama5d2-xult/src/sama5d2-xult.h b/boards/arm/sama5/sama5d2-xult/src/sama5d2-xult.h index 0a281731c2..6944fe91ee 100644 --- a/boards/arm/sama5/sama5d2-xult/src/sama5d2-xult.h +++ b/boards/arm/sama5/sama5d2-xult/src/sama5d2-xult.h @@ -42,13 +42,15 @@ /* Configuration ************************************************************/ -#define HAVE_SDMMC 1 -#define HAVE_AT25 1 -#define HAVE_NAND 1 -#define HAVE_USBHOST 1 -#define HAVE_USBDEV 1 -#define HAVE_USBMONITOR 1 -#define HAVE_NETWORK 1 +#define HAVE_SDMMC 1 +#define HAVE_AT25 1 +#define HAVE_NAND 1 +#define HAVE_USBHOST 1 +#define HAVE_USBDEV 1 +#define HAVE_USBMONITOR 1 +#define HAVE_NETWORK 1 +#define HAVE_MX25RXX 1 +#define HAVE_MX25RXX_NXFFS 1 /* SDMMC */ @@ -169,6 +171,17 @@ # define AT25_MINOR _AT25_MINOR #endif +/* MX25RXX QuadSPI flash */ + +#if !defined(CONFIG_MTD_MX25RXX) || !defined(CONFIG_SAMA5_QSPI0) +# undef HAVE_MX25RXX +# undef HAVE_MX25RXX_NXFFS +#endif + +#ifndef CONFIG_FS_NXFFS +# undef HAVE_MX25RXX_NXFFS +#endif + /* MMC/SD minor numbers: The NSH device minor extended is extended to * support two devices. If CONFIG_NSH_MMCSDMINOR is zero, these will be: * /dev/mmcsd0 and /dev/mmcsd1.