[SOLVED] Jtrace + SWO Pin + STM32CubeIDE clock sliding - ITM trace

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

  • [SOLVED] Jtrace + SWO Pin + STM32CubeIDE clock sliding - ITM trace

    Since either my JTrace don't work correctly wtih STM32 board:

    The given reference board is STM32507VG (which is included in JTrace port. The program was micropython default build for STM32F4DISCOVERY.

    Since my STM32f427 board doesn't work well with ETM, I tried to use ITM PC sampling. However, mu current JLink board seems to suggest much higher CoreClockCpus, e.g. STM32F407 has just 168 MHz, but SWViewers showed estimated clock rate 252 Mhz.

    After measuing the responses and parsing with sigrok I understood to get the vale from CPUClock/prescaler to SWO it would be easier setup the CPU clock in the 253 MHz range, to get some reasoneable results:

    With using the real 168 MHz the measure baudrate is 3428571 when it should have been 2250000.
    Images
    • Screenshot_20200708_015914.png

      52.77 kB, 696×552, viewed 198 times
    • Screenshot_20200708_020236.png

      111.85 kB, 756×569, viewed 203 times
    • Screenshot_20200708_021116.png

      99.69 kB, 1,920×1,051, viewed 230 times

    The post was edited 2 times, last by zamniah ().

  • Hello,

    Thank you for your inquiry.
    Such an issue is not known to us.
    It appears that the clock initialization of your target application is not correct.

    For reference could you give the attached example project a try?
    You can rebuild and flash it using Embedded Studio:
    segger.com/products/development-tools/embedded-studio/

    If you now start the SWO Viewer. Does it work as expected?
    The default clock in this example is 16 MHz.
    If you edit the example project to initialize the core to 168 MHz. Do you see the same behaviour?
    If yes could you attach the modified project?

    Best regards,
    Nino
    Files
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • OK, solved this. Apparently STM32 Cube IDE sets prescalers, etc. wrong and SWOViewer acts weird.

    I got it working via gdb scripts from orbuculum, this enables SWO ITM PC sampling, core clock 168 MHz, SWO baud rate 2Mbaud. Commands for GDB:

    Source Code

    1. target extended-remote :2331
    2. source Support/gdbtrace.init
    3. monitor SWO EnableTarget 168000000 2000000 0xFF 0
    4. enableSTM32SWO 4
    5. prepareSWO 168000000 2000000 0 0
    6. dwtSamplePC 1
    7. dwtSyncTap 3
    8. dwtPostTap 1
    9. dwtPostInit 1
    10. dwtPostReset 15
    11. dwtCycEna 1
    12. ITMId 1
    13. ITMGTSFreq 3
    14. ITMTSPrescale 3
    15. ITMTXEna 1
    16. ITMSYNCEna 1
    17. ITMEna 1
    18. ITMTER 0 0xFFFFFFFF
    19. ITMTPR 0xFFFFFFFF
    20. continue
    Display All

    This enables measuring the code profile via ITM with orbtop or pcsampl:



    Shell-Script

    1. 34.04% 3571 qstr_find_strn
    2. 13.99% 1468 gc_mark_subtree
    3. 8.37% 879 mp_map_lookup
    4. 6.02% 632 gc_alloc
    5. 5.10% 535 mp_execute_bytecode
    6. 4.26% 447 sha256_Transform
    7. 3.87% 406 gc_sweep
    8. 2.48% 261 gc_collect_end
    9. 1.74% 183 gc_free
    10. 1.43% 151 frexpf
    11. 1.38% 145 qstr_add
    12. 1.32% 139 mp_obj_get_type
    13. 0.95% 100 mp_binary_op
    14. 0.76% 80 mp_obj_get_type_str
    15. 0.66% 70 mp_load_method_maybe
    16. -----------------
    17. 86.37% 9067 of 10490 Samples
    18. Ex | Count | MaxD | TotalTicks | AveTicks | minTicks | maxTicks
    19. ----+----------+-------+-------------+------------+------------+------------
    20. [---H] Interval = 1020mS / 0 (~0 Ticks/mS)
    Display All

    It would be nice if Ozone had ITM code profile in addition to ETM code profile, since for most board it's easier to get ITM working.