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

Exit CLI and start Logging

I have a working project that uses the NRF_LOG module to send debug outputs over the UART backend. When just using the logging module everything works correctly.

I added the CLI module for use in a manufacturing mode and I'd like to disable the CLI after manufacturing mode has been exited. I can successful stop and uninit the CLI. After that I call NRF_LOG_DEFAULT_BACKENDS_INIT() so I can use the logging module with the same UART backend. After I print a few logs I get the following error -

<error> app: ERROR 17 [NRF_ERROR_BUSY] at C:\Nordic_Semi\nRF5SDK160098a08e2\components\libraries\log\src\nrf_log_backend_uart.c:83

PC at: 0x00000907

<error> app: End of error report

I modified the CLI example to demonstrate this behavior and have attached it here. I'm using nRF5 SDK v16.0.0. Is there something else that needs to be done to use the logging module after disabling the CLI?

7024.cli-exit.zip

Parents
  • Thanks for uploading a project demonstrating the issue, and sorry for the delayed response.

    It took me a while to narrow down the problem. Turns out the UARTE keeps triggering the NRF_DRV_UART_EVT_ERROR event even though the logger backend is initializing UARTE in TX only mode. This is a problem because it causes the  "m_xfer_done"  in nrf_log_backend_uart.c:uart_evt_handler() to always be set to 'true', which again causes the blocking serial_tx() function to become non-blocking.

    I do not know why the ERROR events are raised. It is strange considering the receiver is not enabled. The nrf_cli_uninit() function is also disabling UARTE as a part its uninit routine. I was however able to work around the problem by power-cycling the peripheral it before it was re-enabled by the logger backend again. Could you please try the same?

        ret = nrf_cli_stop(&m_cli_uart);
        APP_ERROR_CHECK(ret);
    
        ret = nrf_cli_uninit(&m_cli_uart);
        APP_ERROR_CHECK(ret);
        
        *(volatile uint32_t *)(NRF_UART0_BASE + 0xFFC) = 0; // Workaround: power-cycle peripheral to make sure it is fully reset. 
        *(volatile uint32_t *)(NRF_UART0_BASE + 0xFFC) = 1;
        nrf_delay_ms(500);
    #endif
        NRF_LOG_INIT(NULL);
        NRF_LOG_DEFAULT_BACKENDS_INIT();  //need to init log backend after un-initting CLI
        NRF_LOG_INFO("CLI exit complete.");
        NRF_LOG_FLUSH();

    Best regards,

    Vidar

Reply
  • Thanks for uploading a project demonstrating the issue, and sorry for the delayed response.

    It took me a while to narrow down the problem. Turns out the UARTE keeps triggering the NRF_DRV_UART_EVT_ERROR event even though the logger backend is initializing UARTE in TX only mode. This is a problem because it causes the  "m_xfer_done"  in nrf_log_backend_uart.c:uart_evt_handler() to always be set to 'true', which again causes the blocking serial_tx() function to become non-blocking.

    I do not know why the ERROR events are raised. It is strange considering the receiver is not enabled. The nrf_cli_uninit() function is also disabling UARTE as a part its uninit routine. I was however able to work around the problem by power-cycling the peripheral it before it was re-enabled by the logger backend again. Could you please try the same?

        ret = nrf_cli_stop(&m_cli_uart);
        APP_ERROR_CHECK(ret);
    
        ret = nrf_cli_uninit(&m_cli_uart);
        APP_ERROR_CHECK(ret);
        
        *(volatile uint32_t *)(NRF_UART0_BASE + 0xFFC) = 0; // Workaround: power-cycle peripheral to make sure it is fully reset. 
        *(volatile uint32_t *)(NRF_UART0_BASE + 0xFFC) = 1;
        nrf_delay_ms(500);
    #endif
        NRF_LOG_INIT(NULL);
        NRF_LOG_DEFAULT_BACKENDS_INIT();  //need to init log backend after un-initting CLI
        NRF_LOG_INFO("CLI exit complete.");
        NRF_LOG_FLUSH();

    Best regards,

    Vidar

Children
No Data
Related