Conversation
6ef93be to
8d73e10
Compare
Adds initial support for the Global TrustZone Controller (GTZC) and
Security Attribution Unit (SAU) on STM32 families with TrustZone:
- WBA (gtzc_wba): TZSC + MPCBB + TZIC
- U5/H5 (gtzc_v1): TZSC + MPCBB + TZIC + MPCWM (watermarks via PAC)
- H503/L5: module stub, PAC sub-peripherals differ from wba/v1
embassy-stm32/src/gtzc/mod.rs:
- `Mpcbb`: wraps pac::gtzc::Mpcbb; per-block and bulk secure/priv ops,
raw bitmap read/write, global lock
- `Tzic`: wraps pac::gtzc::Tzic; enable/clear/status per register group,
convenience `enable_all(n_regs)`
- `lock()` / `is_locked()`: lock TZSC config (cfg-gated per variant)
embassy-stm32/src/sau/mod.rs:
- `init(&[Region])`: programs up to 8 SAU regions, enables SAU and
SecureFault via the cortex-m peripheral API
- `disable()`: clears SAU enable bit
examples/stm32wba6/src/bin/trustzone_setup.rs:
- End-to-end example: SAU regions → MPCBB1/MPCBB2 → TZSC seccfgr →
TZIC enable → lock
Both gtzc and sau modules compile cleanly for stm32wba65ri (gtzc_wba)
and stm32u585ai (gtzc_v1).
8d73e10 to
c1a771c
Compare
|
I'm going through the code and I realize it might be better to add some of these registers to |
1010f74 to
2c4ee84
Compare
|
Two functions in the SAU driver — |
1b6ea29 to
555e80b
Compare
…S boot - sau: add route_irq_to_nonsecure, enable_nonsecure_fpu, jump_to_nonsecure Raw register access used for NVIC ITNS (0xE000_E380) and SCB NSACR (0xE000_ED8C) pending cortex-m PR embassy-rs#647; TODO comments reference the PR. Fix disable() to set ALLNS=1 (was incorrectly writing 0). Fix doc example addresses to match WBA65RI memory map. - gtzc: add enable_clock, MPCBB superblock locking, srwiladis, invsecstate - trustzone_setup: rewrite example with correct WBA65RI addresses and all steps - Cargo.toml: patch cortex-m to leftger/cortex-m feat/trustzone for FPU.fpccr
555e80b to
94d5aff
Compare
|
The SAU and SCB stuff can partially already be achieved within cortex-m. I would remove it here. Any functionality missing in cortex-m should be added there. I am not familiar with how STM does their own trustzone bus peripherals, but generally in MCUs they are very similar in diversity to how clock trees are arranged. Mostly they consist of a list of all memories (in sections) and peripherals, and you can configure bus access permissions for those. Hence for each SKU with a different set of peripherals, these bus-configuration blocks are unique. If no one else has time or affinity with Trustzone I can take a look whether the arrangement makes sense. |
|
I have PR#647 and PR#648 in the pipeline to address your comments @Wassasin. I'll give it a week for the maintainers to look over it. I'm not in a huge rush to get this through but I'd like to iterate on TrustZone by the end of the month. In the worst case I can have the manual register manipulation here as a placeholder and we can always remove it once |
Adds initial support for the Global TrustZone Controller (GTZC) and Security Attribution Unit (SAU) on STM32 families with TrustZone:
embassy-stm32/src/gtzc/mod.rs:
Mpcbb: wraps pac::gtzc::Mpcbb; per-block and bulk secure/priv ops, raw bitmap read/write, global lockTzic: wraps pac::gtzc::Tzic; enable/clear/status per register group, convenienceenable_all(n_regs)lock()/is_locked(): lock TZSC config (cfg-gated per variant)embassy-stm32/src/sau/mod.rs:
init(&[Region]): programs up to 8 SAU regions, enables SAU and SecureFault via the cortex-m peripheral APIdisable(): clears SAU enable bitexamples/stm32wba6/src/bin/trustzone_setup.rs:
Both gtzc and sau modules compile cleanly for stm32wba65ri (gtzc_wba) and stm32u585ai (gtzc_v1).