32-bit Arm Cortex MCUs. It contains detailed information for getting started as well as hints and tips to make the best use of STM32 Software Development Tools in STM32 ecosystem. This application note applies to the microcontrollers listed in Table Table 1.
Foreword AN4989 Foreword General information ® ® This document applies to STM32 32-bit Arm Cortex MCUs. Note: Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere. Software versions The various examples in this application note are illustrated on basis of the following versions of the tools: •...
AN4989 STM32 ecosystem outlines STM32 ecosystem outlines STMicroelectronics and its partners are providing a full hardware and software ecosystem to support rapid evaluation, prototyping, and productizing of complete systems using STM32 microcontrollers. As presented in Figure 1, the ecosystem is composed of all the collaterals required to develop a project with STM32.
AN4989 Figure 2. Development tools overview STM32 Nucleo STM32 Nucleo boards are affordable solutions for user willing to try out new ideas and to quickly create prototypes based on STM32 MCU. Figure 3. Nucleo-144, Nucleo-64 and Nucleo-32 boards STM32 Nucleo boards feature the same connectors. They can easily be extended with a large number of specialized application hardware add-ons.
AN4989 STM32 ecosystem outlines All STM32 Nucleo boards integrate an ST-LINK debugger/programmer, so there is no need for a separate probe. The figure below shows an example of STM32 Nucleo structure Figure 4. STM32 Nucleo-144 structure A complete description of the embedded ST-LINK features is provided in Section 2.1.2: ST-...
STM32 ecosystem outlines AN4989 Discovery kits STM32 Discovery kits are a cheap and complete solution for the evaluation of the outstanding capabilities of STM32 MCUs. They carry the necessary infrastructure for demonstration of specific device characteristics, the HAL library, and comprehensive software examples allow to fully benefit from the devices features and added values.
For further information and access to complete documentation visit www.st.com/stm32evaltools. STM32 nucleo expansion STM32 Nucleo expansion boards carry all the required components to Evaluate ST devices to be used together with an STM32 MCU. Build STM32-based applications leveraging functionality and performance of ST’s device portfolio.
USB (using the STM32CubeMonPwr software tool with its comprehensive graphical user interface). It can be used to supply and measure the consumption of STM32 Nucleo-32, Nucleo-64, Nucleo-68 or Nucleo-144 boards, using ARDUINO connectors. Alternatively, it supplies and measures the consumption of any target connected by wires via the basic connector.
Page 15
AN4989 STM32 ecosystem outlines KEY FEATURES ® ® • STM32L496VGT6 microcontroller featuring Arm Cortex -M4 core at 80 MHz / 100 DMIPS and three 12-bit ADC at 5 Msps • Programmable voltage source from 1.8 V to 3.3 V •...
It is available as: • Stand-alone in-circuit debugger • Embedded in all STM32 hardware kits (Nucleo boards, Discovery kits, EVAL boards) ST-LINK/V2 and ST-LINK-V3 are the main used versions. Figure 8 shows ST-LINK/V2 and ST-LINK/V2- ISOL stand-alone probes on the right.
AN4989 STM32 ecosystem outlines Figure 10 shows an example of an embedded ST-LINK/V2 as part of a Nucleo board. Figure 10. On-board ST-LINK-V3 on Nucleo AN4989 Rev 3 17/118...
Page 18
STM32 ecosystem outlines AN4989 ST-LINK/V2 basic features • 5 V power supplied by a USB connector • USB 2.0 full-speed-compatible interface • USB standard Type-A to Mini- B cable • JTAG/serial wire debug (SWD) specific features: – 1.65 V to 3.6 V application voltage supported on the JTAG/SWD interface and 5 V tolerant inputs –...
STM32 ecosystem outlines In order to identify the ST-LINK version on a board and the related features associated with it, please refer STMicroelectronics technical note Overview of the ST-LINK embedded in STM32 MCU Nucleo, Discovery Kits and Eval Boards (TN1235).
STM32 ecosystem outlines AN4989 Software development tools ® ® The STM32 family of 32-bit Arm Cortex -M core-based microcontrollers is supported by a complete range of software tools. It encompasses traditional integrated development environments - IDEs with C/C++ compilers and debuggers from major third parties that are complemented with tools from ST allowing to configure and initialize the MCU or monitor its behavior in run time.
C code through a step-by-step process. The first step consists in selecting the STM32 microcontroller that matches the required set of peripherals. MCU can be selected as stand-alone for custom PCB (MCU Selector) or pre-...
After the selection of an empty STM32 MCU or MPU, or preconfigured microcontroller from the selection of a board, the project is created, and initialization code generated. At any time...
Page 23
Live variable watch view – System analysis and real-time tracing (SWV) – CPU fault analysis tool • Support of ST-LINK (STMicroelectronics) and J-Link (SEGGER) debug probes ® ® • Import project from Atollic TrueSTUDIO and AC6 System Workbench for STM32 (STM32CubeIDE) ®...
Over 3100 sample projects for EVAL boards from many different manufacturers – User and reference guides in PDF format – Context-sensitive on-line help • Chip-specific support: – 4300 example projects included for STMicroelectronics EVAL boards ® ® – Support for 4 Gbyte applications in Arm and Thumb mode ®...
(UART, USB DFU, I C, SPI, and CAN). STM32CubeProgrammer offers a wide range of features to program STM32 internal memories (such as Flash, RAM, and OTP) as well as external memories. STM32CubeProgrammer also allows option programming and upload, programming content verification, and programming automation through scripting.
• Offers a command-line interface for automation through scripting • ST-LINK firmware update • Enables secure firmware creation using the STM32 Trusted Package Creator tool • Supports OTA programming for the STM32WB Series ® • Multi-OS support: Windows, Linux, macOS Figure 14.
STM32 ecosystem outlines 2.2.5 STM32CubeMonitor The STM32CubeMonitor family of tools helps to fine-tune and diagnose STM32 applications at run-time by reading and visualizing their variables in real-time. In addition to specialized versions (power, RF, USB-PD), the versatile STM32CubeMonitor provides a flow-based graphical editor to build custom dashboards simply, and quickly add widgets such as gauges, bar graphs and plots.
A collection of Middleware components, like RTOS, USB library, file system, TCP/IP stack, Touch sensing library or Graphic Library (depending on the MCU series) • A complete set of code examples running on STMicroelectronics boards: STM32 Nucleo, Discovery kits and EVAL boards Tip: There is a fair chance that a Cube Project example matches the project in design.
AN4989 STM32 ecosystem outlines Figure 16. STM32CubeProjectList screenshot Information and sharing STMicroelectronics offers a very complete and wide range of solution on the web to get connected to STM32 World. Figure 17. Get connected to STM32 world AN4989 Rev 3...
Errata sheet Contained known issues and device limitation. ® Target software developer with a full description of the STM32 Cortex Programmer manual processor programming model, instruction set and core peripherals It describes new features, known limitations and corrections on a specific...
The home page of ST Community is https://community.st.com/welcome. For any problem met, it is interesting to first browse the STM32 Forum for related topics and eventually to post a new one if no relevant thread is found. AN4989 Rev 3...
(search for STM32 Education). This site provides free educational resources created by STMicroelectronics engineers for bringing an STM32 project to life. On this site, a user learns at his own pace, watches classes as per his own schedule, anytime, anywhere, on any device, or apply to one of the live learning sessions led by STMicroelectronics experts at a nearby location.
AN4989 Compiling for debug Compiling for debug This chapter reviews the various options for debug-friendly compiling solutions. Optimization Compiler are usually configured by default to optimize performance and/or code size. In most cases, this reduces or even prevents program debugging. The most common symptoms resulting from code optimization are: •...
AN4989 Compiling for debug ® 3.1.2 Keil MDK-Arm µVision In Project Option for Target->C/C++->Optimization ® Figure 19. Keil µVision Code Optimization option ® Keil documentation suggests that Level1 (-O1) can be a suitable alternative for debug. Refer to www.keil.com support page Compiler optimization levels and the debug view for details.
Compiling for debug AN4989 3.1.3 STM32CubeIDE In project Properties->Settings->Tool Settings->MCU GCC Compiler->Optimization Figure 20. STM32CubeIDE optimization level setting gcc also provides the -Og option: -Og enables optimizations that do not interfere with debugging. It offers a reasonable level of optimization while maintaining fast compilation and a good debugging experience. Debugging information Debugging information is generated by the compiler together with the machine code.
Compiling for debug AN4989 ® 3.2.2 Keil -MDK-Arm µVision Debug Information Tick box is accessible in Project -> Options -> Output Pane. It is set by default. ® Figure 22. Keil Debug Information option 38/118 AN4989 Rev 3...
AN4989 Compiling for debug 3.2.3 STM32CubeIDE Option to manage Debugging Information are in Properties -> C/C++ Build -> Settings -> Tool Settings -> Debugging. Figure 23. STM32CubeIDE debug information option Debug Level can be set among four levels: • None: Level 0 produces no debug information at all; •...
This chapter intends to provide the minimal set of information in order to prevent or quickly fix issues related to connection. SWD/JTAG pinout On STMicroelectronics hardware kits, SWD must be made available for connection with ST- LINK. SWD is always mapped on PA13 (SWDIO) and PA14 (SWCLK). This is the default state after reset.
AN4989 Connecting to the board Figure 25. SWD pins PA13 and PA14 in Reserved but inactive state under STM32CubeMX Figure 26. SWD pins PA13 and PA14 in Active State under STM32CubeMX All three states are functional from SWD connection point of view. It is anyway recommended to explicitly activate the SWD pins by selecting “Serial Wire”...
Connection mode and reset mode are 2 different but dependent concepts: Reset mode can be either: • Hardware: drive the NRST pin of the MCU. In all STMicroelectronics hardware kits, the debugger can drive this NRST through ST-LINK/V2 or ST-LINK-V3. Hint: On Nucleo, check that relevant Solder Bridge SB12 is not OFF.
AN4989 Connecting to the board 4.2.2 IAR™ EWARM Reset and Connection mode are seen as a single reset mode option as shown in Figure Figure 27. Reset Mode in IAR8.10: screenshot • System (default): Normal Connection. Software System Reset prior to jump at main. •...
Connecting to the board AN4989 ® 4.2.3 Keil MDK-Arm µVISION Can be set through Project -> Options -> Debug -> Settings -> Debug ® Figure 28. Connect and Reset option Keil Connect: controls the operations that are executed when the µVision debugger connects to the target device.
AN4989 Connecting to the board Reset: controls the reset operations performed by the target device. The available options vary with the selected device. • Autodetect selects the best suitable reset method for the target device. This can be a specialized reset or standard method. If Autodetect finds an unknown device, it uses the SYSRESETREQ method.
AN4989 Connecting to the board ® Figure 31. Keil hotplug step3 With these options disabled, the debugger starts, and the target hardware stops at the current location of the program counter. This allows to analyze the memory and register content. Because Options For Target - Debug - Load Application at startup is disabled, the debugger does not have any application program and debug information.
In case of problem to connect to the board with STM32CubeIDE, make sure that NRST from ST-LINK is properly connected to STM32 NRST. Hotplug mode is not proposed by STM32CubeIDE. STM32CubeProgrammer can be used instead.
Software system reset: Resets all STM32 components except the Debug via the Cortex-M application interrupt and reset control register (AIRCR). • Hardware reset: Resets the STM32 device via the nRST pin. The RESET pin of the JTAG connector (pin 15) must be connected to the device reset pin. •...
Connecting to the board AN4989 • With ‘Normal’ connection mode, the target is reset then halted. The type of reset is selected using the ‘Reset Mode’ option. • The ‘Connect Under Reset’ mode enables connection to the target using a reset vector catch before executing any instructions.
AN4989 Breaking and stepping into code Breaking and stepping into code This chapter provides users with highlights about a few points affecting system behavior at code break. Debug support for timers, RTC, watchdog, BxCAN and I During a breakpoint, it is necessary to choose how the counter of timers, RTC and watchdog should behave: •...
Breaking and stepping into code AN4989 5.2.3 STM32CubeIDE In Run -> Debug Configuration -> Debugger Pane Figure 37. Access to Generator Options in STM32CubeIDE V2.0.0 Note: SWD communication is always possible on all ST boards whereas JTAG is only present on EVAL boards.
A simple reset does re- enable code execution; power must be switched off and on so that power-on reset enables code execution. The restriction depends on the STM32 Series as described in Table...
Level 2: No Debug. JTAG/SWD connection is killed. There is no way back. In this case, nobody - even STMicroelectronics - can perform any analysis of defective parts. • Level 0.5 is an additional protection level associated with TrustZone(only available in STM32L5 Serie).
In order to get deeper into the subject, the user can usefully refer to Joseh Yiu’s work and book collection The Definitive Guide to Arm-Cortex-M, and to Carmelo Noviello’s recent on- line guide Mastering STM32. Default weak Handlers By default Handlers are implemented as __weak functions which perform endless loops:...
Exception handling AN4989 Custom Handlers One way to generate templates of Handler functions is to use STM32CubeMX. In Configuration -> NVIC Configuration -> Code Generation, use Generate IRQ handler tick boxes as shown in Figure Figure 38. Asking for Handler code generation When Non maskable interrupt and Hard fault interrupt are selected, the following code is generated: void NMI_Handler(void)
Page 59
AN4989 Exception handling In order to trap the exception, a hardware or a software breakpoint can be set in the IDE or ® directly programmed in the source code using Arm instruction BKPT. Caution: BKPT is not tolerated if no debugger is connected (refer to Chapter 9: Dual-Core microcontroller debugging on page 92).
Exception handling AN4989 ® Figure 39. Keil Access to Show Caller Code in Contextual menu Trapping div/0 exception Most often, code execution causing a division by zero are difficult to investigate: • Nothing is neither triggered nor trapped. • Erroneous returned value generates an unexpected and unpredictable behavior that is very difficult to analyze.
AN4989 Exception handling ® 6.3.2 Cortex -M3/4/7 case For targets that support hardware division instructions, Trapping of DIV0 operation is possible by configuring System Control Block (SCB) registers, accessible through CMSIS library. ® For example on Cortex -M3: SCB_CCR register description is provided in Figure ®...
Exception handling AN4989 IAR™ EWARM Detailed R/W access to the values of each SCB registers bits at runtime can be obtained through View -> Register -> System Control Block (from Pick List) as shown in Figure Figure 42. IAR™ EWARM exception handling 62/118 AN4989 Rev 3...
AN4989 Exception handling ® Keil MDK-Arm µVISION SCB->CCR can be managed at run time through View -> System Viewer -> Core Peripheral -> System Control and Configure. Refer to Figure 43 for details. ® Figure 43. Keil System Control and Configure AN4989 Rev 3 63/118...
Exception handling AN4989 The fault type can be investigated using Peripherals -> Core Peripherals -> Fault Reports as shown in Figure ® Figure 44. Keil Fault Reports 64/118 AN4989 Rev 3...
AN4989 Exception handling STM32CubeIDE At runtime, while debug is in break state, the SCB register can be accessed in read mode or in write mode through: Window -> Show View -> SFRs as shown in Figure Figure 45. STM32CubeIDE SCB register access If you need more informations about the Hardfault,you can first enable faulting or halting when the processor executes an SDIV or UDIV instruction with a divisor of 0: SCB->CCR | = 0x01.
Exception handling AN4989 If the code performs an SDIV or UDIV instruction with a divisor of 0, code stops with informations in “Fault Analyzer” (see Figure 46). Figure 46. Fault Analyzer in STM32CubeIDE 66/118 AN4989 Rev 3...
Page 67
AN4989 Exception handling Independently from the IDE, for projects including the CMSIS library, the content of the registers in the code can also be printed: void HardFault_Handler(void) volatile uint32_t csfr= SCB-> CSFR ; // load into variable printf ( "SCB-> CSFR 0x%08x \n", SCB-> CSFR) // print while (1) The same content can as well be obtained directly from the memory with any memory browser.
USART or SWO, benefiting from facilities offered by STMicroelectronics hardware kits and ecosystem tools. STM32 Virtual COM port driver STM32 Virtual COM Port Driver (VCP) is a feature supported by ST-LINK/V2-B embedded in most of recent hardware kits (refer to Section 2.1: Hardware development tools on page 9).
AN4989 Printf debugging Printf via UART Direct connection from PC UART to board pinout does not work due to signal level incompatibility. Take care to use external adapter (such as MAX232, ST3241EB, FTDI USB/UART) or the USART connected to Virtual COM port. Trick: Appendix B: Use Nucleo “cuttable”...
Printf debugging AN4989 Figure 49. USART2 setting with STM32CubeMX Retargeting printf to UART depends on the toolchain. ® For IAR™ EWARM and Keil MDK-Arm µVISION this is done by overriding the stdio fputc function #include "stdio.h" int fputc(int ch, FILE *f) HAL_UART_Transmit(&UartHandle, (uint8_t *)&ch, 1, 0xFFFF);...
_write(int file, char *ptr, int len) int DataIdx; for (DataIdx = 0; DataIdx < len; DataIdx++){ __io_putchar( *ptr++ );} return len; Refer to STM32Cube provided example UART_Printf() available for almost all STM32 Series. An example is available in STM32Cube_FW_F3_V1.7.0\Projects\ STM32F303ZE-Nucleo\Examples\UART\UART_Printf. Caution: USART word length includes parity which is not the case for most of UART terminal.
Printf debugging AN4989 It has to be used in combination with a Serial Wire Viewer (SWV) on host side which provides the following features: • PC (Program Counter) sampling • Event counters that show CPU cycle statistics • Exception and Interrupt execution with timing statistics •...
AN4989 Printf debugging IAR™ EWARM IAR™ EWARM provides an integrated access to SWO. Redirection of printf and scanf is possible using Library Configuration options as shown in Figure Figure 51. Semihosting/SWO configuration with IAR™ EWARM Care must be taken that clock setup is correct by using ST-LINK -> Communication Pane as illustrated in Figure AN4989 Rev 3...
Printf debugging AN4989 Figure 52. IAR™ EWARM SWO Clock setting Once configured, IAR™ EWARM properly sets TRACE_IOEN and TRACE_MODE and configures the related GPIO. SWO printf occurrences are visible in Terminal I/O windows. Port Stimulus 0 is used by printf and scanf. It is not configurable. ®...
AN4989 Printf debugging ® Figure 53. SWO configuration with Keil SWV viewer is called “Debug (printf) Viewer” and is accessible while in debug through View -> Serial Windows -> Debug (prinf) Viewer as shown in Figure ® Figure 54. Access to SWV in Keil ®...
Page 76
Printf debugging AN4989 library which split trace between stimulus based on their importance (info, debug, error) or there source. STM32CubeIDE With STM32CubeIDE you also have to redirect printf to SWO by some piece of code. With syscall.c integrated to the project: #include "stdio.h"...
AN4989 Printf debugging Figure 55. Enable SWD in STM32CubeIDE Enable SWV ITM Data Console in Window ->Show View -> SWV -> SWV ITM Data Console as shown in the figure below: AN4989 Rev 3 77/118...
Printf debugging AN4989 Figure 56. Enable SWV ITM Data Console in STM32CubeIDE Enable ITM Stimulus Port 0 after clicking on “Configure trace” as shown in the below figure. 78/118 AN4989 Rev 3...
AN4989 Printf debugging Figure 57. Enable ITM stimulus Port 0 in STM32CubeIDE Click on “Start Trace” button Figure 58. Start Trace button in STM32CubeIDE Press “Resume” button, and your printf message is printed in SWV ITM Data Console. Semihosting ® Semihosting is a mechanism that enables code running on an Arm target to communicate and use the Input/Output facilities on a host computer that is running a debugger.
Printf debugging AN4989 Semihosting depends on the library provided by the IDE. The next sections present how to set semihosting using the three main IDEs covered in this application note. 7.4.1 IAR™ EWARM IAR™ EWARM provides a highly integrated semihosting feature, enabled by default. Figure 59 shows how to check if it is the case for the project in Options ->...
AN4989 Printf debugging 7.4.3 STM32CubeIDE Set linker parameters First the linker must ignore the default syscalls.c file and has to use the newlib-nano librairies, which contains printf() function. in Project -> Properties -> C/C++ General -> Paths and Symbol Click on the Source Location tab. Click on the arrow near to “[Project name]/Core”, and select “Filter(empty)”.
Printf debugging AN4989 Figure 61. Properties for semihosting in STM32CubeIDE- Librairies Next, select MCU GCC Linker -> Miscellaneous while still in the Tool Settings tab. Click the Add… button and enter -specs=rdimon.specs into the dialog box. This add the linker flags in order to include the librdimon library. Figure 62.
Page 83
AN4989 Printf debugging Add printf Code Above int main(void) (USER CODE 0 section), add: extern void initialize_monitor_handles(void); Then configure the semihosting system call: In int main(void) before the while(1) loop (USER CODE 1 section) add: Initialise_monitor_handles(); Then inside the while(1) loop, add: Printf(“Hello World!\n”);...
Printf debugging AN4989 Debug configuration In Run -> Debug configuration -> Debugger tab, change the debugger probe to ST-LINK (Open OCD). In Generator options, choose “Software system reset“as reset Mode. Figure 63. Semihosting in STM32CubeIDE – Debug configuration In the Startup tab enter the command: monitor arm semihosting enable. 84/118 AN4989 Rev 3...
Printf debugging AN4989 In the debugging perspective, click Run -> Resume, and you should see “Hello, World!” being printed at the bottom of the console once per second. Figure 65. Semihosting in STM32CubeIDE – Run 86/118 AN4989 Rev 3...
Debug through hardware exploration As a complement to software instrumentation, a user facing a non-working system may take great advantage to monitor STM32 pin states (GPIO or clock among others) with external tools such as oscilloscopes or logic analyzers. This chapter presents the possibilities offered by STMicroelectronics hardware kits and...
Debug through hardware exploration AN4989 This is typically pin PA8 for all STM32 families. ® For Nucleo kits, the PA8 pin is accessible on the D7 pin of the ARDUINO connector. For other board pin configuration, please refer to the board schematics.
AN4989 Debug through hardware exploration Figure 68. MCO Multiplexer in STM32CubeMX Clock Configuration Pane The divider allows to output a signal frequency compatible with output capabilities. 8.2.2 HAL_RCC_MCOConfig Independantly of the fact that STM32CubeMX is used or not, MCO configuration is done using the hal_rcc or LL function: stm32XXxx_hal_rcc.c/ stm32XXxx_hal_rcc.h void HAL_RCC_MCOConfig( uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t...
STM32L4 Series also provides an LSCO (Low Speed Clock Output) on PA2 in order to output LSE or LSI, same as MCO, but with benefit to be still available during stop and standby mode. Refer to section 6.2.15 Clock-out capability of STMicroelectronics reference manual ® STM32L4x5 and STM32L4x6 advanced Arm -based 32-bit MCUs (RM035) for details.
Dual-Core microcontroller debugging AN4989 Dual-Core microcontroller debugging STM32H7x5/x7 Series are dual core microcontrollers using heterogeneous core architecture: An Arm Cortex-M7 core and an Arm Cortex-M4 core. Debug process is different for these dual core microcontrollers as we need a simultaneous debug of both cores using a single hardware debug probe.
AN4989 From debug to release From debug to release It is important to have in mind that most of technics presented in this AN and suitable for debugging have to be properly cleaned to prevent problem while releasing the application. The following action list can be used as a checklist helping to avoid the most common problems: •...
Troubleshooting AN4989 Troubleshooting Table 6 summarizes solutions to overcome some of the most frequent issues faced during debug setting and operation. Table 6. Troubleshooting Problem Solution Ensure debug in low-power in DBGMCU register is enabled. Connection with target lost during debug of low-power Ensure SWD pin not set in analog state.
This appendix provides a tutorial for the different ways to Read/Write the DBGMCU registers with various tools and IDEs. By software HAL and LL provide functions to set/reset DBGMCU registers. Refer to STM32Cube\Repository\STM32Cube_FW_[MCU] _[Version]\Drivers\STM32[MCU]xx_HAL_Driver\ STM32[MCU]xx_User_Manual.chm Figure 70 Figure 71 show the positions of the DBGMCU registers iwithin the LL and HAL libraries.
Managing DBGMCU registers AN4989 Figure 71. DBGMCU_CR HAL Library Functions For M0 Cortex based families (L0/F0) DBGMCU module need to be clocked by setting bit 22 of register RCC_APB2ENR (refer to the corresponding reference manual) prior to be written. RCC->APB2ENR |= RCC_APB2ENR_DBGMCUEN; Some HAL macros are also available to Enable/Disable this clock.
AN4989 Managing DBGMCU registers IAR™ EWARM Read/Write of DBGMCU registers is possible through the register window as shown in Figure Figure 72. Access to DBGMCU register with IAR™ EWARM ® In case a more permanent setup is required EWARM C-SPY debugger macros enable to define execUserSetup(), which is executed at debugger start prior to program execution.
Managing DBGMCU registers AN4989 ® Figure 73. EWARM C-SPY Macro script setting A basic sample code of execUserSetup() function used to enable low-power debug on L0 is provided below: execUserSetup(){/* Write a message to the debug log __message "L0 DBGMCU Setup IAR Macro \n"; __writeMemory32 (0x00400000, 0x40021034, "Memory");...
AN4989 Managing DBGMCU registers ® Keil MDK-Arm µVision At runtime, access to the DBGMCU register is possible through View -> System Viewer -> DBG. ® Figure 74. Accessing DBGMCU register in Keil MDK-Arm µVision (1/2) AN4989 Rev 3 99/118...
Managing DBGMCU registers AN4989 ® Figure 75. Accessing DBGMCU register in Keil MDK-Arm µVision (2/2)) Each bit in the register can be set or reset independently. ® For a permanent debug configuration, use Keil MDK-Arm µVision initialization file capability. Debugger script files are plain text files that contain debugger commands. These files are not created by the tools.
Managing DBGMCU registers AN4989 STM32CubeIDE By default, STM32CubeIDEenable Low-Power debug. This default setting can be changed through Run->Debug Configurations->Debugger Pane. • Setting up with OpenOCD server By clicking on the Show generator options as presented in the figure below. Figure 77. Access to Generator Options in STM32CubeIDE V2.0.0 DBGMCU options are available under Reset Mode in the Mode Setup group as shown in Figure 102/118...
Managing DBGMCU registers AN4989 Figure 79. Access to DBGMCU settings with STM32CubeIDE V1.3.0 If needed, the DBGMCU value can be changed at run time through the I/O Registers window as shown in Figure 104/118 AN4989 Rev 3...
AN4989 Managing DBGMCU registers Figure 80. Runtime R/W access to DBGMCU register with SSTM32CubeIDE Note: All DBGMCU registers values are kept while reset. Pay attention to not let a debug or unwanted state when returning to normal execution. (refer to Chapter 9: Dual-Core microcontroller debugging on page 92).
As debugger interface to program and debug an external application as documented in the user manual – STM32 Nucleo-144 board: section 6.3.4 of Using ST-LINK/V2-1 to program and debug an external STM32 application (UM1974) – STM32 Nucleo-64 board: Using ST-LINK/V2-1 to program and debug an external...
AN4989 Use Nucleo “cuttable” ST-LINK as stand-alone VCP Any available UART of the STM32 application can be connected to the CN3 connector of the ST-LINK part. Figure 82 illustrates a project using NUCLEO-F302R8 is using ST-LINK part of a NUCLEO-L476RG for connection of UART1 to the host.
Use Nucleo “cuttable” ST-LINK as stand-alone VCP AN4989 Figure 83. Virtual COM port on PC side Note: This usage implies to have several targets connected to a single host PC. In order to properly identify the target and the VCP, refer to Appendix C: Managing various targets on the same 108/118...
AN4989 Managing various targets on the same PC Appendix C Managing various targets on the same PC This appendix provides hints to identify and control the connection to a specific target among several ones using ST-LINK probe. Each ST-LINK connection is identified by a serial number. In order to correlate a serial number with a board, it is advised to use STM32CubeProgrammer.
Managing various targets on the same PC AN4989 Figure 85. Getting target ST-LINK S/N from the console The next sections detail the selection of a specific target with each of the main IDEs considered in this application note. IAR™ EWARM The first time a debug session is launched while several targets are connected, a Debug Probe Selection window pops up.
AN4989 Managing various targets on the same PC Figure 87. IAR™ EWARM Debug Probe Selection with nickname Important: The pop-up window is displayed only at first time. The selection made is then applied by default to further connections. Changing this initial selection requires that the "Debug Probe Selection"...
Managing various targets on the same PC AN4989 ® Keil MDK-Arm µVision The list of connected targets is visible in ST-LINK debug pane (Options -> Debug -> ST- LINK -> Settings -> Debug Pane) as presented in Figure ® Figure 89. Keil ST-LINK selection In the Debug Adapter section, the pick list allows to select among all connected targets.
AN4989 Managing various targets on the same PC Figure 90. Error message for multiple ST-LINK detected in STM32CubeIDE • Setting up with OpenOCD rIt is possible to force the connection to a specific target using the ST-LINK S/N. In Run -> Debug Configurations -> Debugger Pane, add the following OpenOCD option: -c hla_serial [ST-LINK S/N] Figure below illustrates the setting of an OpenOCD option for forcing a connection.
Managing various targets on the same PC AN4989 Figure 91. Forcing specific ST-LINK S/N with STM32CubeIDE with OpenOCD option • Setting up with ST-LINK GDB server 114/118 AN4989 Rev 3...
AN4989 Managing various targets on the same PC Figure 92. Forcing specific ST-LINK S/N with STM32CubeIDE with ST-LINK GDB server AN4989 Rev 3 115/118...
Section 1.1: General information 26-Jan-2021 – Section 2.4.2: Wiki platform – Section 2.4.3: Github – Figure 2: Development tools overview – Figure 4: STM32 Nucleo-144 structure – Figure 15: STM32Cube monitor – Figure 14: STM32Cube programmer AN4989 Rev 3 117/118...
Page 118
IMPORTANT NOTICE – PLEASE READ CAREFULLY STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders.
Need help?
Do you have a question about the STM32 and is the answer not in the manual?
Questions and answers