Это видео недоступно.
Сожалеем об этом.

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 */

Комментарии • 79

  • @WorldChampion92
    @WorldChampion92 5 месяцев назад

    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

    • @mw2noobis
      @mw2noobis 4 месяца назад

      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

  • @ajdarseidzade688
    @ajdarseidzade688 2 года назад

    Great video and presenter! Helped me remember the *basics* of working with FATFs. Thanks for the video lesson.

  • @Ali-cp7dr
    @Ali-cp7dr 3 года назад +4

    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.

  • @n3r0z3r0
    @n3r0z3r0 Год назад

    If someone looked into ST implementation of SDIO + FATFS, I believe he will have an indelible impression till the end of the life.

  • @eitantal726
    @eitantal726 Месяц назад

    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

  • @AnhTuNguyenanhtunguyen
    @AnhTuNguyenanhtunguyen 3 года назад +1

    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 :)

    • @stmicroelectronics
      @stmicroelectronics  3 года назад

      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 ?

  • @blahman442
    @blahman442 3 года назад +1

    Hi. It is giving disk error with san disk sd card 16 GB formatted to FAT32

  • @bacem1439
    @bacem1439 3 года назад +2

    for read image from sd in lcd svp!

  • @Graham1904
    @Graham1904 3 года назад +5

    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?

    • @stmicroelectronics
      @stmicroelectronics  3 года назад +1

      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

    • @dajianghe
      @dajianghe Год назад

      @@stmicroelectronics Do you have tutorial or sample code on read/write SD card through SPI?

    • @WorldChampion92
      @WorldChampion92 5 месяцев назад

      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

  • @goranhasse4370
    @goranhasse4370 3 года назад +4

    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

    • @lumpyfishgravy
      @lumpyfishgravy 3 года назад

      Me too - same board. I'm going to try to get sdmmc working as that seems to be the main problem.

    • @mohammedeqbalabdulkhaleqes9534
      @mohammedeqbalabdulkhaleqes9534 3 года назад

      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!

    • @SahilBoble
      @SahilBoble Год назад

      @@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.

  • @barrykeane2716
    @barrykeane2716 3 года назад +1

    Well done! Very good explanation.

  • @CosimoDavideViggiano
    @CosimoDavideViggiano 3 года назад +2

    Great tutorial but it doesn't work on F446RE/F401RE boards. There is anything for that boards?

    • @stmicroelectronics
      @stmicroelectronics  3 года назад

      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 ?

  • @EmbeddedSorcery
    @EmbeddedSorcery 11 месяцев назад +2

    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?

    • @tasknbufe
      @tasknbufe Месяц назад

      how did you solve the DMA problem?

    • @EmbeddedSorcery
      @EmbeddedSorcery 29 дней назад

      @@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.

  • @sergeyyakovenko9224
    @sergeyyakovenko9224 3 года назад +5

    Really good tutorial, but it doesn't work with L4 series

  • @georgseidl717
    @georgseidl717 2 года назад

    Great tutorial, perfect explained, everything works fine, thank you Georg

  • @holgergumbel6813
    @holgergumbel6813 3 года назад +3

    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

    • @stmicroelectronics
      @stmicroelectronics  3 года назад +1

      Hello, Visit our online community to find answers to your technical questions and share ideas with your developers and ST experts : community.st.com

    • @BJH-fm1pf
      @BJH-fm1pf 2 года назад

      Hi, I am having the same issue. It's driving me nuts. Did you ever figure out what the issue was?

    • @vidica94
      @vidica94 Год назад

      @@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 ?

    • @BJH-fm1pf
      @BJH-fm1pf Год назад +1

      @@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.

    • @wolverene1234567890
      @wolverene1234567890 11 месяцев назад

      @@BJH-fm1pf Im working with f446 and had the same error , can you elaborate where you found that function.

  • @LarsBgildThomsen
    @LarsBgildThomsen 3 года назад +2

    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.

    • @nicolasfillon
      @nicolasfillon 3 года назад

      Hello, I have a working project to share with you. Can you please send me an email at: Nicolas.fillon@st.com

    • @nicolasfillon
      @nicolasfillon 3 года назад +5

      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

    • @stationHQ
      @stationHQ 3 года назад

      @@nicolasfillon , Thanks for your diligence; we are still waiting for your link to your working project?

  • @jirinovacek9934
    @jirinovacek9934 2 года назад +1

    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.

  • @phucnguyenhuu804
    @phucnguyenhuu804 3 года назад +2

    how to read(decryption) file.mp3...thanks

    • @stmicroelectronics
      @stmicroelectronics  3 года назад

      Hello! Visit our online community to find answers to your technical questions and share ideas with our developers and ST experts : community.st.com

  • @user-xf2pm3pb7h
    @user-xf2pm3pb7h Год назад

    I need example about HS USB with external phy like USB3300. where ???

  • @bobdole27
    @bobdole27 3 года назад +1

    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

    • @stmicroelectronics
      @stmicroelectronics  3 года назад

      Hello, Visit our online community to find answers to your technical questions and share ideas with your developers and ST experts : community.st.com

  • @napent
    @napent 3 года назад +4

    Benchmark it please

  • @Graham1904
    @Graham1904 3 года назад +1

    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...

    • @stmicroelectronics
      @stmicroelectronics  3 года назад

      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 ?

  • @frevanneste7595
    @frevanneste7595 2 года назад

    I keep getting this error: fatal error: fatfs.h: No such file or directory
    I have no idea how I can resolve this

  • @mychromebook9935
    @mychromebook9935 3 года назад +1

    wow useful ! how would i go about wiring up a keypad or something to log those values ?

    • @stmicroelectronics
      @stmicroelectronics  3 года назад

      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?

    • @mychromebook9935
      @mychromebook9935 3 года назад

      @@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

  • @hakobhakobyan2856
    @hakobhakobyan2856 Год назад

    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

    • @stmicroelectronics
      @stmicroelectronics  Год назад

      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.

  • @pasiunepepaine
    @pasiunepepaine 2 года назад

    Cool!

  • @user-ef2rr7kz4m
    @user-ef2rr7kz4m 2 года назад

    Спасибо большое!

  • @alexandrev.3332
    @alexandrev.3332 2 года назад

    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

    • @stmicroelectronics
      @stmicroelectronics  2 года назад

      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

  • @victorcamargo7926
    @victorcamargo7926 2 года назад

    link not working

  • @adnansayder2148
    @adnansayder2148 3 года назад +1

    ST outherizeds please u must choose talker as original Britain accent

    • @stationHQ
      @stationHQ 3 года назад +4

      @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

    • @adnansayder2148
      @adnansayder2148 3 года назад

      @@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

    • @stationHQ
      @stationHQ 3 года назад +1

      @@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

    • @AnhTuNguyenanhtunguyen
      @AnhTuNguyenanhtunguyen 3 года назад +4

      You should try to understand English with different accent because it is a global language, not only for British.

  • @adnansayder2148
    @adnansayder2148 3 года назад +1

    İtalian accent İndian accent German accent now French accent ı difficult understand

    • @stmicroelectronics
      @stmicroelectronics  3 года назад

      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.

    • @adnansayder2148
      @adnansayder2148 3 года назад

      @@stmicroelectronics Thanks dear we are all parts of electrronic design and product eco system

  • @osmankadayif
    @osmankadayif 2 года назад

    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 ?