0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

stm32 CubeMx 实现SD卡/sd nand FATFS读写测试

深圳市雷龙发展有限公司 2023-06-03 09:20 次阅读

文章目录

stm32 CubeMx 实现SD卡/SD nand FATFS读写测试

1. 前言

2. 环境介绍

2.1 软硬件说明

2.2 外设原理图

3. 工程搭建

3.1 CubeMx 配置

3.2 SDIO时钟配置说明

3.2 读写测试

3.2.1 添加读写测试代码

3.3 FATFS文件操作

3.3.1 修改读写测试代码

3.4 配置问题记录

3.4.1 CubeMx生成代码bug

3.4.2 SD插入检测引脚配置

4. 结束语

1. 前言

SD卡/SD nand是嵌入式开发中常为使用的大容量存储设备,SD nand虽然当前价格比SD卡高,但胜在价格、封装以及稳定性上有优势,实际操作和SD卡没什么区别。

关于 SD卡/SDnand 的驱动,有了CubeMx之后其实基本上都自动生成了对应的驱动了,基本上把驱动配置一下之后,自己写一些应用就可以完成基本的读写了,同时关于FATFS文件系统,也可以直接采用CubeMx配置,也不用自己移植,因此使用STM32开发这些还是比较爽的!不过使用过程中也有一些坑,自动生成的驱动有时候也还是有一些bug,因此还是需要大家对对应驱动有一定的了解。

本文将主要分享关于使用 CubeMx 配置 stm32 的工程,通过SDIO总线完成 SD卡/SD nand 的读写,并配置FATFS,采用文件操作实现对 SD卡/SD nand 的读写操作;此外还将分享博主在调试过程中遇到的一些问题,比如CubeMx自动生成的驱动存在的bug等,以及分享关于驱动部分的代码分析!

2. 环境介绍

2.1 软硬件说明

硬件环境:

主控:stm32f103vet6

SD nand: CSNP1GCR01-AOW【样品CS创世SD NAND由深圳市雷龙发展有限公司免费提供的,感兴趣的可到雷龙官网申请】

软件环境:

CubeMx版本:Version 6.6.1

注意:当前最新版本 V6.8.0,生成的工程配置存在bug,具体细节在后文描述

2.2 外设原理图

SD卡槽原理图部分如下:

image.php?url=YD_cnt_77_01Mx085OLIn5

image.php?url=YD_cnt_77_01Mx08XWjQKw

3. 工程搭建

3.1 CubeMx 配置

  1. 1.选择芯片ACCESS TO MCU SELECTOR
image.php?url=YD_cnt_77_01Mx08XJhnc8

  1. 2.搜索对应的芯片型号,在对应列表下方选择对应芯片
  2. 3.配置时钟方案,采用外部高速时钟,无源晶振方案
image.php?url=YD_cnt_77_01Mx08VaagmX

  1. 4.配置调试器,由于我采用SWD调试接口,因此选择 Serial Wrie 串行总线
image.php?url=YD_cnt_77_01Mx08UssGAQ

  1. 5.配置SDIO外设,由于我们所使用的SD nand支持4线传输,因此此处选择4线宽度;如果你所使用的SD nand或SD卡不支持4线传输,此处应选择1线宽度;支持4线宽度的SD卡肯定可以使用1线宽度,因此如果你实在不知道你的SD卡支持几线宽度,你可以直接选择1线宽度!4线和1线宽度的差别也就在于速度上相差了4倍!
  2. (注意这里暂时不需要对SDIO的参数进行配置,后面我们再回来配置!)
image.php?url=YD_cnt_77_01Mx08Trm7ST

  1. 6.完成时钟树配置:
  • 配置外部晶振频率
  • 调整时钟选择,SYSCLK由PLL产生,PLL由外部时钟倍频产生
  • 配置SDIO外设时钟,注意此处SDIO外设比较特殊,有两个时钟!具体原因见后文!
image.php?url=YD_cnt_77_01Mx08T1NKIR

  1. 7.
  2. 修改SDIO参数配置,主要是修改SDIOCLK的分频
  • 由于我们上述配置的SDIO时钟为 72M,而SD卡支持的通讯速率在0MHz至25MHz之间,因此我们需要分频,配置 SDIO Clock divider bypass 为 Disable
  • 此处设置 SDIOCLK clock divide factor CLKDIV分频系数为 8,这个受限于具体的SD卡支持的最大速度。如果设置值较小,可能由于SDIO_CK速度过高,SD卡/SDnand不支持,导致通讯失败,因此建议先将此值设大点(或查看SD卡/SDnand手册,或先设一个较大值,软件完成SD信息读取后再配置)
  • 注意这个配置的时钟是用于SD读写通讯时候的时钟,而不是SD卡信息识别过程时的速度!
image.php?url=YD_cnt_77_01Mx08Ri0q0N

image.php?url=YD_cnt_77_01Mx08RnA1Z4

编辑

8.勾选 FATFS 配置,选择 SD Card

image.php?url=YD_cnt_77_01Mx08R9Am7n

编辑

9.配置SD卡检测引脚,有以下两种方案

  • 方案一:选择一个输入IO,作为触发引脚
image.php?url=YD_cnt_77_01Mx08PfCgh3

编辑

  • 方案二:不配置输入IO,最后生成代码的时候无视警报即可,生成的代码会自动取消输入检测判断
image.php?url=YD_cnt_77_01Mx08P3dHpR

编辑

10.配置调试串口,用来打印信息,此处我选择USART1,大家可根据自己硬件环境自行选择

image.php?url=YD_cnt_77_01Mx08OFrG9X

编辑

11.配置工程信息

  • 配置工程名
  • 选择工程路径
  • 配置应用程序结构,我习惯选择 Basic 结构
  • 选择IDE工具及版本
  • 修改堆栈大小,适当改大一点,怕不够用
image.php?url=YD_cnt_77_01Mx08NTJ89o

编辑

12.勾选将外设初始化放置在独立的.c和.h文件,这样每个外设的初始化是独立的,方便阅读移植!

image.php?url=YD_cnt_77_01Mx08LoQemv

编辑

13.生成代码

image.php?url=YD_cnt_77_01Mx08LBLxXn

编辑

3.2 SDIO时钟配置说明

在上述CubeMx时钟配置中,外设的时钟一般都是只有一路过去,但是在此处我们会发现SDIO的时钟在时钟树中有两个!没弄清楚还会以为这是CubeMx出现bug了!

image.php?url=YD_cnt_77_01Mx08KVSMts

编辑

其实这是SDIO外设的特殊点,我们查看数据手册上的时钟树,便可以发现,实际上是真的有两路时钟,分别是:1)SDIOCLK;2)至SDIO的AHB接口;

image.php?url=YD_cnt_77_01Mx08JPVVjB

之后,我们看到数据手册的SDIO章节,我们可以看到SDIO外设分为:1)AHB总线接口 和 2)SDIO适配器两大块,且使用不同的时钟,这也就是我们在时钟树配置中可以看到有两路时钟配置的原因了!

从下图我们可以知道,SDIO外设不同于其他外设,其外设模块部分与中断、DMA是分开的,并采用不同的时钟!

image.php?url=YD_cnt_77_01Mx08IWsorx

关于AHB总线接口及SDIO适配器更多细节,大家可自行阅读参考手册部分章节内容,此处不做赘述。

此外,关于时钟配置有一个特别需要注意的,也就是SDIO_CK时钟信号。SDIO_CK时钟,也就是我们SDIO外设与SD卡/SD nand通讯的CLK时钟,从上图我们可知,SDIO_CK时钟来自SDIO适配器,也就是来自SDIOCLK,对应CubeMX时钟配置中的:

image.php?url=YD_cnt_77_01Mx08HKsQvu

image.php?url=YD_cnt_77_01Mx08H2hi40

3.2 读写测试

3.2.1 添加读写测试代码

  1. 1.使能 MicroLIB 微库,否则调用 printf 函数会卡住
image.php?url=YD_cnt_77_01Mx08G9BZVO

2.修改编码规则为 UTF-8,这是由于我们CubeMx中配置的FATFS的编码格式为 UTF-8导致,如果不修改为 UTF-8 则部分中文会乱码! //TODO:确认是由FATFS配置导致

image.php?url=YD_cnt_77_01Mx08FO8oOv

image.php?url=YD_cnt_77_01Mx08EYFRKS

3.添加 printf 重映射 (位置可根据自行决定)

  1. #include
  2. int fputc(int ch, FILE *f)
  3. {
  4. HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1,0xffff);
  5. return (ch);
  6. }

4.添加 sdcard 信息打印函数,查看卡片信息

  1. HAL_SD_CardInfoTypeDef SDCardInfo;
  2. void printf_sdcard_info(void)
  3. {
  4. uint64_t CardCap; //SD卡容量
  5. HAL_SD_CardCIDTypeDef SDCard_CID;
  6. HAL_SD_GetCardCID(&hsd,&SDCard_CID); //获取CID
  7. HAL_SD_GetCardInfo(&hsd,&SDCardInfo); //获取SD卡信息
  8. CardCap=(uint64_t)(SDCardInfo.LogBlockNbr)*(uint64_t)(SDCardInfo.LogBlockSize); //计算SD卡容量
  9. switch(SDCardInfo.CardType)
  10. {
  11. case CARD_SDSC:
  12. {
  13. if(SDCardInfo.CardVersion == CARD_V1_X)
  14. printf("Card Type:SDSC V1\r\n");
  15. else if(SDCardInfo.CardVersion == CARD_V2_X)
  16. printf("Card Type:SDSC V2\r\n");
  17. }
  18. break;
  19. case CARD_SDHC_SDXC:printf("Card Type:SDHC\r\n");break;
  20. default:break;
  21. }
  22. printf("Card ManufacturerID: %d \r\n",SDCard_CID.ManufacturerID); //制造商ID
  23. printf("CardVersion: %d \r\n",(uint32_t)(SDCardInfo.CardVersion)); //卡版本号
  24. printf("Class: %d \r\n",(uint32_t)(SDCardInfo.Class)); //SD卡类别
  25. printf("Card RCA(RelCardAdd):%d \r\n",SDCardInfo.RelCardAdd); //卡相对地址
  26. printf("Card BlockNbr: %d \r\n",SDCardInfo.BlockNbr); //块数量
  27. printf("Card BlockSize: %d \r\n",SDCardInfo.BlockSize); //块大小
  28. printf("LogBlockNbr: %d \r\n",(uint32_t)(SDCardInfo.LogBlockNbr)); //逻辑块数量
  29. printf("LogBlockSize: %d \r\n",(uint32_t)(SDCardInfo.LogBlockSize)); //逻辑块大小
  30. printf("Card Capacity: %d MB\r\n",(uint32_t)(CardCap>>20)); //卡容量
  31. }

5.添加初始化及读写测试代码,注意此处我们没有直接使用FATFS的读写接口,我们先测试生成的SD驱动函数接口

  1. int main(void)
  2. {
  3. /* USER CODE BEGIN 1 */
  4. BYTE send_buf[512];
  5. DRESULT ret;
  6. /* USER CODE END 1 */
  7. /* ...省略若干自动生成代码... */
  8. /* USER CODE BEGIN 2 */
  9. SD_Driver.disk_initialize(0);
  10. printf_sdcard_info();
  11. printf("\r\n\r\n********** 英文读写测试 **********\r\n");
  12. ret = SD_Driver.disk_write(0,
  13. (BYTE *)"Life is too short to spend time with people who suck the happiness out of you. \
  14. If someone wants you in their life, they’ll make room for you. You shouldn’t have to fight for a spot. Never, ever\
  15. insist yourself to someone who continuously overlooks your worth. And remember, it’s not the people that stand by \
  16. your side when you’re at your best, but the ones who stand beside you when you’re at your worst that are your true\
  17. friends",20,2);
  18. printf("sd write result:%d\r\n", ret);
  19. ret = SD_Driver.disk_read(0, send_buf, 20, 2);
  20. printf("sd reak result:%d\r\n", ret);
  21. printf("sd read content:\r\n%s\r\n", send_buf);
  22. printf("\r\n\r\n********** 中文读写测试 **********\r\n");
  23. ret = SD_Driver.disk_write(0,
  24. (BYTE *)"开发者社区的明天需要大家一同开源共创,期待下一次你的分享,让我们一同携手共进,推动人类科技的发展!!!\r\n\
  25. 创作不易,转载请注明出处~\r\n\
  26. 更多文章敬请关注:爱出名的狗腿子\r\n", 22, 2);
  27. printf("sd write result:%d\r\n", ret);
  28. ret = SD_Driver.disk_read(0, send_buf, 22, 2);
  29. printf("sd reak result:%d\r\n", ret);
  30. printf("sd read content:\r\n%s\r\n", send_buf);
  31. /* USER CODE END 2 */
  32. while (1)
  33. {
  34. /* USER CODE END WHILE */
  35. /* USER CODE BEGIN 3 */
  36. }
  37. /* USER CODE END 3 */
  38. }

6.修改烧录器配置,配置为烧录后自动运行

image.php?url=YD_cnt_77_01Mx08M2ko1H

7.下载测试,这里由于我们采用UTF-8编码,所以使用的串口上位机也需要支持UTF-8解析,我们这里使用Mobaxterm上位机,测试结果如下:

image.php?url=YD_cnt_77_01Mx08DUiQpY

8.main.c 文件全部代码如下,供大家参考:

  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2023 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* USER CODE END Header */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "main.h"
  21. #include "fatfs.h"
  22. #include "sdio.h"
  23. #include "usart.h"
  24. #include "gpio.h"
  25. /* Private includes ----------------------------------------------------------*/
  26. /* USER CODE BEGIN Includes */
  27. #include
  28. /* USER CODE END Includes */
  29. /* Private typedef -----------------------------------------------------------*/
  30. /* USER CODE BEGIN PTD */
  31. /* USER CODE END PTD */
  32. /* Private define ------------------------------------------------------------*/
  33. /* USER CODE BEGIN PD */
  34. /* USER CODE END PD */
  35. /* Private macro -------------------------------------------------------------*/
  36. /* USER CODE BEGIN PM */
  37. /* USER CODE END PM */
  38. /* Private variables ---------------------------------------------------------*/
  39. /* USER CODE BEGIN PV */
  40. /* USER CODE END PV */
  41. /* Private function prototypes -----------------------------------------------*/
  42. void SystemClock_Config(void);
  43. /* USER CODE BEGIN PFP */
  44. /* USER CODE END PFP */
  45. /* Private user code ---------------------------------------------------------*/
  46. /* USER CODE BEGIN 0 */
  47. HAL_SD_CardInfoTypeDef SDCardInfo;
  48. void printf_sdcard_info(void)
  49. {
  50. uint64_t CardCap; //SD卡容量
  51. HAL_SD_CardCIDTypeDef SDCard_CID;
  52. HAL_SD_GetCardCID(&hsd,&SDCard_CID); //获取CID
  53. HAL_SD_GetCardInfo(&hsd,&SDCardInfo); //获取SD卡信息
  54. CardCap=(uint64_t)(SDCardInfo.LogBlockNbr)*(uint64_t)(SDCardInfo.LogBlockSize); //计算SD卡容量
  55. switch(SDCardInfo.CardType)
  56. {
  57. case CARD_SDSC:
  58. {
  59. if(SDCardInfo.CardVersion == CARD_V1_X)
  60. printf("Card Type:SDSC V1\r\n");
  61. else if(SDCardInfo.CardVersion == CARD_V2_X)
  62. printf("Card Type:SDSC V2\r\n");
  63. }
  64. break;
  65. case CARD_SDHC_SDXC:printf("Card Type:SDHC\r\n");break;
  66. default:break;
  67. }
  68. printf("Card ManufacturerID: %d \r\n",SDCard_CID.ManufacturerID); //制造商ID
  69. printf("CardVersion: %d \r\n",(uint32_t)(SDCardInfo.CardVersion)); //卡版本号
  70. printf("Class: %d \r\n",(uint32_t)(SDCardInfo.Class)); //SD卡类别
  71. printf("Card RCA(RelCardAdd):%d \r\n",SDCardInfo.RelCardAdd); //卡相对地址
  72. printf("Card BlockNbr: %d \r\n",SDCardInfo.BlockNbr); //块数量
  73. printf("Card BlockSize: %d \r\n",SDCardInfo.BlockSize); //块大小
  74. printf("LogBlockNbr: %d \r\n",(uint32_t)(SDCardInfo.LogBlockNbr)); //逻辑块数量
  75. printf("LogBlockSize: %d \r\n",(uint32_t)(SDCardInfo.LogBlockSize)); //逻辑块大小
  76. printf("Card Capacity: %d MB\r\n",(uint32_t)(CardCap>>20)); //卡容量
  77. }
  78. int fputc(int ch, FILE *f)
  79. {
  80. HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1,0xffff);
  81. return (ch);
  82. }
  83. /* USER CODE END 0 */
  84. /**
  85. * @brief The application entry point.
  86. * @retval int
  87. */
  88. int main(void)
  89. {
  90. /* USER CODE BEGIN 1 */
  91. BYTE send_buf[512];
  92. DRESULT ret;
  93. /* USER CODE END 1 */
  94. /* MCU Configuration--------------------------------------------------------*/
  95. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  96. HAL_Init();
  97. /* USER CODE BEGIN Init */
  98. /* USER CODE END Init */
  99. /* Configure the system clock */
  100. SystemClock_Config();
  101. /* USER CODE BEGIN SysInit */
  102. /* USER CODE END SysInit */
  103. /* Initialize all configured peripherals */
  104. MX_GPIO_Init();
  105. MX_SDIO_SD_Init();
  106. MX_USART1_UART_Init();
  107. MX_FATFS_Init();
  108. /* USER CODE BEGIN 2 */
  109. SD_Driver.disk_initialize(0);
  110. printf_sdcard_info();
  111. printf("\r\n\r\n********** 英文读写测试 **********\r\n");
  112. ret = SD_Driver.disk_write(0,
  113. (BYTE *)"Life is too short to spend time with people who suck the happiness out of you. \
  114. If someone wants you in their life, they’ll make room for you. You shouldn’t have to fight for a spot. Never, ever\
  115. insist yourself to someone who continuously overlooks your worth. And remember, it’s not the people that stand by \
  116. your side when you’re at your best, but the ones who stand beside you when you’re at your worst that are your true\
  117. friends",20,2);
  118. printf("sd write result:%d\r\n", ret);
  119. ret = SD_Driver.disk_read(0, send_buf, 20, 2);
  120. printf("sd reak result:%d\r\n", ret);
  121. printf("sd read content:\r\n%s\r\n", send_buf);
  122. printf("\r\n\r\n********** 中文读写测试 **********\r\n");
  123. ret = SD_Driver.disk_write(0,
  124. (BYTE *)"开发者社区的明天需要大家一同开源共创,期待下一次你的分享,让我们一同携手共进,推动人类科技的发展!!!\r\n\
  125. 创作不易,转载请注明出处~\r\n\
  126. 更多文章敬请关注:爱出名的狗腿子\r\n", 22, 2);
  127. printf("sd write result:%d\r\n", ret);
  128. ret = SD_Driver.disk_read(0, send_buf, 22, 2);
  129. printf("sd reak result:%d\r\n", ret);
  130. printf("sd read content:\r\n%s\r\n", send_buf);
  131. /* USER CODE END 2 */
  132. /* Infinite loop */
  133. /* USER CODE BEGIN WHILE */
  134. while (1)
  135. {
  136. /* USER CODE END WHILE */
  137. /* USER CODE BEGIN 3 */
  138. }
  139. /* USER CODE END 3 */
  140. }
  141. /**
  142. * @brief System Clock Configuration
  143. * @retval None
  144. */
  145. void SystemClock_Config(void)
  146. {
  147. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  148. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  149. /** Initializes the RCC Oscillators according to the specified parameters
  150. * in the RCC_OscInitTypeDef structure.
  151. */
  152. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  153. RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  154. RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
  155. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  156. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  157. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  158. RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
  159. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  160. {
  161. Error_Handler();
  162. }
  163. /** Initializes the CPU, AHB and APB buses clocks
  164. */
  165. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  166. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  167. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  168. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  169. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  170. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  171. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  172. {
  173. Error_Handler();
  174. }
  175. }
  176. /* USER CODE BEGIN 4 */
  177. /* USER CODE END 4 */
  178. /**
  179. * @brief This function is executed in case of error occurrence.
  180. * @retval None
  181. */
  182. void Error_Handler(void)
  183. {
  184. /* USER CODE BEGIN Error_Handler_Debug */
  185. /* User can add his own implementation to report the HAL error return state */
  186. __disable_irq();
  187. while (1)
  188. {
  189. }
  190. /* USER CODE END Error_Handler_Debug */
  191. }
  192. #ifdef USE_FULL_ASSERT
  193. /**
  194. * @brief Reports the name of the source file and the source line number
  195. * where the assert_param error has occurred.
  196. * @param file: pointer to the source file name
  197. * @param line: assert_param error line source number
  198. * @retval None
  199. */
  200. void assert_failed(uint8_t *file, uint32_t line)
  201. {
  202. /* USER CODE BEGIN 6 */
  203. /* User can add his own implementation to report the file name and line number,
  204. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  205. /* USER CODE END 6 */
  206. }
  207. #endif /* USE_FULL_ASSERT */

3.3 FATFS文件操作

移植了FATFS,当然也就可以只用通用的文件系统操作函数完成文件的读写,通用的文件系统操作API 在 ff.c 文件内,声明在 ff.h 文件内,主要使用的API接口如下:

  1. FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
  2. FRESULT f_close (FIL* fp); /* Close an open file object */
  3. FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
  4. FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */
  5. FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
  6. FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
  7. FRESULT f_truncate (FIL* fp); /* Truncate file */
  8. FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */
  9. FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
  10. FRESULT f_closedir (DIR* dp); /* Close an open directory */
  11. FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
  12. FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */
  13. FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */
  14. FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
  15. FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
  16. FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
  17. FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
  18. FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */
  19. FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */
  20. FRESULT f_chdir (const TCHAR* path); /* Change current directory */
  21. FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
  22. FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
  23. FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
  24. FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
  25. FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
  26. FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
  27. FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */
  28. FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
  29. int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
  30. int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
  31. int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
  32. TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */

关于API的使用此处不做过多赘述,大家可以自行上官网查阅 FATFS官网,或者网上搜索,或直接看下述示例亦可。

3.3.1 修改读写测试代码

修改3.2.1章节所使用的读写测试代码,此处我们直接使用FATFS文件系统的读写函数接口,修改主函数如下,注意需要包含fatfs.h头文件!

  1. #include "fatfs.h"
  2. int main()
  3. {
  4. /* USER CODE BEGIN 1 */
  5. #define USERPath "0:/"
  6. BYTE write_buf[] = "\r\n\r\n\
  7. hello world!\r\n\
  8. 开发者社区的明天需要大家一同开源共创,期待下一次你的分享,让我们一同携手共进,推动人类科技的发展!!!\r\n\
  9. 创作不易,转载请注明出处~\r\n\
  10. 更多文章敬请关注:爱出名的狗腿子\r\n\r\n\
  11. ";
  12. BYTE read_buf[1024] = {0};
  13. UINT num;
  14. FRESULT ret;
  15. /* USER CODE END 1 */
  16. /* ... 省略初始化代码... */
  17. /* USER CODE BEGIN 2 */
  18. /* 挂载文件系统,挂载的时候会完成对应硬件设备(SD卡/SDnand)初始化 */
  19. ret = f_mount(&SDFatFS, USERPath, 1);
  20. if (ret != FR_OK) {
  21. printf("f_mount error!\r\n");
  22. goto mount_error;
  23. } else if(ret == FR_NO_FILESYSTEM) { /* 检测是否存在文件系统,如果没有则进行格式化 */
  24. printf("未检测到FATFS文件系统,执行格式化...\r\n");
  25. ret = f_mkfs(USERPath, 0, 0);
  26. if(ret == FR_OK) {
  27. printf("格式化成功!\r\n");
  28. f_mount(NULL, USERPath, 1); /* 先取消挂载,后重新挂载 */
  29. ret = f_mount(&SDFatFS, USERPath, 1);
  30. } else {
  31. printf("格式化失败!\r\n");
  32. goto mount_error;
  33. }
  34. } else {
  35. printf("f_mount success!\r\n");
  36. }
  37. /* 读写测试 */
  38. printf("\r\n ========== write test ==========\r\n");
  39. ret = f_open(&SDFile, "hello.txt", FA_CREATE_ALWAYS | FA_WRITE);
  40. if(ret == FR_OK) {
  41. printf("open file sucess!\r\n");
  42. ret = f_write(&SDFile, write_buf, sizeof(write_buf), &num);
  43. if(ret == FR_OK) {
  44. printf("write "%s" success!\r\nwrite len:%d\r\n", write_buf, num);
  45. } else {
  46. printf("write error! ret:%d \r\n", ret);
  47. goto rw_error;
  48. }
  49. f_close(&SDFile);
  50. } else {
  51. printf("open file error!\r\n");
  52. goto rw_error;
  53. }
  54. printf("\r\n ========== read test ==========\r\n");
  55. ret = f_open(&SDFile, "hello.txt",FA_OPEN_EXISTING | FA_READ);
  56. if(ret == FR_OK) {
  57. printf("open file sucess!\r\n");
  58. ret = f_read(&SDFile, read_buf, sizeof(read_buf), &num);
  59. if(ret == FR_OK) {
  60. printf("read data:"%s"!\r\nread len:%d\r\n", read_buf, num);
  61. } else {
  62. printf("read error! ret:%d \r\n", ret);
  63. goto rw_error;
  64. }
  65. } else {
  66. printf("open file error!\r\n");
  67. goto rw_error;
  68. }
  69. rw_error:
  70. f_close(&SDFile);
  71. mount_error:
  72. f_mount(NULL, USERPath, 1);
  73. /* USER CODE END 2 */
  74. while (1) {
  75. }
  76. }

#define USERPath "0:/" 表示挂载的位置,这是由于FATFS初始化的时候链接的根目录为 0:/ ,所以挂载的文件系统需要在此目录下,当然也可以是此目录下的路径,如0:/hello,但不能是其他目录,如 1:/

image.php?url=YD_cnt_77_01Mx08CWe7Ji

测试结果如下:

image.php?url=YD_cnt_77_01Mx08BWSRPJ

main.c完整内容如下:

  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2023 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* USER CODE END Header */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "main.h"
  21. #include "fatfs.h"
  22. #include "sdio.h"
  23. #include "usart.h"
  24. #include "gpio.h"
  25. /* Private includes ----------------------------------------------------------*/
  26. /* USER CODE BEGIN Includes */
  27. #include
  28. #include "fatfs.h"
  29. /* USER CODE END Includes */
  30. /* Private typedef -----------------------------------------------------------*/
  31. /* USER CODE BEGIN PTD */
  32. /* USER CODE END PTD */
  33. /* Private define ------------------------------------------------------------*/
  34. /* USER CODE BEGIN PD */
  35. /* USER CODE END PD */
  36. /* Private macro -------------------------------------------------------------*/
  37. /* USER CODE BEGIN PM */
  38. /* USER CODE END PM */
  39. /* Private variables ---------------------------------------------------------*/
  40. /* USER CODE BEGIN PV */
  41. /* USER CODE END PV */
  42. /* Private function prototypes -----------------------------------------------*/
  43. void SystemClock_Config(void);
  44. /* USER CODE BEGIN PFP */
  45. /* USER CODE END PFP */
  46. /* Private user code ---------------------------------------------------------*/
  47. /* USER CODE BEGIN 0 */
  48. HAL_SD_CardInfoTypeDef SDCardInfo;
  49. void printf_sdcard_info(void)
  50. {
  51. uint64_t CardCap; //SD卡容釿
  52. HAL_SD_CardCIDTypeDef SDCard_CID;
  53. HAL_SD_GetCardCID(&hsd,&SDCard_CID); //获取CID
  54. HAL_SD_GetCardInfo(&hsd,&SDCardInfo); //获取SD卡信恿
  55. CardCap=(uint64_t)(SDCardInfo.LogBlockNbr)*(uint64_t)(SDCardInfo.LogBlockSize); //计算SD卡容釿
  56. switch(SDCardInfo.CardType)
  57. {
  58. case CARD_SDSC:
  59. {
  60. if(SDCardInfo.CardVersion == CARD_V1_X)
  61. printf("Card Type:SDSC V1\r\n");
  62. else if(SDCardInfo.CardVersion == CARD_V2_X)
  63. printf("Card Type:SDSC V2\r\n");
  64. }
  65. break;
  66. case CARD_SDHC_SDXC:printf("Card Type:SDHC\r\n");break;
  67. default:break;
  68. }
  69. printf("Card ManufacturerID: %d \r\n",SDCard_CID.ManufacturerID); //制鿠商ID
  70. printf("CardVersion: %d \r\n",(uint32_t)(SDCardInfo.CardVersion)); //卡版本号
  71. printf("Class: %d \r\n",(uint32_t)(SDCardInfo.Class)); //SD卡类刿
  72. printf("Card RCA(RelCardAdd):%d \r\n",SDCardInfo.RelCardAdd); //卡相对地坿
  73. printf("Card BlockNbr: %d \r\n",SDCardInfo.BlockNbr); //块数釿
  74. printf("Card BlockSize: %d \r\n",SDCardInfo.BlockSize); //块大尿
  75. printf("LogBlockNbr: %d \r\n",(uint32_t)(SDCardInfo.LogBlockNbr)); //逻辑块数釿
  76. printf("LogBlockSize: %d \r\n",(uint32_t)(SDCardInfo.LogBlockSize)); //逻辑块大尿
  77. printf("Card Capacity: %d MB\r\n",(uint32_t)(CardCap>>20)); //卡容釿
  78. }
  79. int fputc(int ch, FILE *f)
  80. {
  81. HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1,0xffff);
  82. return (ch);
  83. }
  84. /* USER CODE END 0 */
  85. /**
  86. * @brief The application entry point.
  87. * @retval int
  88. */
  89. int main(void)
  90. {
  91. /* USER CODE BEGIN 1 */
  92. #define USERPath "0:/"
  93. BYTE write_buf[] = "\r\n\r\n\
  94. hello world!\r\n\
  95. 开发者社区的明天需要大家一同开源共创,期待下一次你的分享,让我们一同携手共进,推动人类科技的发展!!!\r\n\
  96. 创作不易,转载请注明出处~\r\n\
  97. 更多文章敬请关注:爱出名的狗腿子\r\n\r\n\
  98. ";
  99. BYTE read_buf[1024] = {0};
  100. UINT num;
  101. FRESULT ret;
  102. /* USER CODE END 1 */
  103. /* MCU Configuration--------------------------------------------------------*/
  104. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  105. HAL_Init();
  106. /* USER CODE BEGIN Init */
  107. /* USER CODE END Init */
  108. /* Configure the system clock */
  109. SystemClock_Config();
  110. /* USER CODE BEGIN SysInit */
  111. /* USER CODE END SysInit */
  112. /* Initialize all configured peripherals */
  113. MX_GPIO_Init();
  114. MX_SDIO_SD_Init();
  115. MX_USART1_UART_Init();
  116. MX_FATFS_Init();
  117. /* USER CODE BEGIN 2 */
  118. /* 挂载文件系统,挂载的时候会完成对应硬件设备(SD卡/SDnand)初始化 */
  119. ret = f_mount(&SDFatFS, USERPath, 1);
  120. if (ret != FR_OK) {
  121. printf("f_mount error!\r\n");
  122. goto mount_error;
  123. } else if(ret == FR_NO_FILESYSTEM) { /* 检测是否存在文件系统,如果没有则进行格式化 */
  124. printf("未检测到FATFS文件系统,执行格式化...\r\n");
  125. ret = f_mkfs(USERPath, 0, 0);
  126. if(ret == FR_OK) {
  127. printf("格式化成功!\r\n");
  128. f_mount(NULL, USERPath, 1); /* 先取消挂载,后重新挂载 */
  129. ret = f_mount(&SDFatFS, USERPath, 1);
  130. } else {
  131. printf("格式化失败!\r\n");
  132. goto mount_error;
  133. }
  134. } else {
  135. printf("f_mount success!\r\n");
  136. }
  137. /* 读写测试 */
  138. printf("\r\n ========== write test ==========\r\n");
  139. ret = f_open(&SDFile, "hello.txt", FA_CREATE_ALWAYS | FA_WRITE);
  140. if(ret == FR_OK) {
  141. printf("open file sucess!\r\n");
  142. ret = f_write(&SDFile, write_buf, sizeof(write_buf), &num);
  143. if(ret == FR_OK) {
  144. printf("write "%s" success!\r\nwrite len:%d\r\n", write_buf, num);
  145. } else {
  146. printf("write error! ret:%d \r\n", ret);
  147. goto rw_error;
  148. }
  149. f_close(&SDFile);
  150. } else {
  151. printf("open file error!\r\n");
  152. goto rw_error;
  153. }
  154. printf("\r\n ========== read test ==========\r\n");
  155. ret = f_open(&SDFile, "hello.txt",FA_OPEN_EXISTING | FA_READ);
  156. if(ret == FR_OK) {
  157. printf("open file sucess!\r\n");
  158. ret = f_read(&SDFile, read_buf, sizeof(read_buf), &num);
  159. if(ret == FR_OK) {
  160. printf("read data:"%s"!\r\nread len:%d\r\n", read_buf, num);
  161. } else {
  162. printf("read error! ret:%d \r\n", ret);
  163. goto rw_error;
  164. }
  165. } else {
  166. printf("open file error!\r\n");
  167. goto rw_error;
  168. }
  169. rw_error:
  170. f_close(&SDFile);
  171. mount_error:
  172. f_mount(NULL, USERPath, 1);
  173. /* USER CODE END 2 */
  174. /* Infinite loop */
  175. /* USER CODE BEGIN WHILE */
  176. while (1)
  177. {
  178. /* USER CODE END WHILE */
  179. /* USER CODE BEGIN 3 */
  180. }
  181. /* USER CODE END 3 */
  182. }
  183. /**
  184. * @brief System Clock Configuration
  185. * @retval None
  186. */
  187. void SystemClock_Config(void)
  188. {
  189. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  190. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  191. /** Initializes the RCC Oscillators according to the specified parameters
  192. * in the RCC_OscInitTypeDef structure.
  193. */
  194. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  195. RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  196. RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
  197. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  198. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  199. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  200. RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
  201. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  202. {
  203. Error_Handler();
  204. }
  205. /** Initializes the CPU, AHB and APB buses clocks
  206. */
  207. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  208. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  209. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  210. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  211. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  212. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  213. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  214. {
  215. Error_Handler();
  216. }
  217. }
  218. /* USER CODE BEGIN 4 */
  219. /* USER CODE END 4 */
  220. /**
  221. * @brief This function is executed in case of error occurrence.
  222. * @retval None
  223. */
  224. void Error_Handler(void)
  225. {
  226. /* USER CODE BEGIN Error_Handler_Debug */
  227. /* User can add his own implementation to report the HAL error return state */
  228. __disable_irq();
  229. while (1)
  230. {
  231. }
  232. /* USER CODE END Error_Handler_Debug */
  233. }
  234. #ifdef USE_FULL_ASSERT
  235. /**
  236. * @brief Reports the name of the source file and the source line number
  237. * where the assert_param error has occurred.
  238. * @param file: pointer to the source file name
  239. * @param line: assert_param error line source number
  240. * @retval None
  241. */
  242. void assert_failed(uint8_t *file, uint32_t line)
  243. {
  244. /* USER CODE BEGIN 6 */
  245. /* User can add his own implementation to report the file name and line number,
  246. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  247. /* USER CODE END 6 */
  248. }
  249. #endif /* USE_FULL_ASSERT */

3.4 配置问题记录

3.4.1 CubeMx生成代码bug

测试发现,使用CubeMx当前最新版本:V6.8.0版本,生成代码会存在以下问题:

  • SD卡/SDnand 卡片信息读取成功,但是读写测试失败

经过仔细分析代码后发现,出现的问题在 MX_SDIO_SD_Init() 此初始化函数内的配置项错误导致,具体分析如下:

  1. 我们在CubeMx里面配置的时候选择的是4线宽度模式 SD 4bit Wide bus
  2. v6.8.0版本CubeMx生成的 MX_SDIO_SD_Init() SD初始化函数内,hsd.Init.BusWide = SDIO_BUS_WIDE_4B;
  3. 看上去没有什么问题,配置4线模式,对应的初始化项也使用4线模式,但是不然,我们继续分析 MX_SDIO_SD_Init() 此初始配置的调用
  4. MX_SDIO_SD_Init() 此函数在main函数内初始化的时候调用,此函数只配置了 hsd 结构体,并未配置给SDIO硬件寄存器
  5. 之后调用 SD_Driver.disk_initialize(0); 函数的时候才真正开始进行SDIO外设配置

BSP_SD_Init()

  ->HAL_SD_Init()

    ->HAL_SD_InitCard()

在 HAL_SD_InitCard() 函数内使用Init结构体配置SDIO外设,总线宽度1bit,时钟速度<400k,以进行卡片的初始化识别。

      -> SD_InitCard()

        -> SDIO_Init(hsd->Instance, hsd->Init)

      -> SDMMC_CmdBlockLength(hsd->Instance, BLOCKSIZE)

· 在 SD_InitCard() 函数内实现SD卡的初始化识别,之后调用 SDIO_Init() 将 MX_SDIO_SD_Init() 内对 hsd 的配置配置给SDIO外设,此处的作用主要是提升SDIO外设时钟速率为我们配置的速率;

· v6.8.0版本的代码此时hsd.Init.BusWide = SDIO_BUS_WIDE_4B; ,因此v6.8.0版本代码后续SDIO外设使用4线通讯;

· 之后调用 SDMMC_CmdBlockLength() 设置块大小,由于SDIO外设已切换到4线模式,而SD卡/SDnand此时仍然处于1线模式,因此配置会出错

   -> HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B)

根据前面获取到的SD卡SCR寄存器值,判断是否支持4线模式,如果支持则发送配置命令通知SD卡/SDnand进入4线模式,之后修改SDIO外设总线宽度为4线模式

6.通过以上分析可知,MX_SDIO_SD_Init() 函数内对 hsd.Init.BusWide = SDIO_BUS_WIDE_4B; 的配置会导致对SD卡块大小的配置失败,从而导致后续读写时失败,报错为块大小设置失败!

7.综上,针对当前最新版本 V6.8.0 版本CubeMx的处理方法是:手动修改此 hsd.Init.BusWide 配置为 SDIO_BUS_WIDE_1B 或更换低版本CubeMx,本人更换V6.6.1版本后无此bug。

3.4.2 SD插入检测引脚配置

使用CubeMx配置FATFS 选择 SD Card 之后,有一个配置参数,用来配置SD Card的输入检测引脚。如果我们在硬件上有设计SD卡的卡槽插入检测引脚插入连接到了MCU的IO,则可配置对应IO为输入模式,并设置对应IO为输入检测引脚,比如,我们设置PD12为输入检测引脚,则配置如下:

对应代码如下,输入检测 IO 低电平有效!

image.php?url=YD_cnt_77_01Mx088b2Vk2

image.php?url=YD_cnt_77_01Mx08Ds3I5r

如果硬件上,没有此插入检测引脚,则可以在CubeMx内不进行配置,只是在生成代码的时候会提示警报而已,可以不用关心,生成的代码项会自动屏蔽插入检测!

image.php?url=YD_cnt_77_01Mx08AGoLIZ

4. 结束语

  • 以上便是本文的全部内容了,欢迎大家评论区留言讨论!
  • 使用CubeMx虽然能帮助我们快速生成驱动,但是对于SD卡/SD nand的驱动流程,我们还是需要有清晰的认识,推荐阅读: SD Nand 与 SD卡 SDIO模式应用流程

————————————————

【本文转载自CSDN,作者: 爱出名的狗腿子】

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • SD卡
    +关注

    关注

    2

    文章

    530

    浏览量

    63012
  • FATFS
    +关注

    关注

    0

    文章

    43

    浏览量

    18150
收藏 人收藏

    评论

    相关推荐

    STM32CubeMX+FreeRTOS+SD+FATFS碰到DMA FIFO溢出问题怎么解决?

    也可以挂载,但是多次新建文件打开和关闭后,fatfs返回FR_DISK_ERR;可能是由于SD无响应后超时导致。 然后我下载STM32CubeMX4.24和1.19.0库文件,配置
    发表于 04-23 07:49

    请问使用STM32F1能实现USB和fatfs同时访问SD吗?

    使用STM32F1能实现USB和fatfs同时访问SD吗,想实现1S写一次数据到
    发表于 04-23 07:48

    STM32F412使用SD,SDIO,FATFS系统,SD挂载文件系统失败的原因?

    \", /* (3) The physical drive cannot work */ 原代码从STM32F103RCT6上验证过,F103 CUBEMX版本好像是5.0的,可以直接运行SD
    发表于 04-11 07:15

    关于stm32cubemx usb读卡和fatfs兼容问题求解

    芯片使用STM32F411,使能SDIO,四线接SD 使用stm32cubemx直接生成USB device,大容量储存设备,可以在电脑上看到U盘,使用
    发表于 04-01 06:09

    stm32 CubeMx 怎么实现SD/sd nand FATFS读写测试

    本实验仅用于记录和分享技术经验若涉及侵权请联系我删除。   stm32 CubeMx 实现SD/sd
    发表于 01-09 17:37

    什么是SD NAND存储芯片?

    标准驱动代码,省去了驱动代码编程环节。支持TF启动的SOC都可以用SD NAND,提供STM32参考例程及原厂技术支持,主流容量:128MB/512MB/2GB/4GB/8GB,比T
    发表于 01-05 17:54

    基于Zynq FPGA对雷龙SD NAND测试

    版本:2018.3   文件系统:FATFS   SD接口:SD2.0 3.1 测试流程   本次测试
    发表于 12-22 17:43

    基于RT-Thread快速上手SD NAND 虚拟文件系统

    操作系统,更是不需要编写任何复杂的驱动代码就可以SD NAND读写操作。   (文末提供,STM32驱动代码下载连接,需要可以自行下载)   将
    发表于 12-15 17:29

    DSP+FPGA+FATFS+SD

    项目背景,在DSP上挂Fatfs文件系统,而SD是挂在FPGA上的,DSP需要通过FPGA与SD交互,大概就是会把数据存到FPGA的DD
    发表于 11-14 09:30

    CS SD NANDSTM32精英V2开发板的测试-是时候将TF换为SD NAND

    非常不错的选择,正好一个项目在选择NAND存储方案, 恰巧论坛中联系到雷龙公司申请到了两片SD NAND,所以就进行一下测试评估。 SD
    发表于 09-26 17:40

    【贴片SD Card介绍】贴片式tf/SD NAND/SD2.0协议

    对于 NAND SD的控制,官方有提供基于 STM32测试程序,这里由于篇幅原因,不做过多介绍,其与普通
    发表于 07-28 16:23

    STM32+SD NAND(贴片SD卡)完成FATFS文件系统移植与测试

    这篇文章就手把手教大家,在STM32上完成FATFS文件系统的移植;主控芯片采用STM32F103ZET6, 存储芯片我这里采用(雷龙) CS创世 SD
    的头像 发表于 07-17 17:24 4551次阅读
    <b class='flag-5'>STM32+SD</b> <b class='flag-5'>NAND</b>(贴片<b class='flag-5'>SD</b>卡)完成<b class='flag-5'>FATFS</b>文件系统移植与<b class='flag-5'>测试</b>

    STM32CubeMx入门教程(10):Fatfs文件系统的应用

    导语"fatfs是一个小型的文件系统,在小型的嵌入式系统中使用非常的广泛,STM32CubeMx自带该文件系统,我们通过简单的配置就能够使用,将前面的SD卡的读写操作进行修改,将文件系
    发表于 07-12 11:39 2614次阅读
    <b class='flag-5'>STM32CubeMx</b>入门教程(10):<b class='flag-5'>Fatfs</b>文件系统的应用

    stm32 CubeMx 实现SD/sd nand FATFS读写测试

    文章目录 stm32 CubeMx 实现SD/SD nan
    发表于 06-02 17:01

    SD挂载完成,不知道有没有能够测试SD读写速度的例子?

    SD挂载完成,不知道有没有能够测试SD读写速度的例子?请知道的大侠赐教!!
    发表于 05-12 15:33