Uan Dung / Mbed OS threads-test
Committer:
Uan
Date:
Sat Jul 20 09:28:34 2019 +0000
Revision:
0:30eb5c705d7f
Cambios

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Uan 0:30eb5c705d7f 1 # Getting started example for Mbed OS
Uan 0:30eb5c705d7f 2
Uan 0:30eb5c705d7f 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).)
Uan 0:30eb5c705d7f 4
Uan 0:30eb5c705d7f 5 Please install [Mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
Uan 0:30eb5c705d7f 6
Uan 0:30eb5c705d7f 7 ## Import the example application
Uan 0:30eb5c705d7f 8
Uan 0:30eb5c705d7f 9 From the command-line, import the example:
Uan 0:30eb5c705d7f 10
Uan 0:30eb5c705d7f 11 ```
Uan 0:30eb5c705d7f 12 mbed import mbed-os-example-blinky
Uan 0:30eb5c705d7f 13 cd mbed-os-example-blinky
Uan 0:30eb5c705d7f 14 ```
Uan 0:30eb5c705d7f 15
Uan 0:30eb5c705d7f 16 ### Now compile
Uan 0:30eb5c705d7f 17
Uan 0:30eb5c705d7f 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:
Uan 0:30eb5c705d7f 19
Uan 0:30eb5c705d7f 20 ```
Uan 0:30eb5c705d7f 21 mbed compile -m K64F -t ARM
Uan 0:30eb5c705d7f 22 ```
Uan 0:30eb5c705d7f 23
Uan 0:30eb5c705d7f 24 Your PC may take a few minutes to compile your code. At the end, you see the following result:
Uan 0:30eb5c705d7f 25
Uan 0:30eb5c705d7f 26 ```
Uan 0:30eb5c705d7f 27 [snip]
Uan 0:30eb5c705d7f 28
Uan 0:30eb5c705d7f 29 Image: ./BUILD/K64F/GCC_ARM/mbed-os-example-blinky.bin
Uan 0:30eb5c705d7f 30 ```
Uan 0:30eb5c705d7f 31
Uan 0:30eb5c705d7f 32 ### Program your board
Uan 0:30eb5c705d7f 33
Uan 0:30eb5c705d7f 34 1. Connect your Mbed device to the computer over USB.
Uan 0:30eb5c705d7f 35 1. Copy the binary file to the Mbed device.
Uan 0:30eb5c705d7f 36 1. Press the reset button to start the program.
Uan 0:30eb5c705d7f 37
Uan 0:30eb5c705d7f 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:
Uan 0:30eb5c705d7f 39
Uan 0:30eb5c705d7f 40 * System Information:
Uan 0:30eb5c705d7f 41 * Mbed OS Version: Will currently default to 999999
Uan 0:30eb5c705d7f 42 * Compiler ID
Uan 0:30eb5c705d7f 43 * ARM = 1
Uan 0:30eb5c705d7f 44 * GCC_ARM = 2
Uan 0:30eb5c705d7f 45 * IAR = 3
Uan 0:30eb5c705d7f 46 * [CPUID Register Information](#cpuid-register-information)
Uan 0:30eb5c705d7f 47 * [Compiler Version](#compiler-version)
Uan 0:30eb5c705d7f 48 * CPU Statistics
Uan 0:30eb5c705d7f 49 * Percentage of runtime that the device has spent awake versus in sleep
Uan 0:30eb5c705d7f 50 * Heap Statistics
Uan 0:30eb5c705d7f 51 * Current heap size
Uan 0:30eb5c705d7f 52 * Max heap size which refers to the largest the heap has grown to
Uan 0:30eb5c705d7f 53 * Thread Statistics
Uan 0:30eb5c705d7f 54 * Provides information on all running threads in the OS including
Uan 0:30eb5c705d7f 55 * Thread ID
Uan 0:30eb5c705d7f 56 * Thread Name
Uan 0:30eb5c705d7f 57 * Thread State
Uan 0:30eb5c705d7f 58 * Thread Priority
Uan 0:30eb5c705d7f 59 * Thread Stack Size
Uan 0:30eb5c705d7f 60 * Thread Stack Space
Uan 0:30eb5c705d7f 61
Uan 0:30eb5c705d7f 62 #### Compiler Version
Uan 0:30eb5c705d7f 63
Uan 0:30eb5c705d7f 64 | Compiler | Version Layout |
Uan 0:30eb5c705d7f 65 | -------- | -------------- |
Uan 0:30eb5c705d7f 66 | ARM | PVVbbbb (P = Major; VV = Minor; bbbb = build number) |
Uan 0:30eb5c705d7f 67 | GCC | VVRRPP (VV = Version; RR = Revision; PP = Patch) |
Uan 0:30eb5c705d7f 68 | IAR | VRRRPPP (V = Version; RRR = Revision; PPP = Patch) |
Uan 0:30eb5c705d7f 69
Uan 0:30eb5c705d7f 70 #### CPUID Register Information
Uan 0:30eb5c705d7f 71
Uan 0:30eb5c705d7f 72 | Bit Field | Field Description | Values |
Uan 0:30eb5c705d7f 73 | --------- | ----------------- | ------ |
Uan 0:30eb5c705d7f 74 |[31:24] | Implementer | 0x41 = ARM |
Uan 0:30eb5c705d7f 75 |[23:20] | Variant | Major revision 0x0 = Revision 0 |
Uan 0:30eb5c705d7f 76 |[19:16] | Architecture | 0xC = Baseline Architecture |
Uan 0:30eb5c705d7f 77 | | | 0xF = Constant (Mainline Architecture) |
Uan 0:30eb5c705d7f 78 |[15:4] | Part Number | 0xC20 = Cortex-M0 |
Uan 0:30eb5c705d7f 79 | | | 0xC60 = Cortex-M0+ |
Uan 0:30eb5c705d7f 80 | | | 0xC23 = Cortex-M3 |
Uan 0:30eb5c705d7f 81 | | | 0xC24 = Cortex-M4 |
Uan 0:30eb5c705d7f 82 | | | 0xC27 = Cortex-M7 |
Uan 0:30eb5c705d7f 83 | | | 0xD20 = Cortex-M23 |
Uan 0:30eb5c705d7f 84 | | | 0xD21 = Cortex-M33 |
Uan 0:30eb5c705d7f 85 |[3:0] | Revision | Minor revision: 0x1 = Patch 1 |
Uan 0:30eb5c705d7f 86
Uan 0:30eb5c705d7f 87
Uan 0:30eb5c705d7f 88
Uan 0:30eb5c705d7f 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).
Uan 0:30eb5c705d7f 90
Uan 0:30eb5c705d7f 91
Uan 0:30eb5c705d7f 92 ### Output
Uan 0:30eb5c705d7f 93
Uan 0:30eb5c705d7f 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.
Uan 0:30eb5c705d7f 95
Uan 0:30eb5c705d7f 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).
Uan 0:30eb5c705d7f 97
Uan 0:30eb5c705d7f 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):
Uan 0:30eb5c705d7f 99
Uan 0:30eb5c705d7f 100 ```
Uan 0:30eb5c705d7f 101 =============================== SYSTEM INFO ================================
Uan 0:30eb5c705d7f 102 Mbed OS Version: 999999
Uan 0:30eb5c705d7f 103 CPU ID: 0x410fc241
Uan 0:30eb5c705d7f 104 Compiler ID: 2
Uan 0:30eb5c705d7f 105 Compiler Version: 60300
Uan 0:30eb5c705d7f 106 RAM0: Start 0x20000000 Size: 0x30000
Uan 0:30eb5c705d7f 107 RAM1: Start 0x1fff0000 Size: 0x10000
Uan 0:30eb5c705d7f 108 ROM0: Start 0x0 Size: 0x100000
Uan 0:30eb5c705d7f 109 ================= CPU STATS =================
Uan 0:30eb5c705d7f 110 Idle: 98% Usage: 2%
Uan 0:30eb5c705d7f 111 ================ HEAP STATS =================
Uan 0:30eb5c705d7f 112 Current heap: 1096
Uan 0:30eb5c705d7f 113 Max heap size: 1096
Uan 0:30eb5c705d7f 114 ================ THREAD STATS ===============
Uan 0:30eb5c705d7f 115 ID: 0x20001eac
Uan 0:30eb5c705d7f 116 Name: main_thread
Uan 0:30eb5c705d7f 117 State: 2
Uan 0:30eb5c705d7f 118 Priority: 24
Uan 0:30eb5c705d7f 119 Stack Size: 4096
Uan 0:30eb5c705d7f 120 Stack Space: 3296
Uan 0:30eb5c705d7f 121
Uan 0:30eb5c705d7f 122 ID: 0x20000f5c
Uan 0:30eb5c705d7f 123 Name: idle_thread
Uan 0:30eb5c705d7f 124 State: 1
Uan 0:30eb5c705d7f 125 Priority: 1
Uan 0:30eb5c705d7f 126 Stack Size: 512
Uan 0:30eb5c705d7f 127 Stack Space: 352
Uan 0:30eb5c705d7f 128
Uan 0:30eb5c705d7f 129 ID: 0x20000f18
Uan 0:30eb5c705d7f 130 Name: timer_thread
Uan 0:30eb5c705d7f 131 State: 3
Uan 0:30eb5c705d7f 132 Priority: 40
Uan 0:30eb5c705d7f 133 Stack Size: 768
Uan 0:30eb5c705d7f 134 Stack Space: 664
Uan 0:30eb5c705d7f 135
Uan 0:30eb5c705d7f 136 ```
Uan 0:30eb5c705d7f 137
Uan 0:30eb5c705d7f 138 ## Troubleshooting
Uan 0:30eb5c705d7f 139
Uan 0:30eb5c705d7f 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.
Uan 0:30eb5c705d7f 141
Uan 0:30eb5c705d7f 142 ## Related Links
Uan 0:30eb5c705d7f 143
Uan 0:30eb5c705d7f 144 * [Mbed OS Stats API](https://os.mbed.com/docs/latest/apis/mbed-statistics.html)
Uan 0:30eb5c705d7f 145 * [Mbed OS Configuration](https://os.mbed.com/docs/latest/reference/configuration.html)
Uan 0:30eb5c705d7f 146 * [Mbed OS Serial Communication](https://os.mbed.com/docs/latest/tutorials/serial-communication.html)
Uan 0:30eb5c705d7f 147
Uan 0:30eb5c705d7f 148 ### License and contributions
Uan 0:30eb5c705d7f 149
Uan 0:30eb5c705d7f 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.
Uan 0:30eb5c705d7f 151
Uan 0:30eb5c705d7f 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.