I've worked on SD-Card support for days now and your video finally helped me out. Thank you so much! Sent you a few coins for that ;)
@salmonhust4 ай бұрын
How to auto format USB MSC Device using RAM ? Please help me 🙏🙏🙏
@electronscape4 жыл бұрын
ok these kinda videos... INVALUABLE!!! THANK YOU!!
@paulopecegueiro16944 жыл бұрын
Hi, is this method work if I use a spi flash memory instead of uSD card? I was thinking about W25Q128JV 🤔
@CaliBeta2 жыл бұрын
hello I am trying part 1 and using 8KB of SRAM of my stm32f103c8 as mass storage, the problem is that when I connect the USB drive to the computer it asks me to format it, but when I start it it gives me a message saying that the drive could not be formatted. I use windows 10 and the USB is connected externally with 3 resistors on a breadboard, a 22 ohm resistor in series from USB D- to PA11(USBDM), for PA12(USBDP) the connection is slightly different, I have two resistors, one of 4.7kohms as pull up from USB (5V) to PA12(USBDP) and the other 22ohms resistor from USB D+ of USB connector to PA11 (USBDP)
@paulnewf6164 Жыл бұрын
Maybe your disk size was too small? Mine failed same on 32*512bytes, but worked with 80*512bytes.
@cocoobi11 ай бұрын
Having the sam problem.. have you found a solution? The size increase did not help..
@hosseinhamidi47764 жыл бұрын
Excellent video and exact to the point. Worked for me on stm32f4 discovery. Thank you!
@noweare14 жыл бұрын
Thanks for your work on making this video.
@Nachodis3 жыл бұрын
Why does the SDIO clock need to run at same speed as the USB speed (12 MHz)? I would expect that SDIO and USB can work independently, and the read() and write() functions just pass data from one to the other?
@tarcisiosouzademelo88573 жыл бұрын
I'm having a problem, the computer recognizes, requests formatting but can't complete the formatting
@BJH-fm1pf2 жыл бұрын
Hi, I have the same issue. Did you figure out the solution? Thanks.
@cocoobi11 ай бұрын
Having the same problem.. did you found a solution? @ControllersTech
@woldecosgrove7 ай бұрын
Hello... i try your code (RAM) on H743 Nucleo (the only board with USB OTG FS) i cant see USB Drive at all, Device Manager error : Unknown USB device (Device descriptor Request fail ) please help ....
@cocoobi11 ай бұрын
Hi, Like others I'm also facing the problem that I can not format the device on the host. Tried al possible configuration and size option.. dindnt help. Do you have an Idea? I also ask in the ST Community for help but nothing so far..
@woldecosgrove7 ай бұрын
Hello... you mentioned in the first part using RAM , connect the USB. what USB is that? is it the external thumb drive? where to connect ? to the nucleo bd USB port? or PC USB port ?
@ControllersTech7 ай бұрын
It is usb cable. Connect it between the dev board and computer. If you are using nucleo or discovery board, keep in mind that the user USB is a separate port than the ST Link USB. Any USB operation can be performed on the user USB port, and not on the ST Link USB port.
@woldecosgrove7 ай бұрын
@@ControllersTech ok i got you, thx ..
@EmbSysDev4 жыл бұрын
Nice videos, keep them coming !! Can you do something about the robot voice though :-)
@gtcollection69334 жыл бұрын
The author's written English is clearly to perfection. His spoken language may not be to par with the voice-over or he could simply a have disability. Quality of the content is what matters.
@cocoobi11 ай бұрын
Hi, I'm facing the same problem as some of the others. I did exactly the same steps as in this tutorial, but at the point where I have to format the device, an error is shown, which say's "Unable to format device". Does anyone found a solution for this problem?
@a1nelson4 жыл бұрын
Not sure, but it appears that the writes are not being made with the block size that is native to the flash device. This is commonly 32K, but could be a little smaller or larger. (By comparison, hard drives are typically 512 bytes and SSDs are 4K.) Ona flash device , a single byte, or even a single bit, change requires that the entire block be rewritten. Therefore, small writes - for instance 512 bytes at a time - will result in the same block being written 32K / 512 = 64 writes to each block. Thus, writes are 64 times slower and the flash device wears out 64 times faster. It’s something to check.
@Nachodis3 жыл бұрын
I would assume that this info (block size and number of blocks) is passed through via the STORAGE_GetCapacity_FS() function which retrieves it from the SD card via HAL_SD_GetCardInfo(). If that information is correctly used, it might all end up fine. On the other hand, reading/writing a 32k block would probably require a RAM memory buffer of the same size, not sure if this is the case (I would need to check where the "uint8_t *buf" memory is created and if it's RAM or e.g. peripheral memory).
@a1nelson3 жыл бұрын
@@Nachodis Edit: wanted to clarify the the following comments refer to the possibility that the OS manages the buffering itself. If the user manages the buffers, then they are free to make good decisions about available memory and it’s usage. Your comment was a very good one. If the file system (in memory) permits writes less than the full block size (e.g., 32K), that implies at least a minimum amount of write caching. Thus, (a) the write from user land isn’t guaranteed to be physically written to the target media. At least one buffer must be maintained, and unless writes are perfectly aligned with those block boundaries, then the write time will become even less deterministic. Whether or not this is an issue is naturally application dependent. (b) Although this behavior isn’t as well known, read cycles also put wear on flash decides. So, it follows that there may be a similarly sized read cache as well. Taken together, 1K-128K (recall that this size can vary quite a bit from device to device, from 512 bytes to 64K) could be required, on top of other file system structures in RAM. It seems unlikely that these large buffers would be baked into the code by default. Perhaps there are caching modes that can be enabled/disabled using preprocessor switches, in the same manner as other OS features. (c) The caching mechanism absolutely requires that there be some mechanism to reliably flush the write cache. On an embedded device, which may be expected to be powered down at arbitrary points in time, this could become a serious issue. LittleFS, though obviously not as portable as FAT, does take into account this idiosyncrasy.
@Nachodis3 жыл бұрын
@@a1nelson Yes, insightful comment. Actually, I just got everything to work after reducing the SDMMC speed. This video does not properly explain why that's necessary, but it is necessary since the MCU might be too slow to take in the fast data from the SDMMC peripheral, which causes errors on the interface. With respect to block sizes, I think we need to distinguish the FATFS allocation unit size and the flash block size. I have an 8GB SD card which is reported in the code to have block_size 512 and block_num 15523840 (in total 7.948.206.080 bytes). The flash memory works in blocks of 512 bytes. The fatFS filesystem on top of it however, works in sectors of 32 kB. This means that, if a FS data sector is allocated for a new file, 64 blocks of 512 bytes might actually need to be allocated (not verified though). The FatFS is defined in sectors of 32 kB but handles the SD card in blocks of 512 byte.
@Unique_Think2 жыл бұрын
STM32F4 USB (MSC) connect pendrive + SDIO SD_Card not working on same time ?
@conorstewart22142 жыл бұрын
Does the SD card speed really need to be the same as the USB speed. It seems like it takes a buffer and then writes it to the SD card, couldnt you get a faster write speed by having the SD card speed faster?
@beyondintech Жыл бұрын
@controllerstech I am using Mass storage with STM32F401 it gets the drive but if i copy anything into it using MSC after power cycle it dissappears , Can you suggest something
@ControllersTech Жыл бұрын
There is nothing to suggest here. That's how the ram works. Ram was used here just to demonstrate that it can work with anything, you should better use some external flash or eeprom for it.
@beyondintech Жыл бұрын
i am using SD card , I did resolve the issue by doing 1B wide bus in the code but it would be great if you can suggest to do it with 4 because with 4 it doesnt work @@ControllersTech
@bluewaveengineering87342 жыл бұрын
If you could provide an example like this using a composite USB with CDC + MSC (using the SD Card) that would be amazing!
@ControllersTech2 жыл бұрын
I guess you can't use 2 modes at the same time. The peripheral needs to be initialised in a particular mode. If you want to change from MSC to CDC, you need to reinitialise it in CDC mode
@lukeh76382 жыл бұрын
@@ControllersTech You have to use the new Composite Mode that Sasha with STM is developing... or use tinyUSB. I just haven't seen anyone get either working on a full project.
@m.nauman78014 жыл бұрын
Awesome videos regarding stm32 boards. Would you make series on TI TM4C boards also?
@taozhai35684 жыл бұрын
Thanks!! Can you make another video to use DMA to speed up the transfer rate, please!
@ControllersTech4 жыл бұрын
I will test it. I am not sure though. But i think the speed can be increased somehow
@taozhai35684 жыл бұрын
@@ControllersTech find a problem that , i can format card by using 'SD Card Formatter 5.0.1' from TUXERA, but cannot do format directly from windows disk format.
@ControllersTech4 жыл бұрын
no problem here. I can format it with windows too
@DanRalley3 жыл бұрын
Can the RAM version of mass storage persist after power cycling? If so, how is the RAM retained?
@paulnewf6164 Жыл бұрын
a) Not without battery backup (Some STM32 appear to have RAM blocks that can have battery backup, similar to the internal RTC) b) If power cycle then RAMDisk will need to be reformatted (i.e. write a routine to init RAMDisk on bootup) c) I believe the RAMDisk is just to show the minimum code to make this work, as any FLASH disk requires much more code, and possibly some flow control. Paul
@RahulThotakura2 ай бұрын
I have stuck in the SPI_SD_card interface using Stm32 in register level,all the registers are configured and debugged in keil IDE but it very difficult to include the FATFS libraries to the project diskio.c/.h ff.c/.h it is very confusing me to add them up by the FATweb page please i request you to help me in this thankyou
@ucontrolchannel59674 жыл бұрын
@Controllers Tech again great job. Thank you soooo much. Can you also make a video on USB mass storage class as a host
@ControllersTech4 жыл бұрын
I want to but don't have the otg cable..
@felixr.18213 жыл бұрын
@Controllers Tech Thanks for your great videos! But could you please do the same tutorial with the SD Card connected via SPI ? I can read and write from my microSD Card using SPI, but I also need to implement the USB MSC Device like in this Video. I can´t get the STORAGE_Read_FS/STORAGE_Write_FS functions in the usbd_storage_if.c file to work. If I connect my custom Board to the PC, Windows always wants me to format the disk. I´m getting the correct capacity of the SD Card in the format device window tho, so my STORAGE_GetCapacity_FS function seems to work. I already searched and tried many hours but i just cant get this to work. Would be really happy if you could help me out with this.
@mousseEV3 жыл бұрын
Hi ! I have exactly the same problem on an F373CC ... I will come back to you if I find a solution or a tutorial that will unlock us! For STORAGE_GetCapacity_FS, did you change the constants by hand or did you find a function that did the job?
@Nachodis3 жыл бұрын
What kind of SD card are you using? I am using SDHC and I'm wondering if the initialization code is correct. E.g. it initializes block size to hardcoded 512, I'm wondering if that's always correct.
@alexanderwolf96532 жыл бұрын
you made my day
@roniolivi3 жыл бұрын
I'm trying do the second part (whit SD Card) in an STM32F411 and MX_SDIO_SD_Init return HAL_ERROR
@kiranpradeep64643 жыл бұрын
Even after changint the inquiry array the name of the drive is not changing in file explorer
@ControllersTech3 жыл бұрын
Try uninstalling the previous driver from windows first. Then connect it again
@MrBorsoft4 жыл бұрын
Hi! Thanks for the tutorial! Is this mass storage mode can be also used with SD card connected over SPI? Or SDIO only?
@ControllersTech4 жыл бұрын
It only works with SDIO for now.
@ozcansorgun85974 жыл бұрын
@@ControllersTech Can you do the same with the SD card connected via SPI?
@ElectroCreativity4 жыл бұрын
Thanks for such videos. Is there any tutorial made by you for reading a text file in Pendrive connected to STM32 using OTG. If not, can you please make tutorial for that.
@ControllersTech4 жыл бұрын
You mean the MSC as a host. I will do that soon.
@ElectroCreativity4 жыл бұрын
@@ControllersTech thanks in advance
@vipulshinde621 Жыл бұрын
Will It work same for SDMMC ?
@eduardodelarosaferrer22054 жыл бұрын
Amazing !
@muratt44 Жыл бұрын
I want to save files to Flash and not to RAM, how can I do this?
@مغربي_راسي_عالي45814 ай бұрын
u can't, it's a ROM type of memory, read only memory ,so u can't write to it
@xDR1TeK4 жыл бұрын
Great video as always. I hate to ask an irrelevant question. For the stm32F103c8 using USB as virtual Com port. However everytime I'm uploading the firmware I have to pull out the USB cable and plug back again so that windows re-enumerate the Com port device. I don't want to ruin the USB recepticle, any solution for this? Looked everywhere.
@ControllersTech4 жыл бұрын
I don't think that it can be done without removing the USB.
@xDR1TeK4 жыл бұрын
@@ControllersTech Thank you.
@aaaaa-ct1vn Жыл бұрын
这个模拟u盘的原理是什么
@tuloca0114 жыл бұрын
Love you
@nutukidapoet68494 жыл бұрын
undefined reference to `hsd' USB_DEVICE/App/usbd_storage_if.o: In function `STORAGE_Read_FS': i have this problem, im using stm32f746ng
@charlesdecellieres62944 жыл бұрын
Add this between those two flags in "usbd_storage_if.c" :) /* USER CODE BEGIN PRIVATE_TYPES */ extern SD_HandleTypeDef hsd; /* USER CODE END PRIVATE_TYPES */
@kadimkisi29184 жыл бұрын
Hi! Thanks for videos..Can you make SD CARD VIEWER (file maneger and media player) on TFT(st7789 or ili9341) for next tutorial.Because a lot of example are for Arduino there is nomore for stm32(KEİL,IAR,CUBEIDE).İf you make this Project ,you will help people like me
@ControllersTech4 жыл бұрын
Okk. It's in my todo list for a while. First need to make that st7735 display to work somehow. Will definitely work on this
@kadimkisi29184 жыл бұрын
Thank you..I m waiting impatiently..I wish you continued success.
@ayoubkouch563 жыл бұрын
stm32 + external flash memory + usb msd +fatfs .no one on this planet can do it.
@ControllersTech3 жыл бұрын
What is external flash here for ?
@ayoubkouch563 жыл бұрын
@@ControllersTech w25qxx for datalogging
@ControllersTech3 жыл бұрын
Okay. And what's usb for then ?
@ayoubkouch563 жыл бұрын
@@ControllersTech to get the txt file from the flash as usb mass storage
@ControllersTech3 жыл бұрын
You know w25qxx is a SPI based flas memory right. How do you plan to use it with usb protocol ?
@jarrettmosco9624 Жыл бұрын
Your views would be 100x if you used your real voice