High-speed access version sd-driver.

Dependents:   SDBlockDevice_GR_PEACH SDBlockDevice_GR_PEACH HagridOS5

This library has modified SDBlockDevice.h based on revision "14: c7dba87" of sd-driver.
https://github.com/ARMmbed/sd-driver

Committer:
dkato
Date:
Thu Mar 23 08:25:54 2017 +0000
Revision:
0:b22a1df967cb
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:b22a1df967cb 1 # mbed OS SDCard Driver (sd-driver) for FAT32 Filesystem Support
dkato 0:b22a1df967cb 2
dkato 0:b22a1df967cb 3
dkato 0:b22a1df967cb 4 Simon Hughes
dkato 0:b22a1df967cb 5
dkato 0:b22a1df967cb 6 20170329
dkato 0:b22a1df967cb 7
dkato 0:b22a1df967cb 8 Version 1.00
dkato 0:b22a1df967cb 9
dkato 0:b22a1df967cb 10
dkato 0:b22a1df967cb 11 # Executive Summary
dkato 0:b22a1df967cb 12
dkato 0:b22a1df967cb 13 The purpose of this document is to describe how to use the mbed OS SDCard
dkato 0:b22a1df967cb 14 driver (sd-driver) so applications can read/write
dkato 0:b22a1df967cb 15 data to flash storage cards using the standard POSIX File API
dkato 0:b22a1df967cb 16 programming interface. The sd-driver uses the SDCard SPI-mode of operation
dkato 0:b22a1df967cb 17 which is a subset of possible SDCard functionality.
dkato 0:b22a1df967cb 18
dkato 0:b22a1df967cb 19 This repository contains the mbed-os SDCard driver for generic SPI
dkato 0:b22a1df967cb 20 SDCard support and other resources, as outlined below:
dkato 0:b22a1df967cb 21
dkato 0:b22a1df967cb 22 - `SDBlockDevice.h` and `SDBlockDevice.cpp`. This is the SDCard driver module presenting
dkato 0:b22a1df967cb 23 a Block Device API (derived from BlockDevice) to the underlying SDCard.
dkato 0:b22a1df967cb 24 - POSIX File API test cases for testing the FAT32 filesystem on SDCard.
dkato 0:b22a1df967cb 25 - basic.cpp, a basic set of functional test cases.
dkato 0:b22a1df967cb 26 - fopen.cpp, more functional tests reading/writing greater volumes of data to SDCard, for example.
dkato 0:b22a1df967cb 27 - `mbed_app.json` mbed-os application configuration file with SPI pin configurations for the CI shield and overrides for specific targets.
dkato 0:b22a1df967cb 28 This file allows the SPI pins to be specified for the target without having to edit the implementation files.
dkato 0:b22a1df967cb 29 - This README which includes [Summary of POSIX File API Documentation](#summary-posix-api-documentation)
dkato 0:b22a1df967cb 30 including detailed instruction on how to use the FAT filesystem and SDBlockDevice driver.
dkato 0:b22a1df967cb 31
dkato 0:b22a1df967cb 32 The SDCard driver is maintained in this repository as a component separate from the main mbed OS repository.
dkato 0:b22a1df967cb 33 Hence the 2 repositories (mbed-os and sd-driver) have to be used together
dkato 0:b22a1df967cb 34 to deliver the FAT32 Filesystem/SDCard support. This document explains how to do this.
dkato 0:b22a1df967cb 35
dkato 0:b22a1df967cb 36
dkato 0:b22a1df967cb 37 # Introduction
dkato 0:b22a1df967cb 38
dkato 0:b22a1df967cb 39 ### Overview
dkato 0:b22a1df967cb 40
dkato 0:b22a1df967cb 41 The scope of this document is to describe how applications use the FAT filesystem and sd-driver
dkato 0:b22a1df967cb 42 components to persistently store data on SDCards. The document is intended to help developers adopt the
dkato 0:b22a1df967cb 43 mbed OS POSIX File API support, and in particular to help explain:
dkato 0:b22a1df967cb 44
dkato 0:b22a1df967cb 45 - How the software components work together to deliver the storage functionality.
dkato 0:b22a1df967cb 46 - How to work with the sd-driver and mbed OS to build the examples. The example code can easily
dkato 0:b22a1df967cb 47 be copied into your new application code.
dkato 0:b22a1df967cb 48 - How to work with the CI Test Shield, which adds an SDCard slot to those targets that do not have already have one.
dkato 0:b22a1df967cb 49 - How to run the POSIX File API mbed Greentea test cases, which provide further example code of how to use
dkato 0:b22a1df967cb 50 the POSIX File API.
dkato 0:b22a1df967cb 51
dkato 0:b22a1df967cb 52 Section 1 provides an Executive Summary, describing the purpose of the sd-driver, the supporting
dkato 0:b22a1df967cb 53 software, examples, test cases and documentation.
dkato 0:b22a1df967cb 54
dkato 0:b22a1df967cb 55 Section 2 provides an an overview of the material covered including descriptions of the major sections.
dkato 0:b22a1df967cb 56
dkato 0:b22a1df967cb 57 Section 3 provides an overview of the mbed OS filesystem software components,
dkato 0:b22a1df967cb 58 including the inter-relationships between the application, POSIX file API, the standard c-library,
dkato 0:b22a1df967cb 59 the mbed OS filesystem and the SDCard driver (sd-driver).
dkato 0:b22a1df967cb 60
dkato 0:b22a1df967cb 61 Section 4 describes how to build and run an example application for reading
dkato 0:b22a1df967cb 62 and writing data to an SDCard using the POSIX File API. The example begins by describing
dkato 0:b22a1df967cb 63 the procedure for building and testing on the K64F target. The final sub-sections
dkato 0:b22a1df967cb 64 describe how to use the test shield to add an SDCard slot to any mbed target,
dkato 0:b22a1df967cb 65 and hence enable the persistent storage of data on any supported target.
dkato 0:b22a1df967cb 66
dkato 0:b22a1df967cb 67 Section 5 describes an example application which uses the raw
dkato 0:b22a1df967cb 68 BlockDevice API to read and write data to the SDCard.
dkato 0:b22a1df967cb 69
dkato 0:b22a1df967cb 70 Section 6 describes how to build and run the SDCard POSIX File API mbed Greentea test cases.
dkato 0:b22a1df967cb 71 There are a number of functional test cases demonstrating how to use the
dkato 0:b22a1df967cb 72 mbed OS POSIX File API.
dkato 0:b22a1df967cb 73
dkato 0:b22a1df967cb 74 Section 7 describes the POSIX File API and provides links to useful API documentation web pages.
dkato 0:b22a1df967cb 75
dkato 0:b22a1df967cb 76
dkato 0:b22a1df967cb 77 ### Known mbed-os and sd-driver Compatible Versions
dkato 0:b22a1df967cb 78
dkato 0:b22a1df967cb 79 The following versions of the mbed-os and sd-driver repositories are known to work together:
dkato 0:b22a1df967cb 80
dkato 0:b22a1df967cb 81 - {mbed-os, sd-driver} = {mbed-os-5.4.0-rc2, sd-driver-0.0.1-mbed-os-5.4.0-rc2}.
dkato 0:b22a1df967cb 82 `K64F`, `NUCLEO_F429ZI` and `UBLOX_EVK_ODIN_W2` fopen and basic filesystem tests working.
dkato 0:b22a1df967cb 83 - {mbed-os, sd-driver} = {mbed-os-5.4.0, sd-driver-0.0.2-mbed-os-5.4.0}.
dkato 0:b22a1df967cb 84 `K64F`, `NUCLEO_F429ZI` and `UBLOX_EVK_ODIN_W2` fopen and basic filesystem tests working.
dkato 0:b22a1df967cb 85 - {mbed-os, sd-driver} = {mbed-os-5.4.1, sd-driver-0.0.3-mbed-os-5.4.1}.
dkato 0:b22a1df967cb 86
dkato 0:b22a1df967cb 87 To find the latest compatible versions, use the following command to see the messages attached to the tags
dkato 0:b22a1df967cb 88 in the sd-driver repository:
dkato 0:b22a1df967cb 89
dkato 0:b22a1df967cb 90 ex_app7/$ cd sd-driver
dkato 0:b22a1df967cb 91 ex_app7/sd-driver$ git tag -n
dkato 0:b22a1df967cb 92 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.
dkato 0:b22a1df967cb 93 sd-driver-0.0.2-mbed-os-5.4.0 Updated README.md to include worked exmaples and restructuring of information.
dkato 0:b22a1df967cb 94 sd-driver-0.0.3-mbed-os-5.4.1 Version compatible with mbed-os-5.4.1.
dkato 0:b22a1df967cb 95
dkato 0:b22a1df967cb 96
dkato 0:b22a1df967cb 97 ### Known Issues With This Document
dkato 0:b22a1df967cb 98
dkato 0:b22a1df967cb 99 There are no known issues with this document.
dkato 0:b22a1df967cb 100
dkato 0:b22a1df967cb 101
dkato 0:b22a1df967cb 102 # Overview of mbed OS Filesystem Software Component Stack
dkato 0:b22a1df967cb 103
dkato 0:b22a1df967cb 104
dkato 0:b22a1df967cb 105 ------------------------
dkato 0:b22a1df967cb 106 | |
dkato 0:b22a1df967cb 107 | Application | // This application uses the POSIX File API
dkato 0:b22a1df967cb 108 | | // to read/write data to persistent storage backends.
dkato 0:b22a1df967cb 109 ------------------------
dkato 0:b22a1df967cb 110
dkato 0:b22a1df967cb 111 ------------------------ // POSIX File API (ISO).
dkato 0:b22a1df967cb 112
dkato 0:b22a1df967cb 113 ------------------------
dkato 0:b22a1df967cb 114 | |
dkato 0:b22a1df967cb 115 | libc | // The standard c library implementation
dkato 0:b22a1df967cb 116 | | // e.g. newlib.
dkato 0:b22a1df967cb 117 ------------------------
dkato 0:b22a1df967cb 118
dkato 0:b22a1df967cb 119 ------------------------ // sys_xxx equivalent API.
dkato 0:b22a1df967cb 120
dkato 0:b22a1df967cb 121 ------------------------
dkato 0:b22a1df967cb 122 | |
dkato 0:b22a1df967cb 123 | mbed_retarget.cpp | // Target specific mapping layer.
dkato 0:b22a1df967cb 124 | |
dkato 0:b22a1df967cb 125 ------------------------
dkato 0:b22a1df967cb 126
dkato 0:b22a1df967cb 127 ------------------------ // Filesystem Upper Edge API.
dkato 0:b22a1df967cb 128
dkato 0:b22a1df967cb 129 ------------------------
dkato 0:b22a1df967cb 130 | |
dkato 0:b22a1df967cb 131 | File System | // File system wrappers and implementation.
dkato 0:b22a1df967cb 132 | |
dkato 0:b22a1df967cb 133 ------------------------
dkato 0:b22a1df967cb 134
dkato 0:b22a1df967cb 135 ------------------------ // FS Lower Edge API (Block Store Interface).
dkato 0:b22a1df967cb 136
dkato 0:b22a1df967cb 137 ------------------------
dkato 0:b22a1df967cb 138 | Block API |
dkato 0:b22a1df967cb 139 | Device Driver | // The SDCard driver, for example.
dkato 0:b22a1df967cb 140 | e.g. sd-driver |
dkato 0:b22a1df967cb 141 ------------------------
dkato 0:b22a1df967cb 142
dkato 0:b22a1df967cb 143 ------------------------ // SPI.h interface.
dkato 0:b22a1df967cb 144
dkato 0:b22a1df967cb 145 ------------------------
dkato 0:b22a1df967cb 146 | |
dkato 0:b22a1df967cb 147 | SPI | // SPI subsystem (C++ classes and C-HAL implementation).
dkato 0:b22a1df967cb 148 | |
dkato 0:b22a1df967cb 149 ------------------------
dkato 0:b22a1df967cb 150
dkato 0:b22a1df967cb 151 Figure 1. mbedOS generic architecture of filesystem software stack.
dkato 0:b22a1df967cb 152
dkato 0:b22a1df967cb 153 The figure above shows the mbed OS software component stack used for data
dkato 0:b22a1df967cb 154 storage on SDCard:
dkato 0:b22a1df967cb 155
dkato 0:b22a1df967cb 156 - At the top level is the application component which uses the standard POSIX File API
dkato 0:b22a1df967cb 157 to read and write application data to persistent storage.
dkato 0:b22a1df967cb 158 - The newlib standard library (libc) stdio.h interface (POSIX File API)
dkato 0:b22a1df967cb 159 implementation is used as it's optimised for resource limited embedded systems.
dkato 0:b22a1df967cb 160 - mbed_retarget.cpp implements the libc back-end file OS handlers and maps them
dkato 0:b22a1df967cb 161 to the FileSystem.
dkato 0:b22a1df967cb 162 - The File System code (hosted in mbed-os) is composed of 2 parts:
dkato 0:b22a1df967cb 163 - The mbed OS file system wrapper classes (e.g. FileSystem, File, FileBase classes)
dkato 0:b22a1df967cb 164 which are used to present a consistent API to the retarget module for different
dkato 0:b22a1df967cb 165 (third-party) file system implementations.
dkato 0:b22a1df967cb 166 - The FAT filesystem implementation code.
dkato 0:b22a1df967cb 167 The [FATFS: Generic FAT File System Module](http://elm-chan.org/fsw/ff/00index_e.html)
dkato 0:b22a1df967cb 168 (ChanFS) has been integrated within mbed-os.
dkato 0:b22a1df967cb 169 - The Block API Device Driver. The SDCard driver is an example of a persistent storage driver.
dkato 0:b22a1df967cb 170 It's maintained as a separate component from the mbed OS repository (in this repository).
dkato 0:b22a1df967cb 171 - The SPI module provides the mbed OS generic SPI API. This functionality is maintained in
dkato 0:b22a1df967cb 172 mbed OS.
dkato 0:b22a1df967cb 173
dkato 0:b22a1df967cb 174
dkato 0:b22a1df967cb 175 # SDCard POSIX File API Example App for Reading/Writing Data
dkato 0:b22a1df967cb 176
dkato 0:b22a1df967cb 177 ### Overview
dkato 0:b22a1df967cb 178
dkato 0:b22a1df967cb 179 This section describes how to build and run an example application that
dkato 0:b22a1df967cb 180 uses the POSIX File API to read and write data to SDCard. The discussion begins by
dkato 0:b22a1df967cb 181 descibing how to run the example on the FRDM K64F target, but this is later
dkato 0:b22a1df967cb 182 generalised to all target platforms that have the standard
dkato 0:b22a1df967cb 183 Arduino form factor headers. Tthe Continuous Integration (CI) Test Shield
dkato 0:b22a1df967cb 184 can be inserted into the headers to add a SDCard slot to the target.
dkato 0:b22a1df967cb 185
dkato 0:b22a1df967cb 186 The example code is a modified version of the
dkato 0:b22a1df967cb 187 [mbed-os-example-fat-filesystem](https://github.com/ARMmbed/mbed-os-example-fat-filesystem) example
dkato 0:b22a1df967cb 188 modified for use with the sd-driver.
dkato 0:b22a1df967cb 189
dkato 0:b22a1df967cb 190 The following sub-sections describe the steps for building and running the example:
dkato 0:b22a1df967cb 191
dkato 0:b22a1df967cb 192 - The [Pre-Requisites](#pre-requisites) section describes the development environment used for this example.
dkato 0:b22a1df967cb 193 Other similar development environments can be used.
dkato 0:b22a1df967cb 194 - The [Create the Example Project](#create-the-example-project) section describes how the application project is created
dkato 0:b22a1df967cb 195 by including the mbed-os and sd-driver code.
dkato 0:b22a1df967cb 196 - The [Build the Example Project](#build-the-example-project) section describes how to build the example application.
dkato 0:b22a1df967cb 197 - The [Insert SDCard into K64F](#insert-sdcard-into-k64f) section describes how to select a card and insert it into the
dkato 0:b22a1df967cb 198 SDCard slot on the K64F.
dkato 0:b22a1df967cb 199 - The [Run the Example Binary on the K64F](#run-the-example-binary-on-the-k64f) section describes how to run the
dkato 0:b22a1df967cb 200 example binary on the target and verify the example has run correctly.
dkato 0:b22a1df967cb 201 - The [Testing with an SDCard on Target XYZ](#testing-with-an-sdcard-on-target-xyx) section describes the use
dkato 0:b22a1df967cb 202 of Continuous Integration Test Shield, which hosts an SDCard slot. By inserting the CI test shield into the
dkato 0:b22a1df967cb 203 Arduino headers of an mbed target platform, the SDCard/FAT Filesystem components can be used to store data
dkato 0:b22a1df967cb 204 persistently on any standard mbed target development board.
dkato 0:b22a1df967cb 205
dkato 0:b22a1df967cb 206
dkato 0:b22a1df967cb 207 ### <a name="pre-requisites"></a> Pre-Requisites
dkato 0:b22a1df967cb 208
dkato 0:b22a1df967cb 209 To work through this example, you should have a working development environment on your machine. For example,
dkato 0:b22a1df967cb 210 the following tools should be installed:
dkato 0:b22a1df967cb 211
dkato 0:b22a1df967cb 212 - A compiler e.g. arm-none-eabi-gcc.
dkato 0:b22a1df967cb 213 - Python 2.7.9 or later.
dkato 0:b22a1df967cb 214 - [mbed Greentea](https://github.com/armmbed/greentea), the mbed OS test tool.
dkato 0:b22a1df967cb 215 - Git Bash or a similar git command line tool to interact with the ARM mbed GitHub repositories.
dkato 0:b22a1df967cb 216 - [mbed-cli](https://github.com/armmbed/mbed-cli), the tool used to make mbed OS application and test builds.
dkato 0:b22a1df967cb 217
dkato 0:b22a1df967cb 218 For more information on how to setup a development environment, please review the documentation on the
dkato 0:b22a1df967cb 219 [mbed documentation site](https://docs.mbed.com).
dkato 0:b22a1df967cb 220
dkato 0:b22a1df967cb 221
dkato 0:b22a1df967cb 222 ### <a name="create-the-example-project"></a> Create the Example Project
dkato 0:b22a1df967cb 223
dkato 0:b22a1df967cb 224 First create the top level application directory sd_ex1 and move into it:
dkato 0:b22a1df967cb 225
dkato 0:b22a1df967cb 226 simhug01@E107851:/d/demo_area$ mkdir sd_ex1
dkato 0:b22a1df967cb 227 simhug01@E107851:/d/demo_area$ cd sd_ex1
dkato 0:b22a1df967cb 228 simhug01@E107851:/d/demo_area/sd_ex1$
dkato 0:b22a1df967cb 229
dkato 0:b22a1df967cb 230 Next, perform the "mbed new" operation to download the mbed-os repository into this directory:
dkato 0:b22a1df967cb 231
dkato 0:b22a1df967cb 232 simhug01@E107851:/d/demo_area/sd_ex1$ mbed new .
dkato 0:b22a1df967cb 233 [mbed] Creating new program "ex_sdcard" (git)
dkato 0:b22a1df967cb 234 [mbed] Adding library "mbed-os" from "https://github.com/ARMmbed/mbed-os" at branch latest
dkato 0:b22a1df967cb 235 [mbed] Updating reference "mbed-os" -> "https://github.com/ARMmbed/mbed-os/#5faf4b26c5954d15c7c1cccac6498e0c690ad101"
dkato 0:b22a1df967cb 236 warning: LF will be replaced by CRLF in mbed-os.lib.
dkato 0:b22a1df967cb 237 The file will have its original line endings in your working directory.
dkato 0:b22a1df967cb 238 (mx1_venv1) simhug01@E107851:/d/demo_area/sd_ex1$ ls -1
dkato 0:b22a1df967cb 239 mbed-os
dkato 0:b22a1df967cb 240 mbed-os.lib
dkato 0:b22a1df967cb 241 mbed_settings.py
dkato 0:b22a1df967cb 242 (mx1_venv1) simhug01@E107851:/d/demo_area/sd_ex1$
dkato 0:b22a1df967cb 243
dkato 0:b22a1df967cb 244 Next, get add the sd-driver component to the application project:
dkato 0:b22a1df967cb 245
dkato 0:b22a1df967cb 246 simhug01@E107851:/d/demo_area/sd_ex1$ mbed add sd-driver
dkato 0:b22a1df967cb 247 <trace removed>
dkato 0:b22a1df967cb 248 simhug01@E107851:/d/demo_area/sd_ex1$
dkato 0:b22a1df967cb 249
dkato 0:b22a1df967cb 250 Next, copy the example1.cpp file and `mbed_app.json` files from inside the sd-driver directory to the top level sd_ex1 directory:
dkato 0:b22a1df967cb 251
dkato 0:b22a1df967cb 252 simhug01@E107851:/d/demo_area/sd_ex1$ cp sd-driver/features/TESTS/examples/example1.cpp .
dkato 0:b22a1df967cb 253 simhug01@E107851:/d/demo_area/sd_ex1$ cp sd-driver/config/mbed_app.json .
dkato 0:b22a1df967cb 254 simhug01@E107851:/d/demo_area/sd_ex1$
dkato 0:b22a1df967cb 255
dkato 0:b22a1df967cb 256 The `mbed_app.json` file specifies the SPI bus pin configuration for different targets.
dkato 0:b22a1df967cb 257 The file includes a specific configuration of the K64F which is used
dkato 0:b22a1df967cb 258 because the mbed compile command specifies the K64F build target. The `mbed_app.json` file
dkato 0:b22a1df967cb 259 is described in more detail in the [Testing with an SDCard on Target XYZ](#testing-with-an-sdcard-on-target-xyx) section.
dkato 0:b22a1df967cb 260
dkato 0:b22a1df967cb 261 ### <a name="build-the-example-project"></a> Build the Example Project
dkato 0:b22a1df967cb 262
dkato 0:b22a1df967cb 263 Next, build the example application:
dkato 0:b22a1df967cb 264
dkato 0:b22a1df967cb 265 simhug01@E107851:/d/demo_area/sd_ex1$ mbed compile -m K64F -t GCC_ARM 2>&1 | tee build_log.txt
dkato 0:b22a1df967cb 266
dkato 0:b22a1df967cb 267
dkato 0:b22a1df967cb 268 #### WARNING: "mbed new ." command and possible mbed-os sd-driver versioning incompatibilities
dkato 0:b22a1df967cb 269
dkato 0:b22a1df967cb 270 If you experience problems building the example then it may mean the version
dkato 0:b22a1df967cb 271 of the mbed-os repository created with the "mbed new ." command is not compatible with
dkato 0:b22a1df967cb 272 the sd-driver repository version created with "mbed add sd-driver" command. This is because:
dkato 0:b22a1df967cb 273
dkato 0:b22a1df967cb 274 - The "mbed new ." creates the mbed-os repository at the latest "Release" e.g. `mbed-os-5.4.0`.
dkato 0:b22a1df967cb 275 - The "mbed add sd-driver" command creates the sd-driver repository at the latest version of
dkato 0:b22a1df967cb 276 master i.e. the tip of master. Changes may be present that are not compatible with
dkato 0:b22a1df967cb 277 the latest mbed-os release e.g. in preparation for the next release.
dkato 0:b22a1df967cb 278
dkato 0:b22a1df967cb 279 This situation can be resolved by checking out compatible versions of the repositories as
dkato 0:b22a1df967cb 280 described in the section [Setting mbed-os/sd-driver Repositories To Compatible Versions](#settting-repos-to-compatible-versions)
dkato 0:b22a1df967cb 281
dkato 0:b22a1df967cb 282 ### <a name="insert-sdcard-into-k64f"></a> Insert SDCard into K64F
dkato 0:b22a1df967cb 283
dkato 0:b22a1df967cb 284 The examples and test cases have been run on a K64F with the following pre-formatted microSDHC cards:
dkato 0:b22a1df967cb 285
dkato 0:b22a1df967cb 286 - Kingston 2GB mircoSDHC card.
dkato 0:b22a1df967cb 287 - Kingston 8GB mircoSDHC card.
dkato 0:b22a1df967cb 288 - SanDisk 16GB mircoSDHC ultra card.
dkato 0:b22a1df967cb 289
dkato 0:b22a1df967cb 290 If the card requires formatting then the following procedure is known to work:
dkato 0:b22a1df967cb 291
dkato 0:b22a1df967cb 292 - Insert microSD card into SD adapter in USB stick (or similar) so the microSD card can be insert into windows PC.
dkato 0:b22a1df967cb 293 - Within file explorer, right click/Format on the USB drive.
dkato 0:b22a1df967cb 294 - Select FAT32, 4096 cluster size, Quick Format.
dkato 0:b22a1df967cb 295 - Format the drive.
dkato 0:b22a1df967cb 296
dkato 0:b22a1df967cb 297 The microSD card should then be ready for use in the K64F. Insert the formatted card
dkato 0:b22a1df967cb 298 into the SDCard slot on the K64F PCB.
dkato 0:b22a1df967cb 299
dkato 0:b22a1df967cb 300
dkato 0:b22a1df967cb 301 ### <a name="run-the-example-binary-on-the-k64f"></a> Run the Example Binary on the K64F
dkato 0:b22a1df967cb 302
dkato 0:b22a1df967cb 303 Once the binary is built, copy the binary from `/d/demo_area/sd_ex1/BUILD/K64F/GCC_ARM/example1.bin` to the K64F.
dkato 0:b22a1df967cb 304 After connecting a serial console and resetting the target, the following trace should be seen:
dkato 0:b22a1df967cb 305
dkato 0:b22a1df967cb 306 Welcome to the filesystem example.
dkato 0:b22a1df967cb 307 Opening a new file, numbers.txt. done.
dkato 0:b22a1df967cb 308 Writing decimal numbers to a file (20/20) done.
dkato 0:b22a1df967cb 309 Closing file. done.
dkato 0:b22a1df967cb 310 Re-opening file read-only. done.
dkato 0:b22a1df967cb 311 Dumping file to screen.
dkato 0:b22a1df967cb 312 0
dkato 0:b22a1df967cb 313 1
dkato 0:b22a1df967cb 314 2
dkato 0:b22a1df967cb 315 3
dkato 0:b22a1df967cb 316 4
dkato 0:b22a1df967cb 317 5
dkato 0:b22a1df967cb 318 6
dkato 0:b22a1df967cb 319 7
dkato 0:b22a1df967cb 320 8
dkato 0:b22a1df967cb 321 9
dkato 0:b22a1df967cb 322 10
dkato 0:b22a1df967cb 323 11
dkato 0:b22a1df967cb 324 12
dkato 0:b22a1df967cb 325 13
dkato 0:b22a1df967cb 326 14
dkato 0:b22a1df967cb 327 15
dkato 0:b22a1df967cb 328 16
dkato 0:b22a1df967cb 329 17
dkato 0:b22a1df967cb 330 18
dkato 0:b22a1df967cb 331 19
dkato 0:b22a1df967cb 332 EOF.
dkato 0:b22a1df967cb 333 Closing file. done.
dkato 0:b22a1df967cb 334 Opening root directory. done.
dkato 0:b22a1df967cb 335 Printing all filenames:
dkato 0:b22a1df967cb 336 numbers.txt
dkato 0:b22a1df967cb 337 Closeing root directory. done.
dkato 0:b22a1df967cb 338 Filesystem Demo complete.
dkato 0:b22a1df967cb 339
dkato 0:b22a1df967cb 340
dkato 0:b22a1df967cb 341 ### <a name="testing-with-an-sdcard-on-target-xyx"></a> Testing with an SDCard on Target XYZ
dkato 0:b22a1df967cb 342
dkato 0:b22a1df967cb 343 The standard way to test is with the mbed CI Test Shield plugged into the
dkato 0:b22a1df967cb 344 target board. This pin mapping for this configuration is parameterised in
dkato 0:b22a1df967cb 345 the `mbed_app.json` file.
dkato 0:b22a1df967cb 346
dkato 0:b22a1df967cb 347 The following is an example of the `mbed_app.json` file available in the repository:
dkato 0:b22a1df967cb 348
dkato 0:b22a1df967cb 349 {
dkato 0:b22a1df967cb 350 "config": {
dkato 0:b22a1df967cb 351 "UART_RX": "D0",
dkato 0:b22a1df967cb 352 "UART_TX": "D1",
dkato 0:b22a1df967cb 353 "DIO_0": "D0",
dkato 0:b22a1df967cb 354 "DIO_1": "D1",
dkato 0:b22a1df967cb 355 "DIO_2": "D2",
dkato 0:b22a1df967cb 356 "DIO_3": "D3",
dkato 0:b22a1df967cb 357 "DIO_4": "D4",
dkato 0:b22a1df967cb 358 "DIO_5": "D5",
dkato 0:b22a1df967cb 359 "DIO_6": "D6",
dkato 0:b22a1df967cb 360 "DIO_7": "D7",
dkato 0:b22a1df967cb 361 "DIO_8": "D8",
dkato 0:b22a1df967cb 362 "DIO_9": "D9",
dkato 0:b22a1df967cb 363 "SPI_CS": "D10",
dkato 0:b22a1df967cb 364 "SPI_MOSI": "D11",
dkato 0:b22a1df967cb 365 "SPI_MISO": "D12",
dkato 0:b22a1df967cb 366 "SPI_CLK": "D13",
dkato 0:b22a1df967cb 367 "I2C_SDA": "D14",
dkato 0:b22a1df967cb 368 "I2C_SCL": "D15",
dkato 0:b22a1df967cb 369 "I2C_TEMP_ADDR":"0x90",
dkato 0:b22a1df967cb 370 "I2C_EEPROM_ADDR":"0xA0",
dkato 0:b22a1df967cb 371 "AIN_0": "A0",
dkato 0:b22a1df967cb 372 "AIN_1": "A1",
dkato 0:b22a1df967cb 373 "AIN_2": "A2",
dkato 0:b22a1df967cb 374 "AIN_3": "A3",
dkato 0:b22a1df967cb 375 "AIN_4": "A4",
dkato 0:b22a1df967cb 376 "AIN_5": "A5",
dkato 0:b22a1df967cb 377 "AOUT" : "A5",
dkato 0:b22a1df967cb 378 "PWM_0": "D3",
dkato 0:b22a1df967cb 379 "PWM_1": "D5",
dkato 0:b22a1df967cb 380 "PWM_2": "D6",
dkato 0:b22a1df967cb 381 "PWM_3": "D9",
dkato 0:b22a1df967cb 382 "DEBUG_MSG": 0,
dkato 0:b22a1df967cb 383 "DEVICE_SPI": 1,
dkato 0:b22a1df967cb 384 "FSFAT_SDCARD_INSTALLED": 1
dkato 0:b22a1df967cb 385 },
dkato 0:b22a1df967cb 386 "target_overrides": {
dkato 0:b22a1df967cb 387 "DISCO_F051R8": {
dkato 0:b22a1df967cb 388 "SPI_MOSI": "SPI_MOSI",
dkato 0:b22a1df967cb 389 "SPI_MISO": "SPI_MISO",
dkato 0:b22a1df967cb 390 "SPI_CLK": "SPI_SCK",
dkato 0:b22a1df967cb 391 "SPI_CS": "SPI_CS"
dkato 0:b22a1df967cb 392 },
dkato 0:b22a1df967cb 393 "K20D50M": {
dkato 0:b22a1df967cb 394 "SPI_MOSI": "PTD2",
dkato 0:b22a1df967cb 395 "SPI_MISO": "PTD3",
dkato 0:b22a1df967cb 396 "SPI_CLK": "PTD1",
dkato 0:b22a1df967cb 397 "SPI_CS": "PTC2"
dkato 0:b22a1df967cb 398 },
dkato 0:b22a1df967cb 399 "KL22F": {
dkato 0:b22a1df967cb 400 "SPI_MOSI": "PTD6",
dkato 0:b22a1df967cb 401 "SPI_MISO": "PTD7",
dkato 0:b22a1df967cb 402 "SPI_CLK": "PTD5",
dkato 0:b22a1df967cb 403 "SPI_CS": "PTD4"
dkato 0:b22a1df967cb 404 },
dkato 0:b22a1df967cb 405 "KL25Z": {
dkato 0:b22a1df967cb 406 "SPI_MOSI": "PTD2",
dkato 0:b22a1df967cb 407 "SPI_MISO": "PTD3",
dkato 0:b22a1df967cb 408 "SPI_CLK": "PTD1",
dkato 0:b22a1df967cb 409 "SPI_CS": "PTD0"
dkato 0:b22a1df967cb 410 },
dkato 0:b22a1df967cb 411 "KL43Z": {
dkato 0:b22a1df967cb 412 "SPI_MOSI": "PTD6",
dkato 0:b22a1df967cb 413 "SPI_MISO": "PTD7",
dkato 0:b22a1df967cb 414 "SPI_CLK": "PTD5",
dkato 0:b22a1df967cb 415 "SPI_CS": "PTD4"
dkato 0:b22a1df967cb 416 },
dkato 0:b22a1df967cb 417 "KL46Z": {
dkato 0:b22a1df967cb 418 "SPI_MOSI": "PTD6",
dkato 0:b22a1df967cb 419 "SPI_MISO": "PTD7",
dkato 0:b22a1df967cb 420 "SPI_CLK": "PTD5",
dkato 0:b22a1df967cb 421 "SPI_CS": "PTD4"
dkato 0:b22a1df967cb 422 },
dkato 0:b22a1df967cb 423 "K64F": {
dkato 0:b22a1df967cb 424 "SPI_MOSI": "PTE3",
dkato 0:b22a1df967cb 425 "SPI_MISO": "PTE1",
dkato 0:b22a1df967cb 426 "SPI_CLK": "PTE2",
dkato 0:b22a1df967cb 427 "SPI_CS": "PTE4"
dkato 0:b22a1df967cb 428 },
dkato 0:b22a1df967cb 429 "K66F": {
dkato 0:b22a1df967cb 430 "SPI_MOSI": "PTE3",
dkato 0:b22a1df967cb 431 "SPI_MISO": "PTE1",
dkato 0:b22a1df967cb 432 "SPI_CLK": "PTE2",
dkato 0:b22a1df967cb 433 "SPI_CS": "PTE4"
dkato 0:b22a1df967cb 434 },
dkato 0:b22a1df967cb 435 "LPC11U37H_401": {
dkato 0:b22a1df967cb 436 "SPI_MOSI": "SDMOSI",
dkato 0:b22a1df967cb 437 "SPI_MISO": "SDMISO",
dkato 0:b22a1df967cb 438 "SPI_CLK": "SDSCLK",
dkato 0:b22a1df967cb 439 "SPI_CS": "SDSSEL"
dkato 0:b22a1df967cb 440 },
dkato 0:b22a1df967cb 441 "LPC2368": {
dkato 0:b22a1df967cb 442 "SPI_MOSI": "p11",
dkato 0:b22a1df967cb 443 "SPI_MISO": "p12",
dkato 0:b22a1df967cb 444 "SPI_CLK": "p13",
dkato 0:b22a1df967cb 445 "SPI_CS": "p14"
dkato 0:b22a1df967cb 446 },
dkato 0:b22a1df967cb 447 "NUCLEO_L031K6": {
dkato 0:b22a1df967cb 448 "SPI_MOSI": "SPI_MOSI",
dkato 0:b22a1df967cb 449 "SPI_MISO": "SPI_MISO",
dkato 0:b22a1df967cb 450 "SPI_CLK": "SPI_SCK",
dkato 0:b22a1df967cb 451 "SPI_CS": "SPI_CS"
dkato 0:b22a1df967cb 452 },
dkato 0:b22a1df967cb 453 "nRF51822": {
dkato 0:b22a1df967cb 454 "SPI_MOSI": "p12",
dkato 0:b22a1df967cb 455 "SPI_MISO": "p13",
dkato 0:b22a1df967cb 456 "SPI_CLK": "p15",
dkato 0:b22a1df967cb 457 "SPI_CS": "p14"
dkato 0:b22a1df967cb 458 },
dkato 0:b22a1df967cb 459 "RZ_A1H": {
dkato 0:b22a1df967cb 460 "SPI_MOSI": "P8_5",
dkato 0:b22a1df967cb 461 "SPI_MISO": "P8_6",
dkato 0:b22a1df967cb 462 "SPI_CLK": "P8_3",
dkato 0:b22a1df967cb 463 "SPI_CS": "P8_4"
dkato 0:b22a1df967cb 464 }
dkato 0:b22a1df967cb 465 }
dkato 0:b22a1df967cb 466 }
dkato 0:b22a1df967cb 467
dkato 0:b22a1df967cb 468 Note the following things about the `mbed_app.json` file:
dkato 0:b22a1df967cb 469
dkato 0:b22a1df967cb 470 - The `mbed_app.json` file is used to define target specific symbols for the SPI pins connecting the SDCard slot to the target MCU:
dkato 0:b22a1df967cb 471 - "SPI\_CS". This is the Chip Select line.
dkato 0:b22a1df967cb 472 - "SPI\_MOSI". This is the Master Out Slave In data line.
dkato 0:b22a1df967cb 473 - "SPI\_MISO". This is the Master In Slave Out data line.
dkato 0:b22a1df967cb 474 - "SPI\_CLK". This is the serial Clock line.
dkato 0:b22a1df967cb 475 - The default configuration defined in the "config" section is for the standard Arduino header pin mappings for the SPI bus.
dkato 0:b22a1df967cb 476 The "config" section defines a dictionary mapping functional names to target board Arduino header pins:
dkato 0:b22a1df967cb 477 - "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.
dkato 0:b22a1df967cb 478 D10 is defined in the target specific PinNames.h file.
dkato 0:b22a1df967cb 479 - "SPI\_MOSI": "D11". This causes the MBED\_CONF\_APP\_SPI\_MOSI symbol to be defined in mbed\_config.h.
dkato 0:b22a1df967cb 480 - "SPI\_MISO": "D12". This causes the MBED\_CONF\_APP\_SPI\_MISO symbol to be defined in mbed\_config.h.
dkato 0:b22a1df967cb 481 - "SPI\_CLK": "D13". This causes the MBED\_CONF\_APP\_SPI\_CLK symbol to be defined in mbed\_config.h.
dkato 0:b22a1df967cb 482 - The `"target_overrides"` section is used to override the "SPI\_xxx" symbols for specific target boards, which may have an SDCard slot, for example.
dkato 0:b22a1df967cb 483 This is the case for the K64F, where the "SPI\_xxx" are mapped to the pin names for the on-board SDCard.
dkato 0:b22a1df967cb 484
dkato 0:b22a1df967cb 485 ```
dkato 0:b22a1df967cb 486 "K64F": {
dkato 0:b22a1df967cb 487 "SPI_MOSI": "PTE3",
dkato 0:b22a1df967cb 488 "SPI_MISO": "PTE1",
dkato 0:b22a1df967cb 489 "SPI_CLK": "PTE2",
dkato 0:b22a1df967cb 490 "SPI_CS": "PTE4"
dkato 0:b22a1df967cb 491 }
dkato 0:b22a1df967cb 492 ```
dkato 0:b22a1df967cb 493 - Thus, in the absence of any target specific definitions in the `"target_overrides"` section, all boards will default to
dkato 0:b22a1df967cb 494 using the Arduino header configuration. For those platforms with a `"target_overrides"` section then this configuration
dkato 0:b22a1df967cb 495 will be used in preference.
dkato 0:b22a1df967cb 496 - Hence in the case that you want to test a platform with an SDCard inserted into a
dkato 0:b22a1df967cb 497 fitted CI test shield (rather than the on-board SDCard slot)
dkato 0:b22a1df967cb 498 and there is a `"target_overrides"` section present in the `mbed_app.json` file, you must then delete the `"target_overrides"`
dkato 0:b22a1df967cb 499 section before building. This will result in the default configuration being used (suitable for the CI
dkato 0:b22a1df967cb 500 Test Shield).
dkato 0:b22a1df967cb 501 - Note when inserting the v1.0.0 CI Test Shield into the Arduino header of the target platform, the shield pins D0 and
dkato 0:b22a1df967cb 502 D1 should be bent to be parallel to the shield PCB so they are not inserted into the Arduino header. This is because
dkato 0:b22a1df967cb 503 some boards use the same UART on DAPLINK and D0/D1, which means the serial debug channel breaks and hence the mbed greentea
dkato 0:b22a1df967cb 504 test suite will not work correctly. This is mainly on older ST boards and should not be a problem on
dkato 0:b22a1df967cb 505 `K64F`, `NUCLEO_F429ZI` and `UBLOX_EVK_ODIN_W2`. Note also that the v2.0.0 CI Test Shield doesn't suffer from this
dkato 0:b22a1df967cb 506 problem and the pins don't need to be bent.
dkato 0:b22a1df967cb 507 - When inserting the SDCard into the card slot on the CI test shield, make sure the card is fully inserted.
dkato 0:b22a1df967cb 508 On insertion, there should be a small clicking sound when the card registers, and the back edge of the card
dkato 0:b22a1df967cb 509 should protrude no more than ~1mm over the edge of the CI test shield PCB. If the SDCard fails to register,
dkato 0:b22a1df967cb 510 try gently pushing the metal flexible strip in the shape of a spade at the top edge of the SDCard metal slot
dkato 0:b22a1df967cb 511 casing with a pair of tweezers, bending it a little to lower it into the slot casing. This helps with the
dkato 0:b22a1df967cb 512 insertion mechanism.
dkato 0:b22a1df967cb 513
dkato 0:b22a1df967cb 514
dkato 0:b22a1df967cb 515 ### Target K64F with CI Test Shield fitted
dkato 0:b22a1df967cb 516
dkato 0:b22a1df967cb 517 ![alt text](docs/pics/sd_driver_k64_with_ci_test_shield.jpg "unseen title text")
dkato 0:b22a1df967cb 518
dkato 0:b22a1df967cb 519 **Figure 2. The figure shows the K64F platform with the CI shield fitted.**
dkato 0:b22a1df967cb 520
dkato 0:b22a1df967cb 521 The above figure shows the K64F with the v1.0.0 CI test shield fitted. Note:
dkato 0:b22a1df967cb 522
dkato 0:b22a1df967cb 523 - The pins D0/D1 (top right of CI test shield) are bent sideways so as not to insert into the header.
dkato 0:b22a1df967cb 524 - The SDCard is fully inserted into the slot and overhangs the PCB by ~1mm.
dkato 0:b22a1df967cb 525
dkato 0:b22a1df967cb 526
dkato 0:b22a1df967cb 527 # SDBlockDevice Example Application
dkato 0:b22a1df967cb 528
dkato 0:b22a1df967cb 529 The following sample code illustrates how to use the sd-driver Block Device API:
dkato 0:b22a1df967cb 530
dkato 0:b22a1df967cb 531
dkato 0:b22a1df967cb 532 #include "mbed.h"
dkato 0:b22a1df967cb 533 #include "SDBlockDevice.h"
dkato 0:b22a1df967cb 534
dkato 0:b22a1df967cb 535 // Instantiate the SDBlockDevice by specifying the SPI pins connected to the SDCard
dkato 0:b22a1df967cb 536 // socket. The PINS are:
dkato 0:b22a1df967cb 537 // MOSI (Master Out Slave In)
dkato 0:b22a1df967cb 538 // MISO (Master In Slave Out)
dkato 0:b22a1df967cb 539 // SCLK (Serial Clock)
dkato 0:b22a1df967cb 540 // CS (Chip Select)
dkato 0:b22a1df967cb 541 SDBlockDevice sd(p5, p6, p7, p12); // mosi, miso, sclk, cs
dkato 0:b22a1df967cb 542 uint8_t block[512] = "Hello World!\n";
dkato 0:b22a1df967cb 543
dkato 0:b22a1df967cb 544 int main()
dkato 0:b22a1df967cb 545 {
dkato 0:b22a1df967cb 546 // call the SDBlockDevice instance initialisation method.
dkato 0:b22a1df967cb 547 sd.init();
dkato 0:b22a1df967cb 548
dkato 0:b22a1df967cb 549 // Write some the data block to the device
dkato 0:b22a1df967cb 550 sd.program(block, 0, 512);
dkato 0:b22a1df967cb 551
dkato 0:b22a1df967cb 552 // read the data block from the device
dkato 0:b22a1df967cb 553 sd.read(block, 0, 512);
dkato 0:b22a1df967cb 554
dkato 0:b22a1df967cb 555 // print the contents of the block
dkato 0:b22a1df967cb 556 printf("%s", block);
dkato 0:b22a1df967cb 557
dkato 0:b22a1df967cb 558 // call the SDBlockDevice instance de-initialisation method.
dkato 0:b22a1df967cb 559 sd.deinit();
dkato 0:b22a1df967cb 560 }
dkato 0:b22a1df967cb 561
dkato 0:b22a1df967cb 562
dkato 0:b22a1df967cb 563 # SDCard POSIX File API mbed Greentea Test Cases
dkato 0:b22a1df967cb 564
dkato 0:b22a1df967cb 565 This section describes how to build and run the POSIX file API test cases.
dkato 0:b22a1df967cb 566 The following steps are covered:
dkato 0:b22a1df967cb 567
dkato 0:b22a1df967cb 568 - [Create the FAT/SDCard Application Project](#create-fat-sdcard-application-project).
dkato 0:b22a1df967cb 569 This section describes how to git clone the mbed OS and sd-driver repositories containing the
dkato 0:b22a1df967cb 570 code and test cases of interest.
dkato 0:b22a1df967cb 571 - [Build the mbed OS Test Cases](#build-the-mbedos-test-cases). This section
dkato 0:b22a1df967cb 572 describes how to build the mbed OS test cases.
dkato 0:b22a1df967cb 573 - [Insert a microSD Card Into the K64F for Greentea Testing](#greentea-insert-sdcard-into-k64f).This section
dkato 0:b22a1df967cb 574 describes how to format (if required) a microSD card prior to running the tests.
dkato 0:b22a1df967cb 575 - [Run the POSIX File Test Case](#run-the-posix-file-test-cases).This section
dkato 0:b22a1df967cb 576 describes how to run the POSIX file test cases.
dkato 0:b22a1df967cb 577
dkato 0:b22a1df967cb 578
dkato 0:b22a1df967cb 579 ### <a name="create-fat-sdcard-application-project"></a> Create the FAT/SDCard Application Project
dkato 0:b22a1df967cb 580
dkato 0:b22a1df967cb 581 This section describes how to create an application project combining the
dkato 0:b22a1df967cb 582 mbed-os and sd-driver repositories into a single project.
dkato 0:b22a1df967cb 583 In summary the following steps will be covered in this section:
dkato 0:b22a1df967cb 584
dkato 0:b22a1df967cb 585 - A top level application project directory is created. The directory name is ex_app1.
dkato 0:b22a1df967cb 586 - In the ex_app1 directory, the mbed-os repository is cloned.
dkato 0:b22a1df967cb 587 - In the ex_app1 directory at the same level as the mbed-os directory, the sd-driver repository is cloned.
dkato 0:b22a1df967cb 588 - The `mbed_app.json` file is copied from the `sd-driver/config/mbed_app.json` to the ex_app1 directory.
dkato 0:b22a1df967cb 589
dkato 0:b22a1df967cb 590 First create the top level application directory ex_app1 and move into it:
dkato 0:b22a1df967cb 591
dkato 0:b22a1df967cb 592 simhug01@E107851:/d/demo_area$ mkdir ex_app1
dkato 0:b22a1df967cb 593 simhug01@E107851:/d/demo_area$ pushd ex_app1
dkato 0:b22a1df967cb 594
dkato 0:b22a1df967cb 595 Next, get a clone of public mbed OS repository in the following way:
dkato 0:b22a1df967cb 596
dkato 0:b22a1df967cb 597 simhug01@E107851:/d/demo_area/ex_app1$ git clone git@github.com:/armmbed/mbed-os
dkato 0:b22a1df967cb 598 <trace removed>
dkato 0:b22a1df967cb 599 simhug01@E107851:/d/demo_area/ex_app1$
dkato 0:b22a1df967cb 600
dkato 0:b22a1df967cb 601 Next, get a clone of the sd-driver repository:
dkato 0:b22a1df967cb 602
dkato 0:b22a1df967cb 603 simhug01@E107851:/d/demo_area/ex_app1$ git clone git@github.com:/armmbed/sd-driver
dkato 0:b22a1df967cb 604 <trace removed>
dkato 0:b22a1df967cb 605 simhug01@E107851:/d/demo_area/ex_app1$
dkato 0:b22a1df967cb 606
dkato 0:b22a1df967cb 607 Finally, copy the `mbed_app.json` application configuration file from `sd-driver/config/mbed_app.json` to the ex_app1 directory:
dkato 0:b22a1df967cb 608
dkato 0:b22a1df967cb 609 simhug01@E107851:/d/demo_area/ex_app1$ cp sd-driver/config/mbed_app.json .
dkato 0:b22a1df967cb 610 simhug01@E107851:/d/demo_area/ex_app1$
dkato 0:b22a1df967cb 611
dkato 0:b22a1df967cb 612 The `mbed_app.json` file specifies the SPI bus pin configuration for different targets,
dkato 0:b22a1df967cb 613 and is discussed in the [Testing with an SDCard on Target XYZ](#testing-with-an-sdcard-on-target-xyx) section.
dkato 0:b22a1df967cb 614
dkato 0:b22a1df967cb 615
dkato 0:b22a1df967cb 616 ### <a name="build-the-mbedos-test-cases"></a> Build the mbed OS Test Cases
dkato 0:b22a1df967cb 617
dkato 0:b22a1df967cb 618 Build the test cases for the K64F target using the following command:
dkato 0:b22a1df967cb 619
dkato 0:b22a1df967cb 620 simhug01@E107851:/d/demo_area/ex_app1$ mbed -v test --compile -t GCC_ARM -m K64F --app-config mbed_app.json 2>&1 | tee build_tests_gcc_20161219_1007.txt
dkato 0:b22a1df967cb 621 <trace removed>
dkato 0:b22a1df967cb 622 simhug01@E107851:/d/demo_area/ex_app1$
dkato 0:b22a1df967cb 623
dkato 0:b22a1df967cb 624 The build trace is quite extensive but on a successful build you should see the following output at the end of the log:
dkato 0:b22a1df967cb 625
dkato 0:b22a1df967cb 626 Build successes:
dkato 0:b22a1df967cb 627 * K64F::GCC_ARM::MBED-BUILD
dkato 0:b22a1df967cb 628 * K64F::GCC_ARM::MBED-OS-FEATURES-FEATURE_LWIP-TESTS-MBEDMICRO-NET-CONNECTIVITY
dkato 0:b22a1df967cb 629 <trace removed>
dkato 0:b22a1df967cb 630 * K64F::GCC_ARM::MBED-OS-FEATURES-TESTS-FILESYSTEM-FAT_FILE_SYSTEM
dkato 0:b22a1df967cb 631 * K64F::GCC_ARM::MBED-OS-FEATURES-TESTS-FILESYSTEM-HEAP_BLOCK_DEVICE
dkato 0:b22a1df967cb 632 * K64F::GCC_ARM::MBED-OS-FEATURES-TESTS-FILESYSTEM-UTIL_BLOCK_DEVICE
dkato 0:b22a1df967cb 633 <trace removed>
dkato 0:b22a1df967cb 634 * K64F::GCC_ARM::SD-DRIVER-FEATURES-TESTS-FILESYSTEM-BASIC
dkato 0:b22a1df967cb 635 * K64F::GCC_ARM::SD-DRIVER-FEATURES-TESTS-FILESYSTEM-FOPEN
dkato 0:b22a1df967cb 636
dkato 0:b22a1df967cb 637 Build skips:
dkato 0:b22a1df967cb 638 * K64F::GCC_ARM::MBED-OS-FEATURES-FEATURE_LWIP-TESTS-MBEDMICRO-NET-TCP_PACKET_PRESSURE
dkato 0:b22a1df967cb 639 <trace removed>
dkato 0:b22a1df967cb 640
dkato 0:b22a1df967cb 641
dkato 0:b22a1df967cb 642 Notice the following tests in the sd-driver tree are listed above:
dkato 0:b22a1df967cb 643
dkato 0:b22a1df967cb 644 - `K64F::GCC_ARM::SD-DRIVER-FEATURES-TESTS-FILESYSTEM-BASIC`
dkato 0:b22a1df967cb 645 - `K64F::GCC_ARM::SD-DRIVER-FEATURES-TESTS-FILESYSTEM-FOPEN`
dkato 0:b22a1df967cb 646
dkato 0:b22a1df967cb 647
dkato 0:b22a1df967cb 648 The FAT32/SDCard test cases are at following locations in the source code tree:
dkato 0:b22a1df967cb 649
dkato 0:b22a1df967cb 650 /d/demo_area/ex_app1/sd-driver/features/TESTS/filesystem/basic/basic.cpp
dkato 0:b22a1df967cb 651 /d/demo_area/ex_app1/sd-driver/features/TESTS/filesystem/fopen/fopen.cpp
dkato 0:b22a1df967cb 652
dkato 0:b22a1df967cb 653
dkato 0:b22a1df967cb 654 #### <a name="settting-repos-to-compatible-versions"></a> Setting mbed-os/sd-driver Repositories To Compatible Versions
dkato 0:b22a1df967cb 655
dkato 0:b22a1df967cb 656 The sd-driver master HEAD and the mbed-os master HEAD should be compatible
dkato 0:b22a1df967cb 657 with one another and therefore no specific tagged versions need to be checked out.
dkato 0:b22a1df967cb 658 However, in the case that you experience problems building, checkout out the compatible
dkato 0:b22a1df967cb 659 tagged version of each repository, as shown below:
dkato 0:b22a1df967cb 660
dkato 0:b22a1df967cb 661 simhug01@E107851:/d/demo_area/ex_app1$ pushd mbed-os
dkato 0:b22a1df967cb 662 simhug01@E107851:/d/demo_area/ex_app1$ git checkout tags/mbed-os-5.4.0
dkato 0:b22a1df967cb 663 simhug01@E107851:/d/demo_area/ex_app1$ popd
dkato 0:b22a1df967cb 664 simhug01@E107851:/d/demo_area/ex_app1$ pushd sd-driver
dkato 0:b22a1df967cb 665 simhug01@E107851:/d/demo_area/ex_app1$ git checkout tags/sd-driver-0.0.2-mbed-os-5.4.0
dkato 0:b22a1df967cb 666 simhug01@E107851:/d/demo_area/ex_app1$ popd
dkato 0:b22a1df967cb 667
dkato 0:b22a1df967cb 668 In the above:
dkato 0:b22a1df967cb 669
dkato 0:b22a1df967cb 670 - `mbed-os-5.4.0` should be replaced with the latest mbed-os release tag.
dkato 0:b22a1df967cb 671 - 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`
dkato 0:b22a1df967cb 672 where `a.b.c` is the latest version code for the `mbed-os-x.y.z` tag.
dkato 0:b22a1df967cb 673
dkato 0:b22a1df967cb 674 ### <a name="greentea-insert-sdcard-into-k64f"></a> Insert SDCard into K64F for Greentea Testing
dkato 0:b22a1df967cb 675
dkato 0:b22a1df967cb 676 See the previous section for [Insert SDCard into K64F](#insert-sdcard-into-k64f) for details.
dkato 0:b22a1df967cb 677
dkato 0:b22a1df967cb 678
dkato 0:b22a1df967cb 679 ### <a name="run-the-posix-file-test-cases"></a> Run the POSIX File Test Case
dkato 0:b22a1df967cb 680
dkato 0:b22a1df967cb 681 To setup for running the test cases, connect the K64F development board to your
dkato 0:b22a1df967cb 682 PC using a suitable USB cable.
dkato 0:b22a1df967cb 683
dkato 0:b22a1df967cb 684 All tests can be run using the following command:
dkato 0:b22a1df967cb 685
dkato 0:b22a1df967cb 686 simhug01@E107851:/d/demo_area/ex_app1$ mbedgt -VS
dkato 0:b22a1df967cb 687 <trace removed>
dkato 0:b22a1df967cb 688
dkato 0:b22a1df967cb 689 However, it's possible to run a particular test case using the following form of the mbedgt command:
dkato 0:b22a1df967cb 690
dkato 0:b22a1df967cb 691 simhug01@E107851:/d/demo_area/ex_app1$ mbedgt -VS --test-by-names=<test-name>
dkato 0:b22a1df967cb 692
dkato 0:b22a1df967cb 693 The names of the tests can be listed using:
dkato 0:b22a1df967cb 694
dkato 0:b22a1df967cb 695 simhug01@E107851:/d/demo_area/ex_app1$ mbedgt -VS --list
dkato 0:b22a1df967cb 696
dkato 0:b22a1df967cb 697 For example, to run the basic test use:
dkato 0:b22a1df967cb 698
dkato 0:b22a1df967cb 699 simhug01@E107851:/d/demo_area/ex_app1$ mbedgt -VS --test-by-names=sd-driver-features-tests-filesystem-basic 2>&1 | tee run_tests_basic.txt
dkato 0:b22a1df967cb 700
dkato 0:b22a1df967cb 701 To run the fopen test use:
dkato 0:b22a1df967cb 702
dkato 0:b22a1df967cb 703 simhug01@E107851:/d/demo_area/ex_app1$ mbedgt -VS --test-by-names=sd-driver-features-tests-filesystem-fopen 2>&1 | tee run_tests_fopen.txt
dkato 0:b22a1df967cb 704
dkato 0:b22a1df967cb 705 On a successful run, results similar to the following will be shown:
dkato 0:b22a1df967cb 706
dkato 0:b22a1df967cb 707 mbedgt: test suite report:
dkato 0:b22a1df967cb 708 +--------------+---------------+-------------------------------------------+--------+--------------------+-------------+
dkato 0:b22a1df967cb 709 | target | platform_name | test suite | result | elapsed_time (sec) | copy_method |
dkato 0:b22a1df967cb 710 +--------------+---------------+-------------------------------------------+--------+--------------------+-------------+
dkato 0:b22a1df967cb 711 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | OK | 151.46 | shell |
dkato 0:b22a1df967cb 712 +--------------+---------------+-------------------------------------------+--------+--------------------+-------------+
dkato 0:b22a1df967cb 713 mbedgt: test suite results: 1 OK
dkato 0:b22a1df967cb 714 mbedgt: test case report:
dkato 0:b22a1df967cb 715 +--------------+---------------+-------------------------------------------+----------------------------------------------------------------------------------------+--------+--------+--------+--------------------+
dkato 0:b22a1df967cb 716 | target | platform_name | test suite | test case | passed | failed | result | elapsed_time (sec) |
dkato 0:b22a1df967cb 717 +--------------+---------------+-------------------------------------------+----------------------------------------------------------------------------------------+--------+--------+--------+--------------------+
dkato 0:b22a1df967cb 718 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_01: fopen()/fwrite()/fclose() directories/file in multi-dir filepath. | 1 | 0 | OK | 7.57 |
dkato 0:b22a1df967cb 719 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_02: fopen(r) pre-existing file try to write it. | 1 | 0 | OK | 0.2 |
dkato 0:b22a1df967cb 720 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_03: fopen(w+) pre-existing file try to write it. | 1 | 0 | OK | 0.41 |
dkato 0:b22a1df967cb 721 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_04: fopen() with a filename exceeding the maximum length. | 1 | 0 | OK | 0.11 |
dkato 0:b22a1df967cb 722 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_06: fopen() with bad filenames (minimal). | 1 | 0 | OK | 0.1 |
dkato 0:b22a1df967cb 723 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_07: fopen()/errno handling. | 1 | 0 | OK | 0.07 |
dkato 0:b22a1df967cb 724 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_08: ferror()/clearerr()/errno handling. | 1 | 0 | OK | 0.1 |
dkato 0:b22a1df967cb 725 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_09: ftell() handling. | 1 | 0 | OK | 0.17 |
dkato 0:b22a1df967cb 726 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_10: remove() test. | 1 | 0 | OK | 1.28 |
dkato 0:b22a1df967cb 727 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_11: rename(). | 1 | 0 | OK | 2.3 |
dkato 0:b22a1df967cb 728 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_12: opendir(), readdir(), closedir() test. | 1 | 0 | OK | 3.57 |
dkato 0:b22a1df967cb 729 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_13: mkdir() test. | 1 | 0 | OK | 1.21 |
dkato 0:b22a1df967cb 730 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_14: stat() test. | 1 | 0 | OK | 1.47 |
dkato 0:b22a1df967cb 731 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_15: format() test. | 1 | 0 | OK | 26.12 |
dkato 0:b22a1df967cb 732 | K64F-GCC_ARM | K64F | sd-driver-features-tests-filesystem-fopen | FSFAT_FOPEN_TEST_16: write/check n x 25kB data files. | 1 | 0 | OK | 87.11 |
dkato 0:b22a1df967cb 733 +--------------+---------------+-------------------------------------------+----------------------------------------------------------------------------------------+--------+--------+--------+--------------------+
dkato 0:b22a1df967cb 734 mbedgt: test case results: 15 OK
dkato 0:b22a1df967cb 735 mbedgt: completed in 152.35 sec
dkato 0:b22a1df967cb 736
dkato 0:b22a1df967cb 737
dkato 0:b22a1df967cb 738 # <a name="summary-posix-api-documentation"></a> Summary of POSIX File API Documentation
dkato 0:b22a1df967cb 739
dkato 0:b22a1df967cb 740 ### POSIX File API
dkato 0:b22a1df967cb 741
dkato 0:b22a1df967cb 742 mbed OS supports a subset of the POSIX File API, as outlined below:
dkato 0:b22a1df967cb 743
dkato 0:b22a1df967cb 744 - [clearerr()](https://linux.die.net/man/3/clearerr).
dkato 0:b22a1df967cb 745 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 746 - [fclose()](https://linux.die.net/man/3/fclose).
dkato 0:b22a1df967cb 747 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 748 - [ferror()](https://linux.die.net/man/3/clearerr).
dkato 0:b22a1df967cb 749 - STATUS: Basic testing implemented.
dkato 0:b22a1df967cb 750 - STATUS: GCC_ARM: Working.
dkato 0:b22a1df967cb 751 - STATUS: ARMCC: ARMCC has problem with ferror(filep) where filep is NULL. Appears to work for non-NULL pointer.
dkato 0:b22a1df967cb 752 - [fgetc()](https://linux.die.net/man/3/fgets).
dkato 0:b22a1df967cb 753 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 754 - [fgets()](https://linux.die.net/man/3/fgets).
dkato 0:b22a1df967cb 755 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 756 - [fputc()](https://linux.die.net/man/3/fputs).
dkato 0:b22a1df967cb 757 - STATUS: Unknown.
dkato 0:b22a1df967cb 758 - [fputs()](https://linux.die.net/man/3/fputs).
dkato 0:b22a1df967cb 759 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 760 - [fprintf()](https://linux.die.net/man/3/fprintf).
dkato 0:b22a1df967cb 761 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 762 - [fopen()](https://linux.die.net/man/3/fopen).
dkato 0:b22a1df967cb 763 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 764 - [freopen()](https://linux.die.net/man/3/fopen).
dkato 0:b22a1df967cb 765 - STATUS: This is not tested.
dkato 0:b22a1df967cb 766 - [fread()](https://linux.die.net/man/3/fread).
dkato 0:b22a1df967cb 767 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 768 - STATUS: n x 25kB stress test working.
dkato 0:b22a1df967cb 769 - [ftell()](https://linux.die.net/man/3/ftell).
dkato 0:b22a1df967cb 770 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 771 - [fwrite()](https://linux.die.net/man/3/fwrite).
dkato 0:b22a1df967cb 772 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 773 - STATUS: n x 25kB stress test working.
dkato 0:b22a1df967cb 774 - [fseek()](https://linux.die.net/man/3/fseek)
dkato 0:b22a1df967cb 775 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 776 - [getc()](https://linux.die.net/man/3/fgets).
dkato 0:b22a1df967cb 777 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 778 - [gets()](https://linux.die.net/man/3/fgets).
dkato 0:b22a1df967cb 779 - STATUS: Unknown.
dkato 0:b22a1df967cb 780 - [putc()](https://linux.die.net/man/3/fputs).
dkato 0:b22a1df967cb 781 - STATUS: Unknown.
dkato 0:b22a1df967cb 782 - [puts()](https://linux.die.net/man/3/fputs).
dkato 0:b22a1df967cb 783 - STATUS: Unknown.
dkato 0:b22a1df967cb 784 - [remove()](https://linux.die.net/man/3/remove)
dkato 0:b22a1df967cb 785 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 786 - [rewind()](https://linux.die.net/man/3/rewind).
dkato 0:b22a1df967cb 787 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 788 - [stat()](https://linux.die.net/man/2/stat)
dkato 0:b22a1df967cb 789 - STATUS: Implemented. Working.
dkato 0:b22a1df967cb 790 - STATUS: Not supported by ARMCC/IAR libc.
dkato 0:b22a1df967cb 791 - [tmpfile()](https://linux.die.net/man/3/tmpfile).
dkato 0:b22a1df967cb 792 - STATUS: Not implemented.
dkato 0:b22a1df967cb 793 - [tmpnam()](https://linux.die.net/man/3/tmpnam).
dkato 0:b22a1df967cb 794 - STATUS: Not implemented.
dkato 0:b22a1df967cb 795
dkato 0:b22a1df967cb 796 Supported directory related operations are as follows:
dkato 0:b22a1df967cb 797
dkato 0:b22a1df967cb 798 - [closedir()](https://linux.die.net/man/3/closedir).
dkato 0:b22a1df967cb 799 - STATUS: Implemented. Working.
dkato 0:b22a1df967cb 800 - [mkdir()](https://linux.die.net/man/3/mkdir).
dkato 0:b22a1df967cb 801 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 802 - [opendir()](https://linux.die.net/man/3/opendir).
dkato 0:b22a1df967cb 803 - STATUS: Implemented. Working.
dkato 0:b22a1df967cb 804 - [readdir()](https://linux.die.net/man/3/readdir).
dkato 0:b22a1df967cb 805 - STATUS: Implemented. Working.
dkato 0:b22a1df967cb 806 - [remove()](https://linux.die.net/man/3/remove).
dkato 0:b22a1df967cb 807 - STATUS: Basic testing implemented. Working.
dkato 0:b22a1df967cb 808 - [rename()](https://linux.die.net/man/3/rename).
dkato 0:b22a1df967cb 809 - STATUS: Implemented. Not tested.
dkato 0:b22a1df967cb 810 - [rewinddir()](https://linux.die.net/man/3/rewinddir).
dkato 0:b22a1df967cb 811 - STATUS: Implemented. Found not to work. Test case not present in repo.
dkato 0:b22a1df967cb 812 - [seekdir()](https://linux.die.net/man/3/seekdir).
dkato 0:b22a1df967cb 813 - STATUS: Implemented. Found not to work. Test case not present in repo.
dkato 0:b22a1df967cb 814 - [telldir()](https://linux.die.net/man/3/telldir).
dkato 0:b22a1df967cb 815 - STATUS: Implemented. Found not to work. Test case not present in repo.
dkato 0:b22a1df967cb 816
dkato 0:b22a1df967cb 817 ### errno
dkato 0:b22a1df967cb 818
dkato 0:b22a1df967cb 819 Basic errno reporting is supported, tested and known to be working.
dkato 0:b22a1df967cb 820
dkato 0:b22a1df967cb 821
dkato 0:b22a1df967cb 822 # Related Projects Resources
dkato 0:b22a1df967cb 823
dkato 0:b22a1df967cb 824 The following are related mbed storage projects and useful resources:
dkato 0:b22a1df967cb 825
dkato 0:b22a1df967cb 826 - The [mbed-os repository](https://github.com/ARMmbed/mbed-os). This is the main mbed OS repository.
dkato 0:b22a1df967cb 827 - The [mbed-os-example-fat-filesystem repository](https://github.com/ARMmbed/mbed-os-example-fat-filesystem).
dkato 0:b22a1df967cb 828 This is an example project for the mbed OS FAT filesystem.
dkato 0:b22a1df967cb 829 - The [spiflash-driver repository](https://github.com/armmbed/spiflash-driver)
dkato 0:b22a1df967cb 830 - The [i2ceeprom-driver repository](https://github.com/ARMmbed/i2ceeprom-driver.git)
dkato 0:b22a1df967cb 831 - The [ci-test-shield repository](https://github.com/ARMmbed/ci-test-shield). This is the project describing
dkato 0:b22a1df967cb 832 the mbed-os Continuous Integration test shield, together with standard tests.
dkato 0:b22a1df967cb 833 - [POSIX File Interface ISO/IEC 9899:TC2 Documentation](http://www.eng.utah.edu/~cs5785/slides-f10/n1124.pdf).
dkato 0:b22a1df967cb 834 - [FATFS: Generic FAT File System Module used in mbed OS](http://elm-chan.org/fsw/ff/00index_e.html)
dkato 0:b22a1df967cb 835
dkato 0:b22a1df967cb 836
dkato 0:b22a1df967cb 837 # Appendix 1: Getting Started with SPIFlash-Driver Example
dkato 0:b22a1df967cb 838
dkato 0:b22a1df967cb 839 ## Overview
dkato 0:b22a1df967cb 840
dkato 0:b22a1df967cb 841 This example describes how to build and run the spiflash-driver SPIFBlockDevice examples to
dkato 0:b22a1df967cb 842 read and write data to a SPI NOR flash part connected to a K64F.
dkato 0:b22a1df967cb 843
dkato 0:b22a1df967cb 844 Hardware required:
dkato 0:b22a1df967cb 845
dkato 0:b22a1df967cb 846 - K64F.
dkato 0:b22a1df967cb 847 - CI test shield.
dkato 0:b22a1df967cb 848 - SPI NOR Flash Device wired to Arduino header pins e.g. the Macronix MX25R2035F. The datasheet is available
dkato 0:b22a1df967cb 849 from the [Macronix website](http://www.macronix.com/).
dkato 0:b22a1df967cb 850 - Micro USB cable.
dkato 0:b22a1df967cb 851
dkato 0:b22a1df967cb 852 Software required:
dkato 0:b22a1df967cb 853
dkato 0:b22a1df967cb 854 - mbed CLI (with all other dependencies installed).
dkato 0:b22a1df967cb 855 - ARMCC / GCC_ARM / IAR compiler.
dkato 0:b22a1df967cb 856 - mbed greentea.
dkato 0:b22a1df967cb 857 - git account.
dkato 0:b22a1df967cb 858
dkato 0:b22a1df967cb 859 Github repos to use:
dkato 0:b22a1df967cb 860
dkato 0:b22a1df967cb 861 - The [mbed OS repository](https://github.com/armmbed/mbed-os)
dkato 0:b22a1df967cb 862 - The [SPI Flash Driver repository](https://github.com/armmbed/spiflash-driver)
dkato 0:b22a1df967cb 863
dkato 0:b22a1df967cb 864 ## Simple SPIFBlockDevice Example
dkato 0:b22a1df967cb 865
dkato 0:b22a1df967cb 866 This section describes how to create an application project combining the
dkato 0:b22a1df967cb 867 mbed-os and spiflash-driver repositories into a single project.
dkato 0:b22a1df967cb 868 In summary the following steps will be covered in this section:
dkato 0:b22a1df967cb 869
dkato 0:b22a1df967cb 870 - A top level application project directory is created. The directory name is ex_app2.
dkato 0:b22a1df967cb 871 - In the ex_app2 directory, the mbed-os repository is cloned.
dkato 0:b22a1df967cb 872 - In the ex_app2 directory at the same level as the mbed-os directory, the spiflash-driver repository is cloned.
dkato 0:b22a1df967cb 873
dkato 0:b22a1df967cb 874 First create the top level application directory ex_app2 and move into it:
dkato 0:b22a1df967cb 875
dkato 0:b22a1df967cb 876 simhug01@E107851:/d/demo_area$ mkdir ex_app2
dkato 0:b22a1df967cb 877 simhug01@E107851:/d/demo_area$ pushd ex_app2
dkato 0:b22a1df967cb 878
dkato 0:b22a1df967cb 879 Next, get a clone of public mbed OS repository in the following way:
dkato 0:b22a1df967cb 880
dkato 0:b22a1df967cb 881 simhug01@E107851:/d/demo_area/ex_app2$ git clone git@github.com:/armmbed/mbed-os
dkato 0:b22a1df967cb 882 <trace removed>
dkato 0:b22a1df967cb 883 simhug01@E107851:/d/demo_area/ex_app2$
dkato 0:b22a1df967cb 884
dkato 0:b22a1df967cb 885 Next, get a clone of the spiflash-driver repository:
dkato 0:b22a1df967cb 886
dkato 0:b22a1df967cb 887 simhug01@E107851:/d/demo_area/ex_app2$ git clone git@github.com:/armmbed/spiflash-driver
dkato 0:b22a1df967cb 888 <trace removed>
dkato 0:b22a1df967cb 889 simhug01@E107851:/d/demo_area/ex_app2$
dkato 0:b22a1df967cb 890
dkato 0:b22a1df967cb 891 In the top level directory create the example2.cpp:
dkato 0:b22a1df967cb 892
dkato 0:b22a1df967cb 893 simhug01@E107851:/d/demo_area/ex_app2$ touch example2.cpp
dkato 0:b22a1df967cb 894
dkato 0:b22a1df967cb 895 Copy the [spiflash-driver example code](https://github.com/armmbed/spiflash-driver)
dkato 0:b22a1df967cb 896 and paste into example2.cpp (reproduced here for convenience and corrected to build for
dkato 0:b22a1df967cb 897 GCC_ARM):
dkato 0:b22a1df967cb 898
dkato 0:b22a1df967cb 899 // Here's an example using the MX25R SPI flash device on the K82F
dkato 0:b22a1df967cb 900 #include "mbed.h"
dkato 0:b22a1df967cb 901 #include "SPIFBlockDevice.h"
dkato 0:b22a1df967cb 902
dkato 0:b22a1df967cb 903 /* This is the original configuration of the SPI Flash Driver
dkato 0:b22a1df967cb 904 * pins for Freescale K82F development board. We're not using
dkato 0:b22a1df967cb 905 * this as we're using the CI Test Shield
dkato 0:b22a1df967cb 906 */
dkato 0:b22a1df967cb 907 // Create flash device on SPI bus with PTE5 as chip select
dkato 0:b22a1df967cb 908 //SPIFBlockDevice spif(PTE2, PTE4, PTE1, PTE5);
dkato 0:b22a1df967cb 909
dkato 0:b22a1df967cb 910 /* This configuration of the SPI Flash Driver pins is for
dkato 0:b22a1df967cb 911 * the Freescale K64F connecting the SPI pins on the
dkato 0:b22a1df967cb 912 * Arduino header to the SPI NOR part.
dkato 0:b22a1df967cb 913 */
dkato 0:b22a1df967cb 914 SPIFBlockDevice spif(D11, D12, D13, D10);
dkato 0:b22a1df967cb 915
dkato 0:b22a1df967cb 916
dkato 0:b22a1df967cb 917 int main() {
dkato 0:b22a1df967cb 918 printf("spif test\n");
dkato 0:b22a1df967cb 919
dkato 0:b22a1df967cb 920 // Initialize the SPI flash device and print the memory layout
dkato 0:b22a1df967cb 921 spif.init();
dkato 0:b22a1df967cb 922 printf("spif size: %llu\n", spif.size());
dkato 0:b22a1df967cb 923 printf("spif read size: %llu\n", spif.get_read_size());
dkato 0:b22a1df967cb 924 printf("spif program size: %llu\n", spif.get_program_size());
dkato 0:b22a1df967cb 925 printf("spif erase size: %llu\n", spif.get_erase_size());
dkato 0:b22a1df967cb 926
dkato 0:b22a1df967cb 927 // Write "Hello World!" to the first block
dkato 0:b22a1df967cb 928 char *buffer = (char*) malloc(spif.get_erase_size());
dkato 0:b22a1df967cb 929 sprintf(buffer, "Hello World!\n");
dkato 0:b22a1df967cb 930 spif.erase(0, spif.get_erase_size());
dkato 0:b22a1df967cb 931 spif.program(buffer, 0, spif.get_erase_size());
dkato 0:b22a1df967cb 932
dkato 0:b22a1df967cb 933 // Read back what was stored
dkato 0:b22a1df967cb 934 spif.read(buffer, 0, spif.get_erase_size());
dkato 0:b22a1df967cb 935 printf("%s", buffer);
dkato 0:b22a1df967cb 936
dkato 0:b22a1df967cb 937 // Deinitialize the device
dkato 0:b22a1df967cb 938 spif.deinit();
dkato 0:b22a1df967cb 939 }
dkato 0:b22a1df967cb 940
dkato 0:b22a1df967cb 941 Note the following modifications to the original code sample:
dkato 0:b22a1df967cb 942
dkato 0:b22a1df967cb 943 - The SPI Flash Driver instance `spif` is given the pin configuration
dkato 0:b22a1df967cb 944 for the SPI bus from the Arduino header pins D11, D12, D13 and D10,
dkato 0:b22a1df967cb 945 as noted in the comments.
dkato 0:b22a1df967cb 946 - The buffer type has been modified to char* to (see line with malloc() above).
dkato 0:b22a1df967cb 947
dkato 0:b22a1df967cb 948 The application can be built with the following command:
dkato 0:b22a1df967cb 949
dkato 0:b22a1df967cb 950 simhug01@E107851:/d/demo_area/ex_app2$ mbed compile -m K64F -t GCC_ARM 2>&1 | tee build_app_ex_app2_log.txt
dkato 0:b22a1df967cb 951
dkato 0:b22a1df967cb 952 Once the binary is built, copy the binary from `/d/demo_area/ex_app2/BUILD/K64F/GCC_ARM/example2.bin` to the K64F.
dkato 0:b22a1df967cb 953 After connecting a serial console and resetting the target, the following trace should be seen:
dkato 0:b22a1df967cb 954
dkato 0:b22a1df967cb 955 spif test
dkato 0:b22a1df967cb 956 spif size: 2097152
dkato 0:b22a1df967cb 957 spif read size: 1
dkato 0:b22a1df967cb 958 spif program size: 1
dkato 0:b22a1df967cb 959 spif erase size: 4096
dkato 0:b22a1df967cb 960 Hello World!
dkato 0:b22a1df967cb 961
dkato 0:b22a1df967cb 962
dkato 0:b22a1df967cb 963 ## Build the mbed OS Test Cases
dkato 0:b22a1df967cb 964
dkato 0:b22a1df967cb 965 If you have completed the previous section "Simple SPIFBlockDevice Example" then first prepare the environment by removing the BUILD
dkato 0:b22a1df967cb 966 directory and hiding or removing the example2.cpp:
dkato 0:b22a1df967cb 967
dkato 0:b22a1df967cb 968 simhug01@E107851:/d/demo_area/ex_app2$ rm -fR BUILD
dkato 0:b22a1df967cb 969 simhug01@E107851:/d/demo_area/ex_app2$ cp example2.cpp example2_cpp
dkato 0:b22a1df967cb 970
dkato 0:b22a1df967cb 971 Build the test cases for the K64F target using the following command:
dkato 0:b22a1df967cb 972
dkato 0:b22a1df967cb 973 simhug01@E107851:/d/demo_area/ex_app2$ mbed -v test --compile -t GCC_ARM -m K64F 2>&1 | tee build_tests_gcc_20170322_1007.txt
dkato 0:b22a1df967cb 974 <trace removed>
dkato 0:b22a1df967cb 975 simhug01@E107851:/d/demo_area/ex_app2$
dkato 0:b22a1df967cb 976
dkato 0:b22a1df967cb 977 The build trace is quite extensive but on a successful build you should see the following output at the end of the log:
dkato 0:b22a1df967cb 978
dkato 0:b22a1df967cb 979 Build successes:
dkato 0:b22a1df967cb 980 * K64F::GCC_ARM::MBED-BUILD
dkato 0:b22a1df967cb 981 * K64F::GCC_ARM::MBED-OS-FEATURES-FEATURE_LWIP-TESTS-MBEDMICRO-NET-CONNECTIVITY
dkato 0:b22a1df967cb 982 <trace removed>
dkato 0:b22a1df967cb 983 * K64F::GCC_ARM::MBED-OS-FEATURES-TESTS-FILESYSTEM-FAT_FILE_SYSTEM
dkato 0:b22a1df967cb 984 * K64F::GCC_ARM::MBED-OS-FEATURES-TESTS-FILESYSTEM-HEAP_BLOCK_DEVICE
dkato 0:b22a1df967cb 985 * K64F::GCC_ARM::MBED-OS-FEATURES-TESTS-FILESYSTEM-UTIL_BLOCK_DEVICE
dkato 0:b22a1df967cb 986 <trace removed>
dkato 0:b22a1df967cb 987 * K64F::GCC_ARM::MBED-OS-TESTS-STORAGE_ABSTRACTION-BASICAPI
dkato 0:b22a1df967cb 988 * K64F::GCC_ARM::SPIFLASH-DRIVER-TESTS-BLOCK_DEVICE-SPIF
dkato 0:b22a1df967cb 989
dkato 0:b22a1df967cb 990
dkato 0:b22a1df967cb 991 Build skips:
dkato 0:b22a1df967cb 992 * K64F::GCC_ARM::MBED-OS-FEATURES-FEATURE_LWIP-TESTS-MBEDMICRO-NET-TCP_PACKET_PRESSURE
dkato 0:b22a1df967cb 993 <trace removed>
dkato 0:b22a1df967cb 994
dkato 0:b22a1df967cb 995 Notice the following test in the spiflash-driver tree listed above:
dkato 0:b22a1df967cb 996
dkato 0:b22a1df967cb 997 - `K64F::GCC_ARM::SPIFLASH-DRIVER-TESTS-BLOCK_DEVICE-SPIF`
dkato 0:b22a1df967cb 998
dkato 0:b22a1df967cb 999
dkato 0:b22a1df967cb 1000 The SPIFBlockDevice test case is at following locations in the source code tree:
dkato 0:b22a1df967cb 1001
dkato 0:b22a1df967cb 1002 /d/demo_area/ex_app2/spiflash-driver/TESTS/block_device/spif/main.cpp
dkato 0:b22a1df967cb 1003
dkato 0:b22a1df967cb 1004 This provides an example of reading and writing data blocks to the block device interface for the SPI NOR part.
dkato 0:b22a1df967cb 1005
dkato 0:b22a1df967cb 1006 Run the test using the following command:
dkato 0:b22a1df967cb 1007
dkato 0:b22a1df967cb 1008 simhug01@E107851:/d/demo_area/ex_app2$ mbedgt -VS --test-by-names=spiflash-driver-tests-block_device-spif 2>&1 | tee run_test_gcc_20170322_1007.txt
dkato 0:b22a1df967cb 1009
dkato 0:b22a1df967cb 1010 The test output should look similar to the following trace:
dkato 0:b22a1df967cb 1011
dkato 0:b22a1df967cb 1012 (mx_env1) simhug01@E107851:/d/datastore/public/jobs/yr2017/2278/sdh_dev_mx1/ex_app5$ mbedgt -VS --test-by-names=spiflash-driver-tests-block_device-sp
dkato 0:b22a1df967cb 1013 if 2>&1 | tee 2278_run_test_ex_app5_br_master_time_20170322_1207_spif.txt
dkato 0:b22a1df967cb 1014 mbedgt: greentea test automation tool ver. 1.2.5
dkato 0:b22a1df967cb 1015 mbedgt: using multiple test specifications from current directory!
dkato 0:b22a1df967cb 1016 using 'BUILD\tests\K64F\GCC_ARM\test_spec.json'
dkato 0:b22a1df967cb 1017 mbedgt: detecting connected mbed-enabled devices...
dkato 0:b22a1df967cb 1018 mbedgt: detected 1 device
dkato 0:b22a1df967cb 1019 +---------------+----------------------+-------------+-------------+--------------------------------------------------+
dkato 0:b22a1df967cb 1020 | platform_name | platform_name_unique | serial_port | mount_point | target_id |
dkato 0:b22a1df967cb 1021 +---------------+----------------------+-------------+-------------+--------------------------------------------------+
dkato 0:b22a1df967cb 1022 | K64F | K64F[0] | COM46 | E: | 0240000029304e450023500878a3001df131000097969900 |
dkato 0:b22a1df967cb 1023 +---------------+----------------------+-------------+-------------+--------------------------------------------------+
dkato 0:b22a1df967cb 1024 mbedgt: processing target 'K64F' toolchain 'GCC_ARM' compatible platforms... (note: switch set to --parallel 1)
dkato 0:b22a1df967cb 1025 +---------------+----------------------+-------------+-------------+--------------------------------------------------+
dkato 0:b22a1df967cb 1026 | platform_name | platform_name_unique | serial_port | mount_point | target_id |
dkato 0:b22a1df967cb 1027 +---------------+----------------------+-------------+-------------+--------------------------------------------------+
dkato 0:b22a1df967cb 1028 | K64F | K64F[0] | COM46:9600 | E: | 0240000029304e450023500878a3001df131000097969900 |
dkato 0:b22a1df967cb 1029 +---------------+----------------------+-------------+-------------+--------------------------------------------------+
dkato 0:b22a1df967cb 1030 mbedgt: test case filter (specified with -n option)
dkato 0:b22a1df967cb 1031 test filtered in 'spiflash-driver-tests-block_device-spif'
dkato 0:b22a1df967cb 1032 mbedgt: running 1 test for platform 'K64F' and toolchain 'GCC_ARM'
dkato 0:b22a1df967cb 1033 use 1 instance of execution threads for testing
dkato 0:b22a1df967cb 1034 mbedgt: checking for 'host_tests' directory above image directory structure
dkato 0:b22a1df967cb 1035 'host_tests' directory not found: two directory levels above image path checked
dkato 0:b22a1df967cb 1036 mbedgt: selecting test case observer...
dkato 0:b22a1df967cb 1037 calling mbedhtrun: mbedhtrun -m K64F -p COM46:9600 -f "BUILD/tests/K64F/GCC_ARM/spiflash-driver/TESTS/block_device/spif/spif.bin" -d E: -C 4 -
dkato 0:b22a1df967cb 1038 c shell -t 0240000029304e450023500878a3001df131000097969900
dkato 0:b22a1df967cb 1039 mbedgt: mbed-host-test-runner: started
dkato 0:b22a1df967cb 1040 [1490184626.50][HTST][INF] host test executor ver. 1.1.6
dkato 0:b22a1df967cb 1041 [1490184626.50][HTST][INF] copy image onto target...
dkato 0:b22a1df967cb 1042 [1490184626.50][COPY][INF] Waiting up to 60 sec for '0240000029304e450023500878a3001df131000097969900' mount point (current is 'E:')...
dkato 0:b22a1df967cb 1043 1 file(s) copied.
dkato 0:b22a1df967cb 1044 [1490184635.79][HTST][INF] starting host test process...
dkato 0:b22a1df967cb 1045 [1490184636.10][CONN][INF] starting connection process...
dkato 0:b22a1df967cb 1046 [1490184636.10][CONN][INF] notify event queue about extra 60 sec timeout for serial port pooling
dkato 0:b22a1df967cb 1047 [1490184636.10][CONN][INF] initializing serial port listener...
dkato 0:b22a1df967cb 1048 [1490184636.10][PLGN][INF] Waiting up to 60 sec for '0240000029304e450023500878a3001df131000097969900' serial port (current is 'COM46')...
dkato 0:b22a1df967cb 1049 [1490184636.12][HTST][INF] setting timeout to: 60 sec
dkato 0:b22a1df967cb 1050 [1490184636.24][SERI][INF] serial(port=COM46, baudrate=9600, timeout=0.01)
dkato 0:b22a1df967cb 1051 <lines deleted to save space>
dkato 0:b22a1df967cb 1052 [1490184649.90][CONN][INF] found KV pair in stream: {{__testcase_name;Testing read write random blocks}}, queued...
dkato 0:b22a1df967cb 1053 [1490184649.97][CONN][RXD] >>> Running case #1: 'Testing read write random blocks'...
dkato 0:b22a1df967cb 1054 [1490184650.02][CONN][INF] found KV pair in stream: {{__testcase_start;Testing read write random blocks}}, queued...
dkato 0:b22a1df967cb 1055 [1490184650.05][CONN][RXD] read size: 1bytes (1bytes)
dkato 0:b22a1df967cb 1056 [1490184650.08][CONN][RXD] program size: 1bytes (1bytes)
dkato 0:b22a1df967cb 1057 [1490184650.12][CONN][RXD] erase size: 4kbytes (4096bytes)
dkato 0:b22a1df967cb 1058 [1490184650.13][CONN][RXD] total size: 2Mbytes (2097152bytes)
dkato 0:b22a1df967cb 1059 [1490184650.17][CONN][RXD] test 002d000:4096...
dkato 0:b22a1df967cb 1060 [1490184650.36][CONN][RXD] write 002d000:4096 aad8573abd84e79e5e3684fa5519aabb...
dkato 0:b22a1df967cb 1061 [1490184650.50][CONN][RXD] read 002d000:4096 aad8573abd84e79e5e3684fa5519aabb...
dkato 0:b22a1df967cb 1062 [1490184650.56][CONN][RXD] error 002d000:4096 00000000000000000000000000000000
dkato 0:b22a1df967cb 1063 [1490184650.58][CONN][RXD] test 0036000:4096...
dkato 0:b22a1df967cb 1064 [1490184650.77][CONN][RXD] write 0036000:4096 92fc08f5b4113047225a8d3b855e5460...
dkato 0:b22a1df967cb 1065 [1490184650.91][CONN][RXD] read 0036000:4096 92fc08f5b4113047225a8d3b855e5460...
dkato 0:b22a1df967cb 1066 [1490184650.97][CONN][RXD] error 0036000:4096 00000000000000000000000000000000
dkato 0:b22a1df967cb 1067 [1490184650.99][CONN][RXD] test 00c6000:4096...
dkato 0:b22a1df967cb 1068 [1490184651.16][CONN][RXD] write 00c6000:4096 89a030a34b17ca3545c7b007001ef74f...
dkato 0:b22a1df967cb 1069 [1490184651.32][CONN][RXD] read 00c6000:4096 89a030a34b17ca3545c7b007001ef74f...
dkato 0:b22a1df967cb 1070 [1490184651.38][CONN][RXD] error 00c6000:4096 00000000000000000000000000000000
dkato 0:b22a1df967cb 1071 [1490184651.40][CONN][RXD] test 00da000:4096...
dkato 0:b22a1df967cb 1072 [1490184651.60][CONN][RXD] write 00da000:4096 446fd0232a3d053af820b69c614b3662...
dkato 0:b22a1df967cb 1073 [1490184651.73][CONN][RXD] read 00da000:4096 446fd0232a3d053af820b69c614b3662...
dkato 0:b22a1df967cb 1074 [1490184651.79][CONN][RXD] error 00da000:4096 00000000000000000000000000000000
dkato 0:b22a1df967cb 1075 [1490184651.81][CONN][RXD] test 0188000:4096...
dkato 0:b22a1df967cb 1076 [1490184652.00][CONN][RXD] write 0188000:4096 9a36d3c6d4034958cade542a9f1e22c2...
dkato 0:b22a1df967cb 1077 [1490184652.14][CONN][RXD] read 0188000:4096 9a36d3c6d4034958cade542a9f1e22c2...
dkato 0:b22a1df967cb 1078 [1490184652.20][CONN][RXD] error 0188000:4096 00000000000000000000000000000000
dkato 0:b22a1df967cb 1079 [1490184652.21][CONN][RXD] test 015f000:4096...
dkato 0:b22a1df967cb 1080 [1490184652.42][CONN][RXD] write 015f000:4096 70f83b9cc6713736c60089a0fa55f12d...
dkato 0:b22a1df967cb 1081 [1490184652.55][CONN][RXD] read 015f000:4096 70f83b9cc6713736c60089a0fa55f12d...
dkato 0:b22a1df967cb 1082 [1490184652.61][CONN][RXD] error 015f000:4096 00000000000000000000000000000000
dkato 0:b22a1df967cb 1083 [1490184652.63][CONN][RXD] test 005c000:4096...
dkato 0:b22a1df967cb 1084 [1490184652.82][CONN][RXD] write 005c000:4096 47a0f043fda26135877bb11c7b7016dc...
dkato 0:b22a1df967cb 1085 [1490184652.96][CONN][RXD] read 005c000:4096 47a0f043fda26135877bb11c7b7016dc...
dkato 0:b22a1df967cb 1086 [1490184653.02][CONN][RXD] error 005c000:4096 00000000000000000000000000000000
dkato 0:b22a1df967cb 1087 [1490184653.04][CONN][RXD] test 0177000:4096...
dkato 0:b22a1df967cb 1088 [1490184653.24][CONN][RXD] write 0177000:4096 174f13941b6385d4a829f2d066a1e375...
dkato 0:b22a1df967cb 1089 [1490184653.37][CONN][RXD] read 0177000:4096 174f13941b6385d4a829f2d066a1e375...
dkato 0:b22a1df967cb 1090 [1490184653.42][CONN][RXD] error 0177000:4096 00000000000000000000000000000000
dkato 0:b22a1df967cb 1091 [1490184653.45][CONN][RXD] test 0173000:4096...
dkato 0:b22a1df967cb 1092 [1490184653.65][CONN][RXD] write 0173000:4096 383f0ca8cc86e3225362805329e0d659...
dkato 0:b22a1df967cb 1093 [1490184653.78][CONN][RXD] read 0173000:4096 383f0ca8cc86e3225362805329e0d659...
dkato 0:b22a1df967cb 1094 [1490184653.84][CONN][RXD] error 0173000:4096 00000000000000000000000000000000
dkato 0:b22a1df967cb 1095 [1490184653.86][CONN][RXD] test 01d9000:4096...
dkato 0:b22a1df967cb 1096 [1490184654.05][CONN][RXD] write 01d9000:4096 73f32decf08112f271131f9837b76f28...
dkato 0:b22a1df967cb 1097 [1490184654.19][CONN][RXD] read 01d9000:4096 73f32decf08112f271131f9837b76f28...
dkato 0:b22a1df967cb 1098 [1490184654.24][CONN][RXD] error 01d9000:4096 00000000000000000000000000000000
dkato 0:b22a1df967cb 1099 [1490184654.31][CONN][INF] found KV pair in stream: {{__testcase_finish;Testing read write random blocks;1;0}}, queued...
dkato 0:b22a1df967cb 1100 [1490184654.38][CONN][RXD] >>> 'Testing read write random blocks': 1 passed, 0 failed
dkato 0:b22a1df967cb 1101 [1490184654.38][CONN][RXD]
dkato 0:b22a1df967cb 1102 [1490184654.41][CONN][RXD] >>> Test cases: 1 passed, 0 failed
dkato 0:b22a1df967cb 1103 [1490184654.44][CONN][INF] found KV pair in stream: {{__testcase_summary;1;0}}, queued...
dkato 0:b22a1df967cb 1104 [1490184654.47][CONN][INF] found KV pair in stream: {{max_heap_usage;0}}, queued...
dkato 0:b22a1df967cb 1105 [1490184654.48][CONN][INF] found KV pair in stream: {{end;success}}, queued...
dkato 0:b22a1df967cb 1106 [1490184654.48][HTST][ERR] orphan event in main phase: {{max_heap_usage;0}}, timestamp=1490184654.467000
dkato 0:b22a1df967cb 1107 [1490184654.48][HTST][INF] __notify_complete(True)
dkato 0:b22a1df967cb 1108 [1490184654.50][CONN][INF] found KV pair in stream: {{__exit;0}}, queued...
dkato 0:b22a1df967cb 1109 [1490184654.51][HTST][INF] __exit(0)
dkato 0:b22a1df967cb 1110 [1490184654.52][HTST][INF] __exit_event_queue received
dkato 0:b22a1df967cb 1111 [1490184654.52][HTST][INF] test suite run finished after 4.75 sec...
dkato 0:b22a1df967cb 1112 [1490184654.53][CONN][INF] received special even '__host_test_finished' value='True', finishing
dkato 0:b22a1df967cb 1113 [1490184654.53][HTST][INF] CONN exited with code: 0
dkato 0:b22a1df967cb 1114 [1490184654.53][HTST][INF] No events in queue
dkato 0:b22a1df967cb 1115 [1490184654.53][HTST][INF] stopped consuming events
dkato 0:b22a1df967cb 1116 [1490184654.53][HTST][INF] host test result() call skipped, received: True
dkato 0:b22a1df967cb 1117 [1490184654.53][HTST][INF] calling blocking teardown()
dkato 0:b22a1df967cb 1118 [1490184654.53][HTST][INF] teardown() finished
dkato 0:b22a1df967cb 1119 [1490184654.53][HTST][INF] {{result;success}}
dkato 0:b22a1df967cb 1120 mbedgt: checking for GCOV data...
dkato 0:b22a1df967cb 1121 mbedgt: mbed-host-test-runner: stopped and returned 'OK'
dkato 0:b22a1df967cb 1122 mbedgt: test on hardware with target id: 0240000029304e450023500878a3001df131000097969900
dkato 0:b22a1df967cb 1123 mbedgt: test suite 'spiflash-driver-tests-block_device-spif' ......................................... OK in 28.42 sec
dkato 0:b22a1df967cb 1124 test case: 'Testing read write random blocks' ................................................ OK in 4.29 sec
dkato 0:b22a1df967cb 1125 mbedgt: test case summary: 1 pass, 0 failures
dkato 0:b22a1df967cb 1126 mbedgt: all tests finished!
dkato 0:b22a1df967cb 1127 mbedgt: shuffle seed: 0.0217829158
dkato 0:b22a1df967cb 1128 mbedgt: test suite report:
dkato 0:b22a1df967cb 1129 +--------------+---------------+-----------------------------------------+--------+--------------------+-------------+
dkato 0:b22a1df967cb 1130 | target | platform_name | test suite | result | elapsed_time (sec) | copy_method |
dkato 0:b22a1df967cb 1131 +--------------+---------------+-----------------------------------------+--------+--------------------+-------------+
dkato 0:b22a1df967cb 1132 | K64F-GCC_ARM | K64F | spiflash-driver-tests-block_device-spif | OK | 28.42 | shell |
dkato 0:b22a1df967cb 1133 +--------------+---------------+-----------------------------------------+--------+--------------------+-------------+
dkato 0:b22a1df967cb 1134 mbedgt: test suite results: 1 OK
dkato 0:b22a1df967cb 1135 mbedgt: test case report:
dkato 0:b22a1df967cb 1136 +--------------+---------------+-----------------------------------------+----------------------------------+--------+--------+--------+--------------------+
dkato 0:b22a1df967cb 1137 | target | platform_name | test suite | test case | passed | failed | result | elapsed_time (sec) |
dkato 0:b22a1df967cb 1138 +--------------+---------------+-----------------------------------------+----------------------------------+--------+--------+--------+--------------------+
dkato 0:b22a1df967cb 1139 | K64F-GCC_ARM | K64F | spiflash-driver-tests-block_device-spif | Testing read write random blocks | 1 | 0 | OK | 4.29 |
dkato 0:b22a1df967cb 1140 +--------------+---------------+-----------------------------------------+----------------------------------+--------+--------+--------+--------------------+
dkato 0:b22a1df967cb 1141 mbedgt: test case results: 1 OK
dkato 0:b22a1df967cb 1142 mbedgt: completed in 35.04 sec
dkato 0:b22a1df967cb 1143 (mx_env1) simhug01@E107851:/d/datastore/public/jobs/yr2017/2278/sdh_dev_mx1/ex_app5$
dkato 0:b22a1df967cb 1144
dkato 0:b22a1df967cb 1145
dkato 0:b22a1df967cb 1146
dkato 0:b22a1df967cb 1147 # Appendix 2: Getting Started With The I2C EEPROM Driver
dkato 0:b22a1df967cb 1148
dkato 0:b22a1df967cb 1149 Hardware required:
dkato 0:b22a1df967cb 1150
dkato 0:b22a1df967cb 1151 - K64F.
dkato 0:b22a1df967cb 1152 - CI test shield.
dkato 0:b22a1df967cb 1153 - Micro USB cable.
dkato 0:b22a1df967cb 1154
dkato 0:b22a1df967cb 1155 Software required:
dkato 0:b22a1df967cb 1156
dkato 0:b22a1df967cb 1157 - mbed CLI (with all other dependencies installed).
dkato 0:b22a1df967cb 1158 - ARMCC / GCC / IAR compiler.
dkato 0:b22a1df967cb 1159 - mbed greentea.
dkato 0:b22a1df967cb 1160 - git account.
dkato 0:b22a1df967cb 1161
dkato 0:b22a1df967cb 1162 Github repos to use:
dkato 0:b22a1df967cb 1163
dkato 0:b22a1df967cb 1164 - The [mbed OS repository](https://github.com/armmbed/mbed-os)
dkato 0:b22a1df967cb 1165 - The [I2C EEPROM driver repository](https://github.com/ARMmbed/i2ceeprom-driver.git)
dkato 0:b22a1df967cb 1166 - The [CI test shield repository](https://github.com/ARMmbed/ci-test-shield.git) for `mbed_app.json` application configuration file.
dkato 0:b22a1df967cb 1167
dkato 0:b22a1df967cb 1168 Steps to follow:
dkato 0:b22a1df967cb 1169
dkato 0:b22a1df967cb 1170 - Create an empty example project in a suitable directory. Move into it.
dkato 0:b22a1df967cb 1171 - Download mbed OS into the example directory via `mbed new .`
dkato 0:b22a1df967cb 1172 - Add the I2C EEPROM driver via `mbed add i2ceeprom-driver`
dkato 0:b22a1df967cb 1173 - Clone the CI test shield repository to another suitable directory. Copy the mbed_app.json
dkato 0:b22a1df967cb 1174 from the CI test shield directory to the top level of the newly created example directory.
dkato 0:b22a1df967cb 1175 - Make sure the I2C pins are SDA on D14 and SCL on D15 and the I2C EEPROM slave address is
dkato 0:b22a1df967cb 1176 0xA0 in the mbed_app.json that you just copied.
dkato 0:b22a1df967cb 1177 - Connect the target to the host machine. Run `mbed detect` to make sure the target is detected.
dkato 0:b22a1df967cb 1178 - Now we are ready to run the greentea tests on this target with
dkato 0:b22a1df967cb 1179 `mbed test -t ARM -m K64F -n i2ceeprom-driver-tests-block_device-i2cee -v`
dkato 0:b22a1df967cb 1180 - Note that the greentea test above makes use of the main.cpp supplied in the
dkato 0:b22a1df967cb 1181 `TESTS\block_device\i2cee` directory. You can customize this if required or use your own test
dkato 0:b22a1df967cb 1182 application via main.cpp. Be sure to have only 1 main(). If using a custom main() then you
dkato 0:b22a1df967cb 1183 can either have this in the TESTS directory or at the top level example directory.
dkato 0:b22a1df967cb 1184 - The tests should pass. If not, time to debug!!
dkato 0:b22a1df967cb 1185 - For other targets, please change the target ID string in the test command above to the
dkato 0:b22a1df967cb 1186 appropriate one. You can check the supported targets from mbed CLI using `mbed target --supported`.
dkato 0:b22a1df967cb 1187
dkato 0:b22a1df967cb 1188 The output should be like this:
dkato 0:b22a1df967cb 1189
dkato 0:b22a1df967cb 1190
dkato 0:b22a1df967cb 1191 Building library mbed-build (K64F, ARM)
dkato 0:b22a1df967cb 1192 Scan: i2c_ex1
dkato 0:b22a1df967cb 1193 Scan: FEATURE_BLE
dkato 0:b22a1df967cb 1194 Scan: FEATURE_COMMON_PAL
dkato 0:b22a1df967cb 1195 Scan: FEATURE_LWIP
dkato 0:b22a1df967cb 1196 Scan: FEATURE_UVISOR
dkato 0:b22a1df967cb 1197 Scan: FEATURE_ETHERNET_HOST
dkato 0:b22a1df967cb 1198 Scan: FEATURE_LOWPAN_BORDER_ROUTER
dkato 0:b22a1df967cb 1199 Scan: FEATURE_LOWPAN_HOST
dkato 0:b22a1df967cb 1200 Scan: FEATURE_LOWPAN_ROUTER
dkato 0:b22a1df967cb 1201 Scan: FEATURE_NANOSTACK
dkato 0:b22a1df967cb 1202 Scan: FEATURE_NANOSTACK_FULL
dkato 0:b22a1df967cb 1203 Scan: FEATURE_THREAD_BORDER_ROUTER
dkato 0:b22a1df967cb 1204 Scan: FEATURE_THREAD_END_DEVICE
dkato 0:b22a1df967cb 1205 Scan: FEATURE_THREAD_ROUTER
dkato 0:b22a1df967cb 1206 Scan: FEATURE_STORAGE
dkato 0:b22a1df967cb 1207 Scan: ARM
dkato 0:b22a1df967cb 1208 Scan: FEATURE_LWIP
dkato 0:b22a1df967cb 1209 Scan: FEATURE_STORAGE
dkato 0:b22a1df967cb 1210 Building project i2cee (K64F, ARM)
dkato 0:b22a1df967cb 1211 Scan: ARM
dkato 0:b22a1df967cb 1212 Scan: FEATURE_LWIP
dkato 0:b22a1df967cb 1213 Scan: FEATURE_STORAGE
dkato 0:b22a1df967cb 1214 Scan: i2cee
dkato 0:b22a1df967cb 1215 +-----------+-------+-------+-------+
dkato 0:b22a1df967cb 1216 | Module | .text | .data | .bss |
dkato 0:b22a1df967cb 1217 +-----------+-------+-------+-------+
dkato 0:b22a1df967cb 1218 | Misc | 49473 | 420 | 11628 |
dkato 0:b22a1df967cb 1219 | Subtotals | 49473 | 420 | 11628 |
dkato 0:b22a1df967cb 1220 +-----------+-------+-------+-------+
dkato 0:b22a1df967cb 1221 Allocated Heap: unknown
dkato 0:b22a1df967cb 1222 Allocated Stack: unknown
dkato 0:b22a1df967cb 1223 Total Static RAM memory (data + bss): 12048 bytes
dkato 0:b22a1df967cb 1224 Total RAM memory (data + bss + heap + stack): 12048 bytes
dkato 0:b22a1df967cb 1225 Total Flash memory (text + data + misc): 49893 bytes
dkato 0:b22a1df967cb 1226 Image: BUILD/tests/K64F/ARM/i2ceeprom-driver/TESTS/block_device/i2cee/i2cee.bin
dkato 0:b22a1df967cb 1227
dkato 0:b22a1df967cb 1228
dkato 0:b22a1df967cb 1229 Memory map breakdown for built projects (values in Bytes):
dkato 0:b22a1df967cb 1230 +-------+--------+-----------+------------+-------+------+-----------+-------------+
dkato 0:b22a1df967cb 1231 | name | target | toolchain | static_ram | stack | heap | total_ram | total_flash |
dkato 0:b22a1df967cb 1232 +-------+--------+-----------+------------+-------+------+-----------+-------------+
dkato 0:b22a1df967cb 1233 | i2cee | K64F | ARM | 12048 | 0 | 0 | 12048 | 49893 |
dkato 0:b22a1df967cb 1234 +-------+--------+-----------+------------+-------+------+-----------+-------------+
dkato 0:b22a1df967cb 1235
dkato 0:b22a1df967cb 1236
dkato 0:b22a1df967cb 1237 Build successes:
dkato 0:b22a1df967cb 1238 * K64F::ARM::I2CEEPROM-DRIVER-TESTS-BLOCK_DEVICE-I2CEE
dkato 0:b22a1df967cb 1239 * K64F::ARM::MBED-BUILD
dkato 0:b22a1df967cb 1240 mbedgt: greentea test automation tool ver. 1.2.5
dkato 0:b22a1df967cb 1241 mbedgt: test specification file 'C:\Ashok\SiPWorkshop\Filesystem\i2c_ex1\BUILD\tests\K64F\ARM\test_spec.json' (specified with --test-spec option)
dkato 0:b22a1df967cb 1242 mbedgt: using 'C:\Ashok\SiPWorkshop\Filesystem\i2c_ex1\BUILD\tests\K64F\ARM\test_spec.json' from current directory!
dkato 0:b22a1df967cb 1243 mbedgt: detecting connected mbed-enabled devices...
dkato 0:b22a1df967cb 1244 mbedgt: detected 1 device
dkato 0:b22a1df967cb 1245 mbedgt: processing target 'K64F' toolchain 'ARM' compatible platforms... (note: switch set to --parallel 1)
dkato 0:b22a1df967cb 1246 mbedgt: test case filter (specified with -n option)
dkato 0:b22a1df967cb 1247 test filtered in 'i2ceeprom-driver-tests-block_device-i2cee'
dkato 0:b22a1df967cb 1248 mbedgt: running 1 test for platform 'K64F' and toolchain 'ARM'
dkato 0:b22a1df967cb 1249 mbedgt: mbed-host-test-runner: started
dkato 0:b22a1df967cb 1250 mbedgt: checking for GCOV data...
dkato 0:b22a1df967cb 1251 mbedgt: test on hardware with target id: 0240000034544e45002600048e3800285a91000097969900
dkato 0:b22a1df967cb 1252 mbedgt: test suite 'i2ceeprom-driver-tests-block_device-i2cee' ....................................... OK in 11.79 sec
dkato 0:b22a1df967cb 1253 test case: 'Testing read write random blocks' ................................................ OK in 1.23 sec
dkato 0:b22a1df967cb 1254 mbedgt: test case summary: 1 pass, 0 failures
dkato 0:b22a1df967cb 1255 mbedgt: all tests finished!
dkato 0:b22a1df967cb 1256 mbedgt: shuffle seed: 0.1529521449
dkato 0:b22a1df967cb 1257 mbedgt: test suite report:
dkato 0:b22a1df967cb 1258 +----------+---------------+-------------------------------------------+--------+--------------------+-------------+
dkato 0:b22a1df967cb 1259 | target | platform_name | test suite | result | elapsed_time (sec) | copy_method |
dkato 0:b22a1df967cb 1260 +----------+---------------+-------------------------------------------+--------+--------------------+-------------+
dkato 0:b22a1df967cb 1261 | K64F-ARM | K64F | i2ceeprom-driver-tests-block_device-i2cee | OK | 11.79 | shell |
dkato 0:b22a1df967cb 1262 +----------+---------------+-------------------------------------------+--------+--------------------+-------------+
dkato 0:b22a1df967cb 1263 mbedgt: test suite results: 1 OK
dkato 0:b22a1df967cb 1264 mbedgt: test case report:
dkato 0:b22a1df967cb 1265 +----------+---------------+-------------------------------------------+----------------------------------+--------+--------+--------+--------------------+
dkato 0:b22a1df967cb 1266 | target | platform_name | test suite | test case | passed | failed | result | elapsed_time (sec) |
dkato 0:b22a1df967cb 1267 +----------+---------------+-------------------------------------------+----------------------------------+--------+--------+--------+--------------------+
dkato 0:b22a1df967cb 1268 | K64F-ARM | K64F | i2ceeprom-driver-tests-block_device-i2cee | Testing read write random blocks | 1 | 0 | OK | 1.23 |
dkato 0:b22a1df967cb 1269 +----------+---------------+-------------------------------------------+----------------------------------+--------+--------+--------+--------------------+
dkato 0:b22a1df967cb 1270 mbedgt: test case results: 1 OK
dkato 0:b22a1df967cb 1271 mbedgt: completed in 13.30 sec