I usually use a mux IC TS3A27518 with a card reader IC to read files directly when connected to PC. And when I need to interface STM32 with the SDCard again, I switch the SDIO pins using the mux. This way I was able to achieve around 20Mbps of speed while transferring files to my PC.
I've gotten similar USB FS rates on the STM32H573 microcontroller as well. 300-700K/sec seems to be normal regardless of backend storage type. So it's just the USB FS limits. My understanding is it's a DMA controller limitation so you have to choose either Ethernet or USB HS on the silicon. STM32 does have USB HS chips, but you'll find they either don't have ethernet or you can only enable one or the other. USB HS and Ethernet are pretty much mutually exclusive on STM32 currently. It's not until you get into their MPU line you start to have options for both. I would love to have both Fast Ethernet and USB HS in STM32.
He's using blocking SD and USB operations. Add some queues in between and you could do the USB-read and SD-write in parallel, instead of having them wait for each other to finish all the time.
@@vatterger even if you double the throughput your still very slow. Plenty of data if you just need a serial console or log files or other relatively small bits of data. I'd hate to try and transfer gigs through it.
Hey Phil, great video. I was just wondering how did you plan for a project . For example your thought process, requirements for the project and proof of concept. I believe that there are many things that you have to go through before having the final product. Would love to have a dedicated video for that. Aspiring PCB design engineer would really benefit from it.
I had an idea a while back to make a custom storage device with a WiFi-enabled MCU inside to use with the cheap digital photo frames. It would serve images from an SDCard via USB to the frame, but every X image requests it would substitute information by generating images from live data like weather, stock prices, news, social media alerts etc :)
Something that would be interesting to show off is using the SD card to update the firmware of the stm32. I have seen some stm32 based hardware that allows someone to encrypt the bootloader and firmware file such that the firmware can be freely shared without it being used on counterfeit hardware (aka boards that aren't sold by the developer) Not sure how you pull that off on the stm32 though!
Amazing video. The timing of this video is impeccable since I decided to use SDMMC yesterday... I sadly forgot to pose a question when I met you at electronica. How do you estimate how much performance you require for your projects and wether you need additional, external ram/flash chips? I was not able to find a video about this topic, but please correct me if I missed something.
Thank you! Regarding your question: it's based on previous experience and also creating 'dummy/template' software projects to get estimates for RAM/flash usage.
I've just been working on a project with this! I tested a dev board with an H750VBT6 (DevEBox thing), and 4 bit SD/MMC works fine at many MHz even without the weak stm pull ups enabled. I made a custom board using the F411VCT6 and for some reason I cannot under any circumstances get 4 bit SDIO working. The slot is a few cm more from the stm than on the dev board, so I tried slowing the clock down incrementally all the way to under 200k, enabled the pullups, still nothing. I've checked pins several dozen times and they are correct. Setting 1 bit mode works fine though. Tried starting over with blank CubeIDE projects for each chip, only doing that bare essentials of HSE clock and SD pin setup, same result. I'm starting to just give up on 4 bit, only difference I see left is the H7 calls it SD/MMC but F4 calls it SDIO, I'm not sure if it matters or if theres a bug in the CubeIDE initialization but its immensely frustrating.
When initializing SDIO or SDMMC I had to use 1 bit mode before Mounting then switch to 4 bit mode after Mounting. hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B; HAL_Delay(1); RES = f_mount(&fs, "0:", 1); HAL_Delay(1); hsd1.Init.BusWide = SDMMC_BUS_WIDE_4B; HAL_Delay(1);
Hi Phil, a few years ago I made the same scheme as you but it didn't work well with all SD cards. So I had to put resistors in series on DAT0..DAT3 if I remember correctly 120 ohm.
@@PhilsLabI did not make measures; I checked the schematic, 150 on all lines DAT0..3 CK, CMD. At the beginning I started without resistor like your scheme then testing with a dozen of card I had troubles; finally I saw these resistors on an old schematic and copied the solution discovering was effective.
Can you make another video using 480Mbps connection ? You already have ULPI example, so this would give you 480Mbps. Also certain STM32F7x3 and STM32U5 has internal HS PHY so no external connections are needed. IT would be nice if you could show example how to do CDC class at ~40MBps to computer read and write. Thanks !
I used it in one of the projects I did, with simple functionality st's usb library works fine but if you slightly try to do something else the library breaks quickly and needs alot of knowledge and modification to work it then.
Opening a compressed PDF directly from WinRAR and looking for bad pages can be a way to visually prove that the file is actually intact but if you can open a file from WinRAR you already know it's good, by default WinRAR will stop decompressing if it finds any error and will delete any partially decompressed file before any other program can open it and then shows you a window explaining what was wrong. 7zip and WinZip do more or less the same. On the other hand some basic decompression programs used by some custom made installers can leave you with empty or partial files with no warning at all...
@@PhilsLab I've searched a bit and ST seems to recommend USBX from the ThreadX project for composite devices, instead of using their own libraries that CubeMX generates. ThreadX seems cool, maybe it's worth a shot. ST's USB libraries aren't always great.
Great tutorial 🙂. I would like to know, if I want to design a USB device for sale, for example a storage class device or a uart converter, do I really need to buy a VID? Or can I use some generic VID PID?
Thanks! You can either purchase them through the USB org, or you often can get them through your MCU/processor/peripheral manufacturer (using their VID, but different PID) (e.g. community.st.com/t5/stm32-mcus-embedded-software/how-to-apply-for-a-usb-pid/td-p/53773). Lastly, there's also an option (if your project is open-source) to get them for free through: pid.codes/
Hi Phil, Can you please do a series on any crypto IC like ATECC608 with STM32? Haven't found any tutorial with both practical and theoretical approach. Thanks in advance.
God bless you Phil. You have done it again. Consider doing one for BLDC FOC motor control.
Thank you!
There is a ready project for development board B-G431B-ESC1
I usually use a mux IC TS3A27518 with a card reader IC to read files directly when connected to PC. And when I need to interface STM32 with the SDCard again, I switch the SDIO pins using the mux. This way I was able to achieve around 20Mbps of speed while transferring files to my PC.
That's a great idea ! Can you mention which card reader IC you use ? TIA.
@@mumbaiverve2307 gl823k-hcy04
@@mumbaiverve2307 Thanks! Its gl823k-hcy04
I wish I had this video when I did my SD card projects! Thank you as always.
As always an amazing and inspiring video. Thank you very much Phil!
Thank you!
I've gotten similar USB FS rates on the STM32H573 microcontroller as well. 300-700K/sec seems to be normal regardless of backend storage type. So it's just the USB FS limits. My understanding is it's a DMA controller limitation so you have to choose either Ethernet or USB HS on the silicon. STM32 does have USB HS chips, but you'll find they either don't have ethernet or you can only enable one or the other. USB HS and Ethernet are pretty much mutually exclusive on STM32 currently. It's not until you get into their MPU line you start to have options for both. I would love to have both Fast Ethernet and USB HS in STM32.
He's using blocking SD and USB operations. Add some queues in between and you could do the USB-read and SD-write in parallel, instead of having them wait for each other to finish all the time.
@@vatterger even if you double the throughput your still very slow. Plenty of data if you just need a serial console or log files or other relatively small bits of data. I'd hate to try and transfer gigs through it.
Hey Phil, amazing tutorial as always. I'd love to see you design an ESC board next.
It's not an indepth guide but he does have a video on ESC design if memory serves.
Hey Phil, great video. I was just wondering how did you plan for a project . For example your thought process, requirements for the project and proof of concept. I believe that there are many things that you have to go through before having the final product. Would love to have a dedicated video for that. Aspiring PCB design engineer would really benefit from it.
I had an idea a while back to make a custom storage device with a WiFi-enabled MCU inside to use with the cheap digital photo frames. It would serve images from an SDCard via USB to the frame, but every X image requests it would substitute information by generating images from live data like weather, stock prices, news, social media alerts etc :)
I'm soo excited about this one!
Thanks, hope it doesn't disappoint!
24:36 this might be related, that you are not running in Debug mode... Debug mode with breakpoints slows down everything significantly...
Thank you. This was very educational. Love your videos.
Thanks, Andrew!
Detailed and very clear explanation. How would things change if DMA and FreeRTOS were implemented?
Something that would be interesting to show off is using the SD card to update the firmware of the stm32.
I have seen some stm32 based hardware that allows someone to encrypt the bootloader and firmware file such that the firmware can be freely shared without it being used on counterfeit hardware (aka boards that aren't sold by the developer)
Not sure how you pull that off on the stm32 though!
Thx Phil for sharing this very useful video.
Thanks for watching!
Amazing video. The timing of this video is impeccable since I decided to use SDMMC yesterday...
I sadly forgot to pose a question when I met you at electronica. How do you estimate how much performance you require for your projects and wether you need additional, external ram/flash chips? I was not able to find a video about this topic, but please correct me if I missed something.
Thank you! Regarding your question: it's based on previous experience and also creating 'dummy/template' software projects to get estimates for RAM/flash usage.
I've just been working on a project with this! I tested a dev board with an H750VBT6 (DevEBox thing), and 4 bit SD/MMC works fine at many MHz even without the weak stm pull ups enabled. I made a custom board using the F411VCT6 and for some reason I cannot under any circumstances get 4 bit SDIO working. The slot is a few cm more from the stm than on the dev board, so I tried slowing the clock down incrementally all the way to under 200k, enabled the pullups, still nothing. I've checked pins several dozen times and they are correct. Setting 1 bit mode works fine though. Tried starting over with blank CubeIDE projects for each chip, only doing that bare essentials of HSE clock and SD pin setup, same result. I'm starting to just give up on 4 bit, only difference I see left is the H7 calls it SD/MMC but F4 calls it SDIO, I'm not sure if it matters or if theres a bug in the CubeIDE initialization but its immensely frustrating.
When initializing SDIO or SDMMC I had to use 1 bit mode before Mounting then switch to 4 bit mode after Mounting.
hsd1.Init.BusWide = SDMMC_BUS_WIDE_1B;
HAL_Delay(1);
RES = f_mount(&fs, "0:", 1);
HAL_Delay(1);
hsd1.Init.BusWide = SDMMC_BUS_WIDE_4B;
HAL_Delay(1);
visiting the Genius Again !
Thanks for sharing your knowledge! I would like to know why is your favorite to use STM MCU (brand) for your devices/videos?
Hi Phil, a few years ago I made the same scheme as you but it didn't work well with all SD cards. So I had to put resistors in series on DAT0..DAT3 if I remember correctly 120 ohm.
Did you adjust drive strengths at all?
@@PhilsLabI did not make measures; I checked the schematic, 150 on all lines DAT0..3 CK, CMD. At the beginning I started without resistor like your scheme then testing with a dozen of card I had troubles; finally I saw these resistors on an old schematic and copied the solution discovering was effective.
Can you make another video using 480Mbps connection ? You already have ULPI example, so this would give you 480Mbps.
Also certain STM32F7x3 and STM32U5 has internal HS PHY so no external connections are needed. IT would be nice if you could show example how to do CDC class at ~40MBps to computer read and write.
Thanks !
Yeah, I'm working on a board with JLC that has USB HS (STM32F7x3 part). Will test it out with that.
I used it in one of the projects I did, with simple functionality st's usb library works fine but if you slightly try to do something else the library breaks quickly and needs alot of knowledge and modification to work it then.
Yeah, the audio USB driver one is quite fun as well..
Where can I learn the basics?
Opening a compressed PDF directly from WinRAR and looking for bad pages can be a way to visually prove that the file is actually intact but if you can open a file from WinRAR you already know it's good, by default WinRAR will stop decompressing if it finds any error and will delete any partially decompressed file before any other program can open it and then shows you a window explaining what was wrong. 7zip and WinZip do more or less the same.
On the other hand some basic decompression programs used by some custom made installers can leave you with empty or partial files with no warning at all...
Good to know, thanks!
Is it possible to have USB Mass Storage and CDC at the same time? Also, why did you go with 3V instead of 3.3V?
Yes, those are 'composite' devices. 3V as I'll mainly be running the device from a battery and wanted to have a lower 'off-threshold'.
@@PhilsLab I've searched a bit and ST seems to recommend USBX from the ThreadX project for composite devices, instead of using their own libraries that CubeMX generates. ThreadX seems cool, maybe it's worth a shot. ST's USB libraries aren't always great.
What is the threshold where it starts to make sense for the embedded system to run Linux?
do you have a link to the pcb stand you use in the intro?
Those are PCBites from Sensepeek.
Great tutorial 🙂. I would like to know, if I want to design a USB device for sale, for example a storage class device or a uart converter, do I really need to buy a VID? Or can I use some generic VID PID?
Thanks! You can either purchase them through the USB org, or you often can get them through your MCU/processor/peripheral manufacturer (using their VID, but different PID) (e.g. community.st.com/t5/stm32-mcus-embedded-software/how-to-apply-for-a-usb-pid/td-p/53773). Lastly, there's also an option (if your project is open-source) to get them for free through: pid.codes/
@@PhilsLab Thanks. I've been watching your content for a while and it's always good quality. I can learn something new every time. 🙂
Fascinating and awesome video like always ... Lovefrom india
Thank you!
FatFS Supports up to 2 TB. You may have to available exFat in the header file
What font did you use on the schematic for labeling the sections (ie, SD Card, etc)
Century Gothic
I wonder how much of a leap it is to go from this, to using NAND with USB4 speeds.
Thanks for the video.
Quite a bit of a leap with USB4!
Hi @phill ,Any black friday sale on courses or in new year ?
Send me a mail to phil@phils-lab.net and we can sort it out! :)
which tool do you use to draw block diagrams ?
draw.io
I really like clock configuration panel of this that IDE
Awesome work, this looks like a great way to implement storage devices in high vibe environments!
Thank you, Kofi!
which feature makes the lines with different colours of highlights?
Altium, click on net, Properties, select a colour.
@PhilsLab thanks 🙏
Nice Sir.From BD.
Thank you!
I could not make this thing work on my stm32L4 device So used spi from scratch. It was painfull
Cool! 💎
Hi Phil,
Can you please do a series on any crypto IC like ATECC608 with STM32?
Haven't found any tutorial with both practical and theoretical approach.
Thanks in advance.
Can't help but comment Nice Video 😌🔥
Thanks a lot!
Nice!
Thanks, Tony!
Great!
Thanks, Irma :)
good ❤
Please upload bumble b micro quad copter files to github
First