Example application demonstrating Memory stats API and debug functions
Fork of mbed-os-example-platform-utils by
README.md@2:c03cd481c34b, 2017-10-30 (annotated)
- Committer:
- Senthil Ramakrishnan
- Date:
- Mon Oct 30 14:21:38 2017 -0500
- Revision:
- 2:c03cd481c34b
- Parent:
- 0:2ab002d36417
- Child:
- 3:92b97ba04fd3
Updated README
Who changed what in which revision?
User | Revision | Line number | New 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 |
SenRam | 0:2ab002d36417 | 32 | MBED_MEM_TRACING_ENABLED |
SenRam | 0:2ab002d36417 | 33 | |
SenRam | 0:2ab002d36417 | 34 | 5. Open a serial console session with the target platform using the following parameters: |
SenRam | 0:2ab002d36417 | 35 | * **Baud rate:** 9600 |
SenRam | 0:2ab002d36417 | 36 | * **Data bits:** 8 |
SenRam | 0:2ab002d36417 | 37 | * **Stop bits:** 1 |
SenRam | 0:2ab002d36417 | 38 | * **Parity:** None |
SenRam | 0:2ab002d36417 | 39 | |
SenRam | 0:2ab002d36417 | 40 | 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 | 41 | |
SenRam | 0:2ab002d36417 | 42 | 7. The serial console should display a similar output to below: |
SenRam | 0:2ab002d36417 | 43 | ``` |
SenRam | 0:2ab002d36417 | 44 | This message is from debug function |
SenRam | 0:2ab002d36417 | 45 | This message is from debug_if |
SenRam | 0:2ab002d36417 | 46 | MemoryStats: |
SenRam | 0:2ab002d36417 | 47 | Bytes allocated currently: 80 |
SenRam | 0:2ab002d36417 | 48 | Max bytes allocated at a given time: 80 |
SenRam | 0:2ab002d36417 | 49 | Cumulative sum of bytes ever allocated: 80 |
SenRam | 0:2ab002d36417 | 50 | Current number of bytes allocated for the heap: 186884 |
SenRam | 0:2ab002d36417 | 51 | Current number of allocations: 2 |
SenRam | 0:2ab002d36417 | 52 | Number of failed allocations: 0 |
SenRam | 0:2ab002d36417 | 53 | Cumulative Stack Info: |
SenRam | 0:2ab002d36417 | 54 | Maximum number of bytes used on the stack: 560 |
SenRam | 0:2ab002d36417 | 55 | Current number of bytes allocated for the stack: 5376 |
SenRam | 0:2ab002d36417 | 56 | Number of stacks stats accumulated in the structure: 3 |
SenRam | 0:2ab002d36417 | 57 | Thread Stack Info: |
SenRam | 0:2ab002d36417 | 58 | Thread: 0 |
SenRam | 0:2ab002d36417 | 59 | Thread Id: 0x20001EE8 |
SenRam | 0:2ab002d36417 | 60 | Thread Name: "main_thread" |
SenRam | 0:2ab002d36417 | 61 | Maximum number of bytes used on the stack: 384 |
SenRam | 0:2ab002d36417 | 62 | Current number of bytes allocated for the stack: 4096 |
SenRam | 0:2ab002d36417 | 63 | Number of stacks stats accumulated in the structure: 1 |
SenRam | 0:2ab002d36417 | 64 | Thread: 1 |
SenRam | 0:2ab002d36417 | 65 | Thread Id: 0x20000394 |
SenRam | 0:2ab002d36417 | 66 | Thread Name: "" |
SenRam | 0:2ab002d36417 | 67 | Maximum number of bytes used on the stack: 64 |
SenRam | 0:2ab002d36417 | 68 | Current number of bytes allocated for the stack: 512 |
SenRam | 0:2ab002d36417 | 69 | Number of stacks stats accumulated in the structure: 1 |
SenRam | 0:2ab002d36417 | 70 | Thread: 2 |
SenRam | 0:2ab002d36417 | 71 | Thread Id: 0x200003DC |
SenRam | 0:2ab002d36417 | 72 | Thread Name: "" |
SenRam | 0:2ab002d36417 | 73 | Maximum number of bytes used on the stack: 112 |
SenRam | 0:2ab002d36417 | 74 | Current number of bytes allocated for the stack: 768 |
SenRam | 0:2ab002d36417 | 75 | Number of stacks stats accumulated in the structure: 1 |
SenRam | 0:2ab002d36417 | 76 | Done... |
SenRam | 0:2ab002d36417 | 77 | |
SenRam | 0:2ab002d36417 | 78 | ``` |
SenRam | 0:2ab002d36417 | 79 | |
SenRam | 0:2ab002d36417 | 80 | ## Documentation ## |
SenRam | 0:2ab002d36417 | 81 | |
SenRam | 0:2ab002d36417 | 82 | More information on the MemoryStats and Debug API can be found in the [mbed handbook](). |