marcin ch / Mbed OS mbed-os-example-blinky_LPC54608
Committer:
marcinch
Date:
Thu Dec 06 11:50:57 2018 +0000
Revision:
4:3bc63d11d829
Parent:
0:09421d80c468
Info about publishing code added

Who changed what in which revision?

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