xx

Committer:
danteeickhoff
Date:
Sun Dec 09 22:34:28 2018 +0000
Revision:
0:5aa0f12e7698
xx

Who changed what in which revision?

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