Periodic SPI reads in TF-M secure partition

I've been investigating the "TF-M secure peripheral partition" sample project (nRF5340DK, NCS v2.5.0, nrf/samples/tfm/tfm_secure_peripheral) and testing if it would be possible to connect the SPI peripheral (in secure partition) to a sensor and read data from it. For my project's requirements, I need to read every 0.5ms with good accuracy i.e., being off by +/-0.1ms or more would not be acceptable.

While I was able to get it experimentally working previously (by adjusting the time delay at src/main.c for the k_work_schedule() call), I need to make sure the timing is accurate i.e., set up a timer interrupt. But the couple approaches I've tried so far don't seem to work:

  1. Set up timer in secure partition (what the sample project already does, but adjust to interrupt every 0.5ms instead of every 1 second)
  2. Set up timer in non-secure partition; on interrupt, submit work item w/ k_work_submit() (the 'signal' for secure partition to perform read)

Both approaches seem to have the same issues:

  • The software appears to keep resetting
    • There's no output on the VCOM debug output
    • The TF-M output (at P0.25) keeps repeatedly outputting the following
      • [Sec Thread] Secure image initializing!
        Booting TF-M v1.8.0
        [INF][Crypto] Provisioning entropy seed... complete.
        [Sec Thread] Secure image initializing!
        Booting TF-M v1.8.0
        [INF][Crypto] Provisioning entropy seed... complete.
        (...keeps repeating...)
  • If I have the timer interrupt less frequently i.e., every 0.5 seconds, it won't restart.
    • But any more frequent than this and the code just seems to break. 

I'm currently investigating the EGU interrupts and PSA function calls to see if the issue is related to this. I am also reconsidering which partition the peripheral should be used in; it would not be preferred to do so, since I need to encrypt the data anyway, so reading it into the secure partition would be more convenient, I imagine. But I did find notes online about the secure partition not being meant for applications requiring periodic activity: site #1 and site #2...Regardless, if there's any suggestions for working around this problem, I'd appreciate the help.

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

EDIT #1 - For approach #2 (timer in non-secure), I did not report the symptoms correctly. Here's what I actually see:

  • Board is not restarting
  • But I only see 1 SPI read occur every 1 seconds (i.e., whenever non-secure executes the process() handler), not every 0.5ms like I expect.
    • The SPI read should perform the SPI read in the secure partition at spp_send() 
    • I submit the send() work item in non-secure, during the timer's interrupt handler.
  • If I check the return value from k_work_submit(), I keep getting 0 (work was already submitted to a queue)

FYI here are my work queue Kconfig options:

CONFIG_SYSTEM_WORKQUEUE_PRIORITY=-1
# CONFIG_SYSTEM_WORKQUEUE_NO_YIELD is not set

Parents Reply Children
No Data
Related