analogdevicesinc / msdk

Software Development Kit for Analog Device's MAX-series microcontrollers
Apache License 2.0
61 stars 81 forks source link

feat(CMSIS): Update MAX32657 CMSIS with TrustZone support #1008

Closed sihyung-maxim closed 4 months ago

sihyung-maxim commented 5 months ago

Description

Some updates to the CMSIS for Verification.

Both DMA0 and DMA1 need to be defined, so we can't use the single MXC_DMA instance anymore.

  1. DMA0 has a secure and non-secure mapping - accessible for secure and non-secure builds. However, DMA0 can not access secure memory or secure peripherals.
  2. DMA1 only has a secure mapping - accessible for secure builds. But DMA1 can access both secure or non-secure memory and peripherals.

I'll have a separate PR for the remaining SYS register updates that I need to make.

Edit: Removing multiple linkers comment, just saw your changes @Jake-Carter. But I don't think we need multiple vector table definitions and startup_max32657.S startup code.

We can have one vector table defined that includes all secure and non-secure handlers, and we can dynamically switch between secure and non-secure vector tables during startup process using the SCB->VTOR vector table offset register. The SCB->VTOR register is banked into two parts, and the appropriate offset for secure and non-secure is used depending on the security context. We can also explicitly label the secure-only interrupts with the _S names, and include a build warning/error if the non-secure application references a secure handler.

The secure vector table is set up in SystemInit() called from Reset_Handler on startup. We'd have to figure out a mechanism for non-secure builds (non-secure reset handler) to set up the non-secure vector table (using SCB->VTOR again). This is at least my current understanding of how we might go about this for our bare metal MSDK.

There's a lot to think about - but given our schedule and priorities, we can focus on handling the secure mode for now so verification can begin. These changes are geared towards finishing the Secure build system changes that you've made, and to prep the non-secure builds for down the road.

Checklist Before Requesting Review