Pololu Wixel with SD Card as USB Mass Storage Device

Project strategic objective:
Make Wixel open/ create /read/write/ change /delete/ files, saved on the SD Card in FAT32 ( may be exFAT ) format. Connect Wixel to the PC as USB Mass Storage Device, for access to Wixel created files.

Current part of project objectives:

  • Initialize SD Card.
  • Connect Wixel to the PC by USB like a Flash Drive.

Project source files:pololu_wixel_msd.rar (597 KB)

For connection SD Card and Wixel we use SPI. Electrical connections are shown in the figure below.


Its so simple because supply voltage jf the Wixel and SD Card is same = 3,3V. So, no need to use any convertors.
In Internet you can find a lot of material about how to initialize SD card, but for a better understanding of the process, I recommend to read this document: sdcard.org/downloads/pls/si … t1_410.pdf in the part where it says about the the SPI mode. Special attention should be paid to the figure 7.2, because this is the algorithm to initialize the card.

So,
The first step of initialization is setup connection with SD Card by SPI(module spi0_master.c). It performs the function init_spi(). Parameters(Frequency, Polarity, Phase) are set up by testing, since they may differ for different types of SD Cards.

Second step is SD Card initialization (module diskio.c). At this stage I took as basis PetitFS library ( elm-chan.org/fsw/ff/00index_p.html ) written by Great Master ChaN. But I had to modify the code because it did not work as-is. The difference you can see by comparing my files and Petit FS source files.
Well. Now we can read/write data blocks from/to SD Card. But what to do with this?

Now we must access the SD Card data for PC by the USB Interface. At this stage we don’t care to know how does FAT32 works. Our Wixel should only perform the ReadBlock/WriteBlock commands coming from the PC.

USB protocol is described in detail in the specifications. Look at it ( usb.org/developers/docs/usb_20_070113.zip - usb_20.pdf ) to understand the basic principles of USB. It is very hard to understand, but very simple to use. In short: because Wixel seems like a SCSI disk on the handshake stage, so PC begins to send to the Wixel simple SCSI commands. The task of the Wixel is just to process this commands. These features provide in module usb_msd.c
It works! Very slow, but works.

But, the primary objective has not been reached yet. Now PC read/write on SD Card, however, we need to Wixel read/write itself.

So, it is time to understanding FAT32.

Key issues:
1. I was able to initialize the SD Card SDHC type 2. however, a SD Card SDHC 4 and SDXC failed to initialize.
2. USB speed very low (read on 160-200 kbit/s, write faster – 500-700 kbit/sec (depend on files length))

Key questions:
1.How to increase the read/write speed? Are there similar SoC like C2511 but with High-Speed USB interface?
2. Where can I find SD Card SDXC and SDHC 4 specifications?

Project in progress ########################################################
Welcome to cooperation!

Hello.

Thank you for sharing your project here! It is cool that you were able to get everything working.

I have added your app to the list of Wixel apps on the forum, and we are also planning on adding it to the Community Projects page.

Full speed USB is 12 Mbps (not counting all the protocol overhead), so I think the USB connection is probably not preventing you from making read and write speeds to be faster. I don’t know if this is possible or if you already implemented it, but it would be good if the USB transfers can happen in parallel with reading/writing data from the card.

For high-speed USB, there are probably some ARM-based microcontrollers from ST or NXP that can do it. It is unlikely that they would have a radio built-in though, like the CC2511.

I am not sure if it does high-speed USB or not, but the mbed acts a USB mass storage device.

–David

Hi, David

You’re right.
Full-speed USB not a reason for low read/write speed in this case.

In accordance with the ti.com/lit/ds/symlink/cc2511f32.pdf :

" The maximum baud rate for SPI master mode and thus SCK frequency is F/8
If SPI master mode does not need to receive data, the maximum SPI rate is F/2"

F is the system clock frequency. F=24Mhz

F/8 =24000000/8=3000000= 3 Mbit/s.
So, use High-speed USB does not make sense.

But I got read data speed on the order below - 0,3Mbit/s. :frowning:

Is it possible to use this type of project for wireless tethering to a camera for photo shoots? use case: camera with SD storage --> wireless --> laptop via “headless” (memory-less) SD card grabbing the data and transmitting wireless via Wixel to laptop for larger screen and real-time photo-editing. there are specific “grip” WIFI solutions, but a generic SD card solution (or USB) would be interesting to photographers for an inexpensive, real-time capture via wireless for in studio or remote photo shoots. this project is interesting in that it uses SD Cards and Wixel, so i will build it out, but really need the inverse of this. if anyone has done something like this with a Wixel on a e.g. Canon 5D or xyz camera, it would be great to share. thank you! ken

Hello, Ken.

I do not think the Wixel would work very well for wirelessly transmitting photos because it can only transfer about 10 KB of data per second. There are a variety of SD cards with built-in WiFi that might work.

–David

David, thank you. i agree. we have many of the WIFI SD cards (e.g. EyeFi). was looking for a cleaner 1:1 solution that did not require IP and was out of band for traditional snooping, blockers and such as many of these shots are in real-time, hostile environments. was drawn to the non-IP 1:1 but the speed issue is for sure legit given the size of the captured files (20MB). greatly appreciate the quick feedback and will keep looking. thank you.