[SOLVED] ETM trace for nRF52840 in Ozone - how to do it without Segger Embedded Studio?

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

  • [SOLVED] ETM trace for nRF52840 in Ozone - how to do it without Segger Embedded Studio?

    Hi,

    I was able to make ETM trace for nRF52840 work (from wiki.segger.com/nRF52_Series_Devices#Tracing_on_nRF52840).

    Thanks for the example and documentation.

    However, if you don't use SES, you can't enable the ETM trace (I'm not sure why now, for STM32 it works flawlessly in Ozone). SES calls "OnTraceStart" which I guess writes something to registers (I used to do this manually, but it was tedious; I really don't wish to sniff it via logic sniffer).

    I'd hope that like monitor mode, you can call some some commands via GDB (GDB MI) that do this for you, like I ported monitor mode to pure gcc+make+gdb:

    github.com/hiviah/nrf52840-monitor-mode-gcc-gdb-only


    I have made monitor mode working for BLE DFU OTA bootloader/updater, but I'd like to have BLE DFU OTA+monitor mode (this works), but also add ETM trace .


    Could I ask for advice how to set registers/setting via commands to JLink GDB server so that it works with Ozone (or settings in Ozone scripts)?


    I updated to latest JLink libraries, SES, Ozone:


    * JLink libs JLink_Linux_V784a

    * Ozone v3.28.c
    * Segger Embedded Studio 7.10a
  • Hello,

    Thank you for your inquiry.
    You seem to confuse some things here. Embedded Studio is not needed for tracing whatsoever.
    In the example project it is simply used to generate an example application as it is our IDE.

    For tracing we recommend to use Ozone as it works IDE/Toolchain independent and also supports streaming trace.

    So no matter what generates your code you can always use Ozone for debugging and tracing. No GDB required.
    Also we do not recommend GDB debuggers for tracing as most of them do not support tracing whatsoever. Simply use Ozone instead, that will always work.

    More information about tracing setup and troubleshooting can be found here:
    wiki.segger.com/J-Trace

    Additionally here are some Nordic Specific things to consider:
    - If you are using the nRF52840-DK board make sure not to use some of the buttons as they share functionality with trace pins: wiki.segger.com/Tracing_on_Nor…0#Specifics.2FLimitations
    - The BLE softdevice must be downloaded ideally by Ozone as well so we have the softdevice instructions which are required for trace reconstruction. You can do so as follows: wiki.segger.com/nRF52_Series_Devices#Softdevice

    Best regards,
    Nino
    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 I've found out where the confusion came from. I used my own jdebug file instead of the provided jdebug file, which has the magic invocation

    Source Code

    1. void BeforeTargetConnect (void) {
    2. //
    3. // Trace pin init is done by J-Link script file as J-Link script files are IDE independent
    4. //
    5. Project.SetJLinkScript("./Nordic_nRF52840_TraceExample.pex");
    6. }

    Do I understand correctly though that adding this PEX file to other nrf52840 projects where I want ETM trace to work will also initialize ETM trace pins? As far as I could test it on some examples, I guess the answer is yes, but just checking.

    BTW the reason my jdebug file without the PEX include did work was because if you first run SES, then Ozone, it also initializes the trace pins in SES first. But adding it to jdebug script is obviously much more useful.

    Why isn't the initialization a part of Ozone trace dialog, like it does for STM32 for example? Are some other CPU families dependent on such "enable ETM trace pins" files? (I remembed I couldn't get K82F ETM trace working some time ago.
  • Hello,

    zamniah wrote:

    Do I understand correctly though that adding this PEX file to other nrf52840 projects where I want ETM trace to work will also initialize ETM trace pins? As far as I could test it on some examples, I guess the answer is yes, but just checking.
    Yes. The JLinkScripts/pex files contain the board specific trace clock and pin init steps.
    So as long as you use the same pins on your own board as the pictured eval board the scripts can be reused.


    zamniah wrote:

    BTW the reason my jdebug file without the PEX include did work was because if you first run SES, then Ozone, it also initializes the trace pins in SES first. But adding it to jdebug script is obviously much more useful.
    Yes in the Embedded Studio example project the same .pex file is set. So trace is inited there completely. But as said, ES is hier just our launch platform for the example project as we are most familiar with that IDE as we control the software ;)


    zamniah wrote:

    Why isn't the initialization a part of Ozone trace dialog, like it does for STM32 for example? Are some other CPU families dependent on such "enable ETM trace pins" files? (I remembed I couldn't get K82F ETM trace working some time ago.
    The problem was that more and more devices supported multiple trace pin combinations and trace clock sources so adding native trace pin inits was becoming an educated guess that could worst case destroy customer hardware. So we changed the approach to the external JLinkScripts/pex files with out of the box example projects so customers who would accidentally turn trace on in Ozone would not risk damaging their setup.
    So it is possible that for older devices like the ST STm32F4xx series and NXP Kinetis series the complete chip specific trace init is executed natively by our J-Link DLL.

    But the recommended way is to do everything via JLinkScript.

    Best regards,
    Nino
    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.
  • Thanks!

    Now I have almost all the parts for the BLE bootloader debug, just can't figure out how to both enable ETM and also monitor mode from jdebug/jlinkscript. Since Project.SetJLinkScript can be used only once (i.e. the last used parameter is executed), I don't know how to both execute the PEX and also setting monitor mode commands. Since PEX is compiled, I can't just copy/paste the code into single jlinkscript. There is also no include in jlinkscript syntax or a way to chain them. And jlinkscript commands can't be used in jdebug file. Tried Script.Exec to call JLINK_ExecCommand but that didn't work out.

    Can I call both of those Jlinkscripts somehow, or do I need to get the source for PEX from support? Otherwise some workaround like running JLink commander on side and then using GDB in batch/MI mode setting the monitor mode parameters. Maybe using one jlinkscript in BeforeTargetConnect and other in AfterTargetReset could serve as workaround (since monitor mode settings seem to survive reset), but it's hackish.
  • Hello,

    We can provide you with the JLinkScript source via mail so you can merge the two scripts together. I think that would be easiest.
    Could you open a support request as explained in my signature via the web form.
    Simply reference this forum thread and that you would like to get the trace pex source for the nRF52.

    Best regards,
    Nino
    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.