zz

Dependencies:   WS2812 PixelArray final_project

Committer:
kimhyunjun
Date:
Sun Jun 16 17:35:35 2019 +0000
Revision:
0:c96221a59771
aaa

Who changed what in which revision?

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