Uan Dung / Mbed OS Final4

Dependencies:   MLX90614

Committer:
Uan
Date:
Tue Jun 30 07:38:14 2020 +0000
Revision:
0:feecd42e3ef8
Test;

Who changed what in which revision?

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