Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
RT-Thread一般讨论
SFUD,QSPI,MT25QL101g. 能探测到,读写没内容,各位大神帮忙看下.
发布于 2020-05-25 11:31:20 浏览:1516
订阅该版
[D/drv.qspi] qspi init success! [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud.c:862) The flash device manufacturer ID is 0x20, memory type ID is 0xBA, capacity ID is 0x21. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:132) Check SFDP header is OK. The reversion is V1.6, NPN is 1. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:175) Check JEDEC basic flash parameter header is OK. The table id is 0, reversion is V1.6, length is 16, parameter table pointer is 0x000030. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:203) JEDEC basic flash parameter table info: [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:204) MSB-LSB 3 2 1 0 [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:207) [0001] 0xFF 0xFB 0x20 0xE5 [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:207) [0002] 0x3F 0xFF 0xFF 0xFF [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:207) [0003] 0x6B 0x27 0xEB 0x29 [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:207) [0004] 0xBB 0x27 0x3B 0x27 [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:207) [0005] 0xFF 0xFF 0xFF 0xFF [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:207) [0006] 0xBB 0x27 0xFF 0xFF [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:207) [0007] 0xEB 0x29 0xFF 0xFF [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:207) [0008] 0xD8 0x10 0x20 0x0C [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:207) [0009] 0x00 0x00 0x52 0x0F [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:215) 4 KB Erase is supported throughout the device. Command is 0x 20. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:234) Write granularity is 64 bytes or larger. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:245) Target flash status register is non-volatile. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:276) 3- or 4-Byte addressing. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:305) Capacity is 134217728 Bytes. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:312) Flash device supports 4KB block erase. Command is 0x20. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:312) Flash device supports 64KB block erase. Command is 0xD8. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud_sfdp.c:312) Flash device supports 32KB block erase. Command is 0x52. [SFUD] Find a Micron flash chip. Size is 134217728 bytes. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud.c:840) Flash device reset success. [SFUD] (../rt-thread/components/drivers/spi/sfud/src/sfud.c:941) Enter 4-Byte addressing mode success. [SFUD] M25QL1GB flash device is initialize success. [D/drv.qspi] qspi init success! [SFUD] Probe SPI flash M25QL1GB by SPI device qspi10 success. 1 - Use SFUD API sfud device name: M25QL1GB, sector_count: 32768, bytes_per_sector: 4096, block_size: 4096. msh />sfud api write data to m25q(address:0x2000) success. sfud api read data from m25q(address:0x2000) is: ------------------------------------------------------------------------------------------------------------ #define SFUD_FLASH_CHIP_TABLE \ { {"M25QL1GB", SFUD_MF_ID_MICRON, 0x20, 0x21, 128L*1024L*1024L,SFUD_WM_PAGE_256B, 4096, 0x21}, } --------------------------------------------------------------------------------------------------------- #include "drv_qspi.h" #include
#define QSPI_BUD_NAME "qspi1" #define QSPI_DEVICE_NAME "qspi10" #define M25Q_FLASH_NAME "M25QL1GB" #define QSPI_CS_PIN GET_PIN(B, 11) #define LED0_PIN GET_PIN(B, 4) #define LED1_PIN GET_PIN(B, 5) rt_uint8_t wData[4096] = {"1234567."}; rt_uint8_t rData[4096] = {"7654321."}; int rt_hw_spi_flash_init(void) { if(stm32_qspi_bus_attach_device(QSPI_BUD_NAME, QSPI_DEVICE_NAME, (rt_uint32_t)QSPI_CS_PIN, 1, RT_NULL, RT_NULL) != RT_EOK) return -RT_ERROR; #ifdef RT_USING_SFUD if(rt_sfud_flash_probe(M25Q_FLASH_NAME, QSPI_DEVICE_NAME) == RT_NULL) return -RT_ERROR; #endif return RT_EOK; } void sfud_w25q_sample(void) { rt_spi_flash_device_t flash_dev; sfud_flash_t sfud_dev; struct rt_device_blk_geometry geometry; // 1- use sfud api rt_kprintf("
1 - Use SFUD API
"); sfud_dev = rt_sfud_flash_find_by_dev_name(M25Q_FLASH_NAME); if(sfud_dev == RT_NULL){ rt_kprintf("sfud can't find %s device.
", M25Q_FLASH_NAME); }else{ rt_kprintf("sfud device name: %s, sector_count: %d, bytes_per_sector: %d, block_size: %d.
", sfud_dev->name, sfud_dev->chip.capacity / sfud_dev->chip.erase_gran, sfud_dev->chip.erase_gran, sfud_dev->chip.erase_gran); if(sfud_erase_write(sfud_dev, 0x002000, sizeof(wData), wData) == SFUD_SUCCESS) rt_kprintf("sfud api write data to m25q(address:0x2000) success.
"); if(sfud_read(sfud_dev, 0x002000, sizeof(rData), rData) == SFUD_SUCCESS) rt_kprintf("sfud api read data from m25q(address:0x2000) is:%s
", rData); } // 2- use rt_device api rt_kprintf("
2 - Use rt_device API
"); flash_dev = (rt_spi_flash_device_t)rt_device_find(M25Q_FLASH_NAME); if(flash_dev == RT_NULL){ rt_kprintf("rt_device api can't find %s device.
", M25Q_FLASH_NAME); }else{ rt_device_open(&flash_dev->flash_device, RT_DEVICE_OFLAG_OPEN); if(rt_device_control(&flash_dev->flash_device, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry) == RT_EOK) rt_kprintf("qspi flash device name: %s, sector_count: %d, bytes_per_sector: %d, block_size: %d.
", flash_dev->flash_device.parent.name, geometry.sector_count, geometry.bytes_per_sector, geometry.block_size); if(rt_device_write(&flash_dev->flash_device, 0x03, wData, 1) > 0) rt_kprintf("rt_device api write data to m25q(address:0x3000) success.
"); if(rt_device_read(&flash_dev->flash_device, 0x03, rData, 1) > 0) rt_kprintf("rt_device api read data from m25q(address:0x3000) is:%s
", rData); rt_device_close(&flash_dev->flash_device); } } int main(void) { int count = 1; /* set LED0 pin mode to output */ rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT); rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT); rt_hw_spi_flash_init(); sfud_w25q_sample(); while (count++) { /* set LED0 pin level to high or low */ rt_pin_write(LED0_PIN, count % 2); //rt_kprintf("Hello RT-Thread!"); rt_thread_mdelay(1000); } return RT_EOK; } void HAL_QSPI_MspInit(QSPI_HandleTypeDef* qspiHandle) { //rt_kprintf("rt_device HAL_QSPI_MspInit
"); GPIO_InitTypeDef GPIO_InitStruct = {0}; if(qspiHandle->Instance==QUADSPI) { /* USER CODE BEGIN QUADSPI_MspInit 0 */ /* USER CODE END QUADSPI_MspInit 0 */ /* QUADSPI clock enable */ __HAL_RCC_QSPI_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /**QUADSPI GPIO Configuration PA6 ------> QUADSPI_BK1_IO3 PA7 ------> QUADSPI_BK1_IO2 PB0 ------> QUADSPI_BK1_IO1 PB1 ------> QUADSPI_BK1_IO0 PB10 ------> QUADSPI_CLK PB11 ------> QUADSPI_NCS */ GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_10|GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* USER CODE BEGIN QUADSPI_MspInit 1 */ /* USER CODE END QUADSPI_MspInit 1 */ } } #if 1 void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* qspiHandle) { if(qspiHandle->Instance==QUADSPI) { /* USER CODE BEGIN QUADSPI_MspDeInit 0 */ /* USER CODE END QUADSPI_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_QSPI_CLK_DISABLE(); /**QUADSPI GPIO Configuration PA6 ------> QUADSPI_BK1_IO3 PA7 ------> QUADSPI_BK1_IO2 PB0 ------> QUADSPI_BK1_IO1 PB1 ------> QUADSPI_BK1_IO0 PB10 ------> QUADSPI_CLK PB11 ------> QUADSPI_NCS */ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_6|GPIO_PIN_7); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_10|GPIO_PIN_11); /* USER CODE BEGIN QUADSPI_MspDeInit 1 */ /* USER CODE END QUADSPI_MspDeInit 1 */ } }
查看更多
1
个回答
默认排序
按发布时间排序
james_s
2021-04-13
这家伙很懒,什么也没写!
看起来没啥错误, 换个flash试试确认硬件没问题
撰写答案
登录
注册新账号
关注者
0
被浏览
1.5k
关于作者
Qzeng
这家伙很懒,什么也没写!
提问
1
回答
0
被采纳
0
关注TA
发私信
相关问题
1
有关动态模块加载的一篇论文
2
最近的调程序总结
3
晕掉了,这么久都不见layer2的踪影啊
4
继续K9ii的历程
5
[GUI相关] FreeType 2
6
[GUI相关]嵌入式系统中文输入法的设计
7
20081101 RT-Thread开发者聚会总结
8
嵌入式系统基础
9
linux2.4.19在at91rm9200 上的寄存器设置
10
[转]基于嵌入式Linux的通用触摸屏校准程序
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
【24嵌入式设计大赛】基于RT-Thread星火一号的智慧家居系统
2
RT-Thread EtherKit开源以太网硬件正式发布
3
如何在master上的BSP中添加配置yml文件
4
使用百度AI助手辅助编写一个rt-thread下的ONVIF设备发现功能的功能代码
5
RT-Thread 发布 EtherKit开源以太网硬件!
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
I2C_IIC
WIZnet_W5500
UART
ota在线升级
PWM
cubemx
freemodbus
flash
packages_软件包
BSP
潘多拉开发板_Pandora
定时器
ADC
GD32
flashDB
socket
中断
Debug
编译报错
msh
SFUD
keil_MDK
rt_mq_消息队列_msg_queue
MicroPython
ulog
C++_cpp
本月问答贡献
踩姑娘的小蘑菇
7
个答案
3
次被采纳
a1012112796
15
个答案
2
次被采纳
张世争
9
个答案
2
次被采纳
rv666
5
个答案
2
次被采纳
用户名由3_15位
13
个答案
1
次被采纳
本月文章贡献
程序员阿伟
9
篇文章
2
次点赞
hhart
3
篇文章
4
次点赞
大龄码农
1
篇文章
5
次点赞
RTT_逍遥
1
篇文章
2
次点赞
ThinkCode
1
篇文章
1
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部