ERROR CONFIGURE UART IN CUSTOM BOARD NRF54L15

Hi everyone,
I have a problem when I tried to configure UART (baudrate, parity, data_bits, stop_bits, flow_ctrl).
I upload my project:

#include "myuart.h"
#include <zephyr/sys/printk.h>

/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS      1000

/* Define the size of the receive buffer */
#define DATA_LENGTH 15  
#define DATA_COUNT 5
#define TOTAL_BUFFER_SIZE (DATA_LENGTH * DATA_COUNT) // 90 byte (18 x 5)

/* Define the receiving timeout period */
#define RECEIVE_TIMEOUT    100

//configure GPIO UART for NRF54L15
static const struct device *uart0_dev = DEVICE_DT_GET(DT_NODELABEL(uart30));
static const struct device *uart1_dev = DEVICE_DT_GET(DT_NODELABEL(uart20));

/* Cấu hình UART (baudrate, parity, v.v.) */
static struct uart_config uart_cfg = {
    .baudrate = 115200,
    .parity = UART_CFG_PARITY_NONE,
    .data_bits = UART_CFG_DATA_BITS_8,
    .stop_bits = UART_CFG_STOP_BITS_1,
    .flow_ctrl = UART_CFG_FLOW_CTRL_NONE,
};

void myuart_init(void)
{
    int ret;

    if (!device_is_ready(uart0_dev)) {
        printk("UART30 device not ready\n");
    }
    if (!device_is_ready(uart1_dev)) {
        printk("UART20 device not ready\n");
    }

    /* Configure UART0, UART1 */
    ret = uart_configure(uart0_dev, &uart_cfg);
    if (ret) {
        printk("Failed to configure UART30, err %d\n", ret);
    }
    ret = uart_configure(uart1_dev, &uart_cfg);
    if (ret) {
        printk("Failed to configure UART20, err %d\n", ret);
    }

    /* Gán callback cho UART0 */
    ret = uart_callback_set(uart0_dev, uart_cb, &uart_data_instance);
    if (ret) {
        printk("Failed to set UART20 callback, err %d\n", ret);
        return;
    }

    ret = uart_rx_enable(uart0_dev, rx_buf, sizeof(rx_buf), RECEIVE_TIMEOUT);
    if (ret) {
        printk("ERROR RX for UART20: %d\n", ret);
        return;
    }

    printk("uart_init Done!\n");
}


file .dts:
&uart20 {
    compatible = "nordic,nrf-uarte";
    status = "okay";
    current-speed = <115200>;
    pinctrl-0 = <&uart20_default>;
    pinctrl-names = "default";
};

&uart30 {
    compatible = "nordic,nrf-uarte";
    status = "okay";
    current-speed = <115200>;
    pinctrl-0 = <&uart30_default>;
    pinctrl-names = "default";
};
file .dtsi:

&pinctrl {
    uart20_default: uart20_default {
        group1 {
            psels = <NRF_PSEL(UART_TX, 1, 4)>;
               
        };
        group2 {
            psels = <NRF_PSEL(UART_RX, 1, 5)>;
            bias-pull-up;
        };
    };

    uart30_default: uart30_default {
        group1 {
            psels = <NRF_PSEL(UART_TX, 0, 0)>;
               
        };
        group2 {
            psels = <NRF_PSEL(UART_RX, 0, 1)>;
            bias-pull-up;
        };
    };
};


but, when I flashed code in board, my error:
"
Failed to configure UART30, err -134
Failed to configure UART20, err -134

"


Can you help me for this problems, please?

  • you need to enable UART_USE_RUNTIME_CONFIGURE to use uart_configure()

    jing

  • Hi,
    It's mean, add "UART_USE_RUNTIME_CONFIGURE =y" in prj.conf file, right?

  • yes.

    add CONFIG_UART_USE_RUNTIME_CONFIGURE=y in your prj.conf and do a pristine build

    jing

  • Hi,
    I upload my prj.conf as below:

    CONFIG_GPIO=y

    CONFIG_UART_CONSOLE=y
    CONFIG_LOG=y

    #Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE0=y
    CONFIG_SERIAL=y
    UART_USE_RUNTIME_CONFIGURE =y

    CONFIG_HEAP_MEM_POOL_SIZE=2048

    # Bluetooth configuration
    # CONFIG_BT=y
    # CONFIG_BT_PERIPHERAL=y

    # Enable bonding
    CONFIG_BT_SETTINGS=y
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y

    # This example requires more stack
    CONFIG_MAIN_STACK_SIZE=1152
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

    # Config logger

    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    CONFIG_LOG_PRINTK=n



    I added "UART_USE_RUNTIME_CONFIGURE =y" as you instructed, but when I build the program, an error occurs:

    warning: BT_SETTINGS (defined at C:/ncs/v2.9.0/zephyr/subsys/bluetooth/host/Kconfig:195,
    subsys/bluetooth\host/Kconfig:195) was assigned the value 'y' but got the value 'n'. Check these
    unsatisfied dependencies: ((SETTINGS && BT_HCI_HOST && BT_RPC_STACK) || (SETTINGS && BT_HCI_HOST &&
    BT_HCI && BT)) (=n). See docs.zephyrproject.org/.../kconfig.html and/or
    look up BT_SETTINGS in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.


    warning: NRFX_UARTE0 (defined at C:/ncs/v2.9.0/zephyr/modules/hal_nordic\nrfx/Kconfig:1024,
    modules\hal_nordic\nrfx/Kconfig:1024, drivers/serial\Kconfig.nrfx_uart_instance:32) was assigned the
    value 'y' but got the value 'n'. Check these unsatisfied dependencies: (HAS_HW_NRF_UART0 ||
    HAS_HW_NRF_UARTE0) (=n). See docs.zephyrproject.org/.../kconfig.html
    and/or look up NRFX_UARTE0 in the menuconfig/guiconfig interface. The Application Development
    Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
    might be helpful too.


    C:/Brain-Life/Nordic/FIRMWARE/nordic_nrf5283/UART-BLE/prj.conf:10: warning: ignoring malformed line 'UART_USE_RUNTIME_CONFIGURE =y'

    error: Aborting due to Kconfig warnings

    Parsing C:/ncs/v2.9.0/zephyr/Kconfig
    Loaded configuration 'C:/Brain-Life/Nordic/FIRMWARE/nordic_nrf5283/boards/nrf54l15_customboard/nrf54l15_custom/nrf54l15_custom_nrf54l15_cpuapp_defconfig'
    Merged configuration 'C:/Brain-Life/Nordic/FIRMWARE/nordic_nrf5283/UART-BLE/prj.conf'
    Merged configuration 'C:/Brain-Life/Nordic/FIRMWARE/nordic_nrf5283/UART-BLE/build_1/UART-BLE/zephyr/.config.sysbuild'
    CMake Error at C:/ncs/v2.9.0/zephyr/cmake/modules/kconfig.cmake:396 (message):
    command failed with return code: 1
    Call Stack (most recent call first):
    C:/ncs/v2.9.0/nrf/cmake/modules/kconfig.cmake:29 (include)
    C:/ncs/v2.9.0/zephyr/cmake/modules/zephyr_default.cmake:133 (include)
    C:/ncs/v2.9.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
    C:/ncs/v2.9.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
    CMakeLists.txt:2 (find_package)


    -- Configuring incomplete, errors occurred!
    CMake Error at cmake/modules/sysbuild_extensions.cmake:514 (message):
    CMake configure failed for Zephyr project: UART-BLE

    Location: C:/Brain-Life/Nordic/FIRMWARE/nordic_nrf5283/UART-BLE
    Call Stack (most recent call first):
    cmake/modules/sysbuild_images.cmake:20 (ExternalZephyrProject_Cmake)
    cmake/modules/sysbuild_default.cmake:20 (include)
    C:/ncs/v2.9.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:75 (include)
    C:/ncs/v2.9.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
    C:/ncs/v2.9.0/zephyr/share/sysbuild-package/cmake/SysbuildConfig.cmake:8 (include)
    template/CMakeLists.txt:10 (find_package)


    -- Configuring incomplete, errors occurred!
    See also "C:/Brain-Life/Nordic/FIRMWARE/nordic_nrf5283/UART-BLE/build_1/CMakeFiles/CMakeOutput.log".
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\b620d30767\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/ncs/toolchains/b620d30767/opt/bin/python.exe '-Bc:\Brain-Life\Nordic\FIRMWARE\nordic_nrf5283\UART-BLE\build_1' -GNinja -DBOARD=nrf54l15_custom/nrf54l15/cpuapp -DNCS_TOOLCHAIN_VERSION=NONE '-DBOARD_ROOT=c:\Brain-Life\Nordic\FIRMWARE\nordic_nrf5283' '-SC:\ncs\v2.9.0\zephyr\share\sysbuild' '-DAPP_DIR:PATH=c:\Brain-Life\Nordic\FIRMWARE\nordic_nrf5283\UART-BLE'

    * The terminal process terminated with exit code: 1.
    * Terminal will be reused by tasks, press any key to close it.

  • must be 

    CONFIG_UART_USE_RUNTIME_CONFIGURE=y

    with the "CONFIG_" in front and without <space> before "="

Related