2008-03-17 11:04 PM
Accessing SD Mass Storage Memory on STM3210B-EVAL
2011-05-17 03:22 AM
Have searched for this on the forum, apologies in advance if there is an answer to this!
I am using the STM321B-EVAL board and got the mass storage demo working with the SD memory card and USB. However what I would like to do is have the STM32 program to be able to read files stored on the SD card; i.e. display a bitmap, play a wavefile or just read a plain text file. Is there any example code to do this? I know the demo software for the EVAL has this but it uses the on-board SmartCard memory - I want to use the SD card instead. Thanks in advance - any help would be greatly appreciated!! James2011-05-17 03:22 AM
Hi JM,
Have a look at the STM32F10xxx USB developer kit (um0424.zip) on the ST website. It has a mass storage example with a SD card as the storage medium. Can you indicate to me where the application you described in your original post can be found? Regards Ed2011-05-17 03:22 AM
Ok, now I have realised that the EVAL USB mass storage demo uses the on-board SPI flash (not the Smart Card)... what needs to be changed in the program to use the removable SD card...??
Thanks again!2011-05-17 03:22 AM
Hi Ed,
Thanks for the reply. Yes I have been using that, I think it comes with the IAR compiler demo. What I want to now is for the STM32 program to be able to read and use data on the SD card. An example is that I connect the STM32 to my PC with a USB cable, copy across a bitmap image to the mass storage memory, but then for the STM32 to read and display the picture on the LCD. The original demo software on the STM3210B-EVAL is UM0425.zip. It uses bitmaps and wavefiles stored in the soldered SPI flash. However these are uploaded by the dfuse utility (via USB). In the mass storage example (um0424.zip, msd.c) I have tried changing the chip enable bit PC12 (SD card enable) to PA4 (SPI flash enable) just to see if it was this simple, but this has no change, the PC still 'sees' the SD card. So basically does the SPI flash and SD memory work the same way (they share the same SPI interface), and how can you select between them in the examples? Cheers again, James2011-05-17 03:22 AM
I have downloaded this demo. I have 2 questions.
1) What modifications would be required to make it run on the KEIL MCBSTM32 board. 2) Is MMC cards supported. Thanks.2011-05-17 03:22 AM
Hi James,
If you dump files on the SD card with a PC (USB mass storage device firmware), the Windows FAT32 file system is used. If you want the STM32 to read the files afterwards, you need to have a FAT32 file system on the STM32 in order to get these files. I havn't seen a FAT32 for STM32, but if you do find one, please share it with us. BR, Bart2011-05-17 03:22 AM
Hi James,
Just googled for FAT32 for ARM and found: http://www.robs-projects.com/filelib.html http://www.larwe.com/zws/products/dosfs/ Probably there is more to find. BR, Bart2011-05-17 03:22 AM
I have had a go at getting the SD Mass Storage Demo working on the Keil Board. I leave some notes here to help people trying this in the future.
Firstly the chip is different between the two boards. They are both 103's but the ST is a 100pin variant and the Keil is a 64 Pin version. The socket on the ST board is MicroSD and the Keil has a full size SD. This means there is no handling for the Write Protect switch on the full size SD card but this is no big issue I guess. This naming convention on the STM32's is very strange indeed. The Pins used for Chip Select and USB Pull Up on the two boards is different. I added these Macro's :- #if 1 // Version for Keil MCBSTM32 #define SDCARD_CS_PIN GPIO_Pin_8 #define SDCARD_CS_PORT GPIOA #define USB_PULL_UP_PIN GPIO_Pin_2 #define USB_PULL_UP_PORT GPIOD #else // Version for ST Board #define SDCARD_CS_PIN GPIO_Pin_12 #define SDCARD_CS_PORT GPIOC #define USB_PULL_UP_PIN GPIO_Pin_9 #define USB_PULL_UP_PORT GPIOD #endif and took out the hard coding of the Pins and Ports for those two chips. ST should NEVER have hard coded the pins in the first place if you ask me. I changed the processor in the project and built the code. When I plugged it into my SD card in the socket it was recognised as a drive by XP but it claimed that the Drive needed to be formatted. So it nearly worked! It was pretty slow to come up but then it does only work at 12 mbits and the software is not optimized. If ST read this please make your code more portable between boards. It does not take much effort. You can see how I did it above. Keep all the board specific stuff in one header file, then it is easy to change :D All the best.2011-05-17 03:22 AM
Hi all,
I've also found via:http://www.st.com/mcu/contentid-90.html
some 3rd party vendors who also have file systems. Some examples: http://www.keil.com/arm/rl-arm/rl-flash.asp http://www.ecoscentric.com/middleware/mmfs.shtml http://www.cmx.com/ffs.htm ... BR, Bart