boards/nrf5340-dk: add mx25 memory support

From now on-board QSPI memory is supported.
This commit is contained in:
raiden00pl 2023-05-23 12:00:07 +02:00 committed by Xiang Xiao
parent 8b89730e61
commit e06ce27f56
7 changed files with 252 additions and 1 deletions

View File

@ -0,0 +1,44 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_DISABLE_IFCONFIG is not set
# CONFIG_NSH_DISABLE_PS is not set
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="nrf5340-dk"
CONFIG_ARCH_BOARD_NRF5340_DK=y
CONFIG_ARCH_CHIP="nrf53"
CONFIG_ARCH_CHIP_NRF5340=y
CONFIG_ARCH_CHIP_NRF5340_CPUAPP=y
CONFIG_ARCH_CHIP_NRF53=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_STDARG_H=y
CONFIG_BOARD_LOOPSPERMSEC=5500
CONFIG_EXPERIMENTAL=y
CONFIG_FS_LITTLEFS=y
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_MM_REGIONS=2
CONFIG_MTD=y
CONFIG_MTD_MX25RXX=y
CONFIG_NRF52_QSPI=y
CONFIG_NRF53_UART0=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=524288
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=26
CONFIG_START_MONTH=3
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_SERIAL_CONSOLE=y

View File

@ -0,0 +1,50 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_NSH_DISABLE_IFCONFIG is not set
# CONFIG_NSH_DISABLE_PS is not set
# CONFIG_STANDARD_SERIAL is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="nrf5340-dk"
CONFIG_ARCH_BOARD_NRF5340_DK=y
CONFIG_ARCH_CHIP="nrf53"
CONFIG_ARCH_CHIP_NRF5340=y
CONFIG_ARCH_CHIP_NRF5340_CPUAPP=y
CONFIG_ARCH_CHIP_NRF53=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_STDARG_H=y
CONFIG_BOARD_LOOPSPERMSEC=5500
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_EXPERIMENTAL=y
CONFIG_FS_LITTLEFS=y
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_MM_REGIONS=2
CONFIG_MTD=y
CONFIG_MTD_MX25RXX=y
CONFIG_MX25RXX_QSPI_FREQUENCY=98000000
CONFIG_MX25RXX_QSPI_READ_FREQUENCY=98000000
CONFIG_NRF53_QSPI=y
CONFIG_NRF53_QSPI_RXDELAY=1
CONFIG_NRF53_UART0=y
CONFIG_NRF53_USE_HFCLK192M=y
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_RAM_SIZE=524288
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=26
CONFIG_START_MONTH=3
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_UART0_SERIAL_CONSOLE=y

View File

@ -155,4 +155,28 @@
#define NRF53_ADC_CH2_PIN (GPIO_MCUSEL_APP | GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(6))
#define NRF53_ADC_CH3_PIN (GPIO_MCUSEL_APP | GPIO_INPUT | GPIO_PORT0 | GPIO_PIN(7))
/* QSPI Pins ****************************************************************/
/* QSPI0
* QSPI CS - P0.18
* QSPI SCK - P0.17
* QSPI IO0 - P0.13
* QSPI IO1 - P0.14
* QSPI IO2 - P0.15
* QSPI IO3 - P0.16
*/
#define NRF53_QSPI0_CSN_PIN (GPIO_MCUSEL_PERIP | GPIO_OUTPUT | \
GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN(18))
#define NRF53_QSPI0_SCK_PIN (GPIO_MCUSEL_PERIP | GPIO_OUTPUT | \
GPIO_PORT0 | GPIO_PIN(17))
#define NRF53_QSPI0_IO0_PIN (GPIO_MCUSEL_PERIP | GPIO_OUTPUT | \
GPIO_PORT0 | GPIO_PIN(13))
#define NRF53_QSPI0_IO1_PIN (GPIO_MCUSEL_PERIP | GPIO_OUTPUT | \
GPIO_PORT0 | GPIO_PIN(14))
#define NRF53_QSPI0_IO2_PIN (GPIO_MCUSEL_PERIP | GPIO_OUTPUT | \
GPIO_PORT0 | GPIO_PIN(15))
#define NRF53_QSPI0_IO3_PIN (GPIO_MCUSEL_PERIP | GPIO_OUTPUT | \
GPIO_PORT0 | GPIO_PIN(16))
#endif /* __BOARDS_ARM_NRF53_NRF5340_DK_INCLUDE_BOARD_H */

View File

@ -56,6 +56,10 @@ ifeq ($(CONFIG_USBDEV_COMPOSITE),y)
CSRCS += nrf53_composite.c
endif
ifeq ($(CONFIG_NRF53_QSPI),y)
CSRCS += nrf53_mx25.c
endif
DEPPATH += --dep-path board
VPATH += :board
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)

View File

@ -118,5 +118,17 @@ int nrf53_pwm_setup(void);
int nrf53_adc_setup(void);
#endif
/****************************************************************************
* Name: nrf53_mx25_initialize
*
* Description:
* Initialize the MX25RXX QSPI memeory
*
****************************************************************************/
#ifdef CONFIG_NRF53_QSPI
int nrf53_mx25_initialize(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __BOARDS_ARM_NRF53_NRF5340_DK_SRC_NRF5340_DK_H */

View File

@ -285,6 +285,16 @@ int nrf53_bringup(void)
usbdev_rndis_initialize(mac);
#endif
#ifdef CONFIG_NRF53_QSPI
/* Initialize the MX25 QSPU memory */
ret = nrf53_mx25_initialize();
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: nrf53_mx25_initialize() failed: %d\n", ret);
}
#endif
/* Initialize BLE */
#ifdef CONFIG_NRF53_APPCORE

View File

@ -0,0 +1,107 @@
/****************************************************************************
* boards/arm/nrf53/nrf5340-dk/src/nrf53_mx25.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <stdio.h>
#include <sys/types.h>
#include <nuttx/fs/fs.h>
#include <nuttx/mtd/mtd.h>
#include <nuttx/spi/qspi.h>
#include "nrf53_qspi.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: nrf53_mx25_initialize
*
* Description:
* Initialize the MX25RXX QSPI memeory
*
****************************************************************************/
int nrf53_mx25_initialize(void)
{
struct qspi_dev_s *qspi_dev;
struct mtd_dev_s *mtd_dev;
char blockdev[32];
int ret = -1;
/* Create an instance of the NRF53 QSPI device driver */
qspi_dev = nrf53_qspi_initialize(0);
if (!qspi_dev)
{
_err("nrf53_qspi_initialize() failed\n");
return -1;
}
_info("nrf53_qspi_initialize() successful\n");
/* Use the QSPI device instance to initialize the MX25 device */
mtd_dev = mx25rxx_initialize(qspi_dev, true);
if (!mtd_dev)
{
_err("mx25rxx_initialize() failed\n");
return -1;
}
/* Configure the device with no partition support */
snprintf(blockdev, sizeof(blockdev), "/dev/mtdqspi%d", 0);
ret = register_mtddriver(blockdev, mtd_dev, 0755, NULL);
if (ret != OK)
{
_err("register_mtddriver() failed: %d\n", ret);
return -1;
}
_info("register_mtddriver() successful\n");
#ifdef CONFIG_FS_LITTLEFS
ret = nx_mount(blockdev, "/mnt/qspi", "littlefs", 0, NULL);
if (ret < 0)
{
ret = nx_mount(blockdev, "/mnt/qspi", "littlefs", 0,
"forceformat");
if (ret < 0)
{
_err("nx_mount() failed: %d\n", ret);
}
else
{
_info("nx_mount() successful\n");
}
}
#endif
return ret;
}