SD card file helloworld demo using new mbed RTOS ver 5 file driver setup. Pins setup for LPC1768 - read comment in code about project's json file requirements for adding the SD filesystem driver
SD card r/w demo for mbed OS version 5 on LPC1768.
File drivers are added in json file with "target.components_add": ["SD"] for use in most recent OS 5 version.
Test messages are sent to serial port with printf's.
README.md@2:21d14147254e, 2019-09-24 (annotated)
- Committer:
- 4180_1
- Date:
- Tue Sep 24 18:16:27 2019 +0000
- Revision:
- 2:21d14147254e
- Parent:
- 0:3588d7473dce
ver 1.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
4180_1 | 0:3588d7473dce | 1 | # Getting started example for Mbed OS |
4180_1 | 0:3588d7473dce | 2 | |
4180_1 | 0:3588d7473dce | 3 | This guide reviews the steps required to get Blinky with the addition of dynamic OS statistics working on an Mbed OS platform. (Note: To see a rendered example you can import into the Arm Online Compiler, please see our [quick start](https://os.mbed.com/docs/mbed-os/latest/quick-start/online-with-the-online-compiler.html#importing-the-code).) |
4180_1 | 0:3588d7473dce | 4 | |
4180_1 | 0:3588d7473dce | 5 | Please install [Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). |
4180_1 | 0:3588d7473dce | 6 | |
4180_1 | 0:3588d7473dce | 7 | ## Import the example application |
4180_1 | 0:3588d7473dce | 8 | |
4180_1 | 0:3588d7473dce | 9 | From the command-line, import the example: |
4180_1 | 0:3588d7473dce | 10 | |
4180_1 | 0:3588d7473dce | 11 | ``` |
4180_1 | 0:3588d7473dce | 12 | mbed import mbed-os-example-blinky |
4180_1 | 0:3588d7473dce | 13 | cd mbed-os-example-blinky |
4180_1 | 0:3588d7473dce | 14 | ``` |
4180_1 | 0:3588d7473dce | 15 | |
4180_1 | 0:3588d7473dce | 16 | ### Now compile |
4180_1 | 0:3588d7473dce | 17 | |
4180_1 | 0:3588d7473dce | 18 | Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the Arm Compiler: |
4180_1 | 0:3588d7473dce | 19 | |
4180_1 | 0:3588d7473dce | 20 | ``` |
4180_1 | 0:3588d7473dce | 21 | mbed compile -m K64F -t ARM |
4180_1 | 0:3588d7473dce | 22 | ``` |
4180_1 | 0:3588d7473dce | 23 | |
4180_1 | 0:3588d7473dce | 24 | Your PC may take a few minutes to compile your code. At the end, you see the following result: |
4180_1 | 0:3588d7473dce | 25 | |
4180_1 | 0:3588d7473dce | 26 | ``` |
4180_1 | 0:3588d7473dce | 27 | [snip] |
4180_1 | 0:3588d7473dce | 28 | |
4180_1 | 0:3588d7473dce | 29 | Image: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin |
4180_1 | 0:3588d7473dce | 30 | ``` |
4180_1 | 0:3588d7473dce | 31 | |
4180_1 | 0:3588d7473dce | 32 | ### Program your board |
4180_1 | 0:3588d7473dce | 33 | |
4180_1 | 0:3588d7473dce | 34 | 1. Connect your Mbed device to the computer over USB. |
4180_1 | 0:3588d7473dce | 35 | 1. Copy the binary file to the Mbed device. |
4180_1 | 0:3588d7473dce | 36 | 1. Press the reset button to start the program. |
4180_1 | 0:3588d7473dce | 37 | |
4180_1 | 0:3588d7473dce | 38 | The LED on your platform turns on and off. The main thread will additionally take a snapshot of the device's runtime statistics and display it over serial to your PC. The snapshot includes: |
4180_1 | 0:3588d7473dce | 39 | |
4180_1 | 0:3588d7473dce | 40 | * System Information: |
4180_1 | 0:3588d7473dce | 41 | * Mbed OS Version: Will currently default to 999999 |
4180_1 | 0:3588d7473dce | 42 | * Compiler ID |
4180_1 | 0:3588d7473dce | 43 | * ARM = 1 |
4180_1 | 0:3588d7473dce | 44 | * GCC_ARM = 2 |
4180_1 | 0:3588d7473dce | 45 | * IAR = 3 |
4180_1 | 0:3588d7473dce | 46 | * [CPUID Register Information](#cpuid-register-information) |
4180_1 | 0:3588d7473dce | 47 | * [Compiler Version](#compiler-version) |
4180_1 | 0:3588d7473dce | 48 | * CPU Statistics |
4180_1 | 0:3588d7473dce | 49 | * Percentage of runtime that the device has spent awake versus in sleep |
4180_1 | 0:3588d7473dce | 50 | * Heap Statistics |
4180_1 | 0:3588d7473dce | 51 | * Current heap size |
4180_1 | 0:3588d7473dce | 52 | * Max heap size which refers to the largest the heap has grown to |
4180_1 | 0:3588d7473dce | 53 | * Thread Statistics |
4180_1 | 0:3588d7473dce | 54 | * Provides information on all running threads in the OS including |
4180_1 | 0:3588d7473dce | 55 | * Thread ID |
4180_1 | 0:3588d7473dce | 56 | * Thread Name |
4180_1 | 0:3588d7473dce | 57 | * Thread State |
4180_1 | 0:3588d7473dce | 58 | * Thread Priority |
4180_1 | 0:3588d7473dce | 59 | * Thread Stack Size |
4180_1 | 0:3588d7473dce | 60 | * Thread Stack Space |
4180_1 | 0:3588d7473dce | 61 | |
4180_1 | 0:3588d7473dce | 62 | #### Compiler Version |
4180_1 | 0:3588d7473dce | 63 | |
4180_1 | 0:3588d7473dce | 64 | | Compiler | Version Layout | |
4180_1 | 0:3588d7473dce | 65 | | -------- | -------------- | |
4180_1 | 0:3588d7473dce | 66 | | ARM | PVVbbbb (P = Major; VV = Minor; bbbb = build number) | |
4180_1 | 0:3588d7473dce | 67 | | GCC | VVRRPP (VV = Version; RR = Revision; PP = Patch) | |
4180_1 | 0:3588d7473dce | 68 | | IAR | VRRRPPP (V = Version; RRR = Revision; PPP = Patch) | |
4180_1 | 0:3588d7473dce | 69 | |
4180_1 | 0:3588d7473dce | 70 | #### CPUID Register Information |
4180_1 | 0:3588d7473dce | 71 | |
4180_1 | 0:3588d7473dce | 72 | | Bit Field | Field Description | Values | |
4180_1 | 0:3588d7473dce | 73 | | --------- | ----------------- | ------ | |
4180_1 | 0:3588d7473dce | 74 | |[31:24] | Implementer | 0x41 = ARM | |
4180_1 | 0:3588d7473dce | 75 | |[23:20] | Variant | Major revision 0x0 = Revision 0 | |
4180_1 | 0:3588d7473dce | 76 | |[19:16] | Architecture | 0xC = Baseline Architecture | |
4180_1 | 0:3588d7473dce | 77 | | | | 0xF = Constant (Mainline Architecture) | |
4180_1 | 0:3588d7473dce | 78 | |[15:4] | Part Number | 0xC20 = Cortex-M0 | |
4180_1 | 0:3588d7473dce | 79 | | | | 0xC60 = Cortex-M0+ | |
4180_1 | 0:3588d7473dce | 80 | | | | 0xC23 = Cortex-M3 | |
4180_1 | 0:3588d7473dce | 81 | | | | 0xC24 = Cortex-M4 | |
4180_1 | 0:3588d7473dce | 82 | | | | 0xC27 = Cortex-M7 | |
4180_1 | 0:3588d7473dce | 83 | | | | 0xD20 = Cortex-M23 | |
4180_1 | 0:3588d7473dce | 84 | | | | 0xD21 = Cortex-M33 | |
4180_1 | 0:3588d7473dce | 85 | |[3:0] | Revision | Minor revision: 0x1 = Patch 1 | |
4180_1 | 0:3588d7473dce | 86 | |
4180_1 | 0:3588d7473dce | 87 | |
4180_1 | 0:3588d7473dce | 88 | |
4180_1 | 0:3588d7473dce | 89 | You can view individual examples and additional API information of the statistics collection tools at the bottom of the page in the [related links section](#related-links). |
4180_1 | 0:3588d7473dce | 90 | |
4180_1 | 0:3588d7473dce | 91 | |
4180_1 | 0:3588d7473dce | 92 | ### Output |
4180_1 | 0:3588d7473dce | 93 | |
4180_1 | 0:3588d7473dce | 94 | To view the serial output you can use any terminal client of your choosing such as [PuTTY](http://www.putty.org/) or [CoolTerm](http://freeware.the-meiers.org/). Unless otherwise specified, printf defaults to a baud rate of 9600 on Mbed OS. |
4180_1 | 0:3588d7473dce | 95 | |
4180_1 | 0:3588d7473dce | 96 | You can find more information on the Mbed OS configuration tools and serial communication in Mbed OS in the related [related links section](#related-links). |
4180_1 | 0:3588d7473dce | 97 | |
4180_1 | 0:3588d7473dce | 98 | The output should contain the following block transmitted at the blinking LED frequency (actual values may vary depending on your target, build profile, and toolchain): |
4180_1 | 0:3588d7473dce | 99 | |
4180_1 | 0:3588d7473dce | 100 | ``` |
4180_1 | 0:3588d7473dce | 101 | =============================== SYSTEM INFO ================================ |
4180_1 | 0:3588d7473dce | 102 | Mbed OS Version: 999999 |
4180_1 | 0:3588d7473dce | 103 | CPU ID: 0x410fc241 |
4180_1 | 0:3588d7473dce | 104 | Compiler ID: 2 |
4180_1 | 0:3588d7473dce | 105 | Compiler Version: 60300 |
4180_1 | 0:3588d7473dce | 106 | RAM0: Start 0x20000000 Size: 0x30000 |
4180_1 | 0:3588d7473dce | 107 | RAM1: Start 0x1fff0000 Size: 0x10000 |
4180_1 | 0:3588d7473dce | 108 | ROM0: Start 0x0 Size: 0x100000 |
4180_1 | 0:3588d7473dce | 109 | ================= CPU STATS ================= |
4180_1 | 0:3588d7473dce | 110 | Idle: 98% Usage: 2% |
4180_1 | 0:3588d7473dce | 111 | ================ HEAP STATS ================= |
4180_1 | 0:3588d7473dce | 112 | Current heap: 1096 |
4180_1 | 0:3588d7473dce | 113 | Max heap size: 1096 |
4180_1 | 0:3588d7473dce | 114 | ================ THREAD STATS =============== |
4180_1 | 0:3588d7473dce | 115 | ID: 0x20001eac |
4180_1 | 0:3588d7473dce | 116 | Name: main_thread |
4180_1 | 0:3588d7473dce | 117 | State: 2 |
4180_1 | 0:3588d7473dce | 118 | Priority: 24 |
4180_1 | 0:3588d7473dce | 119 | Stack Size: 4096 |
4180_1 | 0:3588d7473dce | 120 | Stack Space: 3296 |
4180_1 | 0:3588d7473dce | 121 | |
4180_1 | 0:3588d7473dce | 122 | ID: 0x20000f5c |
4180_1 | 0:3588d7473dce | 123 | Name: idle_thread |
4180_1 | 0:3588d7473dce | 124 | State: 1 |
4180_1 | 0:3588d7473dce | 125 | Priority: 1 |
4180_1 | 0:3588d7473dce | 126 | Stack Size: 512 |
4180_1 | 0:3588d7473dce | 127 | Stack Space: 352 |
4180_1 | 0:3588d7473dce | 128 | |
4180_1 | 0:3588d7473dce | 129 | ID: 0x20000f18 |
4180_1 | 0:3588d7473dce | 130 | Name: timer_thread |
4180_1 | 0:3588d7473dce | 131 | State: 3 |
4180_1 | 0:3588d7473dce | 132 | Priority: 40 |
4180_1 | 0:3588d7473dce | 133 | Stack Size: 768 |
4180_1 | 0:3588d7473dce | 134 | Stack Space: 664 |
4180_1 | 0:3588d7473dce | 135 | |
4180_1 | 0:3588d7473dce | 136 | ``` |
4180_1 | 0:3588d7473dce | 137 | |
4180_1 | 0:3588d7473dce | 138 | ## Troubleshooting |
4180_1 | 0:3588d7473dce | 139 | |
4180_1 | 0:3588d7473dce | 140 | If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it. |
4180_1 | 0:3588d7473dce | 141 | |
4180_1 | 0:3588d7473dce | 142 | ## Related Links |
4180_1 | 0:3588d7473dce | 143 | |
4180_1 | 0:3588d7473dce | 144 | * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html) |
4180_1 | 0:3588d7473dce | 145 | * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html) |
4180_1 | 0:3588d7473dce | 146 | * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html) |
4180_1 | 0:3588d7473dce | 147 | |
4180_1 | 0:3588d7473dce | 148 | ### License and contributions |
4180_1 | 0:3588d7473dce | 149 | |
4180_1 | 0:3588d7473dce | 150 | The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see contributing.md for more info. |
4180_1 | 0:3588d7473dce | 151 | |
4180_1 | 0:3588d7473dce | 152 | This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide. |