Cannot disable UART0 on nRF9160 via overlay file when ASYN UART1 is used.

Hi Nordic,

I am using Circuitdojo nRF9160 to develop a low-power application. In my application, I want to use one of the board's UART interfaces to communicate with a sensor via ASYN UART.

And, I have some issues:


1. In case I enable and use ASYN UART1 to communicate with the sensor, and I want to disable UART0 via the overlay file to save energy.
The program always appears with errors. However, when I disable the UART1 (via overlay), I can disable UART0 easily without any errors.
Could you please tell me why? I cannot find the reason.


2. In case I cannot disable UART0 when I am using ASYN UART1, there is another way. I can use UART0 as an ASYN UART to communicate with the sensor. Is it feasible? and if yes, how I can prevent it from printing messages while I am still able to use it to communicate with the sensor normally?

Thank you for your support!

Best regards,
Vu

Parents
  • Dear Nordic,

    Just an update:

    When I shift to use UART0 as an ASYN UART to communicate with the sensor, I also cannot disable UART1 (used to print consoles) via overlay file. There is an error when the program is built. Weirdly, when I do not disable the UART1, no error appears.

    Best,

    Vu

  • Hello Vu,

    Could you show me what kind of error are you getting?

    Best regards,

    Michal

  • Hi Michal,

    When I do not disable my UART0 (used for print consoles only) and use UART1 to read data from the sensor, there is no error and my application works well.

    In case I disable UART0 via overlay for saving energy, I cannot build the application, there is always an error. You can see that in my log file below.

    Could you please tell me the reason?

    (Sorry, I tried to add the log file into the code box, but It does not work.)

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    * Executing task: nRF Connect: Generate config circuitdojo_feather_nrf9160_ns for c:\Users\vanvu\OneDrive\Desktop\Code3_Nordic

    Building Code3_Nordic
    C:\Windows\system32\cmd.exe /d /s /c "west build --build-dir c:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build c:/Users/vanvu/OneDrive/Desktop/Code3_Nordic --pristine --board circuitdojo_feather_nrf9160_ns --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=c:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/prj.conf"

    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic
    -- CMake version: 3.20.5
    -- Found Python3: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe (found suitable version "3.8.2", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v2.5.1/zephyr/.cache
    -- Zephyr version: 3.4.99 (C:/ncs/v2.5.1/zephyr)
    -- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
    -- Board: circuitdojo_feather_nrf9160_ns
    -- Found host-tools: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found Dtc: C:/ncs/toolchains/c57af46cb7/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/ncs/v2.5.1/zephyr/boards/arm/circuitdojo_feather_nrf9160/circuitdojo_feather_nrf9160_ns.dts
    -- Found devicetree overlay: C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/app.overlay
    -- Generated zephyr.dts: C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/zephyr/dts.cmake
    Parsing C:/ncs/v2.5.1/zephyr/Kconfig
    Loaded configuration 'C:/ncs/v2.5.1/zephyr/boards/arm/circuitdojo_feather_nrf9160/circuitdojo_feather_nrf9160_ns_defconfig'
    Merged configuration 'c:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/prj.conf'
    Configuration saved to 'C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/zephyr/.config'
    Kconfig header saved to 'C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38")
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- Found Python3: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe (found version "3.8.2") found components: Interpreter
    Changed board to secure circuitdojo_feather_nrf9160 (NOT NS)

    === child image mcuboot - begin ===
    loading initial cache file C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/mcuboot/child_image_preload.cmake
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/ncs/v2.5.1/bootloader/mcuboot/boot/zephyr
    -- CMake version: 3.20.5
    -- Found Python3: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe (found suitable version "3.8.2", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v2.5.1/zephyr/.cache
    -- Zephyr version: 3.4.99 (C:/ncs/v2.5.1/zephyr)
    -- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
    -- Board: circuitdojo_feather_nrf9160
    -- Found host-tools: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found Dtc: C:/ncs/toolchains/c57af46cb7/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/ncs/v2.5.1/zephyr/boards/arm/circuitdojo_feather_nrf9160/circuitdojo_feather_nrf9160.dts
    -- Found devicetree overlay: C:/ncs/v2.5.1/bootloader/mcuboot/boot/zephyr/app.overlay
    -- Generated zephyr.dts: C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/mcuboot/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/mcuboot/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/mcuboot/zephyr/dts.cmake

    warning: UART_CONSOLE (defined at drivers/console/Kconfig:43) was assigned the value 'y' but got the
    value 'n'. Check these unsatisfied dependencies: CONSOLE (=n). See
    docs.zephyrproject.org/.../kconfig.html and/or look up UART_CONSOLE 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.

    Parsing C:/ncs/v2.5.1/bootloader/mcuboot/boot/zephyr/Kconfig
    Loaded configuration 'C:/ncs/v2.5.1/zephyr/boards/arm/circuitdojo_feather_nrf9160/circuitdojo_feather_nrf9160_defconfig'
    Merged configuration 'C:/ncs/v2.5.1/bootloader/mcuboot/boot/zephyr/prj.conf'
    Merged configuration 'C:/ncs/v2.5.1/bootloader/mcuboot/boot/zephyr/boards/circuitdojo_feather_nrf9160.conf'
    Merged configuration 'C:/ncs/v2.5.1/nrf/modules/mcuboot/tfm.conf'
    Merged configuration 'C:/ncs/v2.5.1/nrf/modules/mcuboot/fih_low_enable.conf'
    Merged configuration 'C:/ncs/v2.5.1/nrf/subsys/partition_manager/partition_manager_enabled.conf'
    Merged configuration 'C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
    Configuration saved to 'C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/mcuboot/zephyr/.config'
    Kconfig header saved to 'C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/mcuboot/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38")
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    MCUBoot bootloader key file: C:/ncs/v2.5.1/bootloader/mcuboot/root-ec-p256.pem
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/mcuboot
    === child image mcuboot - end ===

    CMake Warning at C:/ncs/v2.5.1/nrf/modules/mcuboot/CMakeLists.txt:320 (message):

    ---------------------------------------------------------
    --- WARNING: Using default MCUBoot key, it should not ---
    --- be used for production. ---
    ---------------------------------------------------------

    CMake Warning at C:/ncs/v2.5.1/nrf/cmake/partition_manager.cmake:79 (message):

    ---------------------------------------------------------------------
    --- WARNING: Using a bootloader without pm_static.yml. ---
    --- There are cases where a deployed product can consist of ---
    --- multiple images, and only a subset of these images can be ---
    --- upgraded through a firmware update mechanism. In such cases, ---
    --- the upgradable images must have partitions that are static ---
    --- and are matching the partition map used by the bootloader ---
    --- programmed onto the device. ---
    ---------------------------------------------------------------------

    Call Stack (most recent call first):
    C:/ncs/v2.5.1/zephyr/cmake/modules/kernel.cmake:247 (include)
    C:/ncs/v2.5.1/zephyr/cmake/modules/zephyr_default.cmake:138 (include)
    C:/ncs/v2.5.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
    C:/ncs/v2.5.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
    CMakeLists.txt:6 (find_package)


    Dropping partition 'nrf_modem_lib_trace' since its size is 0.
    Dropping partition 'nonsecure_storage' since it is empty.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build
    -- west build: building application
    [4/209] Generating include/generated/version.h
    -- Zephyr version: 3.4.99 (C:/ncs/v2.5.1/zephyr), build: 83980fe16794
    [209/209] Linking C executable zephyr\zephyr.elf
    Memory region Used Size Region Size %age Used
    FLASH: 48484 B 48 KB 98.64%
    RAM: 24584 B 32 KB 75.02%
    IDT_LIST: 0 GB 2 KB 0.00%
    [7/241] Generating include/generated/version.h
    -- Zephyr version: 3.4.99 (C:/ncs/v2.5.1/zephyr), build: 83980fe16794
    [12/241] Generating ../../tfm/CMakeCache.txt
    CMake Warning at cmake/version.cmake:22 (message):
    Actual TF-M version is not available from Git repository. Settled to
    v1.8.0
    Call Stack (most recent call first):
    CMakeLists.txt:22 (include)


    -- Found Git: C:/ncs/toolchains/c57af46cb7/mingw64/bin/git.exe (found version "2.37.3.windows.1")
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- Found Python3: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe (found version "3.8.2") found components: Interpreter
    CMake Deprecation Warning at C:/ncs/v2.5.1/zephyr/cmake/modules/FindDeprecated.cmake:121 (message):
    'PYTHON_PREFER' variable is deprecated. Please use Python3_EXECUTABLE
    instead.
    Call Stack (most recent call first):
    C:/ncs/v2.5.1/zephyr/cmake/modules/python.cmake:16 (find_package)
    C:/ncs/v2.5.1/zephyr/cmake/modules/user_cache.cmake:30 (include)
    C:/ncs/v2.5.1/zephyr/cmake/modules/extensions.cmake:5 (include)
    C:/ncs/v2.5.1/nrf/subsys/nrf_security/tfm/CMakeLists.txt:36 (include)


    -- Found Python3: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe (found suitable version "3.8.2", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v2.5.1/zephyr/.cache
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/tfm
    [153/157] Linking C executable bin\tfm_s.axf
    Memory region Used Size Region Size %age Used
    FLASH: 31544 B 32256 B 97.79%
    RAM: 14736 B 32 KB 44.97%
    [23/241] Performing install step for 'tfm'
    -- Install configuration: "MinSizeRel"
    [151/241] Building C object CMakeFiles/app.dir/src/main.c.obj
    In file included from ../src/main.c:4:
    ../include/uart_sensor.h:40:16: warning: 'comingData' defined but not used [-Wunused-variable]
    40 | static uint8_t comingData; //V- This variable is set to 1 when there is Uart data coming
    | ^~~~~~~~~~
    ../include/uart_sensor.h:37:16: warning: 'rx_buf' defined but not used [-Wunused-variable]
    37 | static uint8_t rx_buf[RECEIVE_BUFF_SIZE] = {0}; // Define the receive buffer => V - buffer includes 4 members, and each member is 1 byte
    | ^~~~~~
    ../include/uart_sensor.h:31:16: warning: 'uart_value' defined but not used [-Wunused-variable]
    31 | static uint8_t uart_value[4] = {0};
    | ^~~~~~~~~~
    [152/241] Building C object CMakeFiles/app.dir/src/switch1.c.obj
    ../src/switch1.c: In function 'check_gpio_sw1':
    ../src/switch1.c:31:5: warning: control reaches end of non-void function [-Wreturn-type]
    31 | }
    | ^
    [153/241] Building C object CMakeFiles/app.dir/src/uart_sensor.c.obj
    ../src/uart_sensor.c: In function 'read_distance':
    ../src/uart_sensor.c:90:1: warning: control reaches end of non-void function [-Wreturn-type]
    90 | }
    | ^
    [182/241] Building C object zephyr/drivers/console/CMakeFiles/drivers__console.dir/uart_console.c.obj
    FAILED: zephyr/drivers/console/CMakeFiles/drivers__console.dir/uart_console.c.obj
    C:\ncs\toolchains\c57af46cb7\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DMBEDTLS_USER_CONFIG_FILE=\"nrf-config-user.h\" -DNRF9160_XXAA -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DNRF_TRUSTZONE_NONSECURE -DPICOLIBC_DOUBLE_PRINTF_SCANF -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -IC:/ncs/v2.5.1/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.5.1/zephyr/soc/arm/nordic_nrf/nrf91 -IC:/ncs/v2.5.1/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.5.1/nrf/include -Itfm/install/interface/include -IC:/ncs/v2.5.1/nrf/include/tfm -IC:/ncs/v2.5.1/nrf/tests/include -Itfm/generated/interface/include -IC:/ncs/v2.5.1/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.5.1/zephyr/modules/cmsis/. -IC:/ncs/v2.5.1/modules/hal/nordic/nrfx -IC:/ncs/v2.5.1/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.5.1/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.5.1/zephyr/modules/hal_nordic/nrfx/. -IC:/ncs/v2.5.1/nrfxlib/nrf_modem/include -Imodules/nrf/subsys/nrf_security/src/include/generated -IC:/ncs/v2.5.1/nrf/subsys/nrf_security/include -IC:/ncs/v2.5.1/nrf/ext/oberon/psa/core/include -IC:/ncs/v2.5.1/nrf/ext/oberon/psa/core/library -IC:/ncs/v2.5.1/modules/crypto/mbedtls/include -IC:/ncs/v2.5.1/modules/crypto/mbedtls/library -IC:/ncs/v2.5.1/nrfxlib/crypto/nrf_oberon/include/mbedtls -IC:/ncs/v2.5.1/nrfxlib/crypto/nrf_oberon/include -Wshadow -fno-strict-aliasing -Os -imacros C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.5.1/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/Users/vanvu/OneDrive/Desktop/Code3_Nordic=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.5.1/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.5.1=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -std=c99 -MD -MT zephyr/drivers/console/CMakeFiles/drivers__console.dir/uart_console.c.obj -MF zephyr\drivers\console\CMakeFiles\drivers__console.dir\uart_console.c.obj.d -o zephyr/drivers/console/CMakeFiles/drivers__console.dir/uart_console.c.obj -c C:/ncs/v2.5.1/zephyr/drivers/console/uart_console.c
    In file included from C:/ncs/v2.5.1/zephyr/include/zephyr/toolchain/gcc.h:92,
    from C:/ncs/v2.5.1/zephyr/include/zephyr/toolchain.h:50,
    from C:/ncs/v2.5.1/zephyr/include/zephyr/kernel_includes.h:19,
    from C:/ncs/v2.5.1/zephyr/include/zephyr/kernel.h:17,
    from C:/ncs/v2.5.1/zephyr/drivers/console/uart_console.c:16:
    C:/ncs/v2.5.1/zephyr/include/zephyr/device.h:85:41: error: '__device_dts_ord_85' undeclared here (not in a function); did you mean '__device_dts_ord_15'?
    85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
    132 | #define _DO_CONCAT(x, y) x ## y
    | ^
    C:/ncs/v2.5.1/zephyr/include/zephyr/device.h:85:33: note: in expansion of macro '_CONCAT'
    85 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
    | ^~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/device.h:211:37: note: in expansion of macro 'DEVICE_NAME_GET'
    211 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
    | ^~~~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/include/zephyr/device.h:228:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
    228 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
    | ^~~~~~~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/drivers/console/uart_console.c:40:9: note: in expansion of macro 'DEVICE_DT_GET'
    40 | DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
    | ^~~~~~~~~~~~~
    [199/241] Building C object zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_nrfx_uarte.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\Users\vanvu\OneDrive\Desktop\Code3_Nordic\build'

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

  • Hi Michal,

    And, this is my full application attached if you need it to double-check. This is only a simple program to read data by using the UART1 interface and then sleep periodically.

    Best,

    Vu

    4331.Code3_Nordic (2).zip

  • Hi Vu,

    Our apology for the long silence. Michal has been on some other assignments and the case slipped past our checks for some reasons.

    The problem is that UART0 is still used by some other features of the Zephyr RTOS. See this part of the CircuitDojo board definition:

    	chosen {
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    	};

    The console, shell, and MCUmgr features still expect UART0.

    You have two options:

    • Disable the features via Kconfig
    • Overlay the features' UART selection to UART1

    Regards,

    Hieu

  • Hi Hieu,

    Thank you for your recommendations.

    Best,

    Van Vu 

  • Hi Vu,

    My pleasure. If everything works, please feel free to close this ticket at your convenience Slight smile

    Regards,

    Hieu

Reply Children
Related