Fork of https://github.com/ARMmbed/sd-driver. Added pin config for MAX32630FTHR

Dependents:   CircularBufferSDCardLib time_between_inerupt

Committer:
DVLevine
Date:
Tue Mar 20 17:35:00 2018 +0000
Revision:
0:69bfc1595ae5
Initial commit

Who changed what in which revision?

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