Board reboots when a function is executed in TF-M

Hi,

I'm moving a project from SPM to TF-M. I have imported a static library and the board (nRF5340DK) restarts automatically every time the following mycli/main.c function is executed: signature.

signature(pk, msg, buffer);

More specifically, the problem occurs when executing blst_sign_pk_in_g1 function, which is located in lib/bls_hsm.h.

blst_sign_pk_in_g1(&sig, &hash, secret_keys_store + pk_index*sizeof(blst_scalar));

Other functions from the static library are executed correctly, so I guess the problem is not in the import of the library, but must be related to memory. In case it is of any interest, a few weeks ago I had problems importing such a static library into TF-M. The problem was solved as indicated in the following forum ticket: Problem importing a library into TF-M: Not enough space to import i.

I attach a link to the github project repo, so that the error can be easily reproduced: bls-hsm-2. To reproduce the error, build and execute application mycli. You will see that the board reboots.

Thank you in advice,

Pablo

Useful information about the project:
- I'm using the nRF5340DK development kit.
- nRF SDK v2.0.0
- The project is based on the example: TF-M Secure Partition Sample. When doing the build for this example, the available and used space shown is as follows:

Parents Reply Children
  • What I wanted to send was this:

    Useful information about the project:
    - I'm using the nRF5340DK development kit.
    - nRF SDK v2.0.0
    - The project is based on the example: TF-M Secure Partition Sample.

    The text at the end is something I forgot to remove. I copied and pasted this information about the project from another ticket where I had a problem with the build.

  • Hi,

    I have looked into your project. I noticed that there are many warnings during build process. I would suggest you to go through these warnings and try to fix them. There seems to be a problem with your project that would need to be investigated further. 

    Could you provide more information on how you narrowed down the problem to the blst_sign_pk_in_g1 function from lib/bls_hsm.h?

    It would be beneficial if you could provide some logs. Could you show application log and secure partition log?

    Have you seen any hard fault errors?

    Bes regards,
    Dejan

  • I narrowed down the problem by doing a step-by-step debug. I found that it is in that line of code that the board reboot occurs.

    As for the warnings I get when doing the build, they don't seem to be related to the problem. I will still try to fix them

    Executing the following command inside bls-hsm-2/mycli, i get this log:

    west build -t partition_manager_report

    The reboot of the board made me think that it might be a RAM problem. To do so, I set the value of the RAM assigned to the safe partition to an extremely high value, by writing the following in prj.conf:

    CONFIG_PM_PARTITION_SIZE_TFM_SRAM=0x63000

    This did not solve the problem. Running the same command, having added this configuration inside prj.conf to the build gives the following log:

    Are them the logs you need?

    Regards,

    Pablo

  • Hi,

    I have a couple of updates about the project. 

    First of all, I have fixed some warnings that appear when doing the build. As I expected, this didn't solve the problem, but it's good to get rid of them.

    Secondly, I have added to the repository a branch called "non_secure", in which I have imported the static library and run the functions in the non-secure partition. The function that gives me problems in tf-m works correctly in non secure partition. To make it work, I have added the following configuration to prj.conf, to allocate spare memory to the main stack:

    CONFIG_MAIN_STACK_SIZE=104080

    Although I am not using the tf-m functions in this branch, I have not removed it from the configuration.

    When building, the following memory usage data is displayed:

    In case it is useful, this is the log obtained when executing the command:

    west build -t partition_manager_report

    Regards,

    Pablo

  • Hi,

    For which board did you build your sample?

    Did your build configuration include "Enable debug options"?

    Best regards,
    Dejan

Related