Implementation of Segger RTT on nRF52832. There is unneeded code in the defines and main(commented out).

Committer:
claytonk
Date:
Fri Apr 26 17:46:21 2019 +0000
Revision:
0:ead2f457b1a2
initial

Who changed what in which revision?

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