-
Notifications
You must be signed in to change notification settings - Fork 84
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
feat(PeriphDrivers): Add Basic MAX32657 PeriphDriver Support #1005
Conversation
@ozersa @ttmut @lorne-maxim @sihyung-maxim FYI. See current status above |
- Target secure memory regions by default (CPU boots into secure mode by default) - Update memory layout and sizes - Remove dual-core/shared/mailbox (single-core device)
- Add MSECURITY_MODE build configuration variable - Defines MSECURITY_MODE_SECURE/MSECURITY_MODE_NONSECURE at compile time
@sihyung-maxim @lorne-maxim @ozersa @ttmut some updates below. 5/1/2024I've updated the ME30 linker script (1978725) and added a basic build mechanism for selecting between secure/non-secure builds (6f19ec6). The M33 will boot/reset into secure mode, so I've made it the default. Additionally, access to the Flash controller is only possible in secure mode. This allows the top-level max32657.h file to map the addresses to the correct aliases at build time (ex for UART: 9f7bbfe). I think that this solves the issue of building completely secure vs non-secure binaries. Please comment on the approach before I apply it to the rest of the peripherals. Security Mode TransitionsConceptually it is also possible to switch between the two modes at run-time. However, if we link the entire application into the secure address mappings then I don't think it is possible to transition. Even if we call a
Conceptually, I have the following questions now:
DMA ComplicationsAfter updating the DMA drivers to account for the ME30's dual instances (df0e566) there are some complications. Many DMA drivers do not expose the DMA instance as an argument at the top-level header. The bottom-level RevA/RevB files call these variations directly. Ex attempting to build AES: - CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/AES/aes_revb.c
/home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/AES/aes_revb.c: In function 'MXC_AES_RevB_TXDMAConfig':
/home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/AES/aes_revb.c:243:5: error: too few arguments to function 'MXC_DMA_Init'
243 | MXC_DMA_Init(); On the ME30, DMA1 is a secure DMA with access to the secure space, and DMA0 is a non-secure instance. If a completely secure image is built, DMA0 will be useless. So - should we treat the ME30 as if it has a single DMA instance, and assign DMA1/DMA0 based on secure vs non-secure builds? |
I'm still working on my side of the updates, but to answer your DMA question: Yeah, I think we should. We still need to define separate names for the DMAs in the registers: for example, GCR_PCLKDISn and _RSTn registers has fields representing each DMA instance. Maybe a better name for the two DMA instances are: In max32657.h:
Also, I've been meaning to implement this name change for newer parts, but we can rename the DMA vector names to something more accurate.
The channel number wouldn't be where you would expect the DMA instance number to be. What do we think? |
@sihyung-maxim I think this solution of mapping onto secure/non-secure base address based on the build value makes sense and would work well. I'm reading more about TrustZone and the SAU/MPCs/PPCs and it sounds like we can partition the memory spaces and security attributes for each peripheral individually at startup. The standard way to do things is to build secure applications separately (first), then compile and link in the non-secure image into the same binary afterwards. So I'm working on a mechanism now for that similar to what we've done with the dual-core micros. The secure image will be responsible for initializing the security attributes for each peripheral on startup. Then the non-secure image will be appended onto the secure image's SRAM/Flash using the non-secure address aliases. This will turn the ME30 projects into dual-project workspaces for the most-part, but seems to be the standard approach. So this works well.
Having the channel is good. I think having the instance in there is also needed. I went with this for the header file atm: DMA0_CH0_IRQn, /* 0x20 0x0080 32: DMA0 Channel 0 */
DMA0_CH1_IRQn, /* 0x21 0x0084 33: DMA0 Channel 1 */
DMA0_CH2_IRQn, /* 0x22 0x0088 34: DMA0 Channel 2 */
DMA0_CH3_IRQn, /* 0x23 0x008C 35: DMA0 Channel 3 */
DMA1_CH0_IRQn, /* 0x24 0x0090 36: DMA1 Channel 0 */
DMA1_CH1_IRQn, /* 0x25 0x0094 37: DMA1 Channel 1 */
DMA1_CH2_IRQn, /* 0x26 0x0098 38: DMA1 CHannel 2 */
DMA1_CH3_IRQn, /* 0x27 0x009C 39: DMA1 Channel 3 */ |
@sihyung-maxim there is also the concept of secure vs non-secure interrupts. We will need to add some additional NVIC entries with a secure/non-secure offset |
This reverts commit df0e566.
- Add <arm_cmse.h> to max32657.h - Define "IS_SECURE_ENVIRONMENT" that uses GCC-provided definitions instead of our custom build-time one. Usage: #if IS_SECURE_ENVIRONMENT ... #endif
- SIR - FCR - WDT - SVM - BOOST - TRIMSIR - RTC - WUT - PWRSEQ - MCR - AES - CRC - TMR - I3C - SPI - TRNG - BTLE
5/2/2024I updated the system for building secure/non-secure images to use the built-in As long as #if IS_SECURE_ENVIRONMENT
// ...
#endif I used the macro to update the peripheral base address aliases for all peripherals we currently have definitions for. Initial PeriphDriver BuildClean PeriphDriver/Hello World build! This build puts everything into the secure address mappings. ~/repos/msdk/Examples/MAX32657/Hello_World (feat/ME30-PeriphDrivers*) » make jhcarter@jhcarter-X670E
Loaded project.mk
****************************************************************************
* Analog Devices MSDK
* v2024_02-109-g4c9522a5ec
* - User Guide: https://analogdevicesinc.github.io/msdk/USERGUIDE/
* - Get Support: https://www.analog.com/support/technical-support.html
* - Report Issues: https://github.com/analogdevicesinc/msdk/issues
* - Contributing: https://analogdevicesinc.github.io/msdk/CONTRIBUTING/
****************************************************************************
- MKDIR /home/jhcarter/repos/msdk/Examples/MAX32657/Hello_World/build
make[1]: Entering directory '/home/jhcarter/repos/msdk/Examples/MAX32657/Hello_World'
- MKDIR /home/jhcarter/repos/msdk/Libraries/PeriphDrivers/bin/MAX32657/spi-v1_softfp
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/SYS/mxc_assert.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/SYS/mxc_delay.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/SYS/mxc_lock.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/SYS/sys_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/SYS/pins_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/AES/aes_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/AES/aes_revb.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/CRC/crc_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/CRC/crc_reva.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/DMA/dma_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/DMA/dma_reva.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/FLC/flc_common.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/FLC/flc_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/FLC/flc_reva.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/GPIO/gpio_common.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/GPIO/gpio_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/GPIO/gpio_reva.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/ICC/icc_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/ICC/icc_reva.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/RTC/rtc_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/RTC/rtc_reva.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/SPI/spi_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/SPI/spi_reva1.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/TMR/tmr_common.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/TMR/tmr_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/TMR/tmr_revb.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/TRNG/trng_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/TRNG/trng_revb.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/UART/uart_common.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/UART/uart_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/UART/uart_reva.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/WDT/wdt_common.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/WDT/wdt_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/WDT/wdt_reva.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/WUT/wut_me30.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/../PeriphDrivers/Source/WUT/wut_reva.c
- AR /home/jhcarter/repos/msdk/Libraries/PeriphDrivers/bin/MAX32657/spi-v1_softfp/libPeriphDriver_spi-v1_softfp.a
make[1]: Leaving directory '/home/jhcarter/repos/msdk/Examples/MAX32657/Hello_World'
- CC main.c
- CC /home/jhcarter/repos/msdk/Libraries/Boards/MAX32657/EvKit_V1/Source/board.c
- CC /home/jhcarter/repos/msdk/Libraries/MiscDrivers/stdio.c
- CC /home/jhcarter/repos/msdk/Libraries/MiscDrivers/LED/led.c
- CC /home/jhcarter/repos/msdk/Libraries/MiscDrivers/PushButton/pb.c
- AS /home/jhcarter/repos/msdk/Libraries/CMSIS/Device/Maxim/MAX32657/Source/GCC/startup_max32657.S
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/Device/Maxim/MAX32657/Source/heap.c
- CC /home/jhcarter/repos/msdk/Libraries/CMSIS/Device/Maxim/MAX32657/Source/system_max32657.c
- LD /home/jhcarter/repos/msdk/Examples/MAX32657/Hello_World/build/max32657.elf
arm-none-eabi-size --format=berkeley /home/jhcarter/repos/msdk/Examples/MAX32657/Hello_World/build/max32657.elf
text data bss dec hex filename
34156 2500 280 36936 9048 /home/jhcarter/repos/msdk/Examples/MAX32657/Hello_World/build/max32657.elf I will start working on the dual-project build system and more advanced linkerfiles now. |
feat(CMSIS): Update MAX32657 CMSIS with TrustZone support
Merged. The build system can specify secure (default) vs non-secure builds with the new
I recommend setting this in Note we still need to check/update pin definitions |
Description
This PR will add basic PeriphDriver support for the ME30. We are targeting a clean build. Functional testing/fixes are beyond the scope of this PR.
I've added a MAX32657 Hello World as an initial build point.
Status:
mxc_sys.h