This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL2-RM57L: printf/ vsnprint crashs

Part Number: LAUNCHXL2-RM57L

Tool/software: Code Composer Studio

Hello,

for debugging purposes, I'd like to use printf() with the SCI2. To make debugging more comfortable to use, you suggested to implement an sci_printf() function: 

the function sci_prinf(). But if I try to use this, the Controller crashs at the vsnprintf() part with an "dataEntry" Interrupt. I tried to increase the stack+heap, but no differences.

this is my main function.

int sbcMain(void)

{

    sciInit();
    gioInit();

    gioSetBit(gioPORTB, 6, gioGetBit(gioPORTB, 6) ^ 1);

    //works
    uint8* text = "sciDisplayTest ";
    sciDisplayText(sciREG1, text, sizeof(text));


    //this is crashing with ... b   dataEntry
    sci_printf("Test %d", 42);


    if (xTaskCreate(vTaskHeartbeat, "vTaskHeartbeat", configMINIMAL_STACK_SIZE,
    NULL,
                    1, &xTask1Handle) != pdTRUE)
    {
        /* Task could not be created */
        while (1)
            ;
    }
    if (xTaskCreate(vTask1, "Task1", configMINIMAL_STACK_SIZE, NULL, 1,
                    &xTask2Handle) != pdTRUE)
    {
        /* Task could not be created */
        while (1)
            ;
    }


    vTaskStartScheduler();

    while (42)
        ;

    return 0;
}

int sci_printf(const char *_format, ...)
{
    char str[128];
    int length = -1;

    va_list argList;
    va_start(argList, _format);

   // length = snprintf(str, sizeof(str), _format, argList);
   length = vsnprintf(str, sizeof(str), _format, argList);

    va_end(argList);

    if (length > 0)
    {
        sciSend(sciREG1, (unsigned) length, (unsigned char*) str);
    }

}

Could you give any hints for debugging this, please?

  • Hello,

    The vsnprintf is part of stdio library:
    int vsnprintf(char *restrict, size_t, const char *restrict, va_list);

    Is the argument of type "char *" compatible with parameter of type "char *restrict"?
  • No that wasn't the problem.

    Actually, I needed to adjust the Stacksize, which I though I did already with Setting it in Build->Arm Linker->Basic Options->Stack Size. I set this already to 0x1500. (was 0x800).

    But you need to change it in HalCoGen->RAM->UserStack(0x1000, which gives a summarized stack of 0x1500) too! 


    Thanks for your help

    Florian