Example application demonstrating Memory stats API and debug functions

Fork of mbed-os-example-platform-utils by Senthil Ramakrishnan

Committer:
Senthil Ramakrishnan
Date:
Mon Oct 30 14:26:48 2017 -0500
Revision:
3:92b97ba04fd3
Parent:
2:c03cd481c34b
Fixed README

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SenRam 0:2ab002d36417 1 # mbed-os-example-platform-utils #
SenRam 0:2ab002d36417 2
SenRam 0:2ab002d36417 3 Platform Utilities usage example for mbed OS
SenRam 0:2ab002d36417 4
SenRam 0:2ab002d36417 5 This is a example showing how to use mbed-OS Debug and MemoryStats utility functions
SenRam 0:2ab002d36417 6
SenRam 0:2ab002d36417 7 The program retrieves stack and heap usage and also demonstrates the usage of Debug APIs.
SenRam 0:2ab002d36417 8
SenRam 0:2ab002d36417 9 ### Suggested hardware for running this example ###
SenRam 0:2ab002d36417 10
SenRam 0:2ab002d36417 11 * [K64F](https://os.mbed.com/platforms/FRDM-K64F/)
SenRam 0:2ab002d36417 12
SenRam 0:2ab002d36417 13 ## Getting started
SenRam 0:2ab002d36417 14
SenRam 0:2ab002d36417 15 1. Import the example
SenRam 0:2ab002d36417 16
SenRam 0:2ab002d36417 17 ```
SenRam 0:2ab002d36417 18 mbed import mbed-os-example-platform-utils
SenRam 0:2ab002d36417 19 cd mbed-os-example-platform-utils
SenRam 0:2ab002d36417 20 ```
SenRam 0:2ab002d36417 21 2. Compile and generate binary
SenRam 0:2ab002d36417 22
SenRam 0:2ab002d36417 23 For example, for `ARMCC`:
SenRam 0:2ab002d36417 24
SenRam 0:2ab002d36417 25 ```
Senthil Ramakrishnan 2:c03cd481c34b 26 mbed compile -t arm -m k64f -DMBED_STACK_STATS_ENABLED -DMBED_HEAP_STATS_ENABLED
SenRam 0:2ab002d36417 27 ```
SenRam 0:2ab002d36417 28
SenRam 0:2ab002d36417 29 NOTE: Make sure you define the following variables:
SenRam 0:2ab002d36417 30 MBED_STACK_STATS_ENABLED
SenRam 0:2ab002d36417 31 MBED_HEAP_STATS_ENABLED
Senthil Ramakrishnan 3:92b97ba04fd3 32
SenRam 0:2ab002d36417 33 5. Open a serial console session with the target platform using the following parameters:
SenRam 0:2ab002d36417 34 * **Baud rate:** 9600
SenRam 0:2ab002d36417 35 * **Data bits:** 8
SenRam 0:2ab002d36417 36 * **Stop bits:** 1
SenRam 0:2ab002d36417 37 * **Parity:** None
SenRam 0:2ab002d36417 38
SenRam 0:2ab002d36417 39 6. Copy or drag the application `mbed-os-example-platform-utils.bin` in the folder `mbed-os-example-platform-utils/BUILD/<TARGET NAME>/<PLATFORM NAME>` onto the target board.
SenRam 0:2ab002d36417 40
SenRam 0:2ab002d36417 41 7. The serial console should display a similar output to below:
SenRam 0:2ab002d36417 42 ```
SenRam 0:2ab002d36417 43 This message is from debug function
SenRam 0:2ab002d36417 44 This message is from debug_if
SenRam 0:2ab002d36417 45 MemoryStats:
SenRam 0:2ab002d36417 46 Bytes allocated currently: 80
SenRam 0:2ab002d36417 47 Max bytes allocated at a given time: 80
SenRam 0:2ab002d36417 48 Cumulative sum of bytes ever allocated: 80
SenRam 0:2ab002d36417 49 Current number of bytes allocated for the heap: 186884
SenRam 0:2ab002d36417 50 Current number of allocations: 2
SenRam 0:2ab002d36417 51 Number of failed allocations: 0
SenRam 0:2ab002d36417 52 Cumulative Stack Info:
SenRam 0:2ab002d36417 53 Maximum number of bytes used on the stack: 560
SenRam 0:2ab002d36417 54 Current number of bytes allocated for the stack: 5376
SenRam 0:2ab002d36417 55 Number of stacks stats accumulated in the structure: 3
SenRam 0:2ab002d36417 56 Thread Stack Info:
SenRam 0:2ab002d36417 57 Thread: 0
SenRam 0:2ab002d36417 58 Thread Id: 0x20001EE8
SenRam 0:2ab002d36417 59 Thread Name: "main_thread"
SenRam 0:2ab002d36417 60 Maximum number of bytes used on the stack: 384
SenRam 0:2ab002d36417 61 Current number of bytes allocated for the stack: 4096
SenRam 0:2ab002d36417 62 Number of stacks stats accumulated in the structure: 1
SenRam 0:2ab002d36417 63 Thread: 1
SenRam 0:2ab002d36417 64 Thread Id: 0x20000394
SenRam 0:2ab002d36417 65 Thread Name: ""
SenRam 0:2ab002d36417 66 Maximum number of bytes used on the stack: 64
SenRam 0:2ab002d36417 67 Current number of bytes allocated for the stack: 512
SenRam 0:2ab002d36417 68 Number of stacks stats accumulated in the structure: 1
SenRam 0:2ab002d36417 69 Thread: 2
SenRam 0:2ab002d36417 70 Thread Id: 0x200003DC
SenRam 0:2ab002d36417 71 Thread Name: ""
SenRam 0:2ab002d36417 72 Maximum number of bytes used on the stack: 112
SenRam 0:2ab002d36417 73 Current number of bytes allocated for the stack: 768
SenRam 0:2ab002d36417 74 Number of stacks stats accumulated in the structure: 1
SenRam 0:2ab002d36417 75 Done...
SenRam 0:2ab002d36417 76
SenRam 0:2ab002d36417 77 ```
SenRam 0:2ab002d36417 78
SenRam 0:2ab002d36417 79 ## Documentation ##
SenRam 0:2ab002d36417 80
SenRam 0:2ab002d36417 81 More information on the MemoryStats and Debug API can be found in the [mbed handbook]().