Build Fail when trying to modify SLM application sample

Hello, 

I've been trying to modify the v2.4.0 Serial LTE Modem application sample for my nRF-9160 custom board, in order for it to communicate with our external MCU through UART2 at PO.28/29, while outputting modem trace log through another UART at PO.03/PO.04(From the reply of Nordic AI, I assume the default port of outputting LOG was uart1?).

I haven't change any original code files, but I've copied the "nrf9160dk_nrf9160_ns.conf", "nrf9160dk_nrf9160_ns.overlay" to modify, and also create an extra "open_uart_trace.conf" file.
I add these 3 files as extra Kconfig fragments and extra Devicetree overlays.

However when I build it, it would end up error, and from the build log it seems like there's a conflict about interrupt?

I can't figure out what did I need to do to fix the problem, please could someone help, thanks!

Below are the 3 files and the build Log.

custom_9160.conf

#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# Configuration file for nRF9160DK.
# This file is merged with prj.conf in the application folder, and options
# set here will take precedence if they are present in both files.

# Use UART_0 (when working with PC terminal)
# unmask the following config
#CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2
#CONFIG_UART_0_NRF_HW_ASYNC=y
#CONFIG_SLM_WAKEUP_PIN=6
#CONFIG_SLM_INDICATE_PIN=2

# Use UART_2 (when working with external MCU)
# unmask the following config
CONFIG_UART_2_NRF_HW_ASYNC_TIMER=2
CONFIG_UART_2_NRF_HW_ASYNC=y
CONFIG_SLM_WAKEUP_PIN=31
CONFIG_SLM_INDICATE_PIN=2

.

custom_9160.overlay
/*
 * Copyright (c) 2021 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

 / {
    chosen {
        ncs,slm-uart = &uart2;
    };
};

&uart0 {
    status = "disabled";
};

&uart1 {
    compatible = "nordic,nrf-uarte";
    current-speed = <230400>;
    status = "okay";

    pinctrl-0 = <&uart1_default_alt>;
    pinctrl-1 = <&uart1_sleep_alt>;
    pinctrl-names = "default", "sleep";
};

&uart2 {
    compatible = "nordic,nrf-uarte";
    current-speed = <115200>;
    status = "okay";
    hw-flow-control;

    pinctrl-0 = <&uart2_default_alt>;
    pinctrl-1 = <&uart2_sleep_alt>;
    pinctrl-names = "default", "sleep";
};

&i2c2 {
    status = "disabled";
};

&pinctrl {
    uart1_default_alt: uart1_default_alt {
        group1 {
            psels = <NRF_PSEL(UART_RX, 0, 3)>;
            bias-pull-up;
        };
        group2 {
            psels = <NRF_PSEL(UART_TX, 0, 4)>;
        };
    };

    uart1_sleep_alt: uart1_sleep_alt {
        group1 {
            psels = <NRF_PSEL(UART_TX, 0, 4)>,
                <NRF_PSEL(UART_RX, 0, 3)>;
            low-power-enable;
        };
    };

    uart2_default_alt: uart2_default_alt {
        group1 {
            psels = <NRF_PSEL(UART_RX, 0, 28)>;
            bias-pull-up;
        };
        group2 {
            psels = <NRF_PSEL(UART_TX, 0, 29)>,
                <NRF_PSEL(UART_RTS, 0, 12)>,
                <NRF_PSEL(UART_CTS, 0, 13)>;
        };
    };

    uart2_sleep_alt: uart2_sleep_alt {
        group1 {
            psels = <NRF_PSEL(UART_TX, 0, 29)>,
                <NRF_PSEL(UART_RX, 0, 28)>,
                <NRF_PSEL(UART_RTS, 0, 12)>,
                <NRF_PSEL(UART_CTS, 0, 13)>;
            low-power-enable;
        };
    };
};
.
open_uart_trace.conf
# Segger RTT
CONFIG_LOG_BACKEND_RTT=n
CONFIG_LOG_BACKEND_UART=y

# Enable below for modem trace
CONFIG_NRF_MODEM_LIB_TRACE=y

.
====Build Log====
* Executing task: nRF Connect: Generate config nrf9160dk_nrf9160_ns for d:\Nordic\Projects\SLM_v2.4.0

Building SLM_v2.4.0
C:\Windows\system32\cmd.exe /d /s /c "west build --build-dir d:/Nordic/Projects/SLM_v2.4.0/uart_trace d:/Nordic/Projects/SLM_v2.4.0 --pristine --board nrf9160dk_nrf9160_ns -- -DNCS_TOOLCHAIN_VERSION=NONE -DEXTRA_CONF_FILE=Extra_configs/uart_trace.conf;boards/custom_9160_A1_1.conf -DEXTRA_DTC_OVERLAY_FILE=boards/custom_9160_A1_1.overlay -DBOARD_ROOT=d:/nordic/projects/slm_v2.4.0"

-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: D:/Nordic/Projects/SLM_v2.4.0
-- CMake version: 3.20.5
-- Found Python3: C:/ncs/toolchains/31f4403e35/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
-- Cache files will be written to: C:/ncs/v2.4.0/zephyr/.cache
-- Zephyr version: 3.3.99 (C:/ncs/v2.4.0/zephyr)
-- Found west (found suitable version "1.0.0", minimum required is "0.7.1")
-- Board: nrf9160dk_nrf9160_ns, Revision: 0.7.0
-- Found host-tools: zephyr 0.16.0 (C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.0 (C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk)
-- Found Dtc: C:/ncs/toolchains/31f4403e35/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found BOARD.dts: C:/ncs/v2.4.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_ns.dts
-- Found devicetree overlay: D:/Nordic/Projects/SLM_v2.4.0/boards/nrf9160dk_nrf9160_ns.overlay
-- Found devicetree overlay: boards/custom_9160_A1_1.overlay
-- Generated zephyr.dts: D:/Nordic/Projects/SLM_v2.4.0/uart_trace/zephyr/zephyr.dts
-- Generated devicetree_generated.h: D:/Nordic/Projects/SLM_v2.4.0/uart_trace/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: D:/Nordic/Projects/SLM_v2.4.0/uart_trace/zephyr/dts.cmake
Parsing D:/Nordic/Projects/SLM_v2.4.0/Kconfig
Loaded configuration 'C:/ncs/v2.4.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_ns_defconfig'
Merged configuration 'D:/Nordic/Projects/SLM_v2.4.0/prj.conf'
Merged configuration 'D:/Nordic/Projects/SLM_v2.4.0/boards/nrf9160dk_nrf9160_ns.conf'
Merged configuration 'D:/Nordic/Projects/SLM_v2.4.0/Extra_configs/uart_trace.conf'
Merged configuration 'D:/Nordic/Projects/SLM_v2.4.0/boards/custom_9160_A1_1.conf'
Configuration saved to 'D:/Nordic/Projects/SLM_v2.4.0/uart_trace/zephyr/.config'
Kconfig header saved to 'D:/Nordic/Projects/SLM_v2.4.0/uart_trace/zephyr/include/generated/autoconf.h'

warning: UART_0_NRF_HW_ASYNC (defined at drivers/serial/Kconfig.nrfx:84) was assigned the value 'y'
but got the value 'n'. Check these unsatisfied dependencies: UART_0_NRF_UARTE (=n), (UART_0_NRF_UART
|| UART_0_NRF_UARTE) (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_UART_0_NRF_HW_ASYNC and/or look up
UART_0_NRF_HW_ASYNC 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: UART_0_NRF_HW_ASYNC_TIMER (defined at drivers/serial/Kconfig.nrfx:103) was assigned the
value '2' but got the value ''. Check these unsatisfied dependencies: UART_0_NRF_HW_ASYNC (=n),
(UART_0_NRF_UART || UART_0_NRF_UARTE) (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_UART_0_NRF_HW_ASYNC_TIMER and/or look up
UART_0_NRF_HW_ASYNC_TIMER 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: LOG_BACKEND_UART (defined at subsys/logging\backends\Kconfig.uart:4) was assigned the value
'y' but got the value 'n'. Check these unsatisfied dependencies: UART_CONSOLE (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_BACKEND_UART and/or look up
LOG_BACKEND_UART 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: Experimental symbol TFTP_LIB is enabled.


warning: Experimental symbol HTTP_CLIENT is enabled.

-- Found GnuLd: c:/ncs/toolchains/31f4403e35/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/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
-- Found Python3: C:/ncs/toolchains/31f4403e35/opt/bin/python.exe (found version "3.8.2") found components: Interpreter
Changed board to secure nrf9160dk_nrf9160 (NOT NS)

=== child image mcuboot - begin ===
loading initial cache file D:/Nordic/Projects/SLM_v2.4.0/uart_trace/mcuboot/child_image_preload.cmake
CMake Warning (dev) at D:/Nordic/Projects/SLM_v2.4.0/uart_trace/mcuboot/child_image_preload.cmake:8 (set):
Syntax error in cmake code at

D:/Nordic/Projects/SLM_v2.4.0/uart_trace/mcuboot/child_image_preload.cmake:8

when parsing string

C:\ncs\toolchains\31f4403e35\opt\bin\python.exe

Invalid escape sequence \3

Policy CMP0010 is not set: Bad variable reference syntax is an error. Run
"cmake --help-policy CMP0010" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.

Loading Zephyr default modules (Zephyr base).
-- Application: C:/ncs/v2.4.0/bootloader/mcuboot/boot/zephyr
-- CMake version: 3.20.5
-- Found Python3: C:/ncs/toolchains/31f4403e35/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
-- Cache files will be written to: C:/ncs/v2.4.0/zephyr/.cache
-- Zephyr version: 3.3.99 (C:/ncs/v2.4.0/zephyr)
-- Found west (found suitable version "1.0.0", minimum required is "0.7.1")
-- Board: nrf9160dk_nrf9160, Revision: 0.7.0
-- Found host-tools: zephyr 0.16.0 (C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.16.0 (C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk)
-- Found Dtc: C:/ncs/toolchains/31f4403e35/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found BOARD.dts: C:/ncs/v2.4.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts
-- Found devicetree overlay: C:/ncs/v2.4.0/bootloader/mcuboot/boot/zephyr/app.overlay
-- Generated zephyr.dts: D:/Nordic/Projects/SLM_v2.4.0/uart_trace/mcuboot/zephyr/zephyr.dts
-- Generated devicetree_generated.h: D:/Nordic/Projects/SLM_v2.4.0/uart_trace/mcuboot/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: D:/Nordic/Projects/SLM_v2.4.0/uart_trace/mcuboot/zephyr/dts.cmake
Parsing C:/ncs/v2.4.0/bootloader/mcuboot/boot/zephyr/Kconfig
Loaded configuration 'C:/ncs/v2.4.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_defconfig'
Merged configuration 'C:/ncs/v2.4.0/bootloader/mcuboot/boot/zephyr/prj.conf'
Merged configuration 'C:/ncs/v2.4.0/nrf/modules/mcuboot/tfm.conf'
Merged configuration 'C:/ncs/v2.4.0/nrf/modules/mcuboot/fih_low_enable.conf'
Merged configuration 'C:/ncs/v2.4.0/nrf/subsys/partition_manager/partition_manager_enabled.conf'
Merged configuration 'D:/Nordic/Projects/SLM_v2.4.0/child_image/mcuboot.conf'
Merged configuration 'D:/Nordic/Projects/SLM_v2.4.0/uart_trace/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
Configuration saved to 'D:/Nordic/Projects/SLM_v2.4.0/uart_trace/mcuboot/zephyr/.config'
Kconfig header saved to 'D:/Nordic/Projects/SLM_v2.4.0/uart_trace/mcuboot/zephyr/include/generated/autoconf.h'
-- Found GnuLd: c:/ncs/toolchains/31f4403e35/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/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
CMake Warning at C:/ncs/v2.4.0/zephyr/CMakeLists.txt:838 (message):
No SOURCES given to Zephyr library: lib__libc__common

Excluding target from build.


CMake Warning at C:/ncs/v2.4.0/zephyr/CMakeLists.txt:838 (message):
No SOURCES given to Zephyr library: drivers__console

Excluding target from build.


MCUBoot bootloader key file: C:/ncs/v2.4.0/bootloader/mcuboot/root-ec-p256.pem
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Nordic/Projects/SLM_v2.4.0/uart_trace/mcuboot
=== child image mcuboot - end ===

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


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




CMake Warning at C:/ncs/v2.4.0/zephyr/CMakeLists.txt:838 (message):
No SOURCES given to Zephyr library: lib__libc__common

Excluding target from build.


-- Configuring done
-- Generating done
-- Build files have been written to: D:/Nordic/Projects/SLM_v2.4.0/uart_trace
-- west build: building application
[1/396] Generating include/generated/version.h
-- Zephyr version: 3.3.99 (C:/ncs/v2.4.0/zephyr), build: v3.3.99-ncs1
[1/182] Generating include/generated/version.h
-- Zephyr version: 3.3.99 (C:/ncs/v2.4.0/zephyr), build: v3.3.99-ncs1
[172/182] Linking C executable zephyr\zephyr_pre0.elf

[176/182] Linking C executable zephyr\zephyr_pre1.elf

[182/182] Linking C executable zephyr\zephyr.elf
Memory region Used Size Region Size %age Used
FLASH: 28546 B 48 KB 58.08%
RAM: 16360 B 32 KB 49.93%
IDT_LIST: 0 GB 2 KB 0.00%
[11/396] Generating ../../tfm/CMakeCache.txt
-- Found Git: C:/ncs/toolchains/31f4403e35/mingw64/bin/git.exe (found version "2.37.3.windows.1")
-- The C compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
-- Found Python3: C:/ncs/toolchains/31f4403e35/opt/bin/python.exe (found version "3.8.2") found components: Interpreter
-- Found Python3: C:/ncs/toolchains/31f4403e35/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
-- Cache files will be written to: C:/ncs/v2.4.0/zephyr/.cache
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Nordic/Projects/SLM_v2.4.0/uart_trace/tfm
[22/396] Performing install step for 'tfm'
-- Install configuration: "MinSizeRel"
[377/396] Linking C executable zephyr\zephyr_pre0.elf

[381/396] Linking C executable zephyr\zephyr_pre1.elf

[383/396] Generating isr_tables.c, isrList.bin
FAILED: zephyr/isr_tables.c zephyr/isrList.bin
cmd.exe /C "cd /D D:\Nordic\Projects\SLM_v2.4.0\uart_trace\zephyr && C:\ncs\toolchains\31f4403e35\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-objcopy.exe --input-target=elf32-littlearm --output-target=binary --only-section=.intList D:/Nordic/Projects/SLM_v2.4.0/uart_trace/zephyr/zephyr_pre1.elf isrList.bin && C:\ncs\toolchains\31f4403e35\opt\bin\python.exe C:/ncs/v2.4.0/zephyr/scripts/build/gen_isr_tables.py --output-source isr_tables.c --kernel D:/Nordic/Projects/SLM_v2.4.0/uart_trace/zephyr/zephyr_pre1.elf --intlist isrList.bin --sw-isr-table --vector-table"
gen_isr_tables.py: error: multiple registrations at table_index 9 for irq 9 (0x9)
Existing handler 0x2c7f1, new handler 0x463b3
Has IRQ_CONNECT or IRQ_DIRECT_CONNECT accidentally been invoked on the same irq multiple times?

ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\31f4403e35\opt\bin\cmake.EXE' --build 'd:\Nordic\Projects\SLM_v2.4.0\uart_trace'

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

Parents Reply
  • Hi,

    I have discussed this issue with our developers. 

    In NCS 2.4.0, the modem trace is not configurable by device tree. Instead, it uses UARTE1 (uart1) by default:
    github.com/.../Kconfig

    Most of the parameters are hardcoded, and if these need to be changed, changes are needed in here:
    github.com/.../uart.c

    But it does follow the pintctrl of: uart1_default: uart1_default
    github.com/.../uart.c

    For getting this to work, you do not need to enable uart1 (as this will lead to IRQ issue as uart1 will likely have a conflict with itself), or uart3. You only need to set the following:

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

    Best regards,
    Dejan

Children
  • Hi Dejans,

    Wow this really is a great news!!
    I'll try this as soon as I get back to work(Didn't have the board with me now).

    However I have some little concern for now.

    Since these was implemented in the library, I assume they would be used by all the applications I might be building(if is version 2.4.0). So it might be risky to directly change the library itself?
    (Change is needed cause the highest matched baudrate of nrf and our UART logger was 230400)

    I've roughly viewed the uart.c file, and came up with an idea.
    If I wrapped the line 60~ line 68 inside an #ifdef #else #endif like below, and then add the "CONFIG_NRF_MODEM_TRACE_LOG_BAUDRATE" self-defined keyword in the extra Kconfig fragments, would this be a safer may to add the change?
    Or is this a totally misunderstand of how config keywords works?

    #ifdef CONFIG_NRF_MODEM_TRACE_LOG_BAUDRATE
    const nrfx_uarte_config_t config = {
    		.skip_gpio_cfg = true,
    		.skip_psel_cfg = true,
    		.hal_cfg.hwfc = NRF_UARTE_HWFC_DISABLED,
    		.hal_cfg.parity = NRF_UARTE_PARITY_EXCLUDED,
    		.baudrate = NRF_UARTE_BAUDRATE_230400,
    		.interrupt_priority = DT_IRQ(UART1_NL, priority),
    		.p_context = NULL,
    	};
    #else
    const nrfx_uarte_config_t config = {
    		.skip_gpio_cfg = true,
    		.skip_psel_cfg = true,
    		.hal_cfg.hwfc = NRF_UARTE_HWFC_DISABLED,
    		.hal_cfg.parity = NRF_UARTE_PARITY_EXCLUDED,
    		.baudrate = NRF_UARTE_BAUDRATE_1000000,
    		.interrupt_priority = DT_IRQ(UART1_NL, priority),
    		.p_context = NULL,
    	};
    #endif

  • Hi,

    Your (or similar) solution should work fine. This part is only used for modem trace collection but it does affect all applications that use it.

    Best regards,
    Dejan

  • Hi Dejans,

    Good news and bad news.

    I've tried your method of only configuring the TX/RX pin assignment, and it works!

    However if I tried to set the UART1 baudrate to 230400, it still can output something, but definitely not complete.

    From the logged file of my uart logger, I still can see the AT commands appears inside it, but as I import the bin file to cellular monitor program, the program and wireshark program both couldn't resolve packets inside it.

    Do you have any Idea to make it work at different baudrates? Or I might just need to give up and find some other uart logger module that support 1M baudrate in this point...

    binary1, outputted with 230400 baudrate
    output.bin

    binary2, outputted with 1M baudrate.
    output2.bin

  • Hi,

    It is recommended to use 1M baudrate. Otherwise, traces could be lost.

    Best regards,
    Dejan

Related