-
Notifications
You must be signed in to change notification settings - Fork 8.3k
boards: st: stm32h573i_dk: Add TF-M non-secure app support #100114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
933a8b6 to
df47604
Compare
df47604 to
51131b4
Compare
|
Currently, fails to build with Zephyr SDK used in main due to a internal compiler error, zephyrproject-rtos/sdk-ng#558. This is fixed starting GCC 13. |
dsseng
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, could you please consider these minor documentation fixups?
| | stm32h573i_dk | For building Trust Zone Disabled firmware for internal flash | | ||
| +-----------------------------------------+--------------------------------------------------------------+ | ||
| | stm32h573i_dk/stm32h573xx/ext_flash_app | For building Trust Zone Disabled firmware for external flash | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TrustZone is spelled without a space
| | stm32h573i_dk | For building Trust Zone Disabled firmware for internal flash | | |
| +-----------------------------------------+--------------------------------------------------------------+ | |
| | stm32h573i_dk/stm32h573xx/ext_flash_app | For building Trust Zone Disabled firmware for external flash | | |
| | stm32h573i_dk | For building firmware without TrustZone for internal flash | | |
| +-----------------------------------------+--------------------------------------------------------------+ | |
| | stm32h573i_dk/stm32h573xx/ext_flash_app | For building firmware without TrustZone for external flash | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with TrustZone disabled more accurate than without TrustZone
| Please note that, after having run a TFM sample on the board, you will need to | ||
| run ``./build/tfm/api_ns/regression.sh`` once more to clean up the board from secure | ||
| options and get back the platform back to a "normal" state and be able to run | ||
| usual, non-TFM, binaries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| usual, non-TFM, binaries. | |
| usual, Secure binaries without TF-M. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, as mentioned below, TZEN Option Byte is not reset by this script hence images not embedding TF-M won't be able to run.
etienne-lms
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many CI build test failures (if not all) are due to a GCC 11/GCC 12 issue triggered in STM32 HAL for this SoC. It's been addressed for STM32U5 in TF-M [1] first then solve in the STM32U5 HAL. The equivalent fix for STM32WBA65 was merged in TF-M [2] and should be addressed in the next release of STM32WBA65 HAL.
I see the issue needs to be addressed in TF-M also for STM32H573. It should be adressed in that SoC next HAL release but until then (and TF-M syncs on), it would need to be addressed in TF-M too, on the model of [1] and [2]. Do you want to post a change in TF-M mainline?
[1] TrustedFirmware-M/trusted-firmware-m@578a6f4
[2] TrustedFirmware-M/trusted-firmware-m@ec61e69
| .. code-block:: bash | ||
| $ west build -b stm32h573i_dk/stm32h573xx/ns samples/tfm_integration/tfm_ipc/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .. code-block:: bash | |
| $ west build -b stm32h573i_dk/stm32h573xx/ns samples/tfm_integration/tfm_ipc/ | |
| .. zephyr-app-commands:: | |
| :zephyr-app: samples/tfm_integration/tfm_ipc | |
| :board: stm32h573i_dk/stm32h573xx/ns | |
| :goals: build |
| $ west build -b stm32h573i_dk/stm32h573xx/ns samples/tfm_integration/tfm_ipc/ | ||
| Once done, before flashing, you need to first run a generated script that | ||
| will set platform option bytes config and erase platform (among others, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| will set platform option bytes config and erase platform (among others, | |
| will set platform Option Bytes config and erase platform (among others, |
| /* Keep in sync with partitions from flash_layout.h in TF-M */ | ||
| /* Scratch area 0000_0000 - 0000_C000 ( 48k) */ | ||
| /* MCUboot (anti-rollback counter) 0000_C000 - 0001_0000 ( 16k) */ | ||
| /* MCUboot 0001_0000 - 0002_8000 (160k) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /* MCUboot 0001_0000 - 0002_8000 (160k) */ | |
| /* MCUboot (BL2) 0001_0000 - 0002_8000 (96k) */ |
Alternatively, to be synced with the partition layout below the mentions 160kB for boot_partition partition:
* MCUBoot data (scratch area/counters) 0000_0000 - 0000_C000 ( 48k)
* MCUboot (BL2) and related resources 0001_0000 - 0002_8000 (160k)
I would rather suggest to update the boot_partition to cover all TF-M.BL2 related resources:
boot_partition: partition@0 {
label = "mcuboot";
reg = <0 DT_SIZE_K(224)>;
};There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I adjusted it to 192k, as Secure storage and Internal trusted storage partitions are used by TF-M and not mcuboot/BL2.
| #address-cells = <1>; | ||
| #size-cells = <1>; | ||
|
|
||
| /* Keep in sync with partitions from flash_layout.h in TF-M */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer comments like:
/* Keep in sync with partitions from flash_layout.h in TF-M
* Scratch area 0000_0000 - 0000_C000 ( 48k)
* MCUboot (anti-rollback counter) 0000_C000 - 0001_0000 ( 16k)
* (...)
*/| - arduino_gpio | ||
| - arduino_i2c | ||
| - arduino_serial | ||
| - arduino_spi | ||
| - gpio | ||
| - uart | ||
| - watchdog | ||
| - entropy | ||
| - dma | ||
| - adc | ||
| - dac | ||
| - netif:eth | ||
| - pwm | ||
| - counter | ||
| - spi | ||
| - octospi | ||
| - can | ||
| - i2c | ||
| - rtc | ||
| - usbd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tags are used by twister to test boards subsystems. It's not intended to be used on the ns variant, there are already tested on the main variant, so prefer remove them from this YAML file.
Maybe adding only the trusted-firmware-m tag here could be useful for covering related tests and samples.
| Please note that, after having run a TFM sample on the board, you will need to | ||
| run ``./build/tfm/api_ns/regression.sh`` once more to clean up the board from secure | ||
| options and get back the platform back to a "normal" state and be able to run | ||
| usual, non-TFM, binaries. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, as mentioned below, TZEN Option Byte is not reset by this script hence images not embedding TF-M won't be able to run.
| toolchain: | ||
| - zephyr | ||
| ram: 256 | ||
| flash: 2048 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| flash: 2048 | |
| ram: 192 | |
| flash: 576 |
TF-M is assigned the last 64kB of SRAM1, leaving only 192kB to Zephyr non-secure application.
The flash partition for Zephyr is 576kB, as defined in your "ns" variant DTS file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I also subtracted the 1kB for MCUboot header as in ext_flash_app.
| zephyr,code-partition = &slot0_ns_partition; | ||
| }; | ||
| }; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update here the SRAMs nodes since some are assigned to the secure world:
/* Last 64kB of SRAM1 are owned by TF-M */
&sram1 {
reg = <0x20000000 DT_SIZE_K(256 - 64)>;
};
/* SRAM2 is owned by TF-M */
&sram2 {
status = "disabled";
};
tests/net/socket/tcp/testcase.yaml
Outdated
| filter: CONFIG_FULL_LIBC_SUPPORTED | ||
| timeout: 180 | ||
| platform_exclude: | ||
| - stm32h573i_dk/stm32h573xx/ns # requires TF-M with BL2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing net and socket tags in the "ns" variant board YAML file will prevent from excluding this variant from all tests and samples where it can't be used, as here.
51131b4 to
f59334b
Compare
|
The following west manifest projects have changed revision in this Pull Request:
⛔ DNM label due to: 1 project with PR revision Note: This message is automatically posted and updated by the Manifest GitHub Action. |
f59334b to
1137c8e
Compare
90d39c1 to
4f3a8d1
Compare
| Please note that, after having run a TF-M sample on the board, you will need to | ||
| use STM32CubeProgrammer_ to return the board to a non-secure state and be able to | ||
| run usual, non-secure binaries without TF-M. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, binaries without TF-M should run in Secure, unless the SoC bootrom does something very special. @tpambor @etienne-lms please correct me if this SoC does something special and the usual binaries would start in ns by default
| run usual, non-secure binaries without TF-M. | |
| run usual binaries without TrustZone and TF-M. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dsseng Yes, you are right. I will correct this.
| +-----------------------------------------+------------------------------------------------------------------+ | ||
| | stm32h573i_dk/stm32h573xx/ext_flash_app | For building firmware with TrustZone disabled for external flash | | ||
| +-----------------------------------------+------------------------------------------------------------------+ | ||
| | stm32h573i_dk/stm32h573xx/ns | For building Non-Secure firmware for internal flash | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the description here maybe suggest it'll be merged with the TF-M as the secure image?
Add support for building Trusted Firmware-M (TF-M) non-secure applications for the STM32H573I-DK board. Signed-off-by: Tim Pambor <[email protected]>
4f3a8d1 to
377cff2
Compare
|



Add support for building Trusted Firmware-M (TF-M) non-secure applications for the STM32H573I-DK board.