How does TF-M select UART1 pins?

Hello DevZone,

I have a confusing question about TF-M. Need  help from a TF-M expert.

In this document, it says that we must disable uart1 in non-secure application, because TF-M use it as secure peripheral.

My question is: how does TF-M select the pins used by uart1_secure?

My board selection is `nrf9160dk/nrf9160/ns`, which is a non-secure board.

I use AI to read the build progress and all the Ninja things. And it told me that TF-M just read the non-secure `zephyr.dts` and use the pin-ctrl of that.

I think this is not reasonable, because uart1 is disabled in my application. There is no reason for TF-M to use the pin-ctrl from a disabled uart.

More general question: how can I choose a peripheral as secure or non-secure in NCS? Should I configure this in Devicetree or Kconfig?

Best regards,

Jayant

Parents Reply Children
  • I understand that sysbuild is used for multi-image building.

    But TF-M seems to be special. There is no way in sysbuild to configure the TF-M overlay.

    More preciously, TF-M is more like a part of application, rather than an independent image:


    After many times searching, I finally found that TF-M never use Zephyr serial driver.

    All the answers are in these header files:

    In `device_cfg.h` we have:

    In `RTE_device.h` we have:

    In `tfm_peripherals_config.h`, we have:

    So, that means TF-M can directly read the non-secure Application's final `zephyr.dts`, and read the pin-ctrl of uart1, even if uart1 is disabled.

    And this question:

    how can I choose a peripheral as secure or non-secure in NCS? Should I configure this in Devicetree or Kconfig?

    The answer is to set CONFIG_NRF_XXXX_SECURE.

    So everything seems to be clear now. And this 

    You mean when I select `nrf9160dk/nrf9160/ns` for my application, the TF-M will use `nrf9160dk/nrf9160` automatically. Because they are in the same board folder.

    seems not to be correct.


    I will test this tomorrow and get back here.

  • I have confirmed that:

    1. TF-M doesn't have a stand alone sysbuild configuration, it is a part of the Application

    2. TF-M will use application's non-secure uart1 pinctrl, even if uart1 is disabled.


    CONFIG_SERIAL=y
    CONFIG_TFM_LOG_LEVEL_SILENCE=n
     

    &uart1 {
        status = "disabled";
    };
    
    &pinctrl{
    	uart1_default: uart1_default {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 16)>,
    				<NRF_PSEL(UART_RTS, 0, 14)>;
    		};
    		group2 {
    			psels = <NRF_PSEL(UART_RX, 0, 17)>,
    				<NRF_PSEL(UART_CTS, 0, 15)>;
    			bias-pull-up;
    		};
    	};
    
    	uart1_sleep: uart1_sleep {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 16)>,
    				<NRF_PSEL(UART_RX, 0, 17)>,
    				<NRF_PSEL(UART_RTS, 0, 14)>,
    				<NRF_PSEL(UART_CTS, 0, 15)>;
    			low-power-enable;
    		};
    	};
    };
    

    Cheers!

Related