Updating Firmware from 2.4.4 to 2.6.5 - device_is_ready() debug

Hi,

We have functioning application code under the 2.4.4 SDK development setup.  I would like to start migrating to newer code but am encountering issues. (Ultimately, I would like to progress to the latest version as well but I think we will do this step by step)

Everything works fine into the initialization until we get to the UART initialization:

static int uart0_init(void)
{
	int retval;
	struct uart_config uart0cfg;

	uart0_dev = DEVICE_DT_GET(UART_0);

	if (!device_is_ready(uart0_dev)) {
        /* Not ready, do not use */
		LOG_ERR("Could not get UART0 device\n");
        return -ENODEV;
	}
	uart0cfg.baudrate = 460800;
	uart0cfg.data_bits = UART_CFG_DATA_BITS_8;
	uart0cfg.flow_ctrl = UART_CFG_FLOW_CTRL_NONE;
	uart0cfg.parity = UART_CFG_PARITY_NONE;
	uart0cfg.stop_bits = UART_CFG_STOP_BITS_1;

	retval = uart_configure(uart0_dev, &uart0cfg);
	uart_callback_set(uart0_dev, uart0_cb, NULL);
	uart_rx_enable(uart0_dev, uart0_rx_buf, sizeof(uart0_rx_buf), 100);
	uart_irq_rx_enable(uart0_dev);
	return retval;
}

It fails the device_is_ready test.  There don't appear to be any conflicts in the dts/overlay or dtsi files.  (these are custom).

I have looked through the migration guides and don't see anything that would point to an issue.

Do you have any guidance on how to get better debug information from the device_is_ready functions?

Thanks!

Parents
  • Hi,

    When it returns not ready it indicates that the init function in zephyr/drivers/serial/uart_nrfx_uart.c or zephyr/drivers/serial/uart_nrfx_uarte.c failed. Which file it's in depends on which devictree binding is selected by your uart0 devicetree node (compatible = "nordic,nrf-uarte"; vs compatible = "nordic,nrf-uart";). But I don't recall any relevant changes between 2.4.4 and v2.6.5 that could explain this error. Do you have logging enabled on another UART instance or RTT and do you see any errors printed from the UART driver?

    I would also be happy to try debugging this on my end if you are able to share a minimal version of your project and board files here.

    Best regards,

    Vidar

  • Thanks Vidar,

    In investigating this, it brings me back to questioning if the 2.4.4 uart information is setup correctly.  I arrived at the solution not because it fully made sense but because it worked.  In any case, here is the code and definitions for the devices:

    For the prj.conf:  (as set and working for the 2.4.4)

    #UART 0 + 1 enable
    CONFIG_SERIAL=y
    CONFIG_UART_ASYNC_API=y
    CONFIG_UART_0_INTERRUPT_DRIVEN=n
    CONFIG_UART_1_INTERRUPT_DRIVEN=n
    #CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_NRFX_UARTE0=y
    CONFIG_NRFX_UARTE1=y

    For the dts/dtsi files, i have the uarte enabled.

    &uart0 {
    	compatible = "nordic,nrf-uarte";
    	status = "okay";
    	label = "UART_0";
    	current-speed = <460800>;
    	pinctrl-0 = <&uart0_default>;
    	pinctrl-1 = <&uart0_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &uart1 {
    	compatible = "nordic,nrf-uarte";
    	status = "okay";
    	label = "UART_1";
    	current-speed = <115200>;
    	pinctrl-0 = <&uart1_default>;
    	pinctrl-1 = <&uart1_sleep>;
    	pinctrl-names = "default", "sleep";
    };

    This is not intuitive as I really am not utilizing the Easy DMA for the uart.

    if I enable these:

    CONFIG_SEGGER_SYSTEMVIEW=y
    CONFIG_TRACING=y

    I get: System fault:  illegal use of the EPSR

    Now under 2.6.4 , if I change the prf.conf to this:  (set the system for uart only - not uarte)

    #UART 0 + 1 enable
    CONFIG_SERIAL=y
    CONFIG_UART_ASYNC_API=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_UART_0_INTERRUPT_DRIVEN=y
    CONFIG_UART_1_INTERRUPT_DRIVEN=y
    #CONFIG_NRFX_UARTE0=y
    #CONFIG_NRFX_UARTE1=y

    And change the dts/dtsi files to compatible = "nordic,nrf-uart"

    The code does not compile and gives an error:

    main.c:965: undefined reference to `__device_dts_ord_128'

    This is linking to the uart1 reference.  Previous build attempts errored out on the uart1 initialization.

    Not sure if this helps in the debugging.  I will look at getting a package together for testing.

    Thanks

Reply
  • Thanks Vidar,

    In investigating this, it brings me back to questioning if the 2.4.4 uart information is setup correctly.  I arrived at the solution not because it fully made sense but because it worked.  In any case, here is the code and definitions for the devices:

    For the prj.conf:  (as set and working for the 2.4.4)

    #UART 0 + 1 enable
    CONFIG_SERIAL=y
    CONFIG_UART_ASYNC_API=y
    CONFIG_UART_0_INTERRUPT_DRIVEN=n
    CONFIG_UART_1_INTERRUPT_DRIVEN=n
    #CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_NRFX_UARTE0=y
    CONFIG_NRFX_UARTE1=y

    For the dts/dtsi files, i have the uarte enabled.

    &uart0 {
    	compatible = "nordic,nrf-uarte";
    	status = "okay";
    	label = "UART_0";
    	current-speed = <460800>;
    	pinctrl-0 = <&uart0_default>;
    	pinctrl-1 = <&uart0_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &uart1 {
    	compatible = "nordic,nrf-uarte";
    	status = "okay";
    	label = "UART_1";
    	current-speed = <115200>;
    	pinctrl-0 = <&uart1_default>;
    	pinctrl-1 = <&uart1_sleep>;
    	pinctrl-names = "default", "sleep";
    };

    This is not intuitive as I really am not utilizing the Easy DMA for the uart.

    if I enable these:

    CONFIG_SEGGER_SYSTEMVIEW=y
    CONFIG_TRACING=y

    I get: System fault:  illegal use of the EPSR

    Now under 2.6.4 , if I change the prf.conf to this:  (set the system for uart only - not uarte)

    #UART 0 + 1 enable
    CONFIG_SERIAL=y
    CONFIG_UART_ASYNC_API=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_UART_0_INTERRUPT_DRIVEN=y
    CONFIG_UART_1_INTERRUPT_DRIVEN=y
    #CONFIG_NRFX_UARTE0=y
    #CONFIG_NRFX_UARTE1=y

    And change the dts/dtsi files to compatible = "nordic,nrf-uart"

    The code does not compile and gives an error:

    main.c:965: undefined reference to `__device_dts_ord_128'

    This is linking to the uart1 reference.  Previous build attempts errored out on the uart1 initialization.

    Not sure if this helps in the debugging.  I will look at getting a package together for testing.

    Thanks

Children
Related