Это видео недоступно.
Сожалеем об этом.
STM32 - Creating a File System on a SD card
HTML-код
- Опубликовано: 15 авг 2024
- Find out more information:
bit.ly/32F746G...
bit.ly/STM32Cu...
bit.ly/FatFSinfo
In this video we will explain you how to create a file system on a SD card using STM32 and ST Toolsets. This is useful for data logging type of application where you need to write data files on an external media like a SD card.
Introduction: 0:00
Board used: 2:32
Beginning of exercise: 2:54
Live Demo: 11:40
Code available here: www.st.com/cont...
/* USER CODE BEGIN 1 */
FRESULT res; /* FatFs function common result code */
uint32_t byteswritten, bytesread; /* File write/read counts */
uint8_t wtext[] = "STM32 FATFS works great!"; /* File write buffer */
uint8_t rtext[_MAX_SS];/* File read buffer */
/* USER CODE END 1 */
...
/* USER CODE BEGIN 2 */
if(f_mount(&SDFatFS, (TCHAR const*)SDPath, 0) != FR_OK)
{
Error_Handler();
}
else
{
if(f_mkfs((TCHAR const*)SDPath, FM_ANY, 0, rtext, sizeof(rtext)) != FR_OK)
{
Error_Handler();
}
else
{
//Open file for writing (Create)
if(f_open(&SDFile, "STM32.TXT", FA_CREATE_ALWAYS | FA_WRITE) != FR_OK)
{
Error_Handler();
}
else
{
//Write to the text file
res = f_write(&SDFile, wtext, strlen((char *)wtext), (void *)&byteswritten);
if((byteswritten == 0) || (res != FR_OK))
{
Error_Handler();
}
else
{
f_close(&SDFile);
}
}
}
}
f_mount(&SDFatFS, (TCHAR const*)NULL, 0);
/* USER CODE END 2 */
In case someone still having troubles with the H7.
These steps worked out for me:
-activate SDMMC in 4Bit wide bus
-For MDMA Controller activate Chanel for sdmmc streams and make shure MDMA interrupt is active for sdmmc
-integrate FatFs Library
NOTE: Parameters in Unmount-Function for SDCard are in the wrong order.
When working with FreeRtos and TouchGFX-> for Fatfs deactivate FS-Reeantrant and activate for FreeRTOS. Than before you are able to work with sd card-> disable D-Cache and enable when done
Hello, can I DM you? We are doing a project and would like help to setup our SD-card reader with our H7. Thanks in advance
Great video and presenter! Helped me remember the *basics* of working with FATFs. Thanks for the video lesson.
Thank you so much for the useful tutorial. Is there a same tutorial for activation of microphone for stm32f746 Discovery board? If not, I would appreciate if you provide it. Many thanks.
If someone looked into ST implementation of SDIO + FATFS, I believe he will have an indelible impression till the end of the life.
Newer CubeMX replaces FatFs with FileX. Formatting with FileX is not as straight-forward as it is with FatFs, you have to specify sector count and bytes-per-sector. To be able to do that, you have to query the SD card about its size
Firstly, thank you guys very much for the really helpful tutorial.
Secondly, for you guys, who don't success with this tutorial, try to use another micro sd card. For me, I used stm32f7508 discovery board, which is very similar to stm32f746, with micro sd card from Intenso it doesn't work at all but for no name micro sd card it works like a charm!
Last but not least, could you guys please give more explainations for the configuration parameters because working is good but understanding is perfect.
Lastly, sorry for my bad English :)
Hi there, thanks for your question - may we point you towards our community.st.com, where you will find a team of people who can answer you directly ?
Hi. It is giving disk error with san disk sd card 16 GB formatted to FAT32
for read image from sd in lcd svp!
Awesome video, well explained, great pace (not too fast),, clear and concise voice, very understandable for us novices :). Your code (a) just formatted the SD card and (b) wrote one line of data to it. How do you write many lines of data, say every 5-seconds from a temperature sensor without having to format the SD card every-time? Can you check for a file name in existence before have to format?
Hello there, glad it was helpful ! For technical questions we really recommend you check out our community of experts and other developers at community.st.com
@@stmicroelectronics Do you have tutorial or sample code on read/write SD card through SPI?
Remove the f_mkfs part to append a new line after opening the file. With f_printf you could write formated data with several coulumns
I Have a similar card: STM32L496G-DISCO and tried this tutorial. Pretty mutch everything is the same but there is some small differences. Under "Plattform settings" there is no uSD-Detect. This seems to be routed to a i2C chip. (Is this nessecary to have). The DMA settings is also a little bit different. Under SDMMC1 the DMA for TX and RX buffer is "Normal". The command f_mount and f_mkfs returns ok but the f_open, f_read etc gives an error in return. Any ideas on what to do? // GH
Me too - same board. I'm going to try to get sdmmc working as that seems to be the main problem.
Try to work without DMA at all. Disable Use of DMA template from the FATFS options as well. Worked for me, except if you also need FREERTOS then DMA is a must!
@@mohammedeqbalabdulkhaleqes9534 I am using L476RG and even with the DMA disabled, I cannot execute the code as it always end up in the error handler.
Well done! Very good explanation.
Glad you enjoyed it!
Great tutorial but it doesn't work on F446RE/F401RE boards. There is anything for that boards?
Hi there, thanks for your question - may we point you towards our community.st.com, where you will find a team of people who can answer you directly ?
Would be useful to see an updated video for H7 that doesn't have DMA setup in CubeIDE. I think it uses a dedicated MDMA?
how did you solve the DMA problem?
@@tasknbufe Might be able to share a rough gist if interested, but my issues were making sure MPU was enabled and finding the right clock settings in the SDMCC HAL init stuff. As long as the SDMMC interrupt is enabled and handled, there's no need to set up DMA since the peripheral has a dedicated channel.
Really good tutorial, but it doesn't work with L4 series
Did you ever get this working on L4?
Great tutorial, perfect explained, everything works fine, thank you Georg
Hello Mr. Fillon,
I tried to transfer the example to the STM32H743 Nucleo Board. Unfortunately I don't succeed. When executing f_mkfs, the response FR_NOT_READY comes. Unfortunately, I haven't found a single tutorial on how to do this for this board. Can you perhaps make a tutorial for this board on how to configure the SDMMC mode correctly? Many greetings, Holger
Hello, Visit our online community to find answers to your technical questions and share ideas with your developers and ST experts : community.st.com
Hi, I am having the same issue. It's driving me nuts. Did you ever figure out what the issue was?
@@BJH-fm1pf same issue, I tried also to port the SD examples for the stm32h735 (i'm using this one) but without success I tried also to opena post on the comunity forum but no success also there did you find a way to fix this ?
@@vidica94 Yes, I did find it. The logic on SD Card Detect signal was reversed. I modified the BSP_PlatformIsDetected() function and inserted status = !status; under USER CODE BEGIN 1.
@@BJH-fm1pf Im working with f446 and had the same error , can you elaborate where you found that function.
I think there's a small bug towards the end. It will end up in the Error_Handler() no matter the result from f_read.
Hello, I have a working project to share with you. Can you please send me an email at: Nicolas.fillon@st.com
found the bug and fixed it the code to be added will be updated shortly in the description of the video, we will also add a link to my working project
@@nicolasfillon , Thanks for your diligence; we are still waiting for your link to your working project?
Hi, that's great. The example works.
How do I implement this with TouchGFX? I set everything the same and mount the SD card (f_mount), but the next command is no longer executed (f_mkfs) and the system stops working.
have the same issue
how to read(decryption) file.mp3...thanks
Hello! Visit our online community to find answers to your technical questions and share ideas with our developers and ST experts : community.st.com
I need example about HS USB with external phy like USB3300. where ???
Could you guys do something like communicating to an ili9327 touchscreen without a library i have an idea, but i just get the process correct
Hello, Visit our online community to find answers to your technical questions and share ideas with your developers and ST experts : community.st.com
Benchmark it please
Great video. Nicely explained. What does one have to do to write data say every 5-seconds without formatting and recreating the file? i.e. append data...
Hi there, thanks for your question - may we point you towards our community.st.com, where you will find a team of people who can answer you directly ?
I keep getting this error: fatal error: fatfs.h: No such file or directory
I have no idea how I can resolve this
wow useful ! how would i go about wiring up a keypad or something to log those values ?
Hi there, thanks for your question - may we point you towards our community.st.com where you will find a team of people who can answer you directly?
@@stmicroelectronics hello yes, i might check it out. I'm a visual learner so I like youtube videos so much. I watch these videos and take notes. Thanks for making these
Hello All great video and I ant to do the same with my stm32l412 nucleo, the problem is I can not find SDMMC1 component in my stM32CUBIDE
Hello! Thanks for your positive feedback. We've shared it with our colleague Nicolas. Regarding your question, the issue you are facing is normal because the L412 does not have SDMMC. You would have instead to consider one of the following parts: L431, L433, L443, L451, L452, L462, L471, L475, L476, L486, L496, , L4A6, L4P5, L4Q5, L4R5, L4S5, L4S7, L4S9.
Cool!
Спасибо большое!
I am having bad problems to write in micro SD card, i saw a lot of videos an anyone works, i did with arduino and working well. I am thinking that STM32 is a no good microcontroller, i am giving up of it because don´t have a good support. If anybody can help me. I have the code that i copy from controllerstech and not work, i used stm32f10c8t6 and a board that is sell for arduino to use SD CARS. In Arduino i wasted 1 minute to write in sd card an in STM32 i am wasting more than one week, very bad microcontroller
Hello, Sorry to hear about it ... Visit our online community to find answers to your technical questions and share ideas with your developers and ST experts : community.st.com
link not working
ST outherizeds please u must choose talker as original Britain accent
@Adnan, there is nothing called Britain accent. ST has employees all over the world and one should therefore exercise patience and the minimum necessary skill to understand the possible different accents that those employees use
@@stationHQ U are right but ım from Turkey and ı
learnt english in my schools ı cant understand all accents and there are a lot of people like me
@@adnansayder2148 , since this is a pre-recorded presentation, my suggestion is to use the trick of slowing down the playback, this way you can follow along more efficiently. At least that is the trick I have learnt and used over the years anytime I need to follow a presentation in a language I am not very "comfortable" with. Please note I did not mean any disrespect. HTH
You should try to understand English with different accent because it is a global language, not only for British.
İtalian accent İndian accent German accent now French accent ı difficult understand
Hi, thanks for your comment, our engineers do their very best to create this content and we do consider it to be important to have the people who know technically what they are talking about to do these videos. That said, we have received this type of comment in the past and we are trying to figure out ways to improve the situation.
@@stmicroelectronics Thanks dear we are all parts of electrronic design and product eco system
how to change file name for ex : DATA1.TXT , DATA2.TXT . NOT İN WHİLE LOOP ACTUALY İN MAİN LOOP I WANT RESET STM32 AND I CHACK FİLE NAME İF I HAVE SAME FİLE NAME I WANT NEW FİLE NAME CAN YOU HELP ME ?