This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[Cortex-M3] SWO Packet Parsing

Note: This was originally posted on 21st February 2012 at http://forums.arm.com

Hi,

I'm trying to play with SEGGER JLink device and ARM M3 micro in order to implement a SWV engine.
Currently I set a SWD protocol communication, and all other needed definitions for the SWO activation:

DEMCR    = 0x01000000
DWT_FUNCTION0 = 0x00000000
DWT_FUNCTION1 = 0x00000000
DWT_FUNCTION2 = 0x00000000
DWT_FUNCTION3 = 0x00000000

I would like to monitor a variable located at address 0x2000017C, a 2 bytes length interger that changes every 100us:

DWT_COMP0   = 0x2000017C
DWT_MASK0  = 0x00000001
DWT_FUNCTION0 = 0x00000023

SELECTED_PIN_PROTOCOL_REG = 0x00000002
TPIU_ACPR       = 0x0000008F
LOCK_ACCESS_REGISTER   = 0xC5ACCE55
ITM_TCR       = 0x0001000F
ITM_TPR       = 0x0000000F
ITM_TER       = 0x00000000
DWT_CTRL       = 0x400003FE
TPIU_FFCR       = 0x00000100

When I start my acquisition phase, I'm able to obtain the buffer content from the TPIU (see attachment):


00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FC 00 00 00 05 8F 00 00 00 00 D0...

but I have difficulties regarding the parsing process: I'm not able to understand if the 28 bytes of 0s belong to the header that should terminates with only one 0b1.
The serie, in fact, terminates with 0xFC = 0b11111100, but I don't know if the first 1 bit (position [7]) belongs to the header definition, so if I have to discard it and consider the remaining value (0b1111100) value for the next data retrieving.

And after the header, how can I understand what type of info is following?

Thank you very much.
Parents
  • Note: This was originally posted on 13th April 2012 at http://forums.arm.com


    Ciao,

    can you please describe your SWO activation flow?
    And later, you should copy&paste a bunch of bytes that you're receving from the JLink device.

    I will let you know, if I'm able, the meaning of the frames.

    Thanks!


    Hi,
    Thanks for the quick response.

    I am not completely sure when you say SWO activation flow.(Sorry I am a newbie ).But allow me to give your detailed scenario.

    I am using 32-Micro-controlller from Energy Micro having Cortex M3 core for my development. The IDE is Eclipse Helios along with segger Jlink tools for debugging.
    Problem description: I am trying to develop some wireless application using Lightweight IP stack on FREE RTOS as lower level operating system.Now there are many Debug printf messages in LWIP stack which I want to get it displayed on some kind of terminal or any console so I can debug my code.

    I have enabled SWo using the Code provided by Energy Micro:void setupSWO(void) function.I know the enzable code works for sure because after calling the function and executing printf ("Hello world "),I can see the SWO packets in SWV tab of JLINK V4.36e control panel.Also , in JLINK Commander I can see the data by enabling by commands SWOread and SWOshow. but these bytes are in HEX and I am not sure whether these are the same data packets which i need or something else .  
    The SWObytes are as shown below:

    J-Link>SWOread
    256 bytes read (5201 bytes in host buffer)
    00000000 = FE F8 F9 DC FC FD 1F E3 F9 F4 BD FC FE FD FE F9
    00000010 = F4 FD FE FE FC F7 F9 F4 7D 38 F8 FD FE FD FA EC
    00000020 = FC FC 7F F0 FE EC 7E FC C7 FA F9 DD F2 FD 3F C7
    00000030 = F8 F8 FC FE FC FE 13 FE F9 FD FD FF FC FC FC F8
    00000040 = F4 B2 FC FD FC FC F9 FC FF FE FC F1 FD FE FC 7C
    00000050 = FE 7F FC FC F9 F0 7C FE 7F FD FB F8 EC 7C FC 7F
    00000060 = FE CF FB FA FF FC FC FC C7 FA E1 FE FC FF FC 3F
    00000070 = E7 F8 DD FC F5 1F FC F9 FE BC FE FF FE 1F D9 E8
    00000080 = FD FC FC 4F FC F9 F6 7E F1 FC 87 FC F8 EC FD FE
    00000090 = FD FE F1 FE ED FE FD BF FC F8 F8 DC BC FD FE C7
    000000A0 = FA F9 DC FE FC FC F2 F8 F8 FF FD FC 1F E3 FE F4
    000000B0 = B5 FE FD FE E3 FE F5 FC FC FE F1 F5 F8 FC 7C FD
    000000C0 = FF FE FD F1 FA E1 7C FC FF FF CF FC FD FE FD F0
    000000D0 = C7 FE F9 FF FD FE 7F C7 FE E6 FD FC FE FC FA FA
    000000E0 = BD F8 FF F2 FD FC F8 F6 FC FF FF FD E0 F5 BC FE
    000000F0 = 7F F9 F8 EC F0 FF 87 F1 F9 8D FF FC FC FC F2 F9

    Also Code to activate SWO:
    void setupSWO(void)
    {
       uint32_t *dwt_ctrl = (uint32_t *) 0xE0001000;
       uint32_t *tpiu_prescaler = (uint32_t *) 0xE0040010;
       uint32_t *tpiu_protocol = (uint32_t *) 0xE00400F0;

       CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;
       /* Enable Serial wire output pin */
       GPIO->ROUTE |= GPIO_ROUTE_SWOPEN;
    #if defined(_EFM32_GIANT_FAMILY)
       /* Set location 0 */
       GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC0;

       /* Enable output on pin - GPIO Port F, Pin 2 */
       GPIO->P[5].MODEL &= ~(_GPIO_P_MODEL_MODE2_MASK);
       GPIO->P[5].MODEL |= GPIO_P_MODEL_MODE2_PUSHPULL;
    #else
       /* Set location 1 */
       GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC1;
       /* Enable output on pin */
       GPIO->P[2].MODEH &= ~(_GPIO_P_MODEH_MODE15_MASK);
       GPIO->P[2].MODEH |= GPIO_P_MODEH_MODE15_PUSHPULL;
    #endif
       /* Enable debug clock AUXHFRCO */
       CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;

       while(!(CMU->STATUS & CMU_STATUS_AUXHFRCORDY));

       /* Enable trace in core debug */
       CoreDebug->DHCSR |= 1;
       CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;

       /* Enable PC and IRQ sampling output */
       *dwt_ctrl = 0x400113FF;
       /* Set TPIU prescaler to 16. */
       *tpiu_prescaler = 0xf;
       /* Set protocol to NRZ */
       *tpiu_protocol = 2;
       /* Unlock ITM and output data */
       ITM->LAR = 0xC5ACCE55;
       ITM->TCR = 0x10009;
    }

    So please advice me on the issue
Reply
  • Note: This was originally posted on 13th April 2012 at http://forums.arm.com


    Ciao,

    can you please describe your SWO activation flow?
    And later, you should copy&paste a bunch of bytes that you're receving from the JLink device.

    I will let you know, if I'm able, the meaning of the frames.

    Thanks!


    Hi,
    Thanks for the quick response.

    I am not completely sure when you say SWO activation flow.(Sorry I am a newbie ).But allow me to give your detailed scenario.

    I am using 32-Micro-controlller from Energy Micro having Cortex M3 core for my development. The IDE is Eclipse Helios along with segger Jlink tools for debugging.
    Problem description: I am trying to develop some wireless application using Lightweight IP stack on FREE RTOS as lower level operating system.Now there are many Debug printf messages in LWIP stack which I want to get it displayed on some kind of terminal or any console so I can debug my code.

    I have enabled SWo using the Code provided by Energy Micro:void setupSWO(void) function.I know the enzable code works for sure because after calling the function and executing printf ("Hello world "),I can see the SWO packets in SWV tab of JLINK V4.36e control panel.Also , in JLINK Commander I can see the data by enabling by commands SWOread and SWOshow. but these bytes are in HEX and I am not sure whether these are the same data packets which i need or something else .  
    The SWObytes are as shown below:

    J-Link>SWOread
    256 bytes read (5201 bytes in host buffer)
    00000000 = FE F8 F9 DC FC FD 1F E3 F9 F4 BD FC FE FD FE F9
    00000010 = F4 FD FE FE FC F7 F9 F4 7D 38 F8 FD FE FD FA EC
    00000020 = FC FC 7F F0 FE EC 7E FC C7 FA F9 DD F2 FD 3F C7
    00000030 = F8 F8 FC FE FC FE 13 FE F9 FD FD FF FC FC FC F8
    00000040 = F4 B2 FC FD FC FC F9 FC FF FE FC F1 FD FE FC 7C
    00000050 = FE 7F FC FC F9 F0 7C FE 7F FD FB F8 EC 7C FC 7F
    00000060 = FE CF FB FA FF FC FC FC C7 FA E1 FE FC FF FC 3F
    00000070 = E7 F8 DD FC F5 1F FC F9 FE BC FE FF FE 1F D9 E8
    00000080 = FD FC FC 4F FC F9 F6 7E F1 FC 87 FC F8 EC FD FE
    00000090 = FD FE F1 FE ED FE FD BF FC F8 F8 DC BC FD FE C7
    000000A0 = FA F9 DC FE FC FC F2 F8 F8 FF FD FC 1F E3 FE F4
    000000B0 = B5 FE FD FE E3 FE F5 FC FC FE F1 F5 F8 FC 7C FD
    000000C0 = FF FE FD F1 FA E1 7C FC FF FF CF FC FD FE FD F0
    000000D0 = C7 FE F9 FF FD FE 7F C7 FE E6 FD FC FE FC FA FA
    000000E0 = BD F8 FF F2 FD FC F8 F6 FC FF FF FD E0 F5 BC FE
    000000F0 = 7F F9 F8 EC F0 FF 87 F1 F9 8D FF FC FC FC F2 F9

    Also Code to activate SWO:
    void setupSWO(void)
    {
       uint32_t *dwt_ctrl = (uint32_t *) 0xE0001000;
       uint32_t *tpiu_prescaler = (uint32_t *) 0xE0040010;
       uint32_t *tpiu_protocol = (uint32_t *) 0xE00400F0;

       CMU->HFPERCLKEN0 |= CMU_HFPERCLKEN0_GPIO;
       /* Enable Serial wire output pin */
       GPIO->ROUTE |= GPIO_ROUTE_SWOPEN;
    #if defined(_EFM32_GIANT_FAMILY)
       /* Set location 0 */
       GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC0;

       /* Enable output on pin - GPIO Port F, Pin 2 */
       GPIO->P[5].MODEL &= ~(_GPIO_P_MODEL_MODE2_MASK);
       GPIO->P[5].MODEL |= GPIO_P_MODEL_MODE2_PUSHPULL;
    #else
       /* Set location 1 */
       GPIO->ROUTE = (GPIO->ROUTE & ~(_GPIO_ROUTE_SWLOCATION_MASK)) | GPIO_ROUTE_SWLOCATION_LOC1;
       /* Enable output on pin */
       GPIO->P[2].MODEH &= ~(_GPIO_P_MODEH_MODE15_MASK);
       GPIO->P[2].MODEH |= GPIO_P_MODEH_MODE15_PUSHPULL;
    #endif
       /* Enable debug clock AUXHFRCO */
       CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;

       while(!(CMU->STATUS & CMU_STATUS_AUXHFRCORDY));

       /* Enable trace in core debug */
       CoreDebug->DHCSR |= 1;
       CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;

       /* Enable PC and IRQ sampling output */
       *dwt_ctrl = 0x400113FF;
       /* Set TPIU prescaler to 16. */
       *tpiu_prescaler = 0xf;
       /* Set protocol to NRZ */
       *tpiu_protocol = 2;
       /* Unlock ITM and output data */
       ITM->LAR = 0xC5ACCE55;
       ITM->TCR = 0x10009;
    }

    So please advice me on the issue
Children
No data