GroupU - 05012018 1543
Fork of 352 by
sd-driver/README.md@4:019309e6090e, 2018-01-09 (annotated)
- Committer:
- mslade
- Date:
- Tue Jan 09 16:39:28 2018 +0000
- Revision:
- 4:019309e6090e
- Parent:
- 1:84581acd1333
Update for DLE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mslade | 1:84581acd1333 | 1 | # mbed OS SDCard Driver (sd-driver) for FAT32 Filesystem Support |
mslade | 1:84581acd1333 | 2 | |
mslade | 1:84581acd1333 | 3 | |
mslade | 1:84581acd1333 | 4 | Simon Hughes |
mslade | 1:84581acd1333 | 5 | |
mslade | 1:84581acd1333 | 6 | 20170329 |
mslade | 1:84581acd1333 | 7 | |
mslade | 1:84581acd1333 | 8 | Version 0.1.1 |
mslade | 1:84581acd1333 | 9 | |
mslade | 1:84581acd1333 | 10 | |
mslade | 1:84581acd1333 | 11 | # Executive Summary |
mslade | 1:84581acd1333 | 12 | |
mslade | 1:84581acd1333 | 13 | The purpose of this document is to describe how to use the mbed OS SDCard |
mslade | 1:84581acd1333 | 14 | driver (sd-driver) so applications can read/write |
mslade | 1:84581acd1333 | 15 | data to flash storage cards using the standard POSIX File API |
mslade | 1:84581acd1333 | 16 | programming interface. The sd-driver uses the SDCard SPI-mode of operation |
mslade | 1:84581acd1333 | 17 | which is a subset of possible SDCard functionality. |
mslade | 1:84581acd1333 | 18 | |
mslade | 1:84581acd1333 | 19 | This repository contains the mbed-os SDCard driver for generic SPI |
mslade | 1:84581acd1333 | 20 | SDCard support and other resources, as outlined below: |
mslade | 1:84581acd1333 | 21 | |
mslade | 1:84581acd1333 | 22 | - `SDBlockDevice.h` and `SDBlockDevice.cpp`. This is the SDCard driver module presenting |
mslade | 1:84581acd1333 | 23 | a Block Device API (derived from BlockDevice) to the underlying SDCard. |
mslade | 1:84581acd1333 | 24 | - POSIX File API test cases for testing the FAT32 filesystem on SDCard. |
mslade | 1:84581acd1333 | 25 | - basic.cpp, a basic set of functional test cases. |
mslade | 1:84581acd1333 | 26 | - fopen.cpp, more functional tests reading/writing greater volumes of data to SDCard, for example. |
mslade | 1:84581acd1333 | 27 | - `mbed_lib.json` mbed-os application configuration file with SPI pin configurations for the CI shield and overrides for specific targets. |
mslade | 1:84581acd1333 | 28 | This file allows the SPI pins to be specified for the target without having to edit the implementation files. |
mslade | 1:84581acd1333 | 29 | - This README which includes [Summary of POSIX File API Documentation](#summary-posix-api-documentation) |
mslade | 1:84581acd1333 | 30 | including detailed instruction on how to use the FAT filesystem and SDBlockDevice driver. |
mslade | 1:84581acd1333 | 31 | |
mslade | 1:84581acd1333 | 32 | The SDCard driver is maintained in this repository as a component separate from the main mbed OS repository. |
mslade | 1:84581acd1333 | 33 | Hence the 2 repositories (mbed-os and sd-driver) have to be used together |
mslade | 1:84581acd1333 | 34 | to deliver the FAT32 Filesystem/SDCard support. This document explains how to do this. |
mslade | 1:84581acd1333 | 35 | |
mslade | 1:84581acd1333 | 36 | |
mslade | 1:84581acd1333 | 37 | # Introduction |
mslade | 1:84581acd1333 | 38 | |
mslade | 1:84581acd1333 | 39 | ### Overview |
mslade | 1:84581acd1333 | 40 | |
mslade | 1:84581acd1333 | 41 | The scope of this document is to describe how applications use the FAT filesystem and sd-driver |
mslade | 1:84581acd1333 | 42 | components to persistently store data on SDCards. The document is intended to help developers adopt the |
mslade | 1:84581acd1333 | 43 | mbed OS POSIX File API support, and in particular to help explain: |
mslade | 1:84581acd1333 | 44 | |
mslade | 1:84581acd1333 | 45 | - How the software components work together to deliver the storage functionality. |
mslade | 1:84581acd1333 | 46 | - How to work with the sd-driver and mbed OS to build the examples. The example code can easily |
mslade | 1:84581acd1333 | 47 | be copied into your new application code. |
mslade | 1:84581acd1333 | 48 | - How to work with the CI Test Shield, which adds an SDCard slot to those targets that do not have already have one. |
mslade | 1:84581acd1333 | 49 | - How to run the POSIX File API mbed Greentea test cases, which provide further example code of how to use |
mslade | 1:84581acd1333 | 50 | the POSIX File API. |
mslade | 1:84581acd1333 | 51 | |
mslade | 1:84581acd1333 | 52 | Section 1 provides an Executive Summary, describing the purpose of the sd-driver, the supporting |
mslade | 1:84581acd1333 | 53 | software, examples, test cases and documentation. |
mslade | 1:84581acd1333 | 54 | |
mslade | 1:84581acd1333 | 55 | Section 2 provides an an overview of the material covered including descriptions of the major sections. |
mslade | 1:84581acd1333 | 56 | |
mslade | 1:84581acd1333 | 57 | Section 3 provides an overview of the mbed OS filesystem software components, |
mslade | 1:84581acd1333 | 58 | including the inter-relationships between the application, POSIX file API, the standard c-library, |
mslade | 1:84581acd1333 | 59 | the mbed OS filesystem and the SDCard driver (sd-driver). |
mslade | 1:84581acd1333 | 60 | |
mslade | 1:84581acd1333 | 61 | Section 4 describes how to build and run an example application for reading |
mslade | 1:84581acd1333 | 62 | and writing data to an SDCard using the POSIX File API. The example begins by describing |
mslade | 1:84581acd1333 | 63 | the procedure for building and testing on the K64F target. The final sub-sections |
mslade | 1:84581acd1333 | 64 | describe how to use the test shield to add an SDCard slot to any mbed target, |
mslade | 1:84581acd1333 | 65 | and hence enable the persistent storage of data on any supported target. |
mslade | 1:84581acd1333 | 66 | |
mslade | 1:84581acd1333 | 67 | Section 5 describes an example application which uses the raw |
mslade | 1:84581acd1333 | 68 | BlockDevice API to read and write data to the SDCard. |
mslade | 1:84581acd1333 | 69 | |
mslade | 1:84581acd1333 | 70 | Section 6 describes how to build and run the SDCard POSIX File API mbed Greentea test cases. |
mslade | 1:84581acd1333 | 71 | There are a number of functional test cases demonstrating how to use the |
mslade | 1:84581acd1333 | 72 | mbed OS POSIX File API. |
mslade | 1:84581acd1333 | 73 | |
mslade | 1:84581acd1333 | 74 | Section 7 describes the POSIX File API and provides links to useful API documentation web pages. |
mslade | 1:84581acd1333 | 75 | |
mslade | 1:84581acd1333 | 76 | |
mslade | 1:84581acd1333 | 77 | ### Known mbed-os and sd-driver Compatible Versions |
mslade | 1:84581acd1333 | 78 | |
mslade | 1:84581acd1333 | 79 | The following versions of the mbed-os and sd-driver repositories are known to work together: |
mslade | 1:84581acd1333 | 80 | |
mslade | 1:84581acd1333 | 81 | - {mbed-os, sd-driver} = {mbed-os-5.4.0-rc2, sd-driver-0.0.1-mbed-os-5.4.0-rc2}. |
mslade | 1:84581acd1333 | 82 | `K64F`, `NUCLEO_F429ZI` and `UBLOX_EVK_ODIN_W2` fopen and basic filesystem tests working. |
mslade | 1:84581acd1333 | 83 | - {mbed-os, sd-driver} = {mbed-os-5.4.0, sd-driver-0.0.2-mbed-os-5.4.0}. |
mslade | 1:84581acd1333 | 84 | `K64F`, `NUCLEO_F429ZI` and `UBLOX_EVK_ODIN_W2` fopen and basic filesystem tests working. |
mslade | 1:84581acd1333 | 85 | - {mbed-os, sd-driver} = {mbed-os-5.4.1, sd-driver-0.0.3-mbed-os-5.4.1}. |
mslade | 1:84581acd1333 | 86 | - {mbed-os, sd-driver} = {mbed-os-5.5.1, sd-driver-0.1.0-mbed-os-5.5.1}. |
mslade | 1:84581acd1333 | 87 | - {mbed-os, sd-driver} = {mbed-os-5.5.4, sd-driver-0.1.1-mbed-os-5.5.4}. |
mslade | 1:84581acd1333 | 88 | - {mbed-os, sd-driver} = {mbed-os-5.6.1, sd-driver-0.1.2-mbed-os-5.6.1}. |
mslade | 1:84581acd1333 | 89 | |
mslade | 1:84581acd1333 | 90 | To find the latest compatible versions, use the following command to see the messages attached to the tags |
mslade | 1:84581acd1333 | 91 | in the sd-driver repository: |
mslade | 1:84581acd1333 | 92 | |
mslade | 1:84581acd1333 | 93 | ex_app7/$ cd sd-driver |
mslade | 1:84581acd1333 | 94 | ex_app7/sd-driver$ git tag -n |
mslade | 1:84581acd1333 | 95 | sd-driver-0.0.1-mbed-os-5.3.4 Version compatible with mbed-os-5.3.4, and private_mbedos_filesystems-0.0.1-mbed-os-5.3.4. |
mslade | 1:84581acd1333 | 96 | sd-driver-0.0.2-mbed-os-5.4.0 Updated README.md to include worked exmaples and restructuring of information. |
mslade | 1:84581acd1333 | 97 | sd-driver-0.0.3-mbed-os-5.4.1 Version compatible with mbed-os-5.4.1. |
mslade | 1:84581acd1333 | 98 | sd-driver-0.1.1-mbed-os-5.5.4 Version compatible with mbed-os-5.5.4 |
mslade | 1:84581acd1333 | 99 | sd-driver-0.1.2-mbed-os-5.6.1 Version compatible with mbed-os-5.6.1 |
mslade | 1:84581acd1333 | 100 | |
mslade | 1:84581acd1333 | 101 | |
mslade | 1:84581acd1333 | 102 | ### Known Issues With This Document |
mslade | 1:84581acd1333 | 103 | |
mslade | 1:84581acd1333 | 104 | There are no known issues with this document. |
mslade | 1:84581acd1333 | 105 | |
mslade | 1:84581acd1333 | 106 | |
mslade | 1:84581acd1333 | 107 | # Overview of mbed OS Filesystem Software Component Stack |
mslade | 1:84581acd1333 | 108 | |
mslade | 1:84581acd1333 | 109 | |
mslade | 1:84581acd1333 | 110 | ------------------------ |
mslade | 1:84581acd1333 | 111 | | | |
mslade | 1:84581acd1333 | 112 | | Application | // This application uses the POSIX File API |
mslade | 1:84581acd1333 | 113 | | | // to read/write data to persistent storage backends. |
mslade | 1:84581acd1333 | 114 | ------------------------ |
mslade | 1:84581acd1333 | 115 | |
mslade | 1:84581acd1333 | 116 | ------------------------ // POSIX File API (ISO). |
mslade | 1:84581acd1333 | 117 | |
mslade | 1:84581acd1333 | 118 | ------------------------ |
mslade | 1:84581acd1333 | 119 | | | |
mslade | 1:84581acd1333 | 120 | | libc | // The standard c library implementation |
mslade | 1:84581acd1333 | 121 | | | // e.g. newlib. |
mslade | 1:84581acd1333 | 122 | ------------------------ |
mslade | 1:84581acd1333 | 123 | |
mslade | 1:84581acd1333 | 124 | ------------------------ // sys_xxx equivalent API. |
mslade | 1:84581acd1333 | 125 | |
mslade | 1:84581acd1333 | 126 | ------------------------ |
mslade | 1:84581acd1333 | 127 | | | |
mslade | 1:84581acd1333 | 128 | | mbed_retarget.cpp | // Target specific mapping layer. |
mslade | 1:84581acd1333 | 129 | | | |
mslade | 1:84581acd1333 | 130 | ------------------------ |
mslade | 1:84581acd1333 | 131 | |
mslade | 1:84581acd1333 | 132 | ------------------------ // Filesystem Upper Edge API. |
mslade | 1:84581acd1333 | 133 | |
mslade | 1:84581acd1333 | 134 | ------------------------ |
mslade | 1:84581acd1333 | 135 | | | |
mslade | 1:84581acd1333 | 136 | | File System | // File system wrappers and implementation. |
mslade | 1:84581acd1333 | 137 | | | |
mslade | 1:84581acd1333 | 138 | ------------------------ |
mslade | 1:84581acd1333 | 139 | |
mslade | 1:84581acd1333 | 140 | ------------------------ // FS Lower Edge API (Block Store Interface). |
mslade | 1:84581acd1333 | 141 | |
mslade | 1:84581acd1333 | 142 | ------------------------ |
mslade | 1:84581acd1333 | 143 | | Block API | |
mslade | 1:84581acd1333 | 144 | | Device Driver | // The SDCard driver, for example. |
mslade | 1:84581acd1333 | 145 | | e.g. sd-driver | |
mslade | 1:84581acd1333 | 146 | ------------------------ |
mslade | 1:84581acd1333 | 147 | |
mslade | 1:84581acd1333 | 148 | ------------------------ // SPI.h interface. |
mslade | 1:84581acd1333 | 149 | |
mslade | 1:84581acd1333 | 150 | ------------------------ |
mslade | 1:84581acd1333 | 151 | | | |
mslade | 1:84581acd1333 | 152 | | SPI | // SPI subsystem (C++ classes and C-HAL implementation). |
mslade | 1:84581acd1333 | 153 | | | |
mslade | 1:84581acd1333 | 154 | ------------------------ |
mslade | 1:84581acd1333 | 155 | |
mslade | 1:84581acd1333 | 156 | Figure 1. mbedOS generic architecture of filesystem software stack. |
mslade | 1:84581acd1333 | 157 | |
mslade | 1:84581acd1333 | 158 | The figure above shows the mbed OS software component stack used for data |
mslade | 1:84581acd1333 | 159 | storage on SDCard: |
mslade | 1:84581acd1333 | 160 | |
mslade | 1:84581acd1333 | 161 | - At the top level is the application component which uses the standard POSIX File API |
mslade | 1:84581acd1333 | 162 | to read and write application data to persistent storage. |
mslade | 1:84581acd1333 | 163 | - The newlib standard library (libc) stdio.h interface (POSIX File API) |
mslade | 1:84581acd1333 | 164 | implementation is used as it's optimised for resource limited embedded systems. |
mslade | 1:84581acd1333 | 165 | - mbed_retarget.cpp implements the libc back-end file OS handlers and maps them |
mslade | 1:84581acd1333 | 166 | to the FileSystem. |
mslade | 1:84581acd1333 | 167 | - The File System code (hosted in mbed-os) is composed of 2 parts: |
mslade | 1:84581acd1333 | 168 | - The mbed OS file system wrapper classes (e.g. FileSystem, File, FileBase classes) |
mslade | 1:84581acd1333 | 169 | which are used to present a consistent API to the retarget module for different |
mslade | 1:84581acd1333 | 170 | (third-party) file system implementations. |
mslade | 1:84581acd1333 | 171 | - The FAT filesystem implementation code. |
mslade | 1:84581acd1333 | 172 | The [FATFS: Generic FAT File System Module](http://elm-chan.org/fsw/ff/00index_e.html) |
mslade | 1:84581acd1333 | 173 | (ChanFS) has been integrated within mbed-os. |
mslade | 1:84581acd1333 | 174 | - The Block API Device Driver. The SDCard driver is an example of a persistent storage driver. |
mslade | 1:84581acd1333 | 175 | It's maintained as a separate component from the mbed OS repository (in this repository). |
mslade | 1:84581acd1333 | 176 | - The SPI module provides the mbed OS generic SPI API. This functionality is maintained in |
mslade | 1:84581acd1333 | 177 | mbed OS. |
mslade | 1:84581acd1333 | 178 | |
mslade | 1:84581acd1333 | 179 | |
mslade | 1:84581acd1333 | 180 | # SDCard POSIX File API Example App for Reading/Writing Data |
mslade | 1:84581acd1333 | 181 | |
mslade | 1:84581acd1333 | 182 | Refer to [SD driver Example](https://github.com/ARMmbed/mbed-os-example-sd-driver) |
mslade | 1:84581acd1333 | 183 | |
mslade | 1:84581acd1333 | 184 | |
mslade | 1:84581acd1333 | 185 | ### <a name="testing-with-an-sdcard-on-target-xyx"></a> Testing with an SDCard on Target XYZ |
mslade | 1:84581acd1333 | 186 | |
mslade | 1:84581acd1333 | 187 | The standard way to test is with the mbed CI Test Shield plugged into the |
mslade | 1:84581acd1333 | 188 | target board. This pin mapping for this configuration is parameterised in |
mslade | 1:84581acd1333 | 189 | the `mbed_lib.json` file. |
mslade | 1:84581acd1333 | 190 | |
mslade | 1:84581acd1333 | 191 | The following is an example of the `mbed_lib.json` file available in the repository: |
mslade | 1:84581acd1333 | 192 | |
mslade | 1:84581acd1333 | 193 | { |
mslade | 1:84581acd1333 | 194 | "config": { |
mslade | 1:84581acd1333 | 195 | "UART_RX": "D0", |
mslade | 1:84581acd1333 | 196 | "UART_TX": "D1", |
mslade | 1:84581acd1333 | 197 | "DIO_0": "D0", |
mslade | 1:84581acd1333 | 198 | "DIO_1": "D1", |
mslade | 1:84581acd1333 | 199 | "DIO_2": "D2", |
mslade | 1:84581acd1333 | 200 | "DIO_3": "D3", |
mslade | 1:84581acd1333 | 201 | "DIO_4": "D4", |
mslade | 1:84581acd1333 | 202 | "DIO_5": "D5", |
mslade | 1:84581acd1333 | 203 | "DIO_6": "D6", |
mslade | 1:84581acd1333 | 204 | "DIO_7": "D7", |
mslade | 1:84581acd1333 | 205 | "DIO_8": "D8", |
mslade | 1:84581acd1333 | 206 | "DIO_9": "D9", |
mslade | 1:84581acd1333 | 207 | "SPI_CS": "D10", |
mslade | 1:84581acd1333 | 208 | "SPI_MOSI": "D11", |
mslade | 1:84581acd1333 | 209 | "SPI_MISO": "D12", |
mslade | 1:84581acd1333 | 210 | "SPI_CLK": "D13", |
mslade | 1:84581acd1333 | 211 | "I2C_SDA": "D14", |
mslade | 1:84581acd1333 | 212 | "I2C_SCL": "D15", |
mslade | 1:84581acd1333 | 213 | "I2C_TEMP_ADDR":"0x90", |
mslade | 1:84581acd1333 | 214 | "I2C_EEPROM_ADDR":"0xA0", |
mslade | 1:84581acd1333 | 215 | "AIN_0": "A0", |
mslade | 1:84581acd1333 | 216 | "AIN_1": "A1", |
mslade | 1:84581acd1333 | 217 | "AIN_2": "A2", |
mslade | 1:84581acd1333 | 218 | "AIN_3": "A3", |
mslade | 1:84581acd1333 | 219 | "AIN_4": "A4", |
mslade | 1:84581acd1333 | 220 | "AIN_5": "A5", |
mslade | 1:84581acd1333 | 221 | "AOUT" : "A5", |
mslade | 1:84581acd1333 | 222 | "PWM_0": "D3", |
mslade | 1:84581acd1333 | 223 | "PWM_1": "D5", |
mslade | 1:84581acd1333 | 224 | "PWM_2": "D6", |
mslade | 1:84581acd1333 | 225 | "PWM_3": "D9", |
mslade | 1:84581acd1333 | 226 | "DEBUG_MSG": 0, |
mslade | 1:84581acd1333 | 227 | "DEVICE_SPI": 1, |
mslade | 1:84581acd1333 | 228 | "FSFAT_SDCARD_INSTALLED": 1 |
mslade | 1:84581acd1333 | 229 | }, |
mslade | 1:84581acd1333 | 230 | "target_overrides": { |
mslade | 1:84581acd1333 | 231 | "DISCO_F051R8": { |
mslade | 1:84581acd1333 | 232 | "SPI_MOSI": "SPI_MOSI", |
mslade | 1:84581acd1333 | 233 | "SPI_MISO": "SPI_MISO", |
mslade | 1:84581acd1333 | 234 | "SPI_CLK": "SPI_SCK", |
mslade | 1:84581acd1333 | 235 | "SPI_CS": "SPI_CS" |
mslade | 1:84581acd1333 | 236 | }, |
mslade | 1:84581acd1333 | 237 | "K20D50M": { |
mslade | 1:84581acd1333 | 238 | "SPI_MOSI": "PTD2", |
mslade | 1:84581acd1333 | 239 | "SPI_MISO": "PTD3", |
mslade | 1:84581acd1333 | 240 | "SPI_CLK": "PTD1", |
mslade | 1:84581acd1333 | 241 | "SPI_CS": "PTC2" |
mslade | 1:84581acd1333 | 242 | }, |
mslade | 1:84581acd1333 | 243 | "KL22F": { |
mslade | 1:84581acd1333 | 244 | "SPI_MOSI": "PTD6", |
mslade | 1:84581acd1333 | 245 | "SPI_MISO": "PTD7", |
mslade | 1:84581acd1333 | 246 | "SPI_CLK": "PTD5", |
mslade | 1:84581acd1333 | 247 | "SPI_CS": "PTD4" |
mslade | 1:84581acd1333 | 248 | }, |
mslade | 1:84581acd1333 | 249 | "KL25Z": { |
mslade | 1:84581acd1333 | 250 | "SPI_MOSI": "PTD2", |
mslade | 1:84581acd1333 | 251 | "SPI_MISO": "PTD3", |
mslade | 1:84581acd1333 | 252 | "SPI_CLK": "PTD1", |
mslade | 1:84581acd1333 | 253 | "SPI_CS": "PTD0" |
mslade | 1:84581acd1333 | 254 | }, |
mslade | 1:84581acd1333 | 255 | "KL43Z": { |
mslade | 1:84581acd1333 | 256 | "SPI_MOSI": "PTD6", |
mslade | 1:84581acd1333 | 257 | "SPI_MISO": "PTD7", |
mslade | 1:84581acd1333 | 258 | "SPI_CLK": "PTD5", |
mslade | 1:84581acd1333 | 259 | "SPI_CS": "PTD4" |
mslade | 1:84581acd1333 | 260 | }, |
mslade | 1:84581acd1333 | 261 | "KL46Z": { |
mslade | 1:84581acd1333 | 262 | "SPI_MOSI": "PTD6", |
mslade | 1:84581acd1333 | 263 | "SPI_MISO": "PTD7", |
mslade | 1:84581acd1333 | 264 | "SPI_CLK": "PTD5", |
mslade | 1:84581acd1333 | 265 | "SPI_CS": "PTD4" |
mslade | 1:84581acd1333 | 266 | }, |
mslade | 1:84581acd1333 | 267 | "K64F": { |
mslade | 1:84581acd1333 | 268 | "SPI_MOSI": "PTE3", |
mslade | 1:84581acd1333 | 269 | "SPI_MISO": "PTE1", |
mslade | 1:84581acd1333 | 270 | "SPI_CLK": "PTE2", |
mslade | 1:84581acd1333 | 271 | "SPI_CS": "PTE4" |
mslade | 1:84581acd1333 | 272 | }, |
mslade | 1:84581acd1333 | 273 | "K66F": { |
mslade | 1:84581acd1333 | 274 | "SPI_MOSI": "PTE3", |
mslade | 1:84581acd1333 | 275 | "SPI_MISO": "PTE1", |
mslade | 1:84581acd1333 | 276 | "SPI_CLK": "PTE2", |
mslade | 1:84581acd1333 | 277 | "SPI_CS": "PTE4" |
mslade | 1:84581acd1333 | 278 | }, |
mslade | 1:84581acd1333 | 279 | "LPC11U37H_401": { |
mslade | 1:84581acd1333 | 280 | "SPI_MOSI": "SDMOSI", |
mslade | 1:84581acd1333 | 281 | "SPI_MISO": "SDMISO", |
mslade | 1:84581acd1333 | 282 | "SPI_CLK": "SDSCLK", |
mslade | 1:84581acd1333 | 283 | "SPI_CS": "SDSSEL" |
mslade | 1:84581acd1333 | 284 | }, |
mslade | 1:84581acd1333 | 285 | "LPC2368": { |
mslade | 1:84581acd1333 | 286 | "SPI_MOSI": "p11", |
mslade | 1:84581acd1333 | 287 | "SPI_MISO": "p12", |
mslade | 1:84581acd1333 | 288 | "SPI_CLK": "p13", |
mslade | 1:84581acd1333 | 289 | "SPI_CS": "p14" |
mslade | 1:84581acd1333 | 290 | }, |
mslade | 1:84581acd1333 | 291 | "NUCLEO_L031K6": { |
mslade | 1:84581acd1333 | 292 | "SPI_MOSI": "SPI_MOSI", |
mslade | 1:84581acd1333 | 293 | "SPI_MISO": "SPI_MISO", |
mslade | 1:84581acd1333 | 294 | "SPI_CLK": "SPI_SCK", |
mslade | 1:84581acd1333 | 295 | "SPI_CS": "SPI_CS" |
mslade | 1:84581acd1333 | 296 | }, |
mslade | 1:84581acd1333 | 297 | "nRF51822": { |
mslade | 1:84581acd1333 | 298 | "SPI_MOSI": "p12", |
mslade | 1:84581acd1333 | 299 | "SPI_MISO": "p13", |
mslade | 1:84581acd1333 | 300 | "SPI_CLK": "p15", |
mslade | 1:84581acd1333 | 301 | "SPI_CS": "p14" |
mslade | 1:84581acd1333 | 302 | }, |
mslade | 1:84581acd1333 | 303 | "RZ_A1H": { |
mslade | 1:84581acd1333 | 304 | "SPI_MOSI": "P8_5", |
mslade | 1:84581acd1333 | 305 | "SPI_MISO": "P8_6", |
mslade | 1:84581acd1333 | 306 | "SPI_CLK": "P8_3", |
mslade | 1:84581acd1333 | 307 | "SPI_CS": "P8_4" |
mslade | 1:84581acd1333 | 308 | } |
mslade | 1:84581acd1333 | 309 | } |
mslade | 1:84581acd1333 | 310 | } |
mslade | 1:84581acd1333 | 311 | |
mslade | 1:84581acd1333 | 312 | Note the following things about the `mbed_lib.json` file: |
mslade | 1:84581acd1333 | 313 | |
mslade | 1:84581acd1333 | 314 | - The `mbed_lib.json` file is used to define target specific symbols for the SPI pins connecting the SDCard slot to the target MCU: |
mslade | 1:84581acd1333 | 315 | - "SPI\_CS". This is the Chip Select line. |
mslade | 1:84581acd1333 | 316 | - "SPI\_MOSI". This is the Master Out Slave In data line. |
mslade | 1:84581acd1333 | 317 | - "SPI\_MISO". This is the Master In Slave Out data line. |
mslade | 1:84581acd1333 | 318 | - "SPI\_CLK". This is the serial Clock line. |
mslade | 1:84581acd1333 | 319 | - The default configuration defined in the "config" section is for the standard Arduino header pin mappings for the SPI bus. |
mslade | 1:84581acd1333 | 320 | The "config" section defines a dictionary mapping functional names to target board Arduino header pins: |
mslade | 1:84581acd1333 | 321 | - "SPI\_CS": "D10". This causes the MBED\_CONF\_APP\_SPI\_CS symbol to be defined in mbed\_config.h as D10, which is used in the filesystem test implementation. |
mslade | 1:84581acd1333 | 322 | D10 is defined in the target specific PinNames.h file. |
mslade | 1:84581acd1333 | 323 | - "SPI\_MOSI": "D11". This causes the MBED\_CONF\_APP\_SPI\_MOSI symbol to be defined in mbed\_config.h. |
mslade | 1:84581acd1333 | 324 | - "SPI\_MISO": "D12". This causes the MBED\_CONF\_APP\_SPI\_MISO symbol to be defined in mbed\_config.h. |
mslade | 1:84581acd1333 | 325 | - "SPI\_CLK": "D13". This causes the MBED\_CONF\_APP\_SPI\_CLK symbol to be defined in mbed\_config.h. |
mslade | 1:84581acd1333 | 326 | - The `"target_overrides"` section is used to override the "SPI\_xxx" symbols for specific target boards, which may have an SDCard slot, for example. |
mslade | 1:84581acd1333 | 327 | This is the case for the K64F, where the "SPI\_xxx" are mapped to the pin names for the on-board SDCard. |
mslade | 1:84581acd1333 | 328 | |
mslade | 1:84581acd1333 | 329 | ``` |
mslade | 1:84581acd1333 | 330 | "K64F": { |
mslade | 1:84581acd1333 | 331 | "SPI_MOSI": "PTE3", |
mslade | 1:84581acd1333 | 332 | "SPI_MISO": "PTE1", |
mslade | 1:84581acd1333 | 333 | "SPI_CLK": "PTE2", |
mslade | 1:84581acd1333 | 334 | "SPI_CS": "PTE4" |
mslade | 1:84581acd1333 | 335 | } |
mslade | 1:84581acd1333 | 336 | ``` |
mslade | 1:84581acd1333 | 337 | - Thus, in the absence of any target specific definitions in the `"target_overrides"` section, all boards will default to |
mslade | 1:84581acd1333 | 338 | using the Arduino header configuration. For those platforms with a `"target_overrides"` section then this configuration |
mslade | 1:84581acd1333 | 339 | will be used in preference. |
mslade | 1:84581acd1333 | 340 | - Hence in the case that you want to test a platform with an SDCard inserted into a |
mslade | 1:84581acd1333 | 341 | fitted CI test shield (rather than the on-board SDCard slot) |
mslade | 1:84581acd1333 | 342 | and there is a `"target_overrides"` section present in the `mbed_lib.json` file, you must then delete the `"target_overrides"` |
mslade | 1:84581acd1333 | 343 | section before building. This will result in the default configuration being used (suitable for the CI |
mslade | 1:84581acd1333 | 344 | Test Shield). |
mslade | 1:84581acd1333 | 345 | - Note when inserting the v1.0.0 CI Test Shield into the Arduino header of the target platform, the shield pins D0 and |
mslade | 1:84581acd1333 | 346 | D1 should be bent to be parallel to the shield PCB so they are not inserted into the Arduino header. This is because |
mslade | 1:84581acd1333 | 347 | some boards use the same UART on DAPLINK and D0/D1, which means the serial debug channel breaks and hence the mbed greentea |
mslade | 1:84581acd1333 | 348 | test suite will not work correctly. This is mainly on older ST boards and should not be a problem on |
mslade | 1:84581acd1333 | 349 | `K64F`, `NUCLEO_F429ZI` and `UBLOX_EVK_ODIN_W2`. Note also that the v2.0.0 CI Test Shield doesn't suffer from this |
mslade | 1:84581acd1333 | 350 | problem and the pins don't need to be bent. |
mslade | 1:84581acd1333 | 351 | - When inserting the SDCard into the card slot on the CI test shield, make sure the card is fully inserted. |
mslade | 1:84581acd1333 | 352 | On insertion, there should be a small clicking sound when the card registers, and the back edge of the card |
mslade | 1:84581acd1333 | 353 | should protrude no more than ~1mm over the edge of the CI test shield PCB. If the SDCard fails to register, |
mslade | 1:84581acd1333 | 354 | try gently pushing the metal flexible strip in the shape of a spade at the top edge of the SDCard metal slot |
mslade | 1:84581acd1333 | 355 | casing with a pair of tweezers, bending it a little to lower it into the slot casing. This helps with the |
mslade | 1:84581acd1333 | 356 | insertion mechanism. |
mslade | 1:84581acd1333 | 357 | |
mslade | 1:84581acd1333 | 358 | ### Wiring instructions for target NUCLEO_F429ZI with CI Test Shield |
mslade | 1:84581acd1333 | 359 | ![alt text](docs/pics/NUCLEO_F429ZI_wiring_with_ci_test_shield.png "unseen title text") |
mslade | 1:84581acd1333 | 360 | |
mslade | 1:84581acd1333 | 361 | **Figure 3. The figure shows how to connect the NUCLEO_F429ZI platform with the CI shield.** |
mslade | 1:84581acd1333 | 362 | |
mslade | 1:84581acd1333 | 363 | The above figure shows how to connect the NUCLEO_F429ZI with the v1.0.0 CI test shield. Note: |
mslade | 1:84581acd1333 | 364 | |
mslade | 1:84581acd1333 | 365 | - To get the SD Card to work with this platform the CI test shield cannot be connected directly to this board, instead follow the instructions above. |
mslade | 1:84581acd1333 | 366 | - Any SD-card adapter will work as long as you connect all the relevant pins (MOSI, MISO, SCLK, CS, 3.3V and GND) as illustrated in figure 3. |
mslade | 1:84581acd1333 | 367 | - The SDCard is fully inserted into the slot and overhangs the PCB by ~1mm. |
mslade | 1:84581acd1333 | 368 | |
mslade | 1:84581acd1333 | 369 | # SDBlockDevice Example Application |
mslade | 1:84581acd1333 | 370 | |
mslade | 1:84581acd1333 | 371 | The following sample code illustrates how to use the sd-driver Block Device API: |
mslade | 1:84581acd1333 | 372 | |
mslade | 1:84581acd1333 | 373 | ``` cpp |
mslade | 1:84581acd1333 | 374 | #include "mbed.h" |
mslade | 1:84581acd1333 | 375 | #include "SDBlockDevice.h" |
mslade | 1:84581acd1333 | 376 | |
mslade | 1:84581acd1333 | 377 | // Instantiate the SDBlockDevice by specifying the SPI pins connected to the SDCard |
mslade | 1:84581acd1333 | 378 | // socket. The PINS are: |
mslade | 1:84581acd1333 | 379 | // MOSI (Master Out Slave In) |
mslade | 1:84581acd1333 | 380 | // MISO (Master In Slave Out) |
mslade | 1:84581acd1333 | 381 | // SCLK (Serial Clock) |
mslade | 1:84581acd1333 | 382 | // CS (Chip Select) |
mslade | 1:84581acd1333 | 383 | SDBlockDevice sd(MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO, MBED_CONF_SD_SPI_CLK, MBED_CONF_SD_SPI_CS); |
mslade | 1:84581acd1333 | 384 | uint8_t block[512] = "Hello World!\n"; |
mslade | 1:84581acd1333 | 385 | |
mslade | 1:84581acd1333 | 386 | int main() |
mslade | 1:84581acd1333 | 387 | { |
mslade | 1:84581acd1333 | 388 | // call the SDBlockDevice instance initialisation method. |
mslade | 1:84581acd1333 | 389 | if ( 0 != sd.init()) { |
mslade | 1:84581acd1333 | 390 | printf("Init failed \n"); |
mslade | 1:84581acd1333 | 391 | return -1; |
mslade | 1:84581acd1333 | 392 | } |
mslade | 1:84581acd1333 | 393 | printf("sd size: %llu\n", sd.size()); |
mslade | 1:84581acd1333 | 394 | printf("sd read size: %llu\n", sd.get_read_size()); |
mslade | 1:84581acd1333 | 395 | printf("sd program size: %llu\n", sd.get_program_size()); |
mslade | 1:84581acd1333 | 396 | printf("sd erase size: %llu\n", sd.get_erase_size()); |
mslade | 1:84581acd1333 | 397 | |
mslade | 1:84581acd1333 | 398 | // set the frequency |
mslade | 1:84581acd1333 | 399 | if ( 0 != sd.frequency(5000000)) { |
mslade | 1:84581acd1333 | 400 | printf("Error setting frequency \n"); |
mslade | 1:84581acd1333 | 401 | } |
mslade | 1:84581acd1333 | 402 | |
mslade | 1:84581acd1333 | 403 | if ( 0 != sd.erase(0, sd.get_erase_size())) { |
mslade | 1:84581acd1333 | 404 | printf("Error Erasing block \n"); |
mslade | 1:84581acd1333 | 405 | } |
mslade | 1:84581acd1333 | 406 | |
mslade | 1:84581acd1333 | 407 | // Write some the data block to the device |
mslade | 1:84581acd1333 | 408 | if ( 0 == sd.program(block, 0, 512)) { |
mslade | 1:84581acd1333 | 409 | // read the data block from the device |
mslade | 1:84581acd1333 | 410 | if ( 0 == sd.read(block, 0, 512)) { |
mslade | 1:84581acd1333 | 411 | // print the contents of the block |
mslade | 1:84581acd1333 | 412 | printf("%s", block); |
mslade | 1:84581acd1333 | 413 | } |
mslade | 1:84581acd1333 | 414 | } |
mslade | 1:84581acd1333 | 415 | |
mslade | 1:84581acd1333 | 416 | // call the SDBlockDevice instance de-initialisation method. |
mslade | 1:84581acd1333 | 417 | sd.deinit(); |
mslade | 1:84581acd1333 | 418 | } |
mslade | 1:84581acd1333 | 419 | ``` |
mslade | 1:84581acd1333 | 420 | |
mslade | 1:84581acd1333 | 421 | # SDCard POSIX File API mbed Greentea Test Cases |
mslade | 1:84581acd1333 | 422 | |
mslade | 1:84581acd1333 | 423 | This section describes how to build and run the POSIX file API test cases. |
mslade | 1:84581acd1333 | 424 | The following steps are covered: |
mslade | 1:84581acd1333 | 425 | |
mslade | 1:84581acd1333 | 426 | - [Create the FAT/SDCard Application Project](#create-fat-sdcard-application-project). |
mslade | 1:84581acd1333 | 427 | This section describes how to git clone the mbed OS and sd-driver repositories containing the |
mslade | 1:84581acd1333 | 428 | code and test cases of interest. |
mslade | 1:84581acd1333 | 429 | - [Build the mbed OS Test Cases](#build-the-mbedos-test-cases). This section |
mslade | 1:84581acd1333 | 430 | describes how to build the mbed OS test cases. |
mslade | 1:84581acd1333 | 431 | - [Insert a microSD Card Into the K64F for Greentea Testing](#greentea-insert-sdcard-into-k64f).This section |
mslade | 1:84581acd1333 | 432 | describes how to format (if required) a microSD card prior to running the tests. |
mslade | 1:84581acd1333 | 433 | - [Run the POSIX File Test Case](#run-the-posix-file-test-cases).This section |
mslade | 1:84581acd1333 | 434 | describes how to run the POSIX file test cases. |
mslade | 1:84581acd1333 | 435 | |
mslade | 1:84581acd1333 | 436 | |
mslade | 1:84581acd1333 | 437 | ### <a name="create-fat-sdcard-application-project"></a> Create the FAT/SDCard Application Project |
mslade | 1:84581acd1333 | 438 | |
mslade | 1:84581acd1333 | 439 | This section describes how to create an application project combining the mbed-os and |
mslade | 1:84581acd1333 | 440 | sd-driver repositories into a single project. |
mslade | 1:84581acd1333 | 441 | In summary the following steps will be covered in this section: |
mslade | 1:84581acd1333 | 442 | |
mslade | 1:84581acd1333 | 443 | - A top level application project directory is created. The directory name is ex_app1. |
mslade | 1:84581acd1333 | 444 | - In the ex_app1 directory, the mbed-os repository is cloned. |
mslade | 1:84581acd1333 | 445 | - In the ex_app1 directory at the same level as the mbed-os directory, the sd-driver repository is cloned. |
mslade | 1:84581acd1333 | 446 | - The `mbed_lib.json` file is copied from the `sd-driver/config/mbed_lib.json` to the ex_app1 directory. |
mslade | 1:84581acd1333 | 447 | |
mslade | 1:84581acd1333 | 448 | First create the top level application directory ex_app1 and move into it: |
mslade | 1:84581acd1333 | 449 | |
mslade | 1:84581acd1333 | 450 | shell:/d/demo_area$ mkdir ex_app1 |
mslade | 1:84581acd1333 | 451 | shell:/d/demo_area$ pushd ex_app1 |
mslade | 1:84581acd1333 | 452 | |
mslade | 1:84581acd1333 | 453 | Next, get a clone of public mbed OS repository in the following way: |
mslade | 1:84581acd1333 | 454 | |
mslade | 1:84581acd1333 | 455 | shell:/d/demo_area/ex_app1$ git clone git@github.com:/armmbed/mbed-os |
mslade | 1:84581acd1333 | 456 | <trace removed> |
mslade | 1:84581acd1333 | 457 | shell:/d/demo_area/ex_app1$ |
mslade | 1:84581acd1333 | 458 | |
mslade | 1:84581acd1333 | 459 | Next, get a clone of the sd-driver repository: |
mslade | 1:84581acd1333 | 460 | |
mslade | 1:84581acd1333 | 461 | shell:/d/demo_area/ex_app1$ git clone git@github.com:/armmbed/sd-driver |
mslade | 1:84581acd1333 | 462 | <trace removed> |
mslade | 1:84581acd1333 | 463 | shell:/d/demo_area/ex_app1$ |
mslade | 1:84581acd1333 | 464 | |
mslade | 1:84581acd1333 | 465 | Note: The `mbed_lib.json` file specifies the SPI bus pin configuration for different targets, |
mslade | 1:84581acd1333 | 466 | and is discussed in the [Testing with an SDCard on Target XYZ](#testing-with-an-sdcard-on-target-xyx) section. |
mslade | 1:84581acd1333 | 467 | |
mslade | 1:84581acd1333 | 468 | ### <a name="build-the-mbedos-test-cases"></a> Build the mbed OS Test Cases |
mslade | 1:84581acd1333 | 469 | |
mslade | 1:84581acd1333 | 470 | Build the test cases for the K64F target using the following command: |
mslade | 1:84581acd1333 | 471 | |
mslade | 1:84581acd1333 | 472 | shell:/d/demo_area/ex_app1$ mbed -v test --compile -t GCC_ARM -m K64F |
mslade | 1:84581acd1333 | 473 | <trace removed> |
mslade | 1:84581acd1333 | 474 | shell:/d/demo_area/ex_app1$ |
mslade | 1:84581acd1333 | 475 | |
mslade | 1:84581acd1333 | 476 | The build trace is quite extensive but on a successful build you should see the following output at the end of the log: |
mslade | 1:84581acd1333 | 477 | |
mslade | 1:84581acd1333 | 478 | Build successes: |
mslade | 1:84581acd1333 | 479 | * K64F::GCC_ARM::MBED-BUILD |
mslade | 1:84581acd1333 | 480 | * K64F::GCC_ARM::MBED-OS-FEATURES-FEATURE_LWIP-TESTS-MBEDMICRO-NET-CONNECTIVITY |
mslade | 1:84581acd1333 | 481 | <trace removed> |
mslade | 1:84581acd1333 | 482 | * K64F::GCC_ARM::MBED-OS-FEATURES-TESTS-FILESYSTEM-FAT_FILE_SYSTEM |
mslade | 1:84581acd1333 | 483 | * K64F::GCC_ARM::MBED-OS-FEATURES-TESTS-FILESYSTEM-HEAP_BLOCK_DEVICE |
mslade | 1:84581acd1333 | 484 | * K64F::GCC_ARM::MBED-OS-FEATURES-TESTS-FILESYSTEM-UTIL_BLOCK_DEVICE |
mslade | 1:84581acd1333 | 485 | <trace removed> |
mslade | 1:84581acd1333 | 486 | * K64F::GCC_ARM::SD-DRIVER-TESTS-FILESYSTEM-BASIC |
mslade | 1:84581acd1333 | 487 | * K64F::GCC_ARM::SD-DRIVER-TESTS-FILESYSTEM-FOPEN |
mslade | 1:84581acd1333 | 488 | * K64F::GCC_ARM::SD-DRIVER-TESTS-BLOCK_DEVICE-BASIC |
mslade | 1:84581acd1333 | 489 | |
mslade | 1:84581acd1333 | 490 | Build skips: |
mslade | 1:84581acd1333 | 491 | * K64F::GCC_ARM::MBED-OS-FEATURES-FEATURE_LWIP-TESTS-MBEDMICRO-NET-TCP_PACKET_PRESSURE |
mslade | 1:84581acd1333 | 492 | <trace removed> |
mslade | 1:84581acd1333 | 493 | |
mslade | 1:84581acd1333 | 494 | |
mslade | 1:84581acd1333 | 495 | Notice the following tests in the sd-driver tree are listed above: |
mslade | 1:84581acd1333 | 496 | |
mslade | 1:84581acd1333 | 497 | - `K64F::GCC_ARM::SD-DRIVER-TESTS-FILESYSTEM-BASIC` |
mslade | 1:84581acd1333 | 498 | - `K64F::GCC_ARM::SD-DRIVER-TESTS-FILESYSTEM-FOPEN` |
mslade | 1:84581acd1333 | 499 | - `K64F::GCC_ARM::SD-DRIVER-TESTS-BLOCK_DEVICE-BASIC` |
mslade | 1:84581acd1333 | 500 | |
mslade | 1:84581acd1333 | 501 | The FAT32/SDCard test cases are at following locations in the source code tree: |
mslade | 1:84581acd1333 | 502 | |
mslade | 1:84581acd1333 | 503 | /d/demo_area/ex_app1/sd-driver/TESTS/filesystem/basic/basic.cpp |
mslade | 1:84581acd1333 | 504 | /d/demo_area/ex_app1/sd-driver/TESTS/filesystem/fopen/fopen.cpp |
mslade | 1:84581acd1333 | 505 | /d/demo_area/ex_app1/sd-driver/TESTS/block_device/basic/basic.cpp |
mslade | 1:84581acd1333 | 506 | |
mslade | 1:84581acd1333 | 507 | #### <a name="settting-repos-to-compatible-versions"></a> Setting mbed-os/sd-driver Repositories To Compatible Versions |
mslade | 1:84581acd1333 | 508 | |
mslade | 1:84581acd1333 | 509 | The sd-driver master HEAD and the mbed-os master HEAD should be compatible |
mslade | 1:84581acd1333 | 510 | with one another and therefore no specific tagged versions need to be checked out. |
mslade | 1:84581acd1333 | 511 | However, in the case that you experience problems building, checkout out the compatible |
mslade | 1:84581acd1333 | 512 | tagged version of each repository, as shown below: |
mslade | 1:84581acd1333 | 513 | |
mslade | 1:84581acd1333 | 514 | shell:/d/demo_area/ex_app1$ pushd mbed-os |
mslade | 1:84581acd1333 | 515 | shell:/d/demo_area/ex_app1$ git checkout tags/mbed-os-5.4.0 |
mslade | 1:84581acd1333 | 516 | shell:/d/demo_area/ex_app1$ popd |
mslade | 1:84581acd1333 | 517 | shell:/d/demo_area/ex_app1$ pushd sd-driver |
mslade | 1:84581acd1333 | 518 | shell:/d/demo_area/ex_app1$ git checkout tags/sd-driver-0.0.2-mbed-os-5.4.0 |
mslade | 1:84581acd1333 | 519 | shell:/d/demo_area/ex_app1$ popd |
mslade | 1:84581acd1333 | 520 | |
mslade | 1:84581acd1333 | 521 | In the above: |
mslade | 1:84581acd1333 | 522 | |
mslade | 1:84581acd1333 | 523 | - `mbed-os-5.4.0` should be replaced with the latest mbed-os release tag. |
mslade | 1:84581acd1333 | 524 | - For an mbed-os release tag `mbed-os-x.y.z`, use the equivalent sd-driver tag `sd-driver-a.b.c-mbed-os-x.y.z` |
mslade | 1:84581acd1333 | 525 | where `a.b.c` is the latest version code for the `mbed-os-x.y.z` tag. |
mslade | 1:84581acd1333 | 526 | |
mslade | 1:84581acd1333 | 527 | ### <a name="greentea-insert-sdcard-into-k64f"></a> Insert SDCard into K64F for Greentea Testing |
mslade | 1:84581acd1333 | 528 | |
mslade | 1:84581acd1333 | 529 | See the previous section for [Insert SDCard into K64F](#insert-sdcard-into-k64f) for details. |
mslade | 1:84581acd1333 | 530 | |
mslade | 1:84581acd1333 | 531 | |
mslade | 1:84581acd1333 | 532 | ### <a name="run-the-posix-file-test-cases"></a> Run the POSIX File Test Case |
mslade | 1:84581acd1333 | 533 | |
mslade | 1:84581acd1333 | 534 | To setup for running the test cases, connect the K64F development board to your |
mslade | 1:84581acd1333 | 535 | PC using a suitable USB cable. |
mslade | 1:84581acd1333 | 536 | |
mslade | 1:84581acd1333 | 537 | All tests can be run using the following command: |
mslade | 1:84581acd1333 | 538 | |
mslade | 1:84581acd1333 | 539 | shell:/d/demo_area/ex_app1$ mbedgt -VS |
mslade | 1:84581acd1333 | 540 | <trace removed> |
mslade | 1:84581acd1333 | 541 | |
mslade | 1:84581acd1333 | 542 | However, it's possible to run a particular test case using the following form of the mbedgt command: |
mslade | 1:84581acd1333 | 543 | |
mslade | 1:84581acd1333 | 544 | shell:/d/demo_area/ex_app1$ mbedgt -VS --test-by-names=<test-name> |
mslade | 1:84581acd1333 | 545 | |
mslade | 1:84581acd1333 | 546 | The names of the tests can be listed using: |
mslade | 1:84581acd1333 | 547 | |
mslade | 1:84581acd1333 | 548 | shell:/d/demo_area/ex_app1$ mbedgt -VS --list |
mslade | 1:84581acd1333 | 549 | |
mslade | 1:84581acd1333 | 550 | For example, to run the basic test use: |
mslade | 1:84581acd1333 | 551 | |
mslade | 1:84581acd1333 | 552 | shell:/d/demo_area/ex_app1$ mbedgt -VS --test-by-names=sd-driver-tests-filesystem-basic |
mslade | 1:84581acd1333 | 553 | |
mslade | 1:84581acd1333 | 554 | To run the fopen test use: |
mslade | 1:84581acd1333 | 555 | |
mslade | 1:84581acd1333 | 556 | shell:/d/demo_area/ex_app1$ mbedgt -VS --test-by-names=sd-driver-tests-filesystem-fopen |
mslade | 1:84581acd1333 | 557 | |
mslade | 1:84581acd1333 | 558 | On a successful run, results similar to the following will be shown: |
mslade | 1:84581acd1333 | 559 | |
mslade | 1:84581acd1333 | 560 | mbedgt: test suite report: |
mslade | 1:84581acd1333 | 561 | +--------------+---------------+-------------------------------------------+--------+--------------------+-------------+ |
mslade | 1:84581acd1333 | 562 | | target | platform_name | test suite | result | elapsed_time (sec) | copy_method | |
mslade | 1:84581acd1333 | 563 | +--------------+---------------+-------------------------------------------+--------+--------------------+-------------+ |
mslade | 1:84581acd1333 | 564 | | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | OK | 151.46 | shell | |
mslade | 1:84581acd1333 | 565 | +--------------+---------------+-------------------------------------------+--------+--------------------+-------------+ |
mslade | 1:84581acd1333 | 566 | mbedgt: test suite results: 1 OK |
mslade | 1:84581acd1333 | 567 | mbedgt: test case report: |
mslade | 1:84581acd1333 | 568 | +--------------+---------------+------------------------------------+----------------------------------------------------------------------------------------+--------+--------+--------+--------------------+ |
mslade | 1:84581acd1333 | 569 | | target | platform_name | test suite | test case | passed | failed | result | elapsed_time (sec) | |
mslade | 1:84581acd1333 | 570 | +--------------+---------------+------------------------------------+----------------------------------------------------------------------------------------+--------+--------+--------+--------------------+ |
mslade | 1:84581acd1333 | 571 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_01: fopen()/fwrite()/fclose() directories/file in multi-dir filepath. | 1 | 0 | OK | 7.57 | |
mslade | 1:84581acd1333 | 572 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_02: fopen(r) pre-existing file try to write it. | 1 | 0 | OK | 0.2 | |
mslade | 1:84581acd1333 | 573 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_03: fopen(w+) pre-existing file try to write it. | 1 | 0 | OK | 0.41 | |
mslade | 1:84581acd1333 | 574 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_04: fopen() with a filename exceeding the maximum length. | 1 | 0 | OK | 0.11 | |
mslade | 1:84581acd1333 | 575 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_06: fopen() with bad filenames (minimal). | 1 | 0 | OK | 0.1 | |
mslade | 1:84581acd1333 | 576 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_07: fopen()/errno handling. | 1 | 0 | OK | 0.07 | |
mslade | 1:84581acd1333 | 577 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_08: ferror()/clearerr()/errno handling. | 1 | 0 | OK | 0.1 | |
mslade | 1:84581acd1333 | 578 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_09: ftell() handling. | 1 | 0 | OK | 0.17 | |
mslade | 1:84581acd1333 | 579 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_10: remove() test. | 1 | 0 | OK | 1.28 | |
mslade | 1:84581acd1333 | 580 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_11: rename(). | 1 | 0 | OK | 2.3 | |
mslade | 1:84581acd1333 | 581 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_12: opendir(), readdir(), closedir() test. | 1 | 0 | OK | 3.57 | |
mslade | 1:84581acd1333 | 582 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_13: mkdir() test. | 1 | 0 | OK | 1.21 | |
mslade | 1:84581acd1333 | 583 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_14: stat() test. | 1 | 0 | OK | 1.47 | |
mslade | 1:84581acd1333 | 584 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_15: format() test. | 1 | 0 | OK | 26.12 | |
mslade | 1:84581acd1333 | 585 | | K64F-GCC_ARM | K64F | sd-driver-tests-filesystem-fopen | FSFAT_FOPEN_TEST_16: write/check n x 25kB data files. | 1 | 0 | OK | 87.11 | |
mslade | 1:84581acd1333 | 586 | +--------------+---------------+------------------------------------+----------------------------------------------------------------------------------------+--------+--------+--------+--------------------+ |
mslade | 1:84581acd1333 | 587 | mbedgt: test case results: 15 OK |
mslade | 1:84581acd1333 | 588 | mbedgt: completed in 152.35 sec |
mslade | 1:84581acd1333 | 589 | |
mslade | 1:84581acd1333 | 590 | |
mslade | 1:84581acd1333 | 591 | # <a name="summary-posix-api-documentation"></a> Summary of POSIX File API Documentation |
mslade | 1:84581acd1333 | 592 | |
mslade | 1:84581acd1333 | 593 | ### POSIX File API |
mslade | 1:84581acd1333 | 594 | |
mslade | 1:84581acd1333 | 595 | mbed OS supports a subset of the POSIX File API, as outlined below: |
mslade | 1:84581acd1333 | 596 | |
mslade | 1:84581acd1333 | 597 | - [clearerr()](https://linux.die.net/man/3/clearerr). |
mslade | 1:84581acd1333 | 598 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 599 | - [fclose()](https://linux.die.net/man/3/fclose). |
mslade | 1:84581acd1333 | 600 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 601 | - [ferror()](https://linux.die.net/man/3/clearerr). |
mslade | 1:84581acd1333 | 602 | - STATUS: Basic testing implemented. |
mslade | 1:84581acd1333 | 603 | - STATUS: GCC_ARM: Working. |
mslade | 1:84581acd1333 | 604 | - STATUS: ARMCC: ARMCC has problem with ferror(filep) where filep is NULL. Appears to work for non-NULL pointer. |
mslade | 1:84581acd1333 | 605 | - [fgetc()](https://linux.die.net/man/3/fgets). |
mslade | 1:84581acd1333 | 606 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 607 | - [fgets()](https://linux.die.net/man/3/fgets). |
mslade | 1:84581acd1333 | 608 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 609 | - [fputc()](https://linux.die.net/man/3/fputs). |
mslade | 1:84581acd1333 | 610 | - STATUS: Unknown. |
mslade | 1:84581acd1333 | 611 | - [fputs()](https://linux.die.net/man/3/fputs). |
mslade | 1:84581acd1333 | 612 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 613 | - [fprintf()](https://linux.die.net/man/3/fprintf). |
mslade | 1:84581acd1333 | 614 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 615 | - [fopen()](https://linux.die.net/man/3/fopen). |
mslade | 1:84581acd1333 | 616 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 617 | - [freopen()](https://linux.die.net/man/3/fopen). |
mslade | 1:84581acd1333 | 618 | - STATUS: This is not tested. |
mslade | 1:84581acd1333 | 619 | - [fread()](https://linux.die.net/man/3/fread). |
mslade | 1:84581acd1333 | 620 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 621 | - STATUS: n x 25kB stress test working. |
mslade | 1:84581acd1333 | 622 | - [ftell()](https://linux.die.net/man/3/ftell). |
mslade | 1:84581acd1333 | 623 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 624 | - [fwrite()](https://linux.die.net/man/3/fwrite). |
mslade | 1:84581acd1333 | 625 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 626 | - STATUS: n x 25kB stress test working. |
mslade | 1:84581acd1333 | 627 | - [fseek()](https://linux.die.net/man/3/fseek) |
mslade | 1:84581acd1333 | 628 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 629 | - [getc()](https://linux.die.net/man/3/fgets). |
mslade | 1:84581acd1333 | 630 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 631 | - [gets()](https://linux.die.net/man/3/fgets). |
mslade | 1:84581acd1333 | 632 | - STATUS: Unknown. |
mslade | 1:84581acd1333 | 633 | - [putc()](https://linux.die.net/man/3/fputs). |
mslade | 1:84581acd1333 | 634 | - STATUS: Unknown. |
mslade | 1:84581acd1333 | 635 | - [puts()](https://linux.die.net/man/3/fputs). |
mslade | 1:84581acd1333 | 636 | - STATUS: Unknown. |
mslade | 1:84581acd1333 | 637 | - [remove()](https://linux.die.net/man/3/remove) |
mslade | 1:84581acd1333 | 638 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 639 | - [rewind()](https://linux.die.net/man/3/rewind). |
mslade | 1:84581acd1333 | 640 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 641 | - [stat()](https://linux.die.net/man/2/stat) |
mslade | 1:84581acd1333 | 642 | - STATUS: Implemented. Working. |
mslade | 1:84581acd1333 | 643 | - STATUS: Not supported by ARMCC/IAR libc. |
mslade | 1:84581acd1333 | 644 | - [tmpfile()](https://linux.die.net/man/3/tmpfile). |
mslade | 1:84581acd1333 | 645 | - STATUS: Not implemented. |
mslade | 1:84581acd1333 | 646 | - [tmpnam()](https://linux.die.net/man/3/tmpnam). |
mslade | 1:84581acd1333 | 647 | - STATUS: Not implemented. |
mslade | 1:84581acd1333 | 648 | |
mslade | 1:84581acd1333 | 649 | Supported directory related operations are as follows: |
mslade | 1:84581acd1333 | 650 | |
mslade | 1:84581acd1333 | 651 | - [closedir()](https://linux.die.net/man/3/closedir). |
mslade | 1:84581acd1333 | 652 | - STATUS: Implemented. Working. |
mslade | 1:84581acd1333 | 653 | - [mkdir()](https://linux.die.net/man/3/mkdir). |
mslade | 1:84581acd1333 | 654 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 655 | - [opendir()](https://linux.die.net/man/3/opendir). |
mslade | 1:84581acd1333 | 656 | - STATUS: Implemented. Working. |
mslade | 1:84581acd1333 | 657 | - [readdir()](https://linux.die.net/man/3/readdir). |
mslade | 1:84581acd1333 | 658 | - STATUS: Implemented. Working. |
mslade | 1:84581acd1333 | 659 | - [remove()](https://linux.die.net/man/3/remove). |
mslade | 1:84581acd1333 | 660 | - STATUS: Basic testing implemented. Working. |
mslade | 1:84581acd1333 | 661 | - [rename()](https://linux.die.net/man/3/rename). |
mslade | 1:84581acd1333 | 662 | - STATUS: Implemented. Not tested. |
mslade | 1:84581acd1333 | 663 | - [rewinddir()](https://linux.die.net/man/3/rewinddir). |
mslade | 1:84581acd1333 | 664 | - STATUS: Implemented. Found not to work. Test case not present in repo. |
mslade | 1:84581acd1333 | 665 | - [seekdir()](https://linux.die.net/man/3/seekdir). |
mslade | 1:84581acd1333 | 666 | - STATUS: Implemented. Found not to work. Test case not present in repo. |
mslade | 1:84581acd1333 | 667 | - [telldir()](https://linux.die.net/man/3/telldir). |
mslade | 1:84581acd1333 | 668 | - STATUS: Implemented. Found not to work. Test case not present in repo. |
mslade | 1:84581acd1333 | 669 | |
mslade | 1:84581acd1333 | 670 | ### errno |
mslade | 1:84581acd1333 | 671 | |
mslade | 1:84581acd1333 | 672 | Basic errno reporting is supported, tested and known to be working. |
mslade | 1:84581acd1333 | 673 | |
mslade | 1:84581acd1333 | 674 | |
mslade | 1:84581acd1333 | 675 | # Related Projects Resources |
mslade | 1:84581acd1333 | 676 | |
mslade | 1:84581acd1333 | 677 | The following are related mbed storage projects and useful resources: |
mslade | 1:84581acd1333 | 678 | |
mslade | 1:84581acd1333 | 679 | - The [mbed-os](https://github.com/ARMmbed/mbed-os) main repository. |
mslade | 1:84581acd1333 | 680 | - The [mbed-os-example-fat-filesystem](https://github.com/ARMmbed/mbed-os-example-fat-filesystem) repository. |
mslade | 1:84581acd1333 | 681 | This is an example project for the mbed OS FAT filesystem. |
mslade | 1:84581acd1333 | 682 | - The [spiflash-driver](https://github.com/armmbed/spiflash-driver) repository. |
mslade | 1:84581acd1333 | 683 | - The [i2ceeprom-driver](https://github.com/ARMmbed/i2ceeprom-driver.git) repository. |
mslade | 1:84581acd1333 | 684 | - The [ci-test-shield](https://github.com/ARMmbed/ci-test-shield) repository. This is the project describing |
mslade | 1:84581acd1333 | 685 | the mbed-os Continuous Integration test shield, together with standard tests. |
mslade | 1:84581acd1333 | 686 | - The [mbed-HDK](https://github.com/ARMmbed/mbed-HDK) repository containing Hardware Development Kit resources |
mslade | 1:84581acd1333 | 687 | including the schematics for the CI test shield. |
mslade | 1:84581acd1333 | 688 | - [POSIX File Interface ISO/IEC 9899:TC2 Documentation](http://www.eng.utah.edu/~cs5785/slides-f10/n1124.pdf). |
mslade | 1:84581acd1333 | 689 | - [FATFS: Generic FAT File System Module used in mbed OS](http://elm-chan.org/fsw/ff/00index_e.html) |