SDFileSystem for LPC17xx
C++ C Makefile Assembly
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
CircularLog
CppUTest @ dbdf4f1
FATFileSystem
LoopbackTest
PcSoakTest
PerformanceTest
SDFileSystem
SDTestLib
SPIDma
SoakTest
SyncTest
bins
gcc4mbed @ 521e2af
tests
.gdbinit
.gitignore
.gitmodules
README.creole

README.creole

How to Clone

This project uses submodules (ie. GCC4MBED and CppUTest). Cloning therefore requires an extra flag to get all of the necessary code.

git clone --recursive git@github.com:adamgreen/SDCard.git

Overview

This version of the SD card driver was heavily influenced by these previous versions:

Features

  • Robustness - Enables more thorough CRC and error checking and will retry on errors when possible.
  • Performance - Supports multi-block read/write operations to increase throughput along with running the SPI communications at 25MHz.
  • Lower CPU Utilization - Uses a new SPI driver, SPIDma, created just for this project. With this driver it is able to utilize DMA for the transfer of the 512 byte blocks. While these larger reads/writes are taking place, the CPU can be interrupted to run higher priority tasks with no impact on the I/O operations.

SoakTest

The code in the SoakTest/ folder uses an updated SDFileSystem driver to create a file on the root of a SD card and then reads from it at random locations. It continues to perform these random reads, validating the read data as it progresses, until the user sends a key press to stop the test. It can be run for an extended period of time to verify read robustness of the card/driver. It will log about errors that it encounters during the read process. It also dumps some of the core properties of the SD card and a few internal SDFileSystem counters that help me determine how well it is working on different devices.

Important Notes!

  • Backup your data before running this test. This is a beta quality driver with writes enabled so it could inadvertently destroy data by mistake.
  • The pre-built binary has been built to run on the Smoothie v1 hardware.
    • It is built to be loaded into FLASH at an offset of 16K. This makes it compatible with the boot loader typically used with Smoothieboards.
    • This test is configured to communicate with the uSD socket on the Smoothieboard PCB itself.
    • It outputs test progress and results to the serial port. You need to have a FTDI (or similar) cable connected to the 1x6 pin Serial header on the Smoothieboard.
  • To see the test progress and results you should connect your favorite terminal emulator to your SmoothieBoard at 9600-N-8-1.
  • Once the firmware is loaded, press the reset button to start the test running. The user will then be prompted for the size of the test file to use. I tend to pick a value between 1 and 100 (MB).

I would really appreciate it if people could run this test on their SmoothieBoards with various uSD cards that they have and report back their results! The bins/ folder contains a pre-built SoakTest-Smoothie1.bin binary that it is ready to be installed on a SmoothieBoard via its boot loader. It is probably enough to just let it run for a few minutes on the bulk of your cards to see if it gets any failures. It would be great if you could let it run for an extended period of time (ie. overnight) on what you consider to be your most reliable card.

If you encounter failures:

  • Create an issue here on GitHub.
  • Include all of the serial output generated by the test when it was run against the failing card.
  • Describe the card as best as you can (brand, capacity, etc.)
  • Please note if there is anything out of the ordinary with respect to your Smoothieboard setup.

I have already hit an issue with a ADATA 8GB uSD card that I have here. The failure is documented in this GitHub issue.

Thanks for your help! I really appreciate it!

Example output when run on a SanDisk Mobile Ultra 16GB MicroSD HC I card:

SDCard Soak Test
Cleanup from previous test run.

How large should the test file be in MB (100MB is default):
Dumping SD CID register contents.
  CID = 0x03 0x53 0x44 0x53 0x55 0x31 0x36 0x47 0x80 0x13 0x51 0xB0 0xF7 0x00 0xBB 0x6D
          Manufacturer ID: 0x03
                   OEM ID: SD
             Product Name: SU16G
         Product Revision: 8.0
    Product Serial Number: 0x1351B0F7
       Manufacturing Date: November 2011
                 Checksum: 0x36
Dumping SD OCR register contents.
  OCR = 0xC0FF8000
          Card Power Up Status: 1
          Card Capacity Status: 1
            UHS-II Card Status: 0
    Switching to 1.8V Accepted: 0
                    2.7 - 2.8V: 1
                    2.8 - 2.9V: 1
                    2.9 - 3.0V: 1
                    3.0 - 3.1V: 1
                    3.1 - 3.2V: 1
                    3.2 - 3.3V: 1
                    3.3 - 3.4V: 1
                    3.4 - 3.5V: 1
                    3.5 - 3.6V: 1
Dumping SD CSD register contents.
  CSD = 0x40 0x0E 0x00 0x32 0x5B 0x59 0x00 0x00 0x76 0xB2 0x7F 0x80 0x0A 0x40 0x40 0x13
    CSD Version: 2.0
                  Data Read Access-Time: 0x0E (1ms)
    Data Read Access-Time in CLK cycles: 0
                      Max Transfer Rate: 25.0MHz
                  Card Command Class  0: yes
                  Card Command Class  1: no
                  Card Command Class  2: yes
                  Card Command Class  3: no
                  Card Command Class  4: yes
                  Card Command Class  5: yes
                  Card Command Class  6: no
                  Card Command Class  7: yes
                  Card Command Class  8: yes
                  Card Command Class  9: no
                  Card Command Class 10: yes
                  Card Command Class 11: no
             Max Read Data Block Length: 512
        Partial Blocks for Read Allowed: no
               Write Block Misalignment: no
                Read Block Misalignment: no
                        DSR Implemented: no
                            Device Size: 15931539456 bytes
              Erase Single Block Enable: 512 bytes
        Erase Sector Size (SECTOR_SIZE): 128
               Write Protect Group Size: 0
             Write Protect Group Enable: no
                     Write Speed Factor: 4
            Max Write Data Block Length: 512
       Partial Blocks for Write Allowed: no
                      File Format Group: 0
                              Copy Flag: copy
             Permanent Write Protection: 0
             Temporary Write Protection: 0
                            File Format: 0
                                    CRC: 0x09
Creating 10 MB test file...
The following soak test will run until you press a key to stop it.
LED1 will blink while the test is progressing smoothly.
Starting soak test now...
Removing test file.
SD Card Driver Counters
    maximumWaitWhileBusyTime = 23
    maximumWaitForR1ResponseLoopCount = 2
    maximumACMD41LoopTime = 13
    cmd12PaddingByteRequiredCount = 13011
Test Completed!