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 <martin.vajnar@gmail.com>
This commit is contained in:
Martin Vajnar 2026-07-01 19:57:33 +02:00 committed by Alan C. Assis
parent 888f35fef9
commit 7f0e365e2f
6 changed files with 179 additions and 2 deletions

View file

@ -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"

View file

@ -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 */

View file

@ -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)

View file

@ -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)

View file

@ -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;
}

View file

@ -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