onomondo / nrf-softsim

Manifest repo for integrating SoftSIM and nrf-sdk
30 stars 6 forks source link

Nordic Thingy:91 (nRF9160) - unable to build softsim_static_profile sample using nRF v2.6.1 SDK - region `FLASH' overflowed #49

Closed jameslshannon closed 2 months ago

jameslshannon commented 3 months ago

Hi,

When trying to build the latest softsim_static_profile sample using nRF 2.6.1 SDK (for board nrf9160_ns) it fails due to a flash overflow - is this a known issue with the provided minimal sample and how is it resolved?

c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: address 0x1a120 of bin\tfm_s.axf section `.TFM_UNPRIV_CODE' is not within region `FLASH'
c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: bin\tfm_s.axf section `.psa_interface_thread_fn_call' will not fit in region `FLASH'
c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: address 0x1fc40 of bin\tfm_s.axf section `.gnu.sgstubs' is not within region `FLASH'
c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: address 0x1a120 of bin\tfm_s.axf section `.TFM_UNPRIV_CODE' is not within region `FLASH'
c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: address 0x1fc40 of bin\tfm_s.axf section `.gnu.sgstubs' is not within region `FLASH'
c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: region `FLASH' overflowed by 32100 bytes
Memory region         Used Size  Region Size  %age Used
           FLASH:       80740 B      48640 B    166.00%
             RAM:       47636 B        88 KB     52.86%
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
[21/346] Completed 'mcuboot_subimage'

Thanks,

James

jameslshannon commented 3 months ago

Looks like this is caused by the static partition mapping in ncs/v2.6.1/nrf/boards/arm/thingy91_nrf9160/thingy91_pm_static.yml for the Nordic Thingy:91. If I increase the tfm:size value here I can avoid the flash overflow at build, but the sample doesn't run on the device - presumably as the partition config is invalid.

-- Found partition manager static configuration: C:/ncs/v2.6.1/nrf/boards/arm/thingy91_nrf9160/thingy91_pm_static.yml
Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_pad' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_primary_app' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_secondary' is not included in the dynamic resolving since it is statically defined.
Partition 'nonsecure_storage' is not included in the dynamic resolving since it is statically defined.
Partition 'tfm_secure' is not included in the dynamic resolving since it is statically defined.
Partition 'tfm_nonsecure' is not included in the dynamic resolving since it is statically defined.
Partition 'tfm' is not included in the dynamic resolving since it is statically defined.
Dropping partition 'nrf_modem_lib_trace' since its size is 0.
Dropping partition 'tfm_ps' since its size is 0.

Do you have an updated thingy91_pm_static.yml config (or values) that support the softsim samples?

Thanks!

MirkoCovizzi commented 2 months ago

Hi James, this build failure is caused by an overflow of the tfm partition due to an increase of the TFM binary due to security requirements introduced by SoftSIM. The Thingy91, compared to a more basic nrf9160, supports MCUBOOT out of the box, which is configured, together with other components, in a static partition layout within NCS that can be found in nrf/boards/arm/thingy91_nrf9160. This static partition layout is loaded by default by the build system and it does not support SoftSIM due to a smaller size of the tfm partition. To resolve the issue, I made a PR that addresses this by updating the appropriate partititions. The PR can be found here: https://github.com/onomondo/nrf-softsim/pull/50

Please feel free to checkout the PR and let me know if this resolves the issue for you. If there are other issues please contact my colleagues at the Nordic DevZone who will provide support.

benjaminbruun commented 2 months ago

Thanks for the contribution Mirko. We have tested the new build configuration with success.

Be sure to open a new issue if new errors occur.

jameslshannon commented 2 months ago

Yes, I can also confirm that it now builds for Thingy:91 - thanks!