ELEC351 SUBMISSION - Same as on the DLE

/media/uploads/Luka_Danilovic/elec_315_prototype_assembly.jpg

Committer:
Luka_Danilovic
Date:
Wed Jan 10 09:49:43 2018 +0000
Revision:
0:c66224a27cf8
ELEC351 SUBMISSION - SAme as on the DLE

Who changed what in which revision?

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