This is an automated email from the ASF dual-hosted git repository.
michallenc 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 5b527528355 stm32f746g-disco: Add support for Winbond W25Q128JVEQ
flash chip
5b527528355 is described below
commit 5b5275283559088e6851d2ccb5fcf9a4356f4b3c
Author: Martin Vajnar <[email protected]>
AuthorDate: Wed Jul 1 19:57:33 2026 +0200
stm32f746g-disco: Add support for Winbond W25Q128JVEQ flash chip
New series of the STM32F746G-DISCO use Winbond W25Q128JVEQ. This commit
adds support for it.
Signed-off-by: Martin Vajnar <[email protected]>
---
boards/arm/stm32f7/stm32f746g-disco/Kconfig | 13 ++
.../arm/stm32f7/stm32f746g-disco/include/board.h | 4 +-
boards/arm/stm32f7/stm32f746g-disco/src/Make.defs | 4 +
.../stm32f7/stm32f746g-disco/src/stm32_bringup.c | 8 ++
.../arm/stm32f7/stm32f746g-disco/src/stm32_w25q.c | 140 +++++++++++++++++++++
.../stm32f746g-disco/src/stm32f746g-disco.h | 12 ++
6 files changed, 179 insertions(+), 2 deletions(-)
diff --git a/boards/arm/stm32f7/stm32f746g-disco/Kconfig
b/boards/arm/stm32f7/stm32f746g-disco/Kconfig
index 15c51d8a03e..3621e4f00c5 100644
--- a/boards/arm/stm32f7/stm32f746g-disco/Kconfig
+++ b/boards/arm/stm32f7/stm32f746g-disco/Kconfig
@@ -16,6 +16,19 @@ config STM32F746GDISCO_FLASH
select MTD_BYTE_WRITE
---help---
Configures an MTD device for use with the onboard flash
+ Micron N25Q.
+
+config STM32F746GDISCO_FLASH_WINBOND
+ bool "MTD driver for external 16Mbyte W25Q128JVEQ FLASH on QSPI port"
+ default n
+ select MTD
+ select MTD_W25QXXXJV
+ select FS_NXFFS
+ select STM32_QSPI
+ ---help---
+ Configures an MTD device for use with the onboard flash
+ Winbond W25Q. Set CONFIG_W25QXXXJV_QSPI_FREQUENCY to
+ 100MHz for correct operation.
config STM32F746GDISCO_TOUCHSCREEN_SWAPXY
bool "STM32F746G DISCO Touchscreen sway X/Y"
diff --git a/boards/arm/stm32f7/stm32f746g-disco/include/board.h
b/boards/arm/stm32f7/stm32f746g-disco/include/board.h
index 35a9e14961f..3cd251de1be 100644
--- a/boards/arm/stm32f7/stm32f746g-disco/include/board.h
+++ b/boards/arm/stm32f7/stm32f746g-disco/include/board.h
@@ -519,12 +519,12 @@
/* QSPI pinset */
-#define GPIO_QSPI_CS (GPIO_QUADSPI_BK1_NCS|GPIO_SPEED_100MHz)
+#define GPIO_QSPI_CS (GPIO_QUADSPI_BK1_NCS_0|GPIO_SPEED_100MHz)
#define GPIO_QSPI_IO0 (GPIO_QUADSPI_BK1_IO0_3|GPIO_SPEED_100MHz)
#define GPIO_QSPI_IO1 (GPIO_QUADSPI_BK1_IO1_3|GPIO_SPEED_100MHz)
#define GPIO_QSPI_IO2 (GPIO_QUADSPI_BK1_IO2_1|GPIO_SPEED_100MHz)
#define GPIO_QSPI_IO3 (GPIO_QUADSPI_BK1_IO3_2|GPIO_SPEED_100MHz)
-#define GPIO_QSPI_SCK (GPIO_QUADSPI_CLK|GPIO_SPEED_100MHz)
+#define GPIO_QSPI_SCK (GPIO_QUADSPI_CLK_0|GPIO_SPEED_100MHz)
/* SAI2 pinset */
diff --git a/boards/arm/stm32f7/stm32f746g-disco/src/Make.defs
b/boards/arm/stm32f7/stm32f746g-disco/src/Make.defs
index bfa456fb8a5..5618415d85f 100644
--- a/boards/arm/stm32f7/stm32f746g-disco/src/Make.defs
+++ b/boards/arm/stm32f7/stm32f746g-disco/src/Make.defs
@@ -58,6 +58,10 @@ ifeq ($(CONFIG_MTD_N25QXXX),y)
CSRCS += stm32_n25q.c
endif
+ifeq ($(CONFIG_MTD_W25QXXXJV),y)
+CSRCS += stm32_w25q.c
+endif
+
ifeq ($(CONFIG_STM32_OTGFS),y)
CSRCS += stm32_usb.c
else ifeq ($(CONFIG_STM32_OTGFSHS),y)
diff --git a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_bringup.c
b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_bringup.c
index 3773c61a101..6b7e4767f0f 100644
--- a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_bringup.c
+++ b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_bringup.c
@@ -138,6 +138,14 @@ int stm32_bringup(void)
}
#endif
+#ifdef CONFIG_MTD_W25QXXXJV
+ ret = stm32_w25qxxx_setup();
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: stm32_w25qxxx_setup failed: %d\n", ret);
+ }
+#endif
+
#ifdef HAVE_SDIO
ret = stm32_sdio_initialize();
if (ret < 0)
diff --git a/boards/arm/stm32f7/stm32f746g-disco/src/stm32_w25q.c
b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_w25q.c
new file mode 100644
index 00000000000..7ea9a654c0f
--- /dev/null
+++ b/boards/arm/stm32f7/stm32f746g-disco/src/stm32_w25q.c
@@ -0,0 +1,140 @@
+/****************************************************************************
+ * boards/arm/stm32f7/stm32f746g-disco/src/stm32_w25q.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * 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 <sys/types.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <errno.h>
+#include <nuttx/debug.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
+
+#include <arch/board/board.h>
+
+#include <nuttx/mtd/mtd.h>
+#include <nuttx/drivers/drivers.h>
+#include <nuttx/drivers/ramdisk.h>
+
+#ifdef CONFIG_FS_NXFFS
+#include <nuttx/fs/nxffs.h>
+#endif
+
+#ifdef CONFIG_FS_SMARTFS
+#include <nuttx/fs/smart.h>
+#endif
+
+#include "stm32f746g-disco.h"
+
+#include "stm32_qspi.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_w25qxxx_setup
+ *
+ * Description:
+ * This function is called by board-bringup logic to configure the
+ * flash device.
+ *
+ * Returned Value:
+ * Zero is returned on success. Otherwise, a negated errno value is
+ * returned to indicate the nature of the failure.
+ *
+ ****************************************************************************/
+
+int stm32_w25qxxx_setup(void)
+{
+ struct qspi_dev_s *qspi_dev;
+ struct mtd_dev_s *mtd_dev;
+ int ret = -1;
+
+ qspi_dev = stm32_qspi_initialize(0);
+ if (!qspi_dev)
+ {
+ _err("ERROR: Failed to initialize W25 minor %d: %d\n",
+ 0, ret);
+ return -1;
+ }
+
+ mtd_dev = w25qxxxjv_initialize(qspi_dev, true);
+ if (!mtd_dev)
+ {
+ _err("ERROR: w25qxxxjv_initialize() failed!\n");
+ return -1;
+ }
+
+#if defined(CONFIG_FS_NXFFS) && !defined(CONFIG_FS_LITTLEFS)
+ /* Initialize to provide NXFFS on the W25QXXX MTD interface */
+
+ ret = nxffs_initialize(mtd_dev);
+ if (ret < 0)
+ {
+ _err("ERROR: NXFFS initialization failed: %d\n", ret);
+ return ret;
+ }
+
+ ret = nx_mount(NULL, "/w25", "nxffs", 0, "autoformat");
+ if (ret < 0)
+ {
+ _err("ERROR: Failed to mount the NXFFS volume: %d\n", ret);
+ return ret;
+ }
+
+#endif
+
+#if !defined(CONFIG_FS_NXFFS) && defined(CONFIG_FS_LITTLEFS)
+ /* Register the MTD driver so that it can be accessed from the
+ * VFS.
+ */
+
+ ret = register_mtddriver("/dev/w25", mtd_dev, 0755, NULL);
+ if (ret < 0)
+ {
+ syslog(LOG_ERR, "ERROR: Failed to register MTD driver: %d\n",
+ ret);
+ }
+
+ /* Mount the LittleFS file system */
+
+ ret = nx_mount("/dev/w25", "/w25", "littlefs", 0, "autoformat");
+ if (ret < 0)
+ {
+ syslog(LOG_ERR,
+ "ERROR: Failed to mount LittleFS at /w25: %d\n",
+ ret);
+ }
+#endif
+
+ return 0;
+}
diff --git a/boards/arm/stm32f7/stm32f746g-disco/src/stm32f746g-disco.h
b/boards/arm/stm32f7/stm32f746g-disco/src/stm32f746g-disco.h
index fec4ada12bd..423f670b08e 100644
--- a/boards/arm/stm32f7/stm32f746g-disco/src/stm32f746g-disco.h
+++ b/boards/arm/stm32f7/stm32f746g-disco/src/stm32f746g-disco.h
@@ -253,6 +253,18 @@ int stm32_tsc_setup(int minor);
int stm32_n25qxxx_setup(void);
#endif
+/****************************************************************************
+ * Name: stm32_w25qxxx_setup
+ *
+ * Description:
+ * Initialize and register the Flash for W25QXXX driver.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_MTD_W25QXXXJV
+int stm32_w25qxxx_setup(void);
+#endif
+
#ifdef HAVE_SDIO
int stm32_sdio_initialize(void);
#endif