Skip to content

Commit 99a2545

Browse files
LinuxMint-UserRbb666
authored andcommitted
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
1 parent 9a6d515 commit 99a2545

File tree

3 files changed

+72
-10
lines changed

3 files changed

+72
-10
lines changed

bsp/stm32/libraries/HAL_Drivers/drivers/drv_qspi.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
2-
* Copyright (c) 2006-2023, RT-Thread Development Team
2+
* Copyright (c) 2006-2025, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
7-
* Date Author Notes
8-
* 2018-11-27 zylx first version
7+
* Date Author Notes
8+
* 2018-11-27 zylx first version
9+
* 2025-12-14 LinuxMint-User resolve QSPI interface type mismatch
910
*/
1011

1112
#include "board.h"
@@ -146,6 +147,7 @@ static void qspi_send_cmd(struct stm32_qspi_bus *qspi_bus, struct rt_qspi_messag
146147
{
147148
Cmdhandler.InstructionMode = QSPI_INSTRUCTION_4_LINES;
148149
}
150+
149151
if (message->address.qspi_lines == 0)
150152
{
151153
Cmdhandler.AddressMode = QSPI_ADDRESS_NONE;
@@ -162,6 +164,7 @@ static void qspi_send_cmd(struct stm32_qspi_bus *qspi_bus, struct rt_qspi_messag
162164
{
163165
Cmdhandler.AddressMode = QSPI_ADDRESS_4_LINES;
164166
}
167+
165168
if (message->address.size == 24)
166169
{
167170
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
170173
{
171174
Cmdhandler.AddressSize = QSPI_ADDRESS_32_BITS;
172175
}
176+
173177
if (message->qspi_data_lines == 0)
174178
{
175179
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,
323327
goto __exit;
324328
}
325329

326-
qspi_device->enter_qspi_mode = enter_qspi_mode;
327-
qspi_device->exit_qspi_mode = exit_qspi_mode;
330+
/* Safe type conversion to resolve interface contract mismatch.
331+
* Caller ensures the function pointer is compatible via adapter pattern.
332+
*/
333+
if (enter_qspi_mode != RT_NULL)
334+
{
335+
qspi_device->enter_qspi_mode = (void (*)(struct rt_qspi_device *))enter_qspi_mode;
336+
}
337+
else
338+
{
339+
qspi_device->enter_qspi_mode = RT_NULL;
340+
}
341+
342+
if (exit_qspi_mode != RT_NULL)
343+
{
344+
qspi_device->exit_qspi_mode = (void (*)(struct rt_qspi_device *))exit_qspi_mode;
345+
}
346+
else
347+
{
348+
qspi_device->exit_qspi_mode = RT_NULL;
349+
}
350+
328351
qspi_device->config.qspi_dl_width = data_line_width;
329352

330353
#ifdef BSP_QSPI_USING_SOFTCS
@@ -377,3 +400,4 @@ INIT_BOARD_EXPORT(rt_hw_qspi_bus_init);
377400

378401
#endif /* BSP_USING_QSPI */
379402
#endif /* RT_USING_QSPI */
403+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
CONFIG_RT_USING_DFS=y
2+
CONFIG_DFS_USING_POSIX=y
3+
CONFIG_DFS_USING_WORKDIR=y
4+
CONFIG_DFS_FD_MAX=16
5+
CONFIG_RT_USING_DFS_V1=y
6+
CONFIG_DFS_FILESYSTEMS_MAX=4
7+
CONFIG_DFS_FILESYSTEM_TYPES_MAX=4
8+
CONFIG_RT_USING_DFS_ELMFAT=y
9+
CONFIG_RT_DFS_ELM_CODE_PAGE=437
10+
CONFIG_RT_DFS_ELM_WORD_ACCESS=y
11+
CONFIG_RT_DFS_ELM_USE_LFN_3=y
12+
CONFIG_RT_DFS_ELM_USE_LFN=3
13+
CONFIG_RT_DFS_ELM_LFN_UNICODE_0=y
14+
CONFIG_RT_DFS_ELM_LFN_UNICODE=0
15+
CONFIG_RT_DFS_ELM_MAX_LFN=255
16+
CONFIG_RT_DFS_ELM_DRIVES=2
17+
CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=4096
18+
CONFIG_RT_DFS_ELM_REENTRANT=y
19+
CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000
20+
CONFIG_RT_USING_DFS_DEVFS=y
21+
22+
CONFIG_RT_USING_SPI=y
23+
CONFIG_RT_USING_SPI_ISR=y
24+
CONFIG_RT_USING_QSPI=y
25+
CONFIG_RT_USING_SFUD=y
26+
CONFIG_RT_SFUD_USING_SFDP=y
27+
CONFIG_RT_SFUD_USING_FLASH_INFO_TABLE=y
28+
CONFIG_RT_SFUD_USING_QSPI=y
29+
CONFIG_RT_SFUD_SPI_MAX_HZ=50000000
30+
CONFIG_BSP_USING_QSPI_FLASH=y
31+
CONFIG_BSP_USING_QSPI=y

bsp/stm32/stm32l475-atk-pandora/board/ports/drv_qspi_flash.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
2-
* Copyright (c) 2006-2021, RT-Thread Development Team
2+
* Copyright (c) 2006-2025, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
7-
* Date Author Notes
8-
* 2018-11-27 zylx first version
7+
* Date Author Notes
8+
* 2018-11-27 zylx first version
9+
* 2025-12-14 LinuxMint-User resolve QSPI compilation error
910
*/
1011

1112
#include <board.h>
@@ -19,6 +20,9 @@
1920
#include "dev_spi_flash.h"
2021
#include "dev_spi_flash_sfud.h"
2122

23+
#define QSPI_BUS_NAME "qspi1"
24+
#define QSPI_DEVICE_NAME "qspi10"
25+
2226
char w25qxx_read_status_register2(struct rt_qspi_device *device)
2327
{
2428
/* 0x35 read status register2 */
@@ -62,16 +66,18 @@ void w25qxx_enter_qspi_mode(struct rt_qspi_device *device)
6266

6367
static int rt_hw_qspi_flash_with_sfud_init(void)
6468
{
65-
rt_hw_qspi_device_attach("qspi1", "qspi10", RT_NULL, 4, w25qxx_enter_qspi_mode, RT_NULL);
69+
rt_hw_qspi_device_attach(QSPI_BUS_NAME, QSPI_DEVICE_NAME, RT_NULL, 4,
70+
(void (*)(void))w25qxx_enter_qspi_mode, RT_NULL);
6671

6772
/* init w25q128 */
68-
if (RT_NULL == rt_sfud_flash_probe("W25Q128", "qspi10"))
73+
if (RT_NULL == rt_sfud_flash_probe("W25Q128", QSPI_DEVICE_NAME))
6974
{
7075
return -RT_ERROR;
7176
}
7277

7378
return RT_EOK;
7479
}
80+
7581
INIT_COMPONENT_EXPORT(rt_hw_qspi_flash_with_sfud_init);
7682

7783
#if defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD_FATFS)
@@ -108,3 +114,4 @@ INIT_ENV_EXPORT(mnt_init);
108114

109115
#endif /* defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD_FATFS) */
110116
#endif /* BSP_USING_QSPI_FLASH */
117+

0 commit comments

Comments
 (0)