mirror of https://github.com/ARMmbed/mbed-os.git
Refer to example readme, instead re-writing all steps
parent
4745e0b21f
commit
f99690487b
163
README.md
163
README.md
|
@ -174,168 +174,7 @@ storage on SDCard:
|
|||
|
||||
# SDCard POSIX File API Example App for Reading/Writing Data
|
||||
|
||||
### Overview
|
||||
|
||||
This section describes how to build and run an example application that
|
||||
uses the POSIX File API to read and write data to SDCard. The discussion begins by
|
||||
descibing how to run the example on the FRDM K64F target, but this is later
|
||||
generalised to all target platforms that have the standard
|
||||
Arduino form factor headers. Tthe Continuous Integration (CI) Test Shield
|
||||
can be inserted into the headers to add a SDCard slot to the target.
|
||||
|
||||
The example code is a modified version of the
|
||||
[mbed-os-example-fat-filesystem](https://github.com/ARMmbed/mbed-os-example-fat-filesystem) example
|
||||
modified for use with the sd-driver.
|
||||
|
||||
The following sub-sections describe the steps for building and running the example:
|
||||
|
||||
- The [Pre-Requisites](#pre-requisites) section describes the development environment used for this example.
|
||||
Other similar development environments can be used.
|
||||
- The [Create the Example Project](#create-the-example-project) section describes how the application project is created
|
||||
by including the mbed-os and sd-driver code.
|
||||
- The [Build the Example Project](#build-the-example-project) section describes how to build the example application.
|
||||
- The [Insert SDCard into K64F](#insert-sdcard-into-k64f) section describes how to select a card and insert it into the
|
||||
SDCard slot on the K64F.
|
||||
- The [Run the Example Binary on the K64F](#run-the-example-binary-on-the-k64f) section describes how to run the
|
||||
example binary on the target and verify the example has run correctly.
|
||||
- The [Testing with an SDCard on Target XYZ](#testing-with-an-sdcard-on-target-xyx) section describes the use
|
||||
of Continuous Integration Test Shield, which hosts an SDCard slot. By inserting the CI test shield into the
|
||||
Arduino headers of an mbed target platform, the SDCard/FAT Filesystem components can be used to store data
|
||||
persistently on any standard mbed target development board.
|
||||
|
||||
|
||||
### <a name="pre-requisites"></a> Pre-Requisites
|
||||
|
||||
To work through this example, you should have a working development environment on your machine. For example,
|
||||
the following tools should be installed:
|
||||
|
||||
- A compiler e.g. arm-none-eabi-gcc.
|
||||
- Python 2.7.9 or later.
|
||||
- [mbed Greentea](https://github.com/armmbed/greentea), the mbed OS test tool.
|
||||
- Git Bash or a similar git command line tool to interact with the ARM mbed GitHub repositories.
|
||||
- [mbed-cli](https://github.com/armmbed/mbed-cli), the tool used to make mbed OS application and test builds.
|
||||
|
||||
For more information on how to setup a development environment, please review the documentation on the
|
||||
[mbed documentation site](https://docs.mbed.com).
|
||||
|
||||
|
||||
### <a name="create-the-example-project"></a> Create the Example Project
|
||||
|
||||
First create the top level application directory sd_ex1 and move into it:
|
||||
|
||||
shell:/d/demo_area$ mkdir sd_ex1
|
||||
shell:/d/demo_area$ cd sd_ex1
|
||||
shell:/d/demo_area/sd_ex1$
|
||||
|
||||
Next, perform the "mbed new" operation to download the mbed-os repository into this directory:
|
||||
|
||||
shell:/d/demo_area/sd_ex1$ mbed new .
|
||||
[mbed] Creating new program "ex_sdcard" (git)
|
||||
[mbed] Adding library "mbed-os" from "https://github.com/ARMmbed/mbed-os" at branch latest
|
||||
[mbed] Updating reference "mbed-os" -> "https://github.com/ARMmbed/mbed-os/#5faf4b26c5954d15c7c1cccac6498e0c690ad101"
|
||||
warning: LF will be replaced by CRLF in mbed-os.lib.
|
||||
The file will have its original line endings in your working directory.
|
||||
shell:/d/demo_area/sd_ex1$ ls -1
|
||||
mbed-os
|
||||
mbed-os.lib
|
||||
mbed_settings.py
|
||||
shell:/d/demo_area/sd_ex1$
|
||||
|
||||
Next, get add the sd-driver component to the application project:
|
||||
|
||||
shell:/d/demo_area/sd_ex1$ mbed add sd-driver
|
||||
<trace removed>
|
||||
shell:/d/demo_area/sd_ex1$
|
||||
|
||||
Next, copy the example1.cpp file and `mbed_lib.json` files from inside the sd-driver directory to the top level sd_ex1 directory:
|
||||
|
||||
shell:/d/demo_area/sd_ex1$ cp sd-driver/features/TESTS/examples/example1.cpp .
|
||||
shell:/d/demo_area/sd_ex1$ cp sd-driver/config/mbed_lib.json .
|
||||
shell:/d/demo_area/sd_ex1$
|
||||
|
||||
The `mbed_lib.json` file specifies the SPI bus pin configuration for different targets.
|
||||
The file includes a specific configuration of the K64F which is used
|
||||
because the mbed compile command specifies the K64F build target. The `mbed_lib.json` file
|
||||
is described in more detail in the [Testing with an SDCard on Target XYZ](#testing-with-an-sdcard-on-target-xyx) section.
|
||||
|
||||
### <a name="build-the-example-project"></a> Build the Example Project
|
||||
|
||||
Next, build the example application:
|
||||
|
||||
shell:/d/demo_area/sd_ex1$ mbed compile -m K64F -t GCC_ARM
|
||||
|
||||
|
||||
#### WARNING: "mbed new ." command and possible mbed-os sd-driver versioning incompatibilities
|
||||
|
||||
If you experience problems building the example then it may mean the version
|
||||
of the mbed-os repository created with the "mbed new ." command is not compatible with
|
||||
the sd-driver repository version created with "mbed add sd-driver" command. This is because:
|
||||
|
||||
- The "mbed new ." creates the mbed-os repository at the latest "Release" e.g. `mbed-os-5.4.0`.
|
||||
- The "mbed add sd-driver" command creates the sd-driver repository at the latest version of
|
||||
master i.e. the tip of master. Changes may be present that are not compatible with
|
||||
the latest mbed-os release e.g. in preparation for the next release.
|
||||
|
||||
This situation can be resolved by checking out compatible versions of the repositories as
|
||||
described in the section [Setting mbed-os/sd-driver Repositories To Compatible Versions](#settting-repos-to-compatible-versions)
|
||||
|
||||
### <a name="insert-sdcard-into-k64f"></a> Insert SDCard into K64F
|
||||
|
||||
The examples and test cases have been run on a K64F with the following pre-formatted microSDHC cards:
|
||||
|
||||
- Kingston 2GB mircoSDHC card.
|
||||
- Kingston 8GB mircoSDHC card.
|
||||
- SanDisk 16GB mircoSDHC ultra card.
|
||||
|
||||
If the card requires formatting then the following procedure is known to work:
|
||||
|
||||
- Insert microSD card into SD adapter in USB stick (or similar) so the microSD card can be insert into windows PC.
|
||||
- Within file explorer, right click/Format on the USB drive.
|
||||
- Select FAT32, 4096 cluster size, Quick Format.
|
||||
- Format the drive.
|
||||
|
||||
The microSD card should then be ready for use in the K64F. Insert the formatted card
|
||||
into the SDCard slot on the K64F PCB.
|
||||
|
||||
|
||||
### <a name="run-the-example-binary-on-the-k64f"></a> Run the Example Binary on the K64F
|
||||
|
||||
Once the binary is built, copy the binary from `/d/demo_area/sd_ex1/BUILD/K64F/GCC_ARM/example1.bin` to the K64F.
|
||||
After connecting a serial console and resetting the target, the following trace should be seen:
|
||||
|
||||
Welcome to the filesystem example.
|
||||
Opening a new file, numbers.txt. done.
|
||||
Writing decimal numbers to a file (20/20) done.
|
||||
Closing file. done.
|
||||
Re-opening file read-only. done.
|
||||
Dumping file to screen.
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
EOF.
|
||||
Closing file. done.
|
||||
Opening root directory. done.
|
||||
Printing all filenames:
|
||||
numbers.txt
|
||||
Closeing root directory. done.
|
||||
Filesystem Demo complete.
|
||||
Refer to [SD driver Example](https://github.com/ARMmbed/mbed-os-example-sd-driver)
|
||||
|
||||
|
||||
### <a name="testing-with-an-sdcard-on-target-xyx"></a> Testing with an SDCard on Target XYZ
|
||||
|
|
Loading…
Reference in New Issue