Uart stubs in NCS v3.4.0

Hi,

I am using the nRF54L15 and recently migrated my project from NCS v3.3.0 to NCS v3.4.0.

My project does not use the UART for TF-M logging, so I have the following configuration:

CONFIG_TFM_LOG_LEVEL_SILENCE=y

This worked correctly in NCS v3.3.0—TF-M logging was disabled and the UART pins were available for my application.

However, after migrating to NCS v3.4.0, I am seeing the following error:

/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/lib/runtime/assert.c:21:(.text.__assert_func+0x1e): undefined reference to `stdio_is_initialized'


To work around the issue, I added custom stub implementations:
#include <stdbool.h>
#include "uart_stdout.h"

int stdio_output_string(const char *str, uint32_t len)
{
	return 0;
}

void stdio_init(void)
{
}

void stdio_uninit(void)
{
}

bool stdio_is_initialized(void)
{
	return false;
}

void stdio_is_initialized_reset(void)
{
}

I also updated my CMakeLists.txt to include these stub implementations. This workaround functions correctly, but it requires patching NCS, which I would like to avoid.

  • Hello,

    I tried reproducing this linker error by building the tfm_hello_world sample with CONFIG_TFM_LOG_LEVEL_SILENCE=y, but was not able to. Are you able to replicate this using the nRF54L15 DK as your build target with one of the SDK samples? I tested with SDK v3.4.0

    Best regards,

    Vidar

  • Hi, sorry for the late response—I was quite busy last week.
    I reproduced the error using the psa_tls sample built for nrf54l15dk/nrf54l15/cpuapp/ns with the debug overlay file.

    Then I dug into it further and noticed that, contrary to what I initially thought, the error I described did not occur because of the:

    CONFIG_TFM_LOG_LEVEL_SILENCE=y
    


    but because of the:
    CONFIG_DEBUG_OPTIMIZATIONS=y


    Then I got the following output (sorry, I can't paste the logs as a code block, so I'm pasting them as plain text):

    /opt/nordic/ncs/toolchains/ccc010f809/opt/zephyr-sdk/gnu/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/14.3.0/../../../../arm-zephyr-eabi/bin/ld: platform/libplatform_s.a(tfm_log.o): in function `output_log':
    /opt/nordic/ncs/v3.4.0/modules/tee/tf-m/trusted-firmware-m/lib/tfm_log/src/tfm_log.c:18:(.text.output_log+0x10): undefined reference to `stdio_output_string'
    /opt/nordic/ncs/toolchains/ccc010f809/opt/zephyr-sdk/gnu/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/14.3.0/../../../../arm-zephyr-eabi/bin/ld: platform/libplatform_s.a(tfm_hal_spm_logdev_peripheral.o): in function `tfm_hal_output_spm_log':
    /opt/nordic/ncs/v3.4.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/common/tfm_hal_spm_logdev_peripheral.c:14:(.text.tfm_hal_output_spm_log+0xe): undefined reference to `stdio_output_string'
    /opt/nordic/ncs/toolchains/ccc010f809/opt/zephyr-sdk/gnu/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/14.3.0/../../../../arm-zephyr-eabi/bin/ld: secure_fw/spm/libtfm_spm.a(tfm_hal_platform_common.o): in function `tfm_hal_platform_common_init':
    /opt/nordic/ncs/v3.4.0/modules/tee/tf-m/trusted-firmware-m/platform/ext/target/nordic_nrf/common/core/tfm_hal_platform_common.c:36:(.text.tfm_hal_platform_common_init+0x46): undefined reference to `stdio_init'
    /opt/nordic/ncs/toolchains/ccc010f809/opt/zephyr-sdk/gnu/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/14.3.0/../../../../arm-zephyr-eabi/bin/ld: secure_fw/partitions/lib/runtime/libtfm_sprt.a(assert.o): in function `__assert_func':
    /opt/nordic/ncs/v3.4.0/modules/tee/tf-m/trusted-firmware-m/secure_fw/partitions/lib/runtime/assert.c:21:(.text.__assert_func+0x2c): undefined reference to `stdio_is_initialized'
    Memory region Used Size Region Size %age Used
    FLASH: 120252 B 512 KB 22.94%
    RAM: 53980 B 128 KB 41.18%
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.



  • Hi,

    Thanks for the update.  I did some preliminary investigation into this. With CONFIG_DEBUG_OPTIMIZATIONS enabled, it seems like you can reproduce the issue with any sample. This issue got introduced by this commit: SPRT: Add custom SPRT: Add custom __assert_func · nrfconnect/sdk-trusted-firmware-m@a4991f0  but the issue is generally masked because assertions are disabled in default release builds.

    I suggest you continue using your workaround for now. I have added the issue to our internal bug tracker so it can be addressed in a future release.

    Thanks,

    Vidar

Related