|
| 1 | +# FAT32 Filesystem Support README # |
| 2 | + |
| 3 | +Simon Hughes |
| 4 | + |
| 5 | +20161219 |
| 6 | + |
| 7 | +Version 0.02 |
| 8 | + |
| 9 | + |
| 10 | +# Executive Summary |
| 11 | + |
| 12 | +These notes are intended to help the mbed client team adopt the mbedOS POSIX File API support. The notes cover: |
| 13 | + |
| 14 | +- Brief notes on how to setup the mbedOS development environment, including links to other resources. |
| 15 | +- How to build the mbedOS test cases. |
| 16 | +- How to run the POSIX File API test case. |
| 17 | + |
| 18 | +Note the following: |
| 19 | + |
| 20 | +- The mbedOS FAT32/SDCard support implements a POSIX File API for off-chip, persistent file storage. |
| 21 | +- The FAT32/SDCard support was present in mbedOS 2, but was moved to the "unsupported" area of the source tree in mbedOS 5. |
| 22 | + This is because there are currently no FAT32/SDCard POSIX API test cases in the public repository, software quality is hence unknown, and the features are therefore unsupported. |
| 23 | +- The implementation of new test cases is an active development activity. So far, one test binary (basic.cpp) has been implemented and is available on the mbed-os branch called 'feature-storage'. The test case support |
| 24 | + is being enhanced as a matter of urgency. |
| 25 | +- The work described here is intended to make the POSIX File API available to the mbed client team before the Christmas holidays. |
| 26 | + Further test cases will be implemented and when completed, the work will be merged into the public repository master branch. In the meantime, |
| 27 | + the work is available from feature-storage branch. |
| 28 | + |
| 29 | +# Getting Started |
| 30 | + |
| 31 | +This section describes how to build and run the POSIX file API test case. The following steps are covered: |
| 32 | + |
| 33 | +- [Installing the Tools](#installing-the-tools). This section briefly describes how to setup the mbedos development environment. |
| 34 | +- [Git Clone the Public mbedOS Repo](#git-clone-the-mbedos-repo). This section describes how to git clone the mbedOS repository containing the FAT32/SDCard and POSIX File API test case of interest. |
| 35 | +- [Build the mbedOS Test Cases](#build-the-mbedos-test-cases). This section describes how to build the mbedOS test cases. |
| 36 | +- [Run the POSIX File Test Case](#run-the-posix-file-test-cases).This section describes how to run the POSIX file test case basic.cpp. |
| 37 | + |
| 38 | +### <a name="installing-the-tools"></a> Installing the Tools |
| 39 | + |
| 40 | +The following tools should be installed: |
| 41 | + |
| 42 | +- arm-none-eabi-gcc. See [mbedOS Development Environment Setup Howto Notes][MBED_DEVENV_NOTES] for guidance. |
| 43 | +- Python 2.7.9 or later. See [mbedOS Development Environment Setup Howto Notes][MBED_DEVENV_NOTES] for guidance. |
| 44 | +- mbed Greentea. This is the mbedOS test tool. |
| 45 | +- Git Bash. See [mbedOS Development Environment Setup Howto Notes][MBED_DEVENV_NOTES] for guidance. |
| 46 | +- mbed-cli. This is the tool used to make mbedOS application and test builds. |
| 47 | + |
| 48 | +Using a Git Bash terminal, setup mbed-cli in the following way: |
| 49 | + |
| 50 | + simhug01@E107851:/d/demo_area$ git clone [email protected]:/armmbed/mbed-cli |
| 51 | + <trace removed> |
| 52 | + simhug01@E107851:/d/demo_area$ pushd mbed-cli |
| 53 | + simhug01@E107851:/d/demo_area/mbed-cli/$ python.exe setup.py install |
| 54 | + simhug01@E107851:/d/demo_area/mbed-cli/$ popd |
| 55 | + |
| 56 | + |
| 57 | +Using a Git Bash terminal, setup Greentea in the following way: |
| 58 | + |
| 59 | + simhug01@E107851:/d/demo_area$ git clone [email protected]:/armmbed/greentea |
| 60 | + <trace removed> |
| 61 | + simhug01@E107851:/d/demo_area$ pushd greentea |
| 62 | + simhug01@E107851:/d/demo_area/greentea/$ python.exe setup.py install |
| 63 | + simhug01@E107851:/d/demo_area/greentea/$ popd |
| 64 | + simhug01@E107851:/d/demo_area/$ |
| 65 | + |
| 66 | + |
| 67 | +### <a name="git-clone-the-mbedos-repo"></a> Git Clone the Public mbedOS Repo |
| 68 | + |
| 69 | +Get a clone of public mbedOS repository in the following way |
| 70 | + |
| 71 | + simhug01@E107851:/d/demo_area$ mkdir ex_app1 |
| 72 | + simhug01@E107851:/d/demo_area$ pushd ex_app1 |
| 73 | + simhug01@E107851:/d/demo_area/ex_app1$ git clone [email protected]:/armmbed/mbed-os |
| 74 | + <trace removed> |
| 75 | + simhug01@E107851:/d/demo_area/ex_app1$ |
| 76 | + |
| 77 | + |
| 78 | +### <a name="build-the-mbedos-test-cases"></a> Build the mbedOS Test Cases |
| 79 | + |
| 80 | +Switch to the `feature-storage` branch using the following commands: |
| 81 | + |
| 82 | + simhug01@E107851:/d/demo_area/ex_app1$ pushd mbed-os |
| 83 | + simhug01@E107851:/d/demo_area/ex_app1$ git branch |
| 84 | + * master |
| 85 | + feature-storage |
| 86 | + <other branches deleted> |
| 87 | + simhug01@E107851:/d/demo_area/ex_app1$ git checkout feature-storage |
| 88 | + Switched to branch 'feature-storage' |
| 89 | + simhug01@E107851:/d/demo_area/ex_app1$ git branch |
| 90 | + master |
| 91 | + * feature-storage |
| 92 | + <other branches deleted> |
| 93 | + simhug01@E107851:/d/demo_area/ex_app1$ |
| 94 | + |
| 95 | +Build the test cases for the K64F target using the following commands: |
| 96 | + |
| 97 | + simhug01@E107851:/d/demo_area/ex_app1$ mbed -v test --compile -t GCC_ARM -m K64F -DFSFAT_SDCARD_INSTALLED 2>&1 | tee build_tests_gcc_20161219_1007.txt |
| 98 | + <trace removed> |
| 99 | + simhug01@E107851:/d/demo_area/ex_app1$ |
| 100 | + |
| 101 | +The complete [build log][BUILD-TESTS-GCC-20161219-1007] is available for reference. |
| 102 | + |
| 103 | + |
| 104 | +### <a name="run-the-posix-file-test-cases"></a> Run the POSIX File Test Case |
| 105 | + |
| 106 | +To setup for running the test cases, complete the following steps: |
| 107 | + |
| 108 | +- Insert a micro SDCard into K64F SDCard socket. |
| 109 | +- Connect the K64F development board to your PC using a suitable USB cable. |
| 110 | + |
| 111 | +All tests can be run using the following command: |
| 112 | + |
| 113 | + simhug01@E107851:/d/demo_area/ex_app1$ mbedgt -VS |
| 114 | + <trace removed> |
| 115 | + |
| 116 | +However, it's possible to run a particular test case using the following .json file: |
| 117 | + |
| 118 | + { |
| 119 | + "builds": { |
| 120 | + "K64F-GCC_ARM": { |
| 121 | + "binary_type": "bootable", |
| 122 | + "tests": { |
| 123 | + "mbed-os-features-storage-feature_storage-tests-fs-fat-basic": { |
| 124 | + "binaries": [ |
| 125 | + { |
| 126 | + "path": "BUILD/tests/K64F/GCC_ARM/mbed-os/features/storage/FEATURE_STORAGE/TESTS/fs-fat/basic/basic.bin" |
| 127 | + } |
| 128 | + ] |
| 129 | + } |
| 130 | + }, |
| 131 | + "toolchain": "GCC_ARM", |
| 132 | + "base_path": "BUILD/tests/K64F/GCC_ARM", |
| 133 | + "baud_rate": 9600, |
| 134 | + "platform": "K64F" |
| 135 | + } |
| 136 | + } |
| 137 | + } |
| 138 | + |
| 139 | +Store the above text in a file called `ex_app1_fat_basic_spec.json` in the ex_app1 directory. The test can be run using the following command: |
| 140 | + |
| 141 | + simhug01@E107851:/d/demo_area/ex_app1$ mbedgt -VS --test-spec=ex_app1_fat_basic_spec.json 2>&1 | tee run_tests_master_gcc_ex_app2_fat_basic_20161219_1011.txt |
| 142 | + <trace removed> |
| 143 | + |
| 144 | +On a successful run, the following table will be shown at the end of the log: |
| 145 | + |
| 146 | + mbedgt: test suite 'mbed-os-features-storage-feature_storage-tests-fs-fat-basic' ..................... OK in 15.86 sec |
| 147 | + test case: 'FSFAT_test_00: fopen()/fgetc()/fprintf()/fclose() test.' ......................... OK in 0.90 sec |
| 148 | + test case: 'FSFAT_test_01: fopen()/fseek()/fclose() test.' ................................... OK in 0.32 sec |
| 149 | + mbedgt: test case summary: 2 passes, 0 failures |
| 150 | + mbedgt: all tests finished! |
| 151 | + mbedgt: shuffle seed: 0.7720862854 |
| 152 | + mbedgt: test suite report: |
| 153 | + +--------------+---------------+-------------------------------------------------------------+--------+--------------------+-------------+ |
| 154 | + | target | platform_name | test suite | result | elapsed_time (sec) | copy_method | |
| 155 | + +--------------+---------------+-------------------------------------------------------------+--------+--------------------+-------------+ |
| 156 | + | K64F-GCC_ARM | K64F | mbed-os-features-storage-feature_storage-tests-fs-fat-basic | OK | 15.86 | shell | |
| 157 | + +--------------+---------------+-------------------------------------------------------------+--------+--------------------+-------------+ |
| 158 | + mbedgt: test suite results: 1 OK |
| 159 | + mbedgt: test case report: |
| 160 | + +--------------+---------------+-------------------------------------------------------------+---------------------------------------------------------+--------+--------+--------+--------------------+ |
| 161 | + | target | platform_name | test suite | test case | passed | failed | result | elapsed_time (sec) | |
| 162 | + +--------------+---------------+-------------------------------------------------------------+---------------------------------------------------------+--------+--------+--------+--------------------+ |
| 163 | + | K64F-GCC_ARM | K64F | mbed-os-features-storage-feature_storage-tests-fs-fat-basic | FSFAT_test_00: fopen()/fgetc()/fprintf()/fclose() test. | 1 | 0 | OK | 0.9 | |
| 164 | + | K64F-GCC_ARM | K64F | mbed-os-features-storage-feature_storage-tests-fs-fat-basic | FSFAT_test_01: fopen()/fseek()/fclose() test. | 1 | 0 | OK | 0.32 | |
| 165 | + +--------------+---------------+-------------------------------------------------------------+---------------------------------------------------------+--------+--------+--------+--------------------+ |
| 166 | + mbedgt: test case results: 2 OK |
| 167 | + mbedgt: completed in 16.53 sec |
| 168 | + |
| 169 | + |
| 170 | +The full [test output log][RUN-TESTS-GCC-20161219-1011] is available for reference. |
| 171 | + |
| 172 | + |
| 173 | +# POSIX File API |
| 174 | + |
| 175 | +mbedOS supports a subset of the POSIX File API, as outlined below: |
| 176 | + |
| 177 | +- [fclose()][MAN_FCLOSE]. |
| 178 | +- [fgetc(), fgets(), getc(), gets()][MAN_FGETS]. |
| 179 | +- [fputc(), fputs(), putc(), puts()][MAN_FPUTS]. |
| 180 | +- fprintf() |
| 181 | +- fopen() |
| 182 | +- freopen() |
| 183 | +- [fread()][MAN_FREAD] |
| 184 | +- [fwrite()][MAN_FWRITE] |
| 185 | +- [fseek()][MAN_FSEEK] |
| 186 | +- [remove()][MAN_REMOVE] |
| 187 | +- [rewind()][MAN_REWIND]. |
| 188 | + |
| 189 | +The FAT32/SDCard support is at the following location in the source code tree: |
| 190 | + |
| 191 | + <mbed-os_src_root>\features\storage\FEATURE_STORAGE\fs |
| 192 | + |
| 193 | +The FAT32/SDCard test cases are at following locations in the source code tree: |
| 194 | + |
| 195 | + <mbed-os_src_root>\features\storage\FEATURE_STORAGE\TESTS\fs-fat\basic\basic.cpp |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | +# Further Reading |
| 202 | + |
| 203 | +* The [mbedOS Development Environment Setup Notes][MBED_DEVENV_NOTES]. |
| 204 | +* The example mbedOS build log [BUILD-TESTS-GCC-20161219-1007][BUILD-TESTS-GCC-20161219-1007] for reference. |
| 205 | +* The example mbedOS test run log [RUN-TESTS-GCC-20161219-1011][RUN-TESTS-GCC-20161219-1011] for reference. |
| 206 | + |
| 207 | + |
| 208 | +[MBED_DEVENV_NOTES]: https://github.com/ARMmbed/meVo/blob/master/docs/ARM_MBED/TN/ARM_MBED_TN_0017/12-mbed_devenv_setup_how_to_notes.docx |
| 209 | +[BUILD-TESTS-GCC-20161219-1007]: https://github.com/ARMmbed/meVo/blob/master/docs/ARM_MBED/TN/ARM_MBED_TN_0017/build_tests_gcc_20161219_1007.txt |
| 210 | +[RUN-TESTS-GCC-20161219-1011]: https://github.com/ARMmbed/meVo/blob/master/docs/ARM_MBED/TN/ARM_MBED_TN_0017/run_tests_master_gcc_ex_app2_fat_basic_20161219_1011.txt |
| 211 | + |
| 212 | +[MAN_FCLOSE]: https://linux.die.net/man/3/fclose |
| 213 | +[MAN_FGETS]: https://linux.die.net/man/3/fgets |
| 214 | +[MAN_FPUTS]: https://linux.die.net/man/3/fputs |
| 215 | +[MAN_FREAD]: https://linux.die.net/man/3/fread |
| 216 | +[MAN_FSEEK]: https://linux.die.net/man/3/fseek |
| 217 | +[MAN_FWRITE]: https://linux.die.net/man/3/fwrite |
| 218 | +[MAN_REMOVE]: https://linux.die.net/man/3/remove |
| 219 | +[MAN_REWIND]: https://linux.die.net/man/3/rewind |
0 commit comments