1
\$\begingroup\$

I recently acquired an STM32F429 Discovery Kit (pictured below). I'm new to the M4 cortex series microcontrollers and ARM in general having only worked with PICs before. I've seen some really nice debugging features of this microcontroller using SWD (serial wire debug) but it seems that this only works if you're using a programmer. Unfortunately I'm not using an SWD/JTAG programmer/debugger like the ST-Link to program the board but rather using the USB cable to do so.

I'd like to find out from users on the forum who have worked with these before what my options for debugging are. I'm going to be working on a Fast Fourier Transform application that uses the LCD screen so more advanced debug techniques like live variable viewing and real time data plotting will be extremely useful. Without the ISP programmer if I want to use printf() statements for debugging purposes in my code will I have to do so by outputting over UART to a terminal application like Putty or using the LCD screen to output test data?

STM32F429 Discovery

\$\endgroup\$
  • \$\begingroup\$ Check out OpenOCD. We are debugging an STM32Fxxx over USB with it. \$\endgroup\$ – Digiproc Feb 7 at 17:37
  • \$\begingroup\$ Using Keil µVision for debugging with STM32F407 Discovery board. \$\endgroup\$ – StainlessSteelRat Feb 7 at 19:21
4
\$\begingroup\$

I have the same board and the top part actually contains the ST-LINK/V2 debugger/programmer. You can even use it to debug/program other boards by configuring the CN4 jumpers. There's more detail in section 6.3 of the User Manual here. It is extremely powerful and quite straight-forward to use in Atollic TrueSTUDIO or System Workbench.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the response! This is great! I'm not quite understanding the datasheet instructions though. Do I remove those CN4 jumpers and then connect cables between the SWD pins and the corresponding pins for the MCU? \$\endgroup\$ – Blargian Feb 7 at 19:05
  • \$\begingroup\$ That's what you do if you want to program another board. For programming the discovery board you leave the jumpers in place. When you program the board through the mini-USB, you're already using the built-in ST-LINK. All I had to do after installing System Workbench or TrueSTUDIO and creating a project, was click "debug" on the main toolbar. \$\endgroup\$ – lnowak Feb 7 at 19:35
  • \$\begingroup\$ @inowak I get it to program when I do it like that but none of the debug features seem to be working - like the live variable view for instance. I followed a tutorial on how to get it to send printf output to port 0 with SWV but no luck. Under the debug settings I have SWD turned on. \$\endgroup\$ – Blargian Feb 7 at 19:43
  • \$\begingroup\$ I don't know what the problem could be. The pins should be configured by default, but it's possible to change their function in the program. Are you using stm32cubemx? \$\endgroup\$ – lnowak Feb 8 at 13:41
  • \$\begingroup\$ @inowak yes, using stm32cubemx. \$\endgroup\$ – Blargian Feb 10 at 16:37
1
\$\begingroup\$

One way that I have used to debug is using the VCP drivers with a JTAG. You can get data out at a semi fast rate, but the real benefit is having a UART connected to you computer through USB and being able to send or receive data through most programming languages (because just about everything supports a COM port. I don't know if this will meet your throughput demands for data but it's worth a look.

\$\endgroup\$
1
\$\begingroup\$

There are two closely connected protocols, plus the ETM trace which are relevant here for debug:

  • SWD/JTAG: This is an externally mastered protocol used for run control and read/write access of core registers and memory (memory can be accessed whilst the core is also running). This is virtualised over the USB connector in this case.

  • SWO: This is 'instrumentation trace'. You can stream both hardware events and software generated output over a dedicated 'uart-like' device. Some debug hardware supports this, it also needs tools support (but can show things like exception timing - so long as you don't overload the available bandwidth).

  • ETM: Typically using a set of 4 pins in an alternate function mode, this streams instruction by instruction information in real time. It requires dedicated hardware, and specific software.

You generally get SWD 'for free' with a dev board. Often you will also get an actual UART shared with the same USB port. The next step up is Serial Wire Output, and the highest level of debug visibility is the Embedded Trace Macrocell (which isn't present on all devices, and isn't available on M0 devices). Hardware for ETM capture at anything over a few 10 MHz is relatively expensive, but it can be good for debugging timing sensitive or one-off types of problem.

For instrumentation, printf() over the UART or direct writes to the ITM/SWO are similar in terms of value and ease of use - SWO can also be used for some automated watchpoint type functions, with the benefit of no software overhead.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.