Works on our device
Dependencies: MS5607
README.md@0:1d19ec036b32, 2019-01-23 (annotated)
- Committer:
- mbenn250
- Date:
- Wed Jan 23 01:47:54 2019 +0000
- Revision:
- 0:1d19ec036b32
Functional
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbenn250 | 0:1d19ec036b32 | 1 | # Getting started example for Mbed OS |
mbenn250 | 0:1d19ec036b32 | 2 | |
mbenn250 | 0:1d19ec036b32 | 3 | This guide reviews the steps required to get Blinky with the addition of dynamic OS statistics working on an Mbed OS platform. |
mbenn250 | 0:1d19ec036b32 | 4 | |
mbenn250 | 0:1d19ec036b32 | 5 | Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). |
mbenn250 | 0:1d19ec036b32 | 6 | |
mbenn250 | 0:1d19ec036b32 | 7 | ## Import the example application |
mbenn250 | 0:1d19ec036b32 | 8 | |
mbenn250 | 0:1d19ec036b32 | 9 | From the command-line, import the example: |
mbenn250 | 0:1d19ec036b32 | 10 | |
mbenn250 | 0:1d19ec036b32 | 11 | ``` |
mbenn250 | 0:1d19ec036b32 | 12 | mbed import mbed-os-example-blinky |
mbenn250 | 0:1d19ec036b32 | 13 | cd mbed-os-example-blinky |
mbenn250 | 0:1d19ec036b32 | 14 | ``` |
mbenn250 | 0:1d19ec036b32 | 15 | |
mbenn250 | 0:1d19ec036b32 | 16 | ### Now compile |
mbenn250 | 0:1d19ec036b32 | 17 | |
mbenn250 | 0:1d19ec036b32 | 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 5: |
mbenn250 | 0:1d19ec036b32 | 19 | |
mbenn250 | 0:1d19ec036b32 | 20 | ``` |
mbenn250 | 0:1d19ec036b32 | 21 | mbed compile -m K64F -t ARM |
mbenn250 | 0:1d19ec036b32 | 22 | ``` |
mbenn250 | 0:1d19ec036b32 | 23 | |
mbenn250 | 0:1d19ec036b32 | 24 | Your PC may take a few minutes to compile your code. At the end, you see the following result: |
mbenn250 | 0:1d19ec036b32 | 25 | |
mbenn250 | 0:1d19ec036b32 | 26 | ``` |
mbenn250 | 0:1d19ec036b32 | 27 | [snip] |
mbenn250 | 0:1d19ec036b32 | 28 | +----------------------------+-------+-------+------+ |
mbenn250 | 0:1d19ec036b32 | 29 | | Module | .text | .data | .bss | |
mbenn250 | 0:1d19ec036b32 | 30 | |--------------------|-----------|----------|----------| |
mbenn250 | 0:1d19ec036b32 | 31 | | [fill] | 98(+0) | 0(+0) | 2211(+0) | |
mbenn250 | 0:1d19ec036b32 | 32 | | [lib]/c.a | 27835(+0) | 2472(+0) | 89(+0) | |
mbenn250 | 0:1d19ec036b32 | 33 | | [lib]/gcc.a | 3168(+0) | 0(+0) | 0(+0) | |
mbenn250 | 0:1d19ec036b32 | 34 | | [lib]/misc | 248(+0) | 8(+0) | 28(+0) | |
mbenn250 | 0:1d19ec036b32 | 35 | | [lib]/nosys.a | 32(+0) | 0(+0) | 0(+0) | |
mbenn250 | 0:1d19ec036b32 | 36 | | main.o | 924(+0) | 0(+0) | 12(+0) | |
mbenn250 | 0:1d19ec036b32 | 37 | | mbed-os/components | 134(+0) | 0(+0) | 0(+0) | |
mbenn250 | 0:1d19ec036b32 | 38 | | mbed-os/drivers | 56(+0) | 0(+0) | 0(+0) | |
mbenn250 | 0:1d19ec036b32 | 39 | | mbed-os/features | 42(+0) | 0(+0) | 184(+0) | |
mbenn250 | 0:1d19ec036b32 | 40 | | mbed-os/hal | 2087(+0) | 8(+0) | 152(+0) | |
mbenn250 | 0:1d19ec036b32 | 41 | | mbed-os/platform | 3633(+0) | 260(+0) | 209(+0) | |
mbenn250 | 0:1d19ec036b32 | 42 | | mbed-os/rtos | 9370(+0) | 168(+0) | 6053(+0) | |
mbenn250 | 0:1d19ec036b32 | 43 | | mbed-os/targets | 9536(+0) | 12(+0) | 382(+0) | |
mbenn250 | 0:1d19ec036b32 | 44 | | Subtotals | 57163(+0) | 2928(+0) | 9320(+0) | |
mbenn250 | 0:1d19ec036b32 | 45 | Total Static RAM memory (data + bss): 12248(+0) bytes |
mbenn250 | 0:1d19ec036b32 | 46 | Total Flash memory (text + data): 60091(+0) bytes |
mbenn250 | 0:1d19ec036b32 | 47 | |
mbenn250 | 0:1d19ec036b32 | 48 | Image: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin |
mbenn250 | 0:1d19ec036b32 | 49 | ``` |
mbenn250 | 0:1d19ec036b32 | 50 | |
mbenn250 | 0:1d19ec036b32 | 51 | ### Program your board |
mbenn250 | 0:1d19ec036b32 | 52 | |
mbenn250 | 0:1d19ec036b32 | 53 | 1. Connect your mbed device to the computer over USB. |
mbenn250 | 0:1d19ec036b32 | 54 | 1. Copy the binary file to the mbed device. |
mbenn250 | 0:1d19ec036b32 | 55 | 1. Press the reset button to start the program. |
mbenn250 | 0:1d19ec036b32 | 56 | |
mbenn250 | 0:1d19ec036b32 | 57 | 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: |
mbenn250 | 0:1d19ec036b32 | 58 | |
mbenn250 | 0:1d19ec036b32 | 59 | * System Information: |
mbenn250 | 0:1d19ec036b32 | 60 | * Mbed OS Version: Will currently default to 999999 |
mbenn250 | 0:1d19ec036b32 | 61 | * Compiler ID |
mbenn250 | 0:1d19ec036b32 | 62 | * ARM = 1 |
mbenn250 | 0:1d19ec036b32 | 63 | * GCC_ARM = 2 |
mbenn250 | 0:1d19ec036b32 | 64 | * IAR = 3 |
mbenn250 | 0:1d19ec036b32 | 65 | * [CPUID Register Information](#cpuid-register-information) |
mbenn250 | 0:1d19ec036b32 | 66 | * [Compiler Version](#compiler-version) |
mbenn250 | 0:1d19ec036b32 | 67 | * CPU Statistics |
mbenn250 | 0:1d19ec036b32 | 68 | * Percentage of runtime that the device has spent awake versus in sleep |
mbenn250 | 0:1d19ec036b32 | 69 | * Heap Statistics |
mbenn250 | 0:1d19ec036b32 | 70 | * Current heap size |
mbenn250 | 0:1d19ec036b32 | 71 | * Max heap size which refers to the largest the heap has grown to |
mbenn250 | 0:1d19ec036b32 | 72 | * Thread Statistics |
mbenn250 | 0:1d19ec036b32 | 73 | * Provides information on all running threads in the OS including |
mbenn250 | 0:1d19ec036b32 | 74 | * Thread ID |
mbenn250 | 0:1d19ec036b32 | 75 | * Thread Name |
mbenn250 | 0:1d19ec036b32 | 76 | * Thread State |
mbenn250 | 0:1d19ec036b32 | 77 | * Thread Priority |
mbenn250 | 0:1d19ec036b32 | 78 | * Thread Stack Size |
mbenn250 | 0:1d19ec036b32 | 79 | * Thread Stack Space |
mbenn250 | 0:1d19ec036b32 | 80 | |
mbenn250 | 0:1d19ec036b32 | 81 | #### Compiler Version |
mbenn250 | 0:1d19ec036b32 | 82 | |
mbenn250 | 0:1d19ec036b32 | 83 | | Compiler | Version Layout | |
mbenn250 | 0:1d19ec036b32 | 84 | | -------- | -------------- | |
mbenn250 | 0:1d19ec036b32 | 85 | | ARM | PVVbbbb (P = Major; VV = Minor; bbbb = build number) | |
mbenn250 | 0:1d19ec036b32 | 86 | | GCC | VVRRPP (VV = Version; RR = Revision; PP = Patch) | |
mbenn250 | 0:1d19ec036b32 | 87 | | IAR | VRRRPPP (V = Version; RRR = Revision; PPP = Patch) | |
mbenn250 | 0:1d19ec036b32 | 88 | |
mbenn250 | 0:1d19ec036b32 | 89 | #### CPUID Register Information |
mbenn250 | 0:1d19ec036b32 | 90 | |
mbenn250 | 0:1d19ec036b32 | 91 | | Bit Field | Field Description | Values | |
mbenn250 | 0:1d19ec036b32 | 92 | | --------- | ----------------- | ------ | |
mbenn250 | 0:1d19ec036b32 | 93 | |[31:24] | Implementer | 0x41 = ARM | |
mbenn250 | 0:1d19ec036b32 | 94 | |[23:20] | Variant | Major revision 0x0 = Revision 0 | |
mbenn250 | 0:1d19ec036b32 | 95 | |[19:16] | Architecture | 0xC = Baseline Architecture | |
mbenn250 | 0:1d19ec036b32 | 96 | | | | 0xF = Constant (Mainline Architecture) | |
mbenn250 | 0:1d19ec036b32 | 97 | |[15:4] | Part Number | 0xC20 = Cortex-M0 | |
mbenn250 | 0:1d19ec036b32 | 98 | | | | 0xC60 = Cortex-M0+ | |
mbenn250 | 0:1d19ec036b32 | 99 | | | | 0xC23 = Cortex-M3 | |
mbenn250 | 0:1d19ec036b32 | 100 | | | | 0xC24 = Cortex-M4 | |
mbenn250 | 0:1d19ec036b32 | 101 | | | | 0xC27 = Cortex-M7 | |
mbenn250 | 0:1d19ec036b32 | 102 | | | | 0xD20 = Cortex-M23 | |
mbenn250 | 0:1d19ec036b32 | 103 | | | | 0xD21 = Cortex-M33 | |
mbenn250 | 0:1d19ec036b32 | 104 | |[3:0] | Revision | Minor revision: 0x1 = Patch 1 | |
mbenn250 | 0:1d19ec036b32 | 105 | |
mbenn250 | 0:1d19ec036b32 | 106 | |
mbenn250 | 0:1d19ec036b32 | 107 | |
mbenn250 | 0:1d19ec036b32 | 108 | 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). |
mbenn250 | 0:1d19ec036b32 | 109 | |
mbenn250 | 0:1d19ec036b32 | 110 | |
mbenn250 | 0:1d19ec036b32 | 111 | ### Output |
mbenn250 | 0:1d19ec036b32 | 112 | |
mbenn250 | 0:1d19ec036b32 | 113 | 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/). |
mbenn250 | 0:1d19ec036b32 | 114 | |
mbenn250 | 0:1d19ec036b32 | 115 | The default baud rate for this application is set to `115200` and may be modified in the `mbed_app.json` file. |
mbenn250 | 0:1d19ec036b32 | 116 | |
mbenn250 | 0:1d19ec036b32 | 117 | You can find more information on the Mbed OS configuration tools and serail communication in Mbed OS in the related [related links section](#related-links). |
mbenn250 | 0:1d19ec036b32 | 118 | |
mbenn250 | 0:1d19ec036b32 | 119 | 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): |
mbenn250 | 0:1d19ec036b32 | 120 | |
mbenn250 | 0:1d19ec036b32 | 121 | ``` |
mbenn250 | 0:1d19ec036b32 | 122 | =============================== SYSTEM INFO ================================ |
mbenn250 | 0:1d19ec036b32 | 123 | Mbed OS Version: 999999 |
mbenn250 | 0:1d19ec036b32 | 124 | CPU ID: 0x410fc241 |
mbenn250 | 0:1d19ec036b32 | 125 | Compiler ID: 2 |
mbenn250 | 0:1d19ec036b32 | 126 | Compiler Version: 60300 |
mbenn250 | 0:1d19ec036b32 | 127 | ================= CPU STATS ================= |
mbenn250 | 0:1d19ec036b32 | 128 | Idle: 98% Usage: 2% |
mbenn250 | 0:1d19ec036b32 | 129 | ================ HEAP STATS ================= |
mbenn250 | 0:1d19ec036b32 | 130 | Current heap: 1096 |
mbenn250 | 0:1d19ec036b32 | 131 | Max heap size: 1096 |
mbenn250 | 0:1d19ec036b32 | 132 | ================ THREAD STATS =============== |
mbenn250 | 0:1d19ec036b32 | 133 | ID: 0x20001eac |
mbenn250 | 0:1d19ec036b32 | 134 | Name: main_thread |
mbenn250 | 0:1d19ec036b32 | 135 | State: 2 |
mbenn250 | 0:1d19ec036b32 | 136 | Priority: 24 |
mbenn250 | 0:1d19ec036b32 | 137 | Stack Size: 4096 |
mbenn250 | 0:1d19ec036b32 | 138 | Stack Space: 3296 |
mbenn250 | 0:1d19ec036b32 | 139 | |
mbenn250 | 0:1d19ec036b32 | 140 | ID: 0x20000f5c |
mbenn250 | 0:1d19ec036b32 | 141 | Name: idle_thread |
mbenn250 | 0:1d19ec036b32 | 142 | State: 1 |
mbenn250 | 0:1d19ec036b32 | 143 | Priority: 1 |
mbenn250 | 0:1d19ec036b32 | 144 | Stack Size: 512 |
mbenn250 | 0:1d19ec036b32 | 145 | Stack Space: 352 |
mbenn250 | 0:1d19ec036b32 | 146 | |
mbenn250 | 0:1d19ec036b32 | 147 | ID: 0x20000f18 |
mbenn250 | 0:1d19ec036b32 | 148 | Name: timer_thread |
mbenn250 | 0:1d19ec036b32 | 149 | State: 3 |
mbenn250 | 0:1d19ec036b32 | 150 | Priority: 40 |
mbenn250 | 0:1d19ec036b32 | 151 | Stack Size: 768 |
mbenn250 | 0:1d19ec036b32 | 152 | Stack Space: 664 |
mbenn250 | 0:1d19ec036b32 | 153 | |
mbenn250 | 0:1d19ec036b32 | 154 | ``` |
mbenn250 | 0:1d19ec036b32 | 155 | |
mbenn250 | 0:1d19ec036b32 | 156 | ## Troubleshooting |
mbenn250 | 0:1d19ec036b32 | 157 | |
mbenn250 | 0:1d19ec036b32 | 158 | 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. |
mbenn250 | 0:1d19ec036b32 | 159 | |
mbenn250 | 0:1d19ec036b32 | 160 | ## Related Links |
mbenn250 | 0:1d19ec036b32 | 161 | |
mbenn250 | 0:1d19ec036b32 | 162 | * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html) |
mbenn250 | 0:1d19ec036b32 | 163 | * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html) |
mbenn250 | 0:1d19ec036b32 | 164 | * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html) |