hfyfyu

Committer:
bogthe
Date:
Sat Jan 12 13:55:39 2019 +0000
Revision:
0:d9dd72246908
uyjg

Who changed what in which revision?

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