first 2016/02 SDFileSystemDMA inherited from Official SDFileSystem.

Dependents:   SDFileSystemDMA-test DmdFullRGB_0_1

Fork of SDFileSystemDMA by mi mi

SDFileSystemDMA is enhanced SDFileSystem library for STM32 micros by using DMA functionality.
Max read transfer rate reaches over 2MByte/sec at 24MHz SPI clock if enough read buffer size is set.
Even though minimum read buffer size (512Byte) is set, read transfer rate will reach over 1MByte/sec at 24MHz SPI Clock.
( but depends on the ability of each SD card)

Test program is here.
https://developer.mbed.org/users/mimi3/code/SDFileSystemDMA-test/

/media/uploads/mimi3/sdfilesystemdma-speed-test3-read-buffer-512byte.png

/media/uploads/mimi3/sdfilesystemdma-speed-test-buffer-vs-spi-clock-nucleo-f411re-96mhz.png

Supported SPI port is shown below table.

(v): Verified. It works well.
(w): Probably it will work well. (not tested)
(c): Only compiled. (not tested)
(f): Over flash.
(r): Only read mode. (when _FS_READONLY==1)
(u) Under construction
(z): Dose not work.

Caution

If your board has SRAM less than or equal to 8KB, the buffer size must be set to 512 Bytes.

Supported Boards:
Cortex-M0

BoardSRAMSPI1SPI2SPI3
NUCLEO-F030R88KB(v)
DISCO-F051R88KB(w)
NUCLEO-F031K64KB(f)
NUCLEO-F042K66KB(r)
NUCLEO-F070RB16KB(w)
NUCLEO-F072RB16KB(w)
NUCLEO-F091RC32KB(c)

Cortex-L0

BoardSRAMSPI1SPI2SPI3
DISCO-L053C88KB(c)
NUCLEO-L053R88KB(c)
NUCLEO-L073RZ20KB(c)

Cortex-M3

BoardSRAMSPI1SPI2SPI3
DISCO-F100RB8KB(v)(v)-
BLUEPILL-F103CB20KB(w)(w)-
NUCLEO-F103RB20KB(v)(v)-
NUCLEO-L152RE80KB(v)(w)-
MOTE-L152RC32KB(w)(w)-

Cortex-M4
F3

BoardSRAMSPI1SPI2SPI3
DISCO-F303VC40KB-(v)(v)
NUCLEO-F303RE64KB(w)(w)(w)
NUCLEO-F302R816KB--(c)
NUCLEO-F303K812KB(c)--
DISCO-F334C812KB(c)--
NUCLEO-F334R812KB(c)--

F4

BoardSPI1SPI2SPI3
ELMO-F411RE(w)-(w)
MTS-MDOT-F411RE(u)-(u)
MTS-DRAGONFLY-F411RE(w)-(w)
NUCLEO-F411RE(v)-(v)
NUCLEO-F401RE(w)-(w)
MTS-MDOT-F405RG(u)-(u)
NUCLEO-F410RB(c)-(c)
NUCLEO-F446RE(c)-(c)
NUCLEO-F429ZI(c)-(c)
B96B-F446VE(c)-(c)
NUCLEO-F446ZE(c)-(c)
DISCO-F429ZI(u)-(u)
DISCO-F469NI(c)-(c)

Information

This library is set to use "short file name" in SDFileSystemDMA/FATFileSystem/ChaN/ffconf.h . ( _USE_LFN=0)
You can change this option to _USE_LFN=1 .

Committer:
mimi3
Date:
Sun Jan 22 23:13:11 2017 +0900
Revision:
38:7077795dbf81
Parent:
10:b48d3ace55db
change: table.md

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mimi3 10:b48d3ace55db 1 /* mbed Microcontroller Library - MemFileSystem
mimi3 10:b48d3ace55db 2 * Copyright (c) 2008, sford
mimi3 10:b48d3ace55db 3 */
mimi3 10:b48d3ace55db 4
mimi3 10:b48d3ace55db 5
mimi3 10:b48d3ace55db 6 #ifndef MBED_MEMFILESYSTEM_H
mimi3 10:b48d3ace55db 7 #define MBED_MEMFILESYSTEM_H
mimi3 10:b48d3ace55db 8
mimi3 10:b48d3ace55db 9 #include "FATFileSystem.h"
mimi3 10:b48d3ace55db 10
mimi3 10:b48d3ace55db 11 namespace mbed
mimi3 10:b48d3ace55db 12 {
mimi3 10:b48d3ace55db 13
mimi3 10:b48d3ace55db 14 class MemFileSystem : public FATFileSystem
mimi3 10:b48d3ace55db 15 {
mimi3 10:b48d3ace55db 16 public:
mimi3 10:b48d3ace55db 17
mimi3 10:b48d3ace55db 18 // 2000 sectors, each 512 bytes (malloced as required)
mimi3 10:b48d3ace55db 19 char *sectors[2000];
mimi3 10:b48d3ace55db 20
mimi3 10:b48d3ace55db 21 MemFileSystem(const char* name) : FATFileSystem(name) {
mimi3 10:b48d3ace55db 22 memset(sectors, 0, sizeof(sectors));
mimi3 10:b48d3ace55db 23 }
mimi3 10:b48d3ace55db 24
mimi3 10:b48d3ace55db 25 virtual ~MemFileSystem() {
mimi3 10:b48d3ace55db 26 for(int i = 0; i < 2000; i++) {
mimi3 10:b48d3ace55db 27 if(sectors[i]) {
mimi3 10:b48d3ace55db 28 free(sectors[i]);
mimi3 10:b48d3ace55db 29 }
mimi3 10:b48d3ace55db 30 }
mimi3 10:b48d3ace55db 31 }
mimi3 10:b48d3ace55db 32
mimi3 10:b48d3ace55db 33 // read a sector in to the buffer, return 0 if ok
mimi3 10:b48d3ace55db 34 virtual int disk_read(char *buffer, int sector) {
mimi3 10:b48d3ace55db 35 if(sectors[sector] == 0) {
mimi3 10:b48d3ace55db 36 // nothing allocated means sector is empty
mimi3 10:b48d3ace55db 37 memset(buffer, 0, 512);
mimi3 10:b48d3ace55db 38 } else {
mimi3 10:b48d3ace55db 39 memcpy(buffer, sectors[sector], 512);
mimi3 10:b48d3ace55db 40 }
mimi3 10:b48d3ace55db 41 return 0;
mimi3 10:b48d3ace55db 42 }
mimi3 10:b48d3ace55db 43
mimi3 10:b48d3ace55db 44 // write a sector from the buffer, return 0 if ok
mimi3 10:b48d3ace55db 45 virtual int disk_write(const char *buffer, int sector) {
mimi3 10:b48d3ace55db 46 // if buffer is zero deallocate sector
mimi3 10:b48d3ace55db 47 char zero[512];
mimi3 10:b48d3ace55db 48 memset(zero, 0, 512);
mimi3 10:b48d3ace55db 49 if(memcmp(zero, buffer, 512)==0) {
mimi3 10:b48d3ace55db 50 if(sectors[sector] != 0) {
mimi3 10:b48d3ace55db 51 free(sectors[sector]);
mimi3 10:b48d3ace55db 52 sectors[sector] = 0;
mimi3 10:b48d3ace55db 53 }
mimi3 10:b48d3ace55db 54 return 0;
mimi3 10:b48d3ace55db 55 }
mimi3 10:b48d3ace55db 56 // else allocate a sector if needed, and write
mimi3 10:b48d3ace55db 57 if(sectors[sector] == 0) {
mimi3 10:b48d3ace55db 58 char *sec = (char*)malloc(512);
mimi3 10:b48d3ace55db 59 if(sec==0) {
mimi3 10:b48d3ace55db 60 return 1; // out of memory
mimi3 10:b48d3ace55db 61 }
mimi3 10:b48d3ace55db 62 sectors[sector] = sec;
mimi3 10:b48d3ace55db 63 }
mimi3 10:b48d3ace55db 64 memcpy(sectors[sector], buffer, 512);
mimi3 10:b48d3ace55db 65 return 0;
mimi3 10:b48d3ace55db 66 }
mimi3 10:b48d3ace55db 67
mimi3 10:b48d3ace55db 68 // return the number of sectors
mimi3 10:b48d3ace55db 69 virtual int disk_sectors() {
mimi3 10:b48d3ace55db 70 return sizeof(sectors)/sizeof(sectors[0]);
mimi3 10:b48d3ace55db 71 }
mimi3 10:b48d3ace55db 72
mimi3 10:b48d3ace55db 73 };
mimi3 10:b48d3ace55db 74
mimi3 10:b48d3ace55db 75 }
mimi3 10:b48d3ace55db 76
mimi3 10:b48d3ace55db 77 #endif