nRF54L15 - NFCT Pins as GPIO with TF-M

Good day,

I'm trying to use pin 1.02 as a GPIO in a TF-M build using a (custom) non-secure board target, and I'm struggling to find the appropriate way to accomplish this. 

All current resources point to deprecated Kconfig defines (USE_NFCT_PINS_AS_GPIO), do not support non-secure targets (uisng the &uicr node in devicetree), are for older SoCs (

TFM_NFCT_PINS_AS_GPIOS only applies to nRF5340 according to v2.9.0 SDK). The only working option I've found is to edit the NFCT PADCONFIG register (which worked); are there any other options?

Thank you
Kind regards,
Mark Laloo
Parents Reply
  • Hi JVer,

    Are you certain that NRF_NFCT_NS->PADCONFIG works when you build without TF-M?

    Without TF-M, your application should be built to run in the Secure Environment, which means it should write to NRF_NFCT_S instead.

    With TF-M, your application should be built to run in the Non-secure Environment, thus NRF_NFCT_NS.

    Kind regards,

    Hieu

Children
  • Hi Hieu,

    Thanks for the response.

    Sorry for my bad explenation, I ment to say that writing the PADCONFIG register only works in non secure mode using the NRF_NFCT_S and NRF_NFCT versions but the solution to use the NRF_NFCT_NS with a Non-Secure build does not work.

    The program correctly faults when attempting to write using the NRF_NFCT_NS version in a secure build.

    I verified that using the NRF_NFCT_S and NRF_NFCT set the register correctly while probing using a debugger with a secure build but changing these to NRF_NFCT_NS and building the application in a Non-Secure build causes the debugger to continue running the code but the register does not update.

    I try to unlock the NFCT pins using a function running POST_KERNEL with a priority of 20. The debugger shows that it gets in the init function before reaching the drivers that require the pins to function as GPIO but although the function runs and exits the register does not get changed.

    We are considering updating the hardware design to avoid the use of these pins,but understanding why it is not possible to unlock the pins in a Non-Secure build is favorable over updating the hardware.

    I tried running the unlock function in PRE_KERNEL_1 but the code seems to crash if I set it like this.

    Kind regards,
    Justin Verkade

  • Hi Justin,

    What is the driver that you are trying to use the pin with?
    At what initialization priority does it initialize?
    And what SDK version are you testing with?

    I didn't try to write to NRF_NFCT_S not during initialization time, but just in main(), and can see pin 1.02 is able to toggle correctly in NCS v3.1.1.

    Kind regards,

    Hieu

  • Hi Hieu,

    We have a MCP251xFD CAN transceiver connected and we are using the can_mcp251xfd zephyr driver. The pins are connected to the SS and MOSI, and the pins and managed by the zephyr driver. The function to disable the IO lock runs in POST_KERNEL with a priority of 20 and has been verified using a debugger to run before the can_mcp251xfd driver. The SDK version is v3.1.1.

    A result table of my findings in secured and non-secured builds are:

    Secured:

    • NRF_NFCT->PADCONFIG          <> Writes the register correctly.
    • NRF_NFCT_S->PADCONFIG     <> Writes the register correctly.
    • NRF_NFCT_NS->PADCONFIG   <> Jumps to z_arm_usage_fault().

    Non-Secured:

    • NRF_NFCT->PADCONFIG          <> Steps over the operation but does not write the register.
    • NRF_NFCT_S->PADCONFIG     <> Jumps to SecureFault_Handler().
    • NRF_NFCT_NS->PADCONFIG   <> Steps over the operation but does not write the register.

    The jumps to SecureFault_Handler() are expected but the NRF_NFCT and NRF_NFCT_NS both step over the write without faults but do not update the register.

    In a secured build where the register does get written correctly the device boots correctly and everything works as intended.

    One additional bit of information that I do not think matters is that we are using a nRF54L10 instead of a L15.

    We are out of ideas and wil most likely change the hardware but we are interested to see if we can find a fix for it.

    Kind regards,
    Justin Verkade

  • Hi Justin,

    Can you get a very simplified test going where you only control the pin as a GPIO?

    Here is my project where I overlayed the Devicetree to have P1.02 as LED1 and toggle it.

    Kind regards,

    Hieu

  • Hi Hieu, Justin

    I've noticed (due to recommendations in other tickets to upgrade our SDK) that the solution we have been using (NRF_NFCT_NS->PADCONFIG=0) no longer works in our project. We previously built using NCS v2.9.1 (where it worked), and have moved to v3.1.1 (no longer working). Tests were completed using non-secure build target, building with TF-M. 

    I have also tested on v3.1.1 with TF-M removed (and building with secure target), and NFCT config now works as expected (using NRF_NFCT_S).

    Note, in this specific test, the GPIO was used to drive an LED.

    Kind regards,
    Mark Laloo 

Related