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
  • Hi Mark,

    Referring to this earlier DevZone case:  nRF5340: best way to configure P0.02 (NFCT) as GPIO with TFM .

    As long as the NFC node is disabled in DeviceTree on the non-secure target, P1.02 will be enabled as a GPIO pin by default.

    Best regards,

    Hieu

  • HI Hieu,

    Thanks for the response. I've seen this post before, with no luck. 

    I've tried disabled the NFC node using:

    &nfct {
        status = "disabled";
    };

    in board_nrf54l15_cpuapp_ns.dts, and after testing again, this does not solve the issue. Debugging in VSCode/Ozone and inspecting the registers, PADCONFIG is still enabled in the NFCT_NS register, and the pin does not function as a GPIO unless I manually disable. Worth noting, the TFM_NFCT_PINS_AS_GPIO appears to target only the 5340 SoC. Is there perhaps something I'm missing alongside the NFCT node change in devicetree?

    Kind regards,
    Mark Laloo 
  • 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 

Reply
  • 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 

Children
  • Hi Mark,

    Thanks for the additional information on this case, this helps.

    I configured the NRF5L15 dev kit and resoldered the connections to output to the IO headers. I can observe the same behavior as metioned that the IO does not get unlocked when building with TF-M and the application running non-secured. I can toggle the pin when it is unlocked in a secured build.

    I did some additional testing and noticed that the NRF_NFCT_NS->PADCONFIG is set to 0 inside the driver init as it gets cleared by the POST_KERNEL function I have but the debugger says the register is still set.

    Trying to write to it does alter NRF_NFCT_NS->PADCONFIG but it does not correlate to the actual register as shown by the debugger.

    Kind regards,
    Justin Verkade

  • Hi Justin and Mark,

    Sorry for the late reply. I broke the environment on my machines and can't test anything for a while.

    That is fixed now, but I still can't reproduce your issue with NVS v3.1.1.

    Do you have a minimal setup I can reproduce the issue with?

    Here is my copy of modified zephyr/samples/basic/blinky sample, where P1.02 works as expected.

    c339307-251106_01.zip

    Best regards,

    Hieu

  • Hi Hieu,

    Sorry for the delay, We only have one nRF54L15 dev kit laying around and we modified it to function exactly as in the prototype hardware so getting an exact working example is difficult and I also do not have enough time to prepare a minimal repoducable example.

    I cut and soldered the connections such that the external 32kHz crystal is disconnected and redirected to the IO headers just like the NFC pins. I use the dev kit board files as base with an overlay file to redirect the debug uart pins on the P1 block to other pins since I needed the default UART pins for different connections. My project Kconfig contains some additional configurations to enable the internal RC oscilator.

    I attempted to write the PADCONFIG register in the main function while in secured and non-secured to attempt to change it with the mentioned results. The results reflect the same on the prototype hardware in that we are unable to change the register in non-secured mode.

    Sadly I do not have enough time to dive much deeper since we internally decided to just use different pins and avoid the problem in our next revision of the hardware. If required I can provide more information but I do not have the time to setup a dev kit for further testing.

    Sadly it is not a quick fix and you provided good support but we need to continue.

    Kind regards,
    Justin Verkade

  • Hi Justin,

    No problem. I too agree that choosing a less special pin is the best way forward. Would also limit the amount of change necessary if one day in the future, NFC is considered.

    Please just let me know if the issue becomes bothersome again in the future.

    -----------------------

    Hi Mark,

    If the issue is blocking your project, please let me know.

    Best regards,

    Hieu

  • Hi Hieu,
    I am trying to use P1.02 and P1.03 as PWM outputs on a custom board that I developed. Now I am running into the same issue, that disabling NFC does not release these two GPIOs. As I need 8 Analog inputs and 7 analog outputs I used all GPIOs from P1 and cannot simply change the PIN. Could you please assist me in solving that issue?
    Do you have any news from the DeviceTree team working on this?

    Thank you in advance!

    Best regards,

    Walter

Related