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

Building with cli and RTT on SDK14

I am working with the peripheral/flash_fds in SDK14.  I need to adapt it to use RTT instead of uart

I have made the obvious changes to switch from uart to RTT, eg substituting rtt/nrf_cli_rtt.c for uart/nrf_cli_uart.c 

However, when I build it (with armgcc) I get these errors:

Compiling file: cli.c

../../../cli.c:87:28: error: expected ')' before numeric constant

NRF_CLI_UART_DEF(cli_uart, 0, 64, 16);

                            ^

In file included from ../../../cli.c:45:0:

../../../cli.c:88:45: error: 'cli_uart' undeclared here (not in a function)

NRF_CLI_DEF(m_cli_uart, "fds example:~$ ", &cli_uart.transport, '\r', 4);

                                             ^

../../../../../../components/libraries/cli/nrf_cli.h:460:24: note: in definition of macro 'NRF_CLI_DEF'

             .p_iface = p_transport_iface,  

                             ^

This is surprising because there is only one version of cli.c in the SDK.  If really generic, why would it make reference to uart things.

I suspect that a version of cli.c for use with RTT has been omitted or exists somewhere else?

Any suggestions pls?

Parents Reply Children
  • Oh. I thought I had 14 and it does include flash_fds.  Maybe I mislabelled it.
    To be sure I am going to download 14.2.0 and try again.

    BR. Paul

  • Now I have a fresh copy of 14.2.0

    Unmodified, flash_fds builds OK

    However, when I switch to RTT I get the same errors reported above.

    The question is still: "why is cli.c referencing uart stuff?"

    BR Paul

  • Like I tried to explain in my previous comment, the cli.c file is not part of the nrf_cli library. It is an example specific source file that is used to initialize the CLI library in that specific example. If you do not want to use UART CLI backend in that example, you need to remove/comment out the initialization of UART CLI backend from the example source file.

  • Hi Jørgen,

    I get that the supplied cli.c is not suited to use with RTT

    However, I think that there is a need to do more than comment out uart references because cli_init, cli_start and cli_process probably need some equivalent code.

    The code changes are probably something like this:

    #if NRF_CLI_UART_ENABLED
    NRF_CLI_UART_DEF(cli_uart, 0, 64, 16);
    NRF_CLI_DEF(m_cli_uart, "fds example:~$ ", &cli_uart.transport, '\r', 4);
    #else
    NRF_CLI_RTT_DEF(cli_rtt);
    NRF_CLI_DEF(m_cli_rtt, "fds example:~$ ", &cli_rtt.transport, '\r', 4);
    #endif
    
    /* Defined in main.c */
    extern char const * fds_err_str[];
    
    void cli_init(void)
    {
    #if NRF_CLI_UART_ENABLED
        nrf_drv_uart_config_t uart_config = NRF_DRV_UART_DEFAULT_CONFIG;
        uart_config.pseltxd               = TX_PIN_NUMBER;
        uart_config.pselrxd               = RX_PIN_NUMBER;
        uart_config.hwfc                  = NRF_UART_HWFC_DISABLED;
    
        ret_code_t rc = nrf_cli_init(&m_cli_uart, &uart_config, true, true, NRF_LOG_SEVERITY_INFO);
        APP_ERROR_CHECK(rc);
    #else
    	rtt_config = 0; // a bad guess
        ret_code_t rc = nrf_cli_init(&m_cli_rtt, &rtt_config, true, true, NRF_LOG_SEVERITY_INFO);
        APP_ERROR_CHECK(rc);
    #endif
    }
    
    
    void cli_start(void)
    {
    #if NRF_CLI_UART_ENABLED
      ret_code_t rc = nrf_cli_start(&m_cli_uart);
    #else
      ret_code_t rc = nrf_cli_start(&m_cli_rtt);
    #endif		
        APP_ERROR_CHECK(rc);
    }
    
    
    void cli_process(void)
    {
    #if NRF_CLI_UART_ENABLED
        nrf_cli_process(&m_cli_uart);
    #else
        nrf_cli_process(&m_cli_rtt);
    #endif
    }
    

    However, despite looking at nrf_cli_rtt.h I did not figure out how to set the second parameter of nrf_cli_init(), amongst other things.

    It would be really helpful if there was an example somewhere.

    BR Paul

  • Yes, you are correct. You need to initialize RTT backend as well if that is not included in the example.

    There are (at least) two examples in SDK 15.2.0 showing initialization and usage of RTT backend for CLI:

    nRF5_SDK_15.2.0_9412b96\examples\ble_central_and_peripheral\experimental\ble_app_interactive
    nRF5_SDK_15.2.0_9412b96\examples\peripheral\experimental_cli_libuarte

    I would not expect there to be any significant changes in the way this is done between SDK 14.2 and SDK 15.2.

Related