Spark Logic

USB mass storage / SD card + speed

madias Wed Sep 12, 2018 10:09 pm

As I tried to get more reading/writing speed for Arpuss “USB mass storage” library (Rogers Core) I found some really interesting informations here:
https://microtechnics.ru/en/stm32-i-usb … e-sd-card/
This might be from interest building up a USB mass storage (SD card) for any HAL core. (now the good news ends).
About the sub optimal reading/writing speed (for me on blue pill about 300-500kB/s – 32GB SDHC with SdFatEX (SPI) – but the SDFat library is NOT the problem!) I found this thread somewhere in the middle of the comments of the side above:

Thank You for your effort, I made the project and it works very well.
The problem now is the speed, how can I increase the speed of read/write, and I wounder why the speed is very low it’s about 200KB/s write and 600KB/s read ?
Thanks

Aveal
on 27.04.2017 at 19:09 said:
It’s common problem that Mass Storage Class in STM32 has slow speed… The best speed I saw I got with NAND memory and 16 bit FSMC and it was near 500 KB/s for writing.

Ahmed
on 27.04.2017 at 20:12 said:
I wounder if I Use High-speed core will the speed much increase or it will be a little bit different ?

John_R
on 28.04.2017 at 13:50 said:
I have the same problem, I try to transfer 1GB file and I got 350 KB/s during a
write and 500 KB/s during a read. But I think DMA will be increase that speed.

Ahmed
on 28.04.2017 at 14:05 said:
The problem is that DMA is Memory -> peripheral, So how can I configure it to work with USB and SDIO ?

Aveal
on 28.04.2017 at 21:35 said:
You can use DMA just for SD card. But I’m not sure that the speed will increase…

So it seems there is no really range upwards for increasing the reading/writing speed. (At least for the F1)

Replies

madias Thu Sep 13, 2018 7:26 pm

[ag123 – Thu Sep 13, 2018 4:31 pm] –
incidentally aren’t there many *slow* cheapo sd card readers? let alone stm32 :lol:

…just wait for a minute, I*ll open my chepo SD-Card Reader (but runs fast) in front of me :)

Edit:
OK, only a single chip:
CP8121N
1729-H
Quick google (as expected): only a few chinese results not even one datasheet.
Honestly: I’m not going to rebuild a SD-Card reader ;) But the STM32Fxxx could be a very potential audio/wav/mp3/ogg/FLAC device (playing AND recording) so a decent SD-Card<>USB speed would be a fine thing (But even 1MBs would be rather slow).
Image

madias Thu Sep 13, 2018 7:48 pm

hmmm. The post before was just a joke, but maybe it could be possible (less effort) “hijacking” such a chip. So via USB you have a decent SD Card reader and internally it’s used as a STM32 SD card module. (a pin diagram of these CPxxx chip would be nice).
Edit: Here we go! Just 0.35 EUR for one chip (with some addons to remove):
https://www.aliexpress.com/item/high-qu … 10436.html

ag123 Thu Sep 13, 2018 9:01 pm

yup, couldn’t find the part number too :lol:
i think these days there are quite a number of asics which are usb2.0 high speed devices
some of the examples, which didn’t happen to be st devices like
Cypress CY7C68013A-56LTXC
https://sigrok.org/wiki/ARMFLY_Mini-Logic
happened to be popular with use as sigrok logic analyzers

these boards are pretty cheap
https://www.aliexpress.com/wholesale?ca … CY7C68013A
i’m not too sure if some of these could be programmed as sdcard readers

as for a stm32 usb2.0 high speed device, i couldn’t find something ‘cheap’
a close one is to use ulpi usb 2.0 high speed phy like the usb3300
https://www.aliexpress.com/wholesale?ca … xt=usb3300
but those prices are anything but ‘cheap’ (the module that is, which cost around usd 7 on ebay/aliexpress)

some of the sd card readers could after all be asics that is purpose built for that sd card to usb interfacing (usb 2.0 high speed) and the firmware preprogrammed.

but there are also some sd card readers loitering around which are only usb full speed devices 10 mbps max, i think for those the performance may be comparable to an ‘unoptimised’ stm32 bp/mm sd card reader. the difference this time is, we could optimise it if we really want to
but that leaves us with usb 2.0 full speed as the limit (10mbps)

ag123 Sat Sep 22, 2018 11:52 pm

i just managed to get usb mass storage and sd reader to compile successfully.
As i’m working in eclipse rather than Arduino IDE, integrating them would hit problems as alll the includes, defines, every single one of them has to be manually configured in the eclipse IDE. the benefits of doing so is the support of CDT (code completion, syntax highlights, jumping to references) and various tools. i’m also using the gnu arm eclipse ide plugins https://gnu-mcu-eclipse.github.io/

i’ve not actually assembled the ‘hardware’ yet hence, it is just a successful compile. :)
i took a look at some of the usb composite codes and realise just how extensive it is, i’d like to thank apruss, libarra, greiman, et.al.
viewtopic.php?f=13&t=2926
viewtopic.php?f=13&t=576
for having put all these things together

it is somewhat unfortunate that stm32f103 do not bundle usb2.0 high speed connectivity and that the higher series which supports it e.g. stm32f40x requires a ulpi usb 2.0 high speed phy hooked up to get usb2.0 high speed connectivity

edit: found an interesting web explaining in a simple way the differences between usb 2.0 full speed vs usb 2.0 high speed 480 mbps
https://www.renesas.com/us/en/solutions … sb2-0.html
according to wikipedia, effective throughput is lower at 280 Mbit/s or 35 MB/s
https://en.wikipedia.org/wiki/USB#USB_2.0

my guess is stm32f103 bp/mm may have issues coping with those speeds even with ulpi and stm32f405/407 would quite likely fit the bill
just that using an f4 still requires an external ulpi usb 2.0 high speed phy transceiver, i think part of the reason is the electrical differences 400mv (high speed) vs 3.3v (full speed) and the signalling speeds

Sign in to reply