[ANSWERED] How to printf() to PC through J-Link?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [ANSWERED] How to printf() to PC through J-Link?

    Colleagues,

    Is it possible to printf() to the PC through J-Link debugger? If so, what has to be done to configure it? If somebody could post an example, that would be awesome.

    Thanks,
    - Nick
  • Hi,

    if you are using a Cortex-M3 device and CMSIS, you can easily use the ITM_Sendchar(c) function, defined in CMSIS core_cm3.h.
    The ITM output (channel 0 for printf) is captured from the J-Link through SWO sampling, this must be configured (dependant on your IDE).

    On ARM7/9 there is a method called semihosting, a printf is redirected through armlib to the debugger, how this works with J-Link the Segger guys should be able to help :)
    In Keil uVision on ARM7/9 and there is the Real Time Agent doing this work, and the CMSIS for Cortex. Note, for STM32F10x the stm32f10x_dbg.ini (found i.e. in STLibBlinky) must be added to debug settings. In uVision you can watch the serial output when debugging in the RTA or ITM window under Serial Windows.

    In IAR the printf's are captured through semihosting and sent to the Terminal. On CM3 the semihosting can also be used, or printf through ITM.

    The advantage on ITM is, that the core does not need to be "stopped" when printing a message.


    BR,
    /th.
  • RE: How to printf() to PC through J-Link?

    kender wrote:


    Is it possible to printf() to the PC through J-Link debugger? If so, what has to be done to configure it? If somebody could post an example, that would be awesome.

    yes, if you are using iar ewarm you can use the dcc for this purpose.
    regards
    gerhard