Skip to content

[RFC] Add stm32wba65i support (port from TF-M 2.2.0 integration) #133

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

etienne-lms
Copy link

This P-R add support for STM32WBA65I chip toruhg platform stm32wba65i_dk based on its integration in mainline TF-M main branch, merged after release tag TFMv2.2.0.

This P-R is picks the TF-M commits related to stm32wba65i_dk implementation and adds some minor fixes for integration in Zephyr TF-M v2.1.2 branch.

With this P-R and few changes in Zephyr repo (P-R to come), platform stm32wba65i_dk passes TF-M tests
- samples/tfm_integration/psa_crypto
- samples/tfm_integration/psa_protected_storage
- samples/tfm_integration/tfm_ipc
- samples/tfm_integration/tfm_regression_test
- samples/tfm_integration/tfm_secure_partition
- tests/subsys/secure_storage/psa/crypto
- tests/subsys/secure_storage/psa/its (with CONFIG_TFM_ITS_MAX_ASSET_SIZE_OVERRIDE=y and CONFIG_TFM_ITS_MAX_ASSET_SIZE=256)

RcColes and others added 12 commits May 14, 2025 08:27
Change-Id: I649c95af347fbb1686a00ebebb8e6a2f0cec7758
Signed-off-by: Ahmad EL JOUAID <[email protected]>
(cherry-picked from commit c6c2511)
Pick changes related to platform STM32WBA65I-DK from commit
49c814c ("Platform: STM32") to correct the platform configuration
directives.

Signed-off-by: Ahmad EL JOUAID <[email protected]>
Signed-off-by: Etienne Carriere <[email protected]>
Change-Id: I15759c26464628b2e0e0f6bebd24d3176a646666
Signed-off-by: Ahmad EL JOUAID <[email protected]>
(cherry picked from commit 5e70372)
Change-Id: I5e9194fb41112aa38f88c5de03f7ad141a0cdf27
Signed-off-by: Ahmad EL JOUAID <[email protected]>
(cherry picked from commit 1930dcd)
… flash_layout.h

Fix flash secure watermark start and end address to cover flash bank1
begin range belonging to secure world: 96kByte of possible boot stage,
48KByte of TF-M persistent data (OTP/NVCNT+PS+ITS) and 384kByte of
TF-M secure firmware: total of 528kByte, sector 0 (0x00) to 66 (0x41):
SECWM1_PSTRT=0x0 SECWM1_PEND=0x41.

Change-Id: Ic4651000ac3c22f54f329d0e0aebb41ffb839b34
Signed-off-by: Ronan Gabou <[email protected]>
(cherry picked from d985df0)
Re-names platform folder from stm32wba65i-dk to stm32wba65i_dk to align
closer to other platforms.

Change-Id: I7f14ea5be18a97031bf2f6f776bbdf2e2adeab8e
Signed-off-by: Matthew Dalzell <[email protected]>
(cherry picked from commit 3d93882)
Remove platform_bl2 compile definition duplicates and keep only
the one conditioned with BL2 being enable to fix build error
when BL2 is disabled as when, for example, building for STM32WBA65-DK
platform:

CMake Error at platform/ext/accelerator/stm/CMakeLists.txt:16 (target_compile_definitions):
  Cannot specify compile definitions for target "platform_bl2" which is not
  built by this project.

Signed-off-by: Etienne Carriere <[email protected]>
Make local function DMA_List_CheckNodesBaseAddresses() neve inline.
This fixes a build issue faced with with STM32WBAXX DMA HAL when building
TF-M for regression tests with GCC11 and GCC12 compilers with optimization
directives. The build issue is not very explicit, as reported by the
build error trace message below:

during GIMPLE pass: evrp
.../build/tfm/api_ns/platform/hal/Src/stm32wbaxx_hal_dma_ex.c: In function 'HAL_DMAEx_List_ReplaceNode_Head':
.../build/tfm/api_ns/platform/hal/Src/stm32wbaxx_hal_dma_ex.c:4350:1: internal compiler error: Segmentation fault
 4350 | }
      | ^
0x74708724251f ???
	./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x747087229d8f __libc_start_call_main
	../sysdeps/nptl/libc_start_call_main.h:58
0x747087229e3f __libc_start_main_impl
	../csu/libc-start.c:392
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://github.com/zephyrproject-rtos/sdk-ng/issues> for instructions.

This fix has been previously applied to the equivalent HAL driver
of stm32u5 platforms, see commit 2f13847 ("stm32u5 hal dma_ex
function not inlined with GCC 11 or 12").

Signed-off-by: Etienne Carriere <[email protected]>
Fix build warnings due to unused variables in a few C source files
for platform stm32wba65i_dk.

Signed-off-by: Etienne Carriere <[email protected]>
Remove duplicated macro definitions to prevent build warnings
in target platform stm32wba65i_dk.

Signed-off-by: Etienne Carriere <[email protected]>
Update the incline description comments in stm32wba65_dk flash_layout.h
according to recent changes in the flash areas offset definitions.

Signed-off-by: Etienne Carriere <[email protected]>
Disable STM32WBA65I MPU prior its configuration to not be
dependent on prior boot stage configuration.

This fixes a issue when TF-M isolation level above 1.

Signed-off-by: Etienne Carriere <[email protected]>
@etienne-lms
Copy link
Author

I've added a commit to fix an issue related to MPU configuration. This fix will be submitted to mainline TF-M.

@tomi-font
Copy link
Collaborator

Hey. You'll need to submit a manifest PR in Zephyr updating the trusted-firmware-m revision in order to get attention on this and eventually get this integrated into Zephyr.

@etienne-lms
Copy link
Author

Thank @tomi-font for the notice. I lately created a P-R in Zephyr related to this change:
zephyrproject-rtos/zephyr#90162

Copy link
Collaborator

@tomi-font tomi-font left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some commits don't seem to be cherry picks from upstream. In this repo we really only want to do cherry picks, so please make sure to submit all the changes upstream first, and ideally they should be merged upstream before being cherry picked here.
Also, it looks like Platform: STM32WBA: correct platform configuration is a partial, edited cherry pick? I think it's also better to avoid those unless there's a huuge list of other commits that would need to be cherry picked to avoid conflicts.

@etienne-lms
Copy link
Author

Upstream of the fixes are on-going in TF-M. I hope we'll be able to post them ASAP.

FYI there are a few other changes i'd like to see at upstream and in Zephyr TF-M but I did not add them in this series. Indeed, I prefer to wait they're acked in TF-M before. In this series I've only added new changes that were required for the TF-M 2.1.x branch to support STM32WBA65I (build warnings/errors + MPU fix). That said most of them also apply to 2.2.x, I agree they need to be addressed at upstream also.

Regarding the partial commit, the original one contains things related to 2.2.x branch, I don't think they apply on 2.1.x which Zephyr is based on.

@tomi-font
Copy link
Collaborator

We already have commits cherry picked from the upstream main branch, which is 2.2.x at the moment. It's no problem at all to cherry pick from there, there is only some risk for conflicts but those can usually be resolved by also cherry picking the needed commits.
So basically you should only need to submit the changes upstream to the main branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants