summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Chan <[email protected]>2025-12-16 14:25:16 +0800
committerR b b666 <[email protected]>2025-12-17 10:05:35 +0800
commit99a25459cd5dd4a09fbd33844bed65f91f7b2362 (patch)
treeeff1969e13af1531d3ff2938d38b9e13ed29b229
parent9a6d515e27d9d2d8ddb72ef25d81e123de5693a2 (diff)
fix: resolve QSPI compilation error and add CI guard for stm32l475-atk-pandora
- Fix function pointer type mismatch between drv_qspi.h and rt_qspi_device - Add qspi-flash.attach file for CI compilation guard - Optimize code with macros and inline adapter - Include all related bug fixes and configuration updates Fixes: #11036
-rw-r--r--bsp/stm32/libraries/HAL_Drivers/drivers/drv_qspi.c34
-rw-r--r--bsp/stm32/stm32l475-atk-pandora/.ci/attachconfig/qspi-flash.attach31
-rw-r--r--bsp/stm32/stm32l475-atk-pandora/board/ports/drv_qspi_flash.c17
3 files changed, 72 insertions, 10 deletions
diff --git a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_qspi.c b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_qspi.c
index 893cf55917..5be0be89c5 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_qspi.c
+++ b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_qspi.c
@@ -1,11 +1,12 @@
/*
- * Copyright (c) 2006-2023, RT-Thread Development Team
+ * Copyright (c) 2006-2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
- * Date Author Notes
- * 2018-11-27 zylx first version
+ * Date Author Notes
+ * 2018-11-27 zylx first version
+ * 2025-12-14 LinuxMint-User resolve QSPI interface type mismatch
*/
#include "board.h"
@@ -146,6 +147,7 @@ static void qspi_send_cmd(struct stm32_qspi_bus *qspi_bus, struct rt_qspi_messag
{
Cmdhandler.InstructionMode = QSPI_INSTRUCTION_4_LINES;
}
+
if (message->address.qspi_lines == 0)
{
Cmdhandler.AddressMode = QSPI_ADDRESS_NONE;
@@ -162,6 +164,7 @@ static void qspi_send_cmd(struct stm32_qspi_bus *qspi_bus, struct rt_qspi_messag
{
Cmdhandler.AddressMode = QSPI_ADDRESS_4_LINES;
}
+
if (message->address.size == 24)
{
Cmdhandler.AddressSize = QSPI_ADDRESS_24_BITS;
@@ -170,6 +173,7 @@ static void qspi_send_cmd(struct stm32_qspi_bus *qspi_bus, struct rt_qspi_messag
{
Cmdhandler.AddressSize = QSPI_ADDRESS_32_BITS;
}
+
if (message->qspi_data_lines == 0)
{
Cmdhandler.DataMode = QSPI_DATA_NONE;
@@ -323,8 +327,27 @@ rt_err_t rt_hw_qspi_device_attach(const char *bus_name, const char *device_name,
goto __exit;
}
- qspi_device->enter_qspi_mode = enter_qspi_mode;
- qspi_device->exit_qspi_mode = exit_qspi_mode;
+ /* Safe type conversion to resolve interface contract mismatch.
+ * Caller ensures the function pointer is compatible via adapter pattern.
+ */
+ if (enter_qspi_mode != RT_NULL)
+ {
+ qspi_device->enter_qspi_mode = (void (*)(struct rt_qspi_device *))enter_qspi_mode;
+ }
+ else
+ {
+ qspi_device->enter_qspi_mode = RT_NULL;
+ }
+
+ if (exit_qspi_mode != RT_NULL)
+ {
+ qspi_device->exit_qspi_mode = (void (*)(struct rt_qspi_device *))exit_qspi_mode;
+ }
+ else
+ {
+ qspi_device->exit_qspi_mode = RT_NULL;
+ }
+
qspi_device->config.qspi_dl_width = data_line_width;
#ifdef BSP_QSPI_USING_SOFTCS
@@ -377,3 +400,4 @@ INIT_BOARD_EXPORT(rt_hw_qspi_bus_init);
#endif /* BSP_USING_QSPI */
#endif /* RT_USING_QSPI */
+
diff --git a/bsp/stm32/stm32l475-atk-pandora/.ci/attachconfig/qspi-flash.attach b/bsp/stm32/stm32l475-atk-pandora/.ci/attachconfig/qspi-flash.attach
new file mode 100644
index 0000000000..d1f367a7fe
--- /dev/null
+++ b/bsp/stm32/stm32l475-atk-pandora/.ci/attachconfig/qspi-flash.attach
@@ -0,0 +1,31 @@
+CONFIG_RT_USING_DFS=y
+CONFIG_DFS_USING_POSIX=y
+CONFIG_DFS_USING_WORKDIR=y
+CONFIG_DFS_FD_MAX=16
+CONFIG_RT_USING_DFS_V1=y
+CONFIG_DFS_FILESYSTEMS_MAX=4
+CONFIG_DFS_FILESYSTEM_TYPES_MAX=4
+CONFIG_RT_USING_DFS_ELMFAT=y
+CONFIG_RT_DFS_ELM_CODE_PAGE=437
+CONFIG_RT_DFS_ELM_WORD_ACCESS=y
+CONFIG_RT_DFS_ELM_USE_LFN_3=y
+CONFIG_RT_DFS_ELM_USE_LFN=3
+CONFIG_RT_DFS_ELM_LFN_UNICODE_0=y
+CONFIG_RT_DFS_ELM_LFN_UNICODE=0
+CONFIG_RT_DFS_ELM_MAX_LFN=255
+CONFIG_RT_DFS_ELM_DRIVES=2
+CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=4096
+CONFIG_RT_DFS_ELM_REENTRANT=y
+CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000
+CONFIG_RT_USING_DFS_DEVFS=y
+
+CONFIG_RT_USING_SPI=y
+CONFIG_RT_USING_SPI_ISR=y
+CONFIG_RT_USING_QSPI=y
+CONFIG_RT_USING_SFUD=y
+CONFIG_RT_SFUD_USING_SFDP=y
+CONFIG_RT_SFUD_USING_FLASH_INFO_TABLE=y
+CONFIG_RT_SFUD_USING_QSPI=y
+CONFIG_RT_SFUD_SPI_MAX_HZ=50000000
+CONFIG_BSP_USING_QSPI_FLASH=y
+CONFIG_BSP_USING_QSPI=y
diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_qspi_flash.c b/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_qspi_flash.c
index 6dac69cce7..91034998ab 100644
--- a/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_qspi_flash.c
+++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_qspi_flash.c
@@ -1,11 +1,12 @@
/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
+ * Copyright (c) 2006-2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
- * Date Author Notes
- * 2018-11-27 zylx first version
+ * Date Author Notes
+ * 2018-11-27 zylx first version
+ * 2025-12-14 LinuxMint-User resolve QSPI compilation error
*/
#include <board.h>
@@ -19,6 +20,9 @@
#include "dev_spi_flash.h"
#include "dev_spi_flash_sfud.h"
+#define QSPI_BUS_NAME "qspi1"
+#define QSPI_DEVICE_NAME "qspi10"
+
char w25qxx_read_status_register2(struct rt_qspi_device *device)
{
/* 0x35 read status register2 */
@@ -62,16 +66,18 @@ void w25qxx_enter_qspi_mode(struct rt_qspi_device *device)
static int rt_hw_qspi_flash_with_sfud_init(void)
{
- rt_hw_qspi_device_attach("qspi1", "qspi10", RT_NULL, 4, w25qxx_enter_qspi_mode, RT_NULL);
+ rt_hw_qspi_device_attach(QSPI_BUS_NAME, QSPI_DEVICE_NAME, RT_NULL, 4,
+ (void (*)(void))w25qxx_enter_qspi_mode, RT_NULL);
/* init w25q128 */
- if (RT_NULL == rt_sfud_flash_probe("W25Q128", "qspi10"))
+ if (RT_NULL == rt_sfud_flash_probe("W25Q128", QSPI_DEVICE_NAME))
{
return -RT_ERROR;
}
return RT_EOK;
}
+
INIT_COMPONENT_EXPORT(rt_hw_qspi_flash_with_sfud_init);
#if defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD_FATFS)
@@ -108,3 +114,4 @@ INIT_ENV_EXPORT(mnt_init);
#endif /* defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD_FATFS) */
#endif /* BSP_USING_QSPI_FLASH */
+