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

SDK 14 printf() Issue

Building for a PCA10040 dev board (nrf52832) in SDK 14.0.0 with the S132SD v5.0.0

I'm an encountering an issue where calls to printf() are only displaying a single byte in the terminal emulator.

I am using app_uart_fifo.c and retargeting printf():

image description

.../components/libraries/fifo is in my include paths and everything is building just fine.

My uart_init() is as such:

static void uart_init(void)
{
    uint32_t	err_code;
		app_uart_comm_params_t const comm_params =
    {
        .rx_pin_no    = RX_PIN_NUMBER,
        .tx_pin_no    = TX_PIN_NUMBER,
        .rts_pin_no   = RTS_PIN_NUMBER,
        .cts_pin_no   = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
        .baud_rate    = UART_BAUDRATE_BAUDRATE_Baud115200
    };

    APP_UART_FIFO_INIT(&comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_event_handle,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
    APP_ERROR_CHECK(err_code);
}

NRF_LOG_USES_RTT and NRF_LOG_INFO are set to 0

RETARGET_ENABLED and APP_FIFO_ENABLED are set to 1

UART_ENABLED is set to 1 and configured as such:

image description

The interesting thing is that an arbitrary number of calls to printf() from outside the loop within main() work as expected, i.e.:

printf("APP STARTED!\r\n");
printf("More text!\r\n");
printf("Even more text!\r\n");
printf("Some more text!\r\n");

// Enter main loop.
for (;;)
{
    if (NRF_LOG_PROCESS() == false)
    {
        power_manage();
    }
}

However, calls to printf() from within a handler function or any subsequent function will print only the first byte, i.e.:

static void some_write_handler(uint16_t conn_handle, ble_whatever_t * p_whatever, uint8_t data)
{
    printf("This will fail...");
    if (data)
		{
				doSomething(data);
		}
}

Prints only T, at which point no other characters will be printed, even with subsequent calls.

Any input would be greatly appreciated.

Parents
  • Hi Jørgen, I believe I found my issue but will respond here for the benefit of any future folks who may encounter a similar problem.

    To address your questions, I'm using Keil uVision so presumably armcc v5.06.

    I did test the retarget.c from SDK 13.1-alpha but the issue persisted.

    The issue eventually turned out to be, or so it appears, with a sensor read timeout timer that had been implemented. The sensor is present on production hardware but not on the eval board which caused something to hang somewhere I couldn't locate.

    This wasn't difficult to fix but was ferociously hard to diagnose. I enabled RTT but, oddly, this made the issue go away. There were also no significant messages related to the failure even with the log level set to debug. I only managed to figure it out by systematically commenting out chunks of code until things started working and narrowing it down from there.

Reply
  • Hi Jørgen, I believe I found my issue but will respond here for the benefit of any future folks who may encounter a similar problem.

    To address your questions, I'm using Keil uVision so presumably armcc v5.06.

    I did test the retarget.c from SDK 13.1-alpha but the issue persisted.

    The issue eventually turned out to be, or so it appears, with a sensor read timeout timer that had been implemented. The sensor is present on production hardware but not on the eval board which caused something to hang somewhere I couldn't locate.

    This wasn't difficult to fix but was ferociously hard to diagnose. I enabled RTT but, oddly, this made the issue go away. There were also no significant messages related to the failure even with the log level set to debug. I only managed to figure it out by systematically commenting out chunks of code until things started working and narrowing it down from there.

Children
No Data
Related