Mcuxpresso IDE Azure RTOS Threadx Debug Guide Rev
Total Page:16
File Type:pdf, Size:1020Kb
MCUXpresso IDE Azure RTOS ThreadX Debug Guide Rev. 11.4.1 — 15 September, 2021 User guide NXP Semiconductors MCUXpresso IDE Azure RTOS ThreadX Debug Guide 15 September, 2021 Copyright © 2021 NXP Semiconductors All rights reserved. MCUXpresso IDE Azure RTOS ThreadX Debug Guide - All information provided in this document is subject to legal disclaimers © 2021 NXP Semiconductors. All rights reserved. User Guide Rev. 11.4.1 — 15 September, 2021 ii NXP Semiconductors MCUXpresso IDE Azure RTOS ThreadX Debug Guide 1. Introduction .................................................................................................................. 1 2. LinkServer Azure RTOS ThreadX Thread Aware Debugging ........................................... 2 2.1. Behavior when thread aware debugging ............................................................. 4 2.2. Debugger Messages .......................................................................................... 5 2.3. Switching between all-stop and non-stop debug modes ....................................... 6 3. Azure RTOS ThreadX Thread Aware Debug Views ........................................................ 7 3.1. Showing the Azure RTOS ThreadX TAD Views ................................................... 7 3.2. Threads View .................................................................................................... 8 3.3. Message Queues View ...................................................................................... 8 3.4. Semaphores View ............................................................................................. 9 3.5. Mutexes View .................................................................................................... 9 3.6. Event Flags View ............................................................................................. 10 3.7. Timers View .................................................................................................... 10 3.8. Memory Block Pools View ................................................................................ 10 3.9. Memory Byte Pools View ................................................................................. 11 3.10. Timeouts ....................................................................................................... 11 4. Thread Aware Debugging with Other Debug Probes ..................................................... 12 4.1. PEmicro Probes ............................................................................................... 12 4.2. SEGGER J-Link Probes ................................................................................... 12 5. Exporting Azure RTOS ThreadX Trace ........................................................................ 13 5.1. Enabling Trace Inside the Application ............................................................... 13 5.1.1. Add required preprocessor symbols ....................................................... 13 5.1.2. Declare the trace buffer ......................................................................... 14 5.1.3. Enable trace ......................................................................................... 14 5.2. Exporting Trace ............................................................................................... 15 5.2.1. Configuration of Trace Export feature ..................................................... 15 5.2.2. Trace Export button .............................................................................. 15 5.2.3. Exporting Trace .................................................................................... 16 6. Legal information ........................................................................................................ 17 MCUXpresso IDE Azure RTOS ThreadX Debug Guide - All information provided in this document is subject to legal disclaimers © 2021 NXP Semiconductors. All rights reserved. User Guide Rev. 11.4.1 — 15 September, 2021 iii NXP Semiconductors MCUXpresso IDE Azure RTOS ThreadX Debug Guide 1. Introduction Azure RTOS is one of the real-time operating systems (RTOS) that is delivered with some of the MCUXpresso SDK packages. It is an advanced real-time OS designed for embedded applications and offers advanced scheduling facilities, message passing, interrupt management, and messaging services. Azure RTOS consists of several components (i.e. ThreadX, FileX, USBX) that can be exercised using demo applications available in board-specific MCUXpresso SDK packages. This guide is intended to highlight debugging capabilities of the MCUXpresso IDE when dealing with an Azure RTOS based application. It does not provide any information on Azure RTOS itself or on developing applications that use Azure RTOS. For more information on Azure RTOS please visit https://docs.microsoft.com/en-us/azure/rtos/ MCUXpresso IDE Azure RTOS ThreadX Debug Guide - All information provided in this document is subject to legal disclaimers © 2021 NXP Semiconductors. All rights reserved. User Guide Rev. 11.4.1 — 15 September, 2021 1 NXP Semiconductors MCUXpresso IDE Azure RTOS ThreadX Debug Guide 2. LinkServer Azure RTOS ThreadX Thread Aware Debugging When debugging via LinkServer debug probes, the MCUXpresso IDE debugger can provide Azure RTOS ThreadX thread aware debug if : 1. Debugging is carried out in All-Stop mode (rather than the default Non-Stop mode). This selection is made when first making a debug connection for a particular project (or after deleting an existing launch configuration). For more details, please see the MCUXpresso IDE User Guide. 2. No changes are made inside TX_THREAD_STRUCT data structure that could impact debugger’s ability to determine available threads from the ThreadX sub-system. Note: If Non-Stop debug mode is used, only the current thread will be seen in the Debug View, as shown in the below screenshot: MCUXpresso IDE Azure RTOS ThreadX Debug Guide - All information provided in this document is subject to legal disclaimers © 2021 NXP Semiconductors. All rights reserved. User Guide Rev. 11.4.1 — 15 September, 2021 2 NXP Semiconductors MCUXpresso IDE Azure RTOS ThreadX Debug Guide However, once all the necessary preconditions are met, the Debug View will display each thread individually, as shown in the next screenshot: MCUXpresso IDE Azure RTOS ThreadX Debug Guide - All information provided in this document is subject to legal disclaimers © 2021 NXP Semiconductors. All rights reserved. User Guide Rev. 11.4.1 — 15 September, 2021 3 NXP Semiconductors MCUXpresso IDE Azure RTOS ThreadX Debug Guide 2.1 Behavior when thread aware debugging MCUXpresso IDE LinkServer Azure RTOS ThreadX thread aware debugging is available once the ThreadX scheduler has started (so will not appear straight after loading the application when the default breakpoint on main() is reached). Debug works in stop mode. In other words, if execution of a user task is halted either through a user action (halt) or a debug event (breakpoint, watchpoint, fault, etc.), the stopped thread is current and no application thread executes in the background. The register context for any thread is available in the Registers view. For suspended or blocked threads, the register context is the context in effect when the thread was swapped out, regardless of which thread stack level is examined within the traceback window. In the below example, the MCU is halted in Thread #7, but a backtrace for the other threads is also available: MCUXpresso IDE Azure RTOS ThreadX Debug Guide - All information provided in this document is subject to legal disclaimers © 2021 NXP Semiconductors. All rights reserved. User Guide Rev. 11.4.1 — 15 September, 2021 4 NXP Semiconductors MCUXpresso IDE Azure RTOS ThreadX Debug Guide 2.2 Debugger Messages LinkServer Azure RTOS ThreadX Thread Aware Debugging requires that the debug session is carried out in All-Stop mode. If this precondition is met, then when you start your debug session, confirmation that LinkServer Azure RTOS ThreadX Thread Aware Debugging is active is recorded in the “Debug Messages” log inside the IDE’s Console view: ... GDB nonstop mode disabled (using allstop mode) Azure RTOS ThreadX stack backtrace is enabled ... as shown in the screenshot below: MCUXpresso IDE Azure RTOS ThreadX Debug Guide - All information provided in this document is subject to legal disclaimers © 2021 NXP Semiconductors. All rights reserved. User Guide Rev. 11.4.1 — 15 September, 2021 5 NXP Semiconductors MCUXpresso IDE Azure RTOS ThreadX Debug Guide If the image is debugged in Non-Stop mode, then the log will indicate that thread aware debugging will not be available: ... GDB nonstop mode enabled Azure RTOS ThreadX stack backtrace is disabled in Non-stop mode (use All-stop) ... 2.3 Switching between all-stop and non-stop debug modes When debugging a project for the first time using a LinkServer debug connection (or when you have deleted any existing launch configuration files), you can select whether to debug in Non- Stop or All-Stop mode (so that you can choose whether or not you wish to use Azure RTOS ThreadX thread awareness). However, you can also easily modify an existing launch configuration file to switch between All- Stop and Non-Stop as follows. • Open the project up in the Project Explorer view and double click on the appropriate launch configuration file (typically “projname LinkServer Debug.launch”) • Switch to the GDB Debugger tab • Tick / Untick the " Non-Stop mode" option, as required. • Click on Apply to save, then Continue Any further