CC3200 using SWD / SWV / SWO / ITM

I am trying to get printf statements to work without using an external UART. I am following the instruction in the ARM manuals best I can and have defined and included the following:

//###################################################

#include <stdio.h>
#include "source/datatypes.h"


#define ITM_Port8(n) (*((volatile UINT8 *)(0xE0000000+4*n)))
#define ITM_Port16(n) (*((volatile UINT16 *)(0xE0000000+4*n)))
#define ITM_Port32(n) (*((volatile UINT32 *)(0xE0000000+4*n)))
#define DEMCR (*((volatile UINT32 *)(0xE000EDFC)))
#define TRCENA 0x01000000

struct __FILE { int handle; };
FILE __stdout;

/*************************************************************************
* Function Name: fputc()
**************************************************************************
* Summary: Overrides the fputc() library function to output to ITM port 0.
*
* Parameters: the character to be displayed
* a file handling structure (for stdout)
*
* Return: the input character.
*
*************************************************************************/
int fputc(int ch, FILE *f)
{
if (DEMCR & TRCENA) {
     while (ITM_Port32(0) == 0);
         ITM_Port8(0) = ch;
}
return ch;
}

//#####################################################

In my normal code I have include a nu,mber of

printf("At point #1/2/3/4");

 statements.

Under the debugger I can follow the code and the gets to 

_CODE_ACCESS int printf(const char *_format, ...)

routine which gets to my fputc()

above, goes through the routine and returns. No character can be seen in the debugger output window. I have tried configuring the probe in both JTAG and SWD mode (and moved the SOP jumper to [001] for 2 wire SWD.

In JTAG mode the process, no errors and also no printf() output.

In SWD mode is come with errors accessing the device.

What am I missing, can anybody help please??

For CC3200 related support functions, including debug enhanced "startup.c" as well as a range of embedded friendly support code, search Github for CC3200 support.
  • In reply to Praveen Kumar N:

    Hi Praveen,

    I just tested PIN_53 and it works!

    I only needed to configure pin in my code: PinModeSet(PIN_53, PIN_MODE_13);. I can successfully record @4Mbit/s. Separate printf bursts that is, not constant recording. I didn't go higher as bit time is in the range of raise/fall time as seen on scope.

    Thanks! This answers my questions regarding trace!

  • In reply to Andre Maree:

    Hi Andre,

    Not sure if I got your question correctly, but I think you want to get the whole trace info (printfs, timestamps, DWT etc) via the JTAG port itself with minimum processor overhead. Am I right ?

    FTDI based JTAG/SWD doesn't supports this. FTDI on CC3200 LP has two ports; first one is used as JTAG(4 wire) or SWD (2 wire and no SWO ), second one is used as UART port for UART A0.

    To get all the trace info via the JTAG you might require a different emulator like J-Link + IAR supports this.

    Thanks and Regards,

    Praveen

    ---------------------------------------------------------------------------------------------------------
    Please click the Verify Answer button on this post if it answers your question.
    ---------------------------------------------------------------------------------------------------------

  • In reply to Praveen Kumar N:

    Thanks Praveen, but just a (hopefully) last question.

    I have a J-Link adapter and can try to see if I can get it to work, but would need to now which pins should me muxed.

    Based on your info on Pins 45, 50 & 53 above, I check in the TRM but did not see any pin config info referencing SWO and/or SWO.

    To get full SWD/SWO/SWV functionality via the J8-J11 jumper pins, what would the HWREG and/or PinXXXXXX instructions be....

    Thanks

    Andre

    BTW, the CC3200 sofar is AWESOME. my next challenge is to get CoAP and then a rules engine working.

    For CC3200 related support functions, including debug enhanced "startup.c" as well as a range of embedded friendly support code, search Github for CC3200 support.
  • In reply to Andre Maree:

    Hi Andre,

    You can't bring out SWV on any of J8-J11. Here is how I have connected my J-Link ( SWV on Pin 50)

    JLink LP
    1 P1.1 (VCC)
    7 J9 (SWDIO)
    9 J8 (SWDCK)
    13 P3.10 (SWO)
    20 P2.1 (GND)

    In the code, you need to mux out SWV on Pin 50 by invoking PinModeSet(PIN_50,PIN_MODE_13);

    And this is how I re-implemented my Message function in uart_if.h

    void
    Message(const char *str)
    {

        if(str != NULL)
        {
            while(*str!='\0')
            {
                while(HWREG(0xE0000000) == 0)
                {

                }
                HWREG(0xE0000000) = *str++;
            }
        }

    }

     

    From IAR GUI,

    1. Go to Project->Options->Debugger->Driver select J-Link/J-Trace from the drop down.
    2. Go to J-Link/J-Trace->Connection->Interface choose ‘SWD’
    3. Connect to the target using ‘Download and Debug’ option
    4. Go to J-Link->SWO Trace Window Settings choose the required trace options.
    5. Go to J-Link->SWO Configuration->ITM Stimulus Ports Enable the required ports and redirection to I/O Terminal and/or log file
    6. Under the clock setup set the CPU clock (80 for cc3200).
    7.  Go to J-Link->SWO Trace to open the trace window.
    8. Run the program. Observe the output on View->I/O Terminal and SWO Trace window.

    Also pls note in this case, since you are using the GUI, you should not do the ITM configuration (from my previous post ) inside your code. The GUI will take care of doing this for you base on the option(s) you select.

    Let me know if this helps.

    Thanks and Regards,

    Praveen

    ---------------------------------------------------------------------------------------------------------
    Please click the Verify Answer button on this post if it answers your question.
    ---------------------------------------------------------------------------------------------------------

  • In reply to Praveen Kumar N:

    In SWD mode, I can use JLink to debug cc3200 LP when JLink's 13 pin not connected. Just connect 1, 7, 9, 20 like yours. Thanks.

    I also want to know howto use JLink to program Serial Flash. Should I must use Uniflash tool to program Flash? If this, I must add a UART circuit (like MAX3232)?

  • In reply to XiangBing Qi:

    we have had some luck using the FTDI USB to 'TTL' (3.3v)  cable for uniflash in the CC3200.

    I too would like to program flash from IAR but can't find a bootloader in any of the IAR directories for this chip.

  • In reply to Praveen Kumar N:

    Hi Praveen,

    I am afraid I have reached the point where I will have to give this up as impossible, at least for now. I have been able to achieve a lot to get a development environment based on Linux (Ubuntu 14.04) Eclipse CDT (Luna) to the point of a perfect compile, but the last load / run / debug step just avoids me.

    I have tried the JLink EDU/  JLinkServer option, connected all as per your sketch, but cannot get the debug config reliable.

    I have tried the GDBServer / OpenOCD (v8 & v9 beta) with the FTDI drivers combination, but again no luck.

    The catch in EVERYTHING it seems lies in the total lack of proper support for a Linux based CC3200 dev environment. Out of desperation I even looked at commercial compiler options ie EWARM (Win only)  and CodeSourcery (Linux but no CC3200) etc but no luck


    Since we have to make a decision on the road forward with the CC3200 it will be appreciated if we can have some clear feedback on TI plans for proper official support of the Linux / Eclipse / GDB / OpenOCD dev environment.
    Please make my day/week/month with some good news.

    Andre

    For CC3200 related support functions, including debug enhanced "startup.c" as well as a range of embedded friendly support code, search Github for CC3200 support.
  • In reply to Andre Maree:

    Andre,

     I had the same feeling about the CC3200SDK unless I spent some time to make it working with Eclipse, latest cross compiler J-Link all running on OSX. Finally I have an environment to work with. I still need to polish it but so far so good.

    When I finished ;) I finally discover this page:

    http://mcuoneclipse.com/2014/02/16/diy-free-toolchain-for-kinetis-part-10-project-creation-with-gnu-arm-eclipse-2-1-2/

    You can find a lot of info there about using Eclipse and Cortex core. I used described method to add task viewer to the debugger and finally it if working ( although slightly differently that described ).

    So read the article and try again.

  • In reply to Andre Maree:

    Hi Praveen,

    Based on the silence from TI guess I should assume "no news means no GOOD news" as far as support for a Linux dev environment for the CC3200 is concerned?

    Really really a sad situation.

    Andre

    For CC3200 related support functions, including debug enhanced "startup.c" as well as a range of embedded friendly support code, search Github for CC3200 support.
  • In reply to Andre Maree:

    It is doable. Will TI provide out of the box solution is another thing. Meanwhile, you can do it yourself: http://searchingforbit.blogspot.si/2014/07/cc3200-launchpad-with-external-debugger.html. Scroll to the part titled "Programming SPI flash without Uniflash through debug port". There is additional info in the comments.