Skip to content

Commit

Permalink
sama5d2-xult: add support for QSPI flash and nxffs
Browse files Browse the repository at this point in the history
Add support for onboard qspi flash with nxffs fs
Signed-off-by: Janne Rosberg <[email protected]>
  • Loading branch information
jrosberg authored and xiaoxiang781216 committed Nov 9, 2023
1 parent 77df430 commit 7f48c18
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 7 deletions.
14 changes: 14 additions & 0 deletions boards/arm/sama5/sama5d2-xult/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
50 changes: 50 additions & 0 deletions boards/arm/sama5/sama5d2-xult/src/sam_bringup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
****************************************************************************/
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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.
Expand Down
27 changes: 20 additions & 7 deletions boards/arm/sama5/sama5d2-xult/src/sama5d2-xult.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 7f48c18

Please sign in to comment.