This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

printf() in Keil over Debug / ITM / UART / RTT, nothing works

I've been trying to for two days. Using nrf52DK, SDK12, no SD, Keil5.

All I want is to get printf() to work over ITM/SW/Debug, I'd even accept RTT if I had to. I can't seem to get anything to work.

Tried to import the retarget.c and app_uart into my simple program, that was a dependency disaster.

I've followed every guide I can find here, every post that mentioned retarget. Keil docs, Nordic docs, etc. Nothing seems to work.

  • Has anyone got printf() over Debug/ITM working!?

  • How can this be so difficult when it's between click and go on STM32 or maybe a couple extra lines of code at the worst?

  • Is there some reason nrf52832 can't use a virtual comm port?

  • I'm also having issues with RTT, so is there an SDK12 guide for that?

  • Using the UART EXAMPLE from SDK12, I get a total failure. Using the loopback test, at the line: if ((rx_data != tx_data[i]) || (err_code != NRF_SUCCESS)) I'm getting an err_code of 0x05 (not found?) totally unmodified code.

Any help would be appreciated.

Parents
  • rct42: Mine looks like what comes with SDK12:

    struct __FILE { int handle; /* Add whatever you need here */ }; 
    FILE __stdout;
    FILE __stdin;
    // --- END ---
    
    int fputc(int ch, FILE * p_file)
       {
     UNUSED_PARAMETER(p_file);
     UNUSED_VARIABLE(app_uart_put((uint8_t)ch));
     return ch;
     }
    
    //There is also a fputc
    

    Yours seems to be missing anything to do at all. Seems to take in char and immediately return it. Are you running a JlinkSettings file in debug? Are you running Keil5 "noPacks" or are you using the Debug ITM component / inside the RTE?

    To be clear There are two problems here. 1. NOTHING I DO seems to make the printf work, or even the RTT in the UART Example. 2. The UART Example itself flat out doesn't work. Goes into the Fifo and always returns NOT_FOUND, which maybe means no data is being received, not sure.

Reply
  • rct42: Mine looks like what comes with SDK12:

    struct __FILE { int handle; /* Add whatever you need here */ }; 
    FILE __stdout;
    FILE __stdin;
    // --- END ---
    
    int fputc(int ch, FILE * p_file)
       {
     UNUSED_PARAMETER(p_file);
     UNUSED_VARIABLE(app_uart_put((uint8_t)ch));
     return ch;
     }
    
    //There is also a fputc
    

    Yours seems to be missing anything to do at all. Seems to take in char and immediately return it. Are you running a JlinkSettings file in debug? Are you running Keil5 "noPacks" or are you using the Debug ITM component / inside the RTE?

    To be clear There are two problems here. 1. NOTHING I DO seems to make the printf work, or even the RTT in the UART Example. 2. The UART Example itself flat out doesn't work. Goes into the Fifo and always returns NOT_FOUND, which maybe means no data is being received, not sure.

Children
No Data
Related