2022-12-05 07:50 AM
Hi all, I am working on a custom data logging board using STM32L4 and an SD NAND (uSD card in form of an IC). Since the SD chip is a surface-mounted IC (https://www.adafruit.com/product/4899) on the board using SPI and FATfs so I want to implement USB MSC to plug and play with the files when finish logging.
I have seen a few examples and the closest is this STM32 USB MSC (Mass Storage Class) » ControllersTech but the example used SDIO mode and I am using SPI mode with FATfs to write content to SD card (based on this SD card using SPI in STM32 » ControllersTech). Can anyone with experience combine the FATfs SPI SD card with USB MSC to give me a hint for the implementation?
Solved! Go to Solution.
2022-12-06 02:27 AM
Hello PLy,
I'm currently trying out the same thing (except that I use a sd card adapter). I've found this post here https://community.st.com/s/question/0D53W00000hRC0uSAG/modify-usbdstogeifc-to-use-sd-card-trougth-spi and the user said, he had success with it.
I on the other hand, am still struggling with everything, as I don't get the SD-Card displayed on Windows. If you happen to find success, I'd be really happy if you would share your experience.
Kind regards
NW
2022-12-05 08:47 AM
What's going to fit in 8KB ?
The surface mount SD card would use an eMMC in the megabyte or gigabyte realm..
2022-12-05 01:10 PM
Hi Tesla sorry for my incorrect link (first time asking a question). What I mention above is a 512MB spi sd card https://www.adafruit.com/product/4899
2022-12-05 02:18 PM
There is an SPI based SD Card implementation in this BSP / Driver example
STM32Cube_FW_L4_V1.14.0\Drivers\BSP\Adafruit_Shield\stm32_adafruit_sd.c
2022-12-06 02:27 AM
Hello PLy,
I'm currently trying out the same thing (except that I use a sd card adapter). I've found this post here https://community.st.com/s/question/0D53W00000hRC0uSAG/modify-usbdstogeifc-to-use-sd-card-trougth-spi and the user said, he had success with it.
I on the other hand, am still struggling with everything, as I don't get the SD-Card displayed on Windows. If you happen to find success, I'd be really happy if you would share your experience.
Kind regards
NW
2022-12-06 03:18 AM
Thank you for the docs! I have found the answer below.
2022-12-06 03:24 AM
Hello NW,
Thanks a lot for your link! I have been looking for it for days. Turn out it was pretty easy to implement on my project.
I have been able to make it work with the example!! Lucky that I use the same driver in the example from your link, it is from this Tutorial: An SD card over SPI using STM32CubeIDE and FatFS (01001000.xyz)
Now I have the board works either as a data logger or a USB stick :)
Are you using the same user_diskio_spi driver as stated in the example?
2022-12-06 04:46 AM
Glad that I could help!
I'm not using the user_diskio_spi from this tutorial, but a very similar one. I think I will do everything again from anew following the tutorial in your link. Might be the issue at the end, though I can't get my head around the issue.
Would you mind to share your project? Just the files for the SD Card and usbd_core_if.c are enough I suppose, just in case if I do a mistake with my own implementation for a fast check up? I'm also using stm32l4.
Kind regards
NW