AVC Code

Dependencies:   FRDM-TFC

Committer:
lamoreauxaj
Date:
Sat Mar 09 22:17:08 2019 +0000
Revision:
7:6efd4f07ae00
Parent:
0:8a7153ecd2bc
k

Who changed what in which revision?

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