Unable to print using printf or nrf_log_info

I am using nrf5 sdk 17.1.0, segger embedded studio v6.40 and nrf52832-dk, when running the spi example, i do able to see the log only after the build, and when i reset the device no log is shown on the Jlink-RTT viewer. When running the uart example provided in nrf5 sdk i was unable to see any anything on the terminal also. Can you please let me know what might be the potential reason?

  • #include <zephyr/kernel.h>
    #include <zephyr/drivers/gpio.h>
    
    /* 1000 msec = 1 sec */
    #define SLEEP_TIME_MS   1000
    
    /* The devicetree node identifier for the "led0" alias. */
    #define LED0_NODE DT_ALIAS(led0)
    
    /*
     * A build error on this line means your board is unsupported.
     * See the sample documentation for information on how to fix this.
     */
    static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
    
    int main(void)
    {
    	int ret;
    
    	if (!gpio_is_ready_dt(&led)) {
    		return 0;
    	}
    
    	ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
    	if (ret < 0) {
    		return 0;
    	}
    
    	while (1) {
    		ret = gpio_pin_toggle_dt(&led);
    		if (ret < 0) {
    			return 0;
    		}
    		printk("\nError: no device found.\n");
    
    		k_msleep(SLEEP_TIME_MS);
    	}
    	return 0;
    }

    I have tried to print using printk in blinky sample of nordic connect sdk, it does show led blink, but it also not print anything on the terminal.

  • Hello,

    The printk() usually prints to the UART, and not the RTT log. If you want to print something to the RTT Log, make sure that RTT logging is enabled in your sdk_config.h. 

    If you try the ble_app_uart example, in nRF5 SDK 17.1.0, you can see that printk() will print to the UART terminal (use something like Putty or Termite), but logging, which uses NRF_LOG_INFO(), will be printed to the RTT log.

    Best regards,

    Edvin

  • I have used UART terminal of nrf connect for desktop and putty but nothing prints there, and for nrf_log_info() i have used RTT log of Jlink RTT viewr separately but nothing shows.

  • What application are you testing on? And what HW are you using? A standard Nordic nRF52832 DK? 

    Best regards,

    Edvin

  • I have performed the factory reset and then able to print on the terminal using the above code on nordic connect sdk, but when again implement this below example on nrf5 sdk nothing prints. 

    If you try the ble_app_uart example, in nRF5 SDK 17.1.0, you can see that printk() will print to the UART terminal (use something like Putty or Termite), but logging, which uses NRF_LOG_INFO(), will be printed to the RTT log.

    Yes, I am using standard nrf52832-DK.

Related