Example of blinking LED on LPCXpresso54608 board (OM13092)
LPC-LINK2 Debug Probe Firmware update required with MBED firmware to enable the mbed flash disk interface (board is seen as MSD mass storage device) so drag and drop programming is possible
tested on Windows 7
Based on
https://os.mbed.com/platforms/LPCXpresso54608/
and
https://os.mbed.com/teams/NXP/wiki/Updating-LPCXpresso-firmware
you need to update your LPCXpresso (programmer/debugger) to the latest firmware to enable the mbed flash disk interface.
Note that for LPCXpresso54114 and LPCXpresso546xx boards there is a 2-step programming process (first bootloader needs to be installed, then binary for LPC546xx board).
Detailed guide as follows:
1. Go to LPCScrypt webpage and download its latest version (needs admin rights)
2. Go to DOCUMENTATION section of above link and select “LPC-Link2 Debug Probe Firmware Programming”
- https://www.nxp.com/docs/en/supporting-information/Debug_Probe_Firmware_Programming.pdf
- Please see page 3. for instructions
3. Configure the selected board to DFU Boot, then connect to the host computer via USB
- In case of: OM13092/LPCXpresso54806
- check jumper JP5 “DFU LINK” (needs to be installed) – to download firmware from IDE
4. Download Link2 (LPC432x) Bootloader binary (Use this Bootloader first for boards that require a 2-step update)
- https://os.mbed.com/media/uploads/mmahadevan/lpc4322_bl_crc.bin
- Save to directory of LPCScrypt
C:\nxp\LPCScrypt_2.0.0_831\probe_firmware\LPCXpressoV2
- LPCXpressoV2 folder has been chosen because I was able to find an info that debug probe LPC432x is being programmed with LPC432x_IAP_CMSIS_DAP_V5_183.bin file (and this file is in LPCXpressoV2 folder)
- to confirm that please go to Start -> start typing LPC -> choose “Program LPC-Link2 with CMSIS-DAP”
5. Make a copy of program_CMSIS.cmd file in C:\nxp\LPCScrypt_2.0.0_831\scripts
and call it program_CMSIS_mbed_daplink.cmd
- Open with Notepad++ program_CMSIS_mbed_daplink.cmd file
- edit:
before set Link2ImageWild=LPC432x_IAP_CMSIS_DAP_*.bin
after set Link2ImageWild=lpc4322_bl_*.bin
- or comment (by adding REM)
before set Link2ImageWild=LPC432x_IAP_CMSIS_DAP_*.bin
after REM set Link2ImageWild=LPC432x_IAP_CMSIS_DAP_*.bin set Link2ImageWild=lpc4322_bl_*.bin
6. Go to Start -> cmd
- go to directory
cd C:\nxp\LPCScrypt_2.0.0_831\scripts
- type command
- program_CMSIS_mbed_daplink
- because of changes in program_CMSIS_mbed_daplink.cmd, now file downloaded from MBED called lpc4322_bl_crc.bin is executed
- Ctrl+C to quit
7. Disconnect the board
8. Remove the jumper JP5 “DFU LINK”
9. Connect again the board
- In that step board should be seen as MAINTANANCE
10. Go to https://armmbed.github.io/DAPLink/ and type in the box 54608, then you will see firmware file called
- 0251_lpc4322_lpc54608xpresso_0x10000.bin
- Download the firmware file
- Save wherever you want
- Drag-and-drop the firmware file onto the mounted drive called MAINTANANCE
- Wait for the file copy operation to complete
- Power cycle the board. It will now enumerate and mount as DAPLINK or the name of the board
11. Ready for drag and drop programming
stats_report.h@4:3bc63d11d829, 2018-12-06 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcinch | 0:09421d80c468 | 1 | /* mbed Microcontroller Library |
marcinch | 0:09421d80c468 | 2 | * Copyright (c) 2018 ARM Limited |
marcinch | 0:09421d80c468 | 3 | * SPDX-License-Identifier: Apache-2.0 |
marcinch | 0:09421d80c468 | 4 | */ |
marcinch | 0:09421d80c468 | 5 | |
marcinch | 0:09421d80c468 | 6 | #ifndef STATS_REPORT_H |
marcinch | 0:09421d80c468 | 7 | #define STATS_REPORT |
marcinch | 0:09421d80c468 | 8 | |
marcinch | 0:09421d80c468 | 9 | #include "mbed.h" |
marcinch | 0:09421d80c468 | 10 | |
marcinch | 0:09421d80c468 | 11 | /** |
marcinch | 0:09421d80c468 | 12 | * System Reporting library. Provides runtime information on device: |
marcinch | 0:09421d80c468 | 13 | * - CPU sleep, idle, and wake times |
marcinch | 0:09421d80c468 | 14 | * - Heap and stack usage |
marcinch | 0:09421d80c468 | 15 | * - Thread information |
marcinch | 0:09421d80c468 | 16 | * - Static system information |
marcinch | 0:09421d80c468 | 17 | */ |
marcinch | 0:09421d80c468 | 18 | class SystemReport { |
marcinch | 0:09421d80c468 | 19 | mbed_stats_heap_t heap_stats; |
marcinch | 0:09421d80c468 | 20 | mbed_stats_cpu_t cpu_stats; |
marcinch | 0:09421d80c468 | 21 | mbed_stats_sys_t sys_stats; |
marcinch | 0:09421d80c468 | 22 | |
marcinch | 0:09421d80c468 | 23 | mbed_stats_thread_t *thread_stats; |
marcinch | 0:09421d80c468 | 24 | uint8_t thread_count; |
marcinch | 0:09421d80c468 | 25 | uint8_t max_thread_count; |
marcinch | 0:09421d80c468 | 26 | uint32_t sample_time_ms; |
marcinch | 0:09421d80c468 | 27 | |
marcinch | 0:09421d80c468 | 28 | public: |
marcinch | 0:09421d80c468 | 29 | /** |
marcinch | 0:09421d80c468 | 30 | * SystemReport - Sample rate in ms is required to handle the CPU percent awake logic |
marcinch | 0:09421d80c468 | 31 | */ |
marcinch | 0:09421d80c468 | 32 | SystemReport(uint32_t sample_rate) : max_thread_count(8), sample_time_ms(sample_rate) |
marcinch | 0:09421d80c468 | 33 | { |
marcinch | 0:09421d80c468 | 34 | thread_stats = new mbed_stats_thread_t[max_thread_count]; |
marcinch | 0:09421d80c468 | 35 | |
marcinch | 0:09421d80c468 | 36 | // Collect the static system information |
marcinch | 0:09421d80c468 | 37 | mbed_stats_sys_get(&sys_stats); |
marcinch | 0:09421d80c468 | 38 | |
marcinch | 0:09421d80c468 | 39 | printf("=============================== SYSTEM INFO ================================\r\n"); |
marcinch | 0:09421d80c468 | 40 | printf("Mbed OS Version: %ld \r\n", sys_stats.os_version); |
marcinch | 0:09421d80c468 | 41 | printf("CPU ID: 0x%lx \r\n", sys_stats.cpu_id); |
marcinch | 0:09421d80c468 | 42 | printf("Compiler ID: %d \r\n", sys_stats.compiler_id); |
marcinch | 0:09421d80c468 | 43 | printf("Compiler Version: %ld \r\n", sys_stats.compiler_version); |
marcinch | 0:09421d80c468 | 44 | } |
marcinch | 0:09421d80c468 | 45 | |
marcinch | 0:09421d80c468 | 46 | ~SystemReport(void) |
marcinch | 0:09421d80c468 | 47 | { |
marcinch | 0:09421d80c468 | 48 | free(thread_stats); |
marcinch | 0:09421d80c468 | 49 | } |
marcinch | 0:09421d80c468 | 50 | |
marcinch | 0:09421d80c468 | 51 | /** |
marcinch | 0:09421d80c468 | 52 | * Report on each Mbed OS Platform stats API |
marcinch | 0:09421d80c468 | 53 | */ |
marcinch | 0:09421d80c468 | 54 | void report_state(void) |
marcinch | 0:09421d80c468 | 55 | { |
marcinch | 0:09421d80c468 | 56 | report_cpu_stats(); |
marcinch | 0:09421d80c468 | 57 | report_heap_stats(); |
marcinch | 0:09421d80c468 | 58 | report_thread_stats(); |
marcinch | 0:09421d80c468 | 59 | |
marcinch | 0:09421d80c468 | 60 | // Clear next line to separate subsequent report logs |
marcinch | 0:09421d80c468 | 61 | printf("\r\n"); |
marcinch | 0:09421d80c468 | 62 | } |
marcinch | 0:09421d80c468 | 63 | |
marcinch | 0:09421d80c468 | 64 | /** |
marcinch | 0:09421d80c468 | 65 | * Report CPU idle and awake time in terms of percentage |
marcinch | 0:09421d80c468 | 66 | */ |
marcinch | 0:09421d80c468 | 67 | void report_cpu_stats(void) |
marcinch | 0:09421d80c468 | 68 | { |
marcinch | 0:09421d80c468 | 69 | static uint64_t prev_idle_time = 0; |
marcinch | 0:09421d80c468 | 70 | |
marcinch | 0:09421d80c468 | 71 | printf("================= CPU STATS =================\r\n"); |
marcinch | 0:09421d80c468 | 72 | |
marcinch | 0:09421d80c468 | 73 | // Collect and print cpu stats |
marcinch | 0:09421d80c468 | 74 | mbed_stats_cpu_get(&cpu_stats); |
marcinch | 0:09421d80c468 | 75 | |
marcinch | 0:09421d80c468 | 76 | uint64_t diff = (cpu_stats.idle_time - prev_idle_time); |
marcinch | 0:09421d80c468 | 77 | uint8_t idle = (diff * 100) / (sample_time_ms * 1000); // usec; |
marcinch | 0:09421d80c468 | 78 | uint8_t usage = 100 - ((diff * 100) / (sample_time_ms * 1000)); // usec;; |
marcinch | 0:09421d80c468 | 79 | prev_idle_time = cpu_stats.idle_time; |
marcinch | 0:09421d80c468 | 80 | |
marcinch | 0:09421d80c468 | 81 | printf("Idle: %d%% Usage: %d%% \r\n", idle, usage); |
marcinch | 0:09421d80c468 | 82 | } |
marcinch | 0:09421d80c468 | 83 | |
marcinch | 0:09421d80c468 | 84 | /** |
marcinch | 0:09421d80c468 | 85 | * Report current heap stats. Current heap refers to the current amount of |
marcinch | 0:09421d80c468 | 86 | * allocated heap. Max heap refers to the highest amount of heap allocated |
marcinch | 0:09421d80c468 | 87 | * since reset. |
marcinch | 0:09421d80c468 | 88 | */ |
marcinch | 0:09421d80c468 | 89 | void report_heap_stats(void) |
marcinch | 0:09421d80c468 | 90 | { |
marcinch | 0:09421d80c468 | 91 | printf("================ HEAP STATS =================\r\n"); |
marcinch | 0:09421d80c468 | 92 | |
marcinch | 0:09421d80c468 | 93 | // Collect and print heap stats |
marcinch | 0:09421d80c468 | 94 | mbed_stats_heap_get(&heap_stats); |
marcinch | 0:09421d80c468 | 95 | |
marcinch | 0:09421d80c468 | 96 | printf("Current heap: %lu\r\n", heap_stats.current_size); |
marcinch | 0:09421d80c468 | 97 | printf("Max heap size: %lu\r\n", heap_stats.max_size); |
marcinch | 0:09421d80c468 | 98 | } |
marcinch | 0:09421d80c468 | 99 | |
marcinch | 0:09421d80c468 | 100 | /** |
marcinch | 0:09421d80c468 | 101 | * Report active thread stats |
marcinch | 0:09421d80c468 | 102 | */ |
marcinch | 0:09421d80c468 | 103 | void report_thread_stats(void) |
marcinch | 0:09421d80c468 | 104 | { |
marcinch | 0:09421d80c468 | 105 | printf("================ THREAD STATS ===============\r\n"); |
marcinch | 0:09421d80c468 | 106 | |
marcinch | 0:09421d80c468 | 107 | // Collect and print running thread stats |
marcinch | 0:09421d80c468 | 108 | int count = mbed_stats_thread_get_each(thread_stats, max_thread_count); |
marcinch | 0:09421d80c468 | 109 | |
marcinch | 0:09421d80c468 | 110 | for (int i = 0; i < count; i++) { |
marcinch | 0:09421d80c468 | 111 | printf("ID: 0x%lx \r\n", thread_stats[i].id); |
marcinch | 0:09421d80c468 | 112 | printf("Name: %s \r\n", thread_stats[i].name); |
marcinch | 0:09421d80c468 | 113 | printf("State: %ld \r\n", thread_stats[i].state); |
marcinch | 0:09421d80c468 | 114 | printf("Priority: %ld \r\n", thread_stats[i].priority); |
marcinch | 0:09421d80c468 | 115 | printf("Stack Size: %ld \r\n", thread_stats[i].stack_size); |
marcinch | 0:09421d80c468 | 116 | printf("Stack Space: %ld \r\n", thread_stats[i].stack_space); |
marcinch | 0:09421d80c468 | 117 | } |
marcinch | 0:09421d80c468 | 118 | } |
marcinch | 0:09421d80c468 | 119 | }; |
marcinch | 0:09421d80c468 | 120 | |
marcinch | 0:09421d80c468 | 121 | #endif // STATS_REPORT_H |