/**************************************************************************//** * @file nu_partition_M2354.h * @version V3.00 * @brief TrustZone partition file * * @copyright SPDX-License-Identifier: Apache-2.0 * @copyright Copyright (C) 2020 Nuvoton Technology Corp. All rights reserved. ******************************************************************************/ #ifndef PARTITION_M2354 #define PARTITION_M2354 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) /* Default M2354 pritition configuration file is for non-TrustZone sample code only. If user wants to use TrurstZone, they should have their partition_m2354.h. For TrustZone projects, path of local partition_m2354.h should be in the front of the include path list to make sure local partition_m2354.h is used. It also apply to non-secure project of the TrustZone projects. */ # error "Link to default nu_partition_M2354.h in secure mode. Please check your include path." #endif /* //-------- <<< Use Configuration Wizard in Context Menu >>> ----------------- */ /* SRAMNSSET */ /* // Bit 0..18 // Secure SRAM Size <0=> 0 KB // <0x4000=> 16KB // <0x8000=> 32KB // <0xc000=> 48KB // <0x10000=> 64KB // <0x14000=> 80KB // <0x18000=> 96KB // <0x1C000=> 112KB // <0x20000=> 128KB // <0x24000=> 144KB // <0x28000=> 160KB // <0x2C000=> 176KB // <0x30000=> 192KB // <0x34000=> 208KB // <0x38000=> 224KB // <0x3C000=> 240KB // <0x40000=> 256KB */ #define SCU_SECURE_SRAM_SIZE 0x18000 #define NON_SECURE_SRAM_BASE (0x30000000 + SCU_SECURE_SRAM_SIZE) /*--------------------------------------------------------------------------------------------------------*/ /* NSBA */ #define FMC_INIT_NSBA 1 /* // Secure Flash ROM Size <0x800-0x80000:0x800> */ #define FMC_SECURE_ROM_SIZE 0x80000 #define FMC_NON_SECURE_BASE (0x10000000 + FMC_SECURE_ROM_SIZE) /*--------------------------------------------------------------------------------------------------------*/ /* // Peripheral Secure Attribution Configuration */ /* PNSSET0 */ /* // Module 0..31 // USBH <0=> Secure <1=> Non-Secure // SD0 <0=> Secure <1=> Non-Secure // EBI <0=> Secure <1=> Non-Secure // PDMA1 <0=> Secure <1=> Non-Secure */ #define SCU_INIT_PNSSET0_VAL 0x0 /* PNSSET1 */ /* // Module 0..31 // CRC <0=> Secure <1=> Non-Secure // CRPT <0=> Secure <1=> Non-Secure */ #define SCU_INIT_PNSSET1_VAL 0x00000 /* PNSSET2 */ /* // Module 0..31 // EWDT <0=> Secure <1=> Non-Secure // EADC <0=> Secure <1=> Non-Secure // ACMP01 <0=> Secure <1=> Non-Secure // // DAC <0=> Secure <1=> Non-Secure // I2S0 <0=> Secure <1=> Non-Secure // OTG <0=> Secure <1=> Non-Secure // TIMER // TMR23 <0=> Secure <1=> Non-Secure // TMR45 <0=> Secure <1=> Non-Secure // EPWM // EPWM0 <0=> Secure <1=> Non-Secure // EPWM1 <0=> Secure <1=> Non-Secure // // BPWM // BPWM0 <0=> Secure <1=> Non-Secure // BPWM1 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_PNSSET2_VAL 0x0 /* PNSSET3 */ /* // Module 0..31 // SPI // QSPI0 <0=> Secure <1=> Non-Secure // SPI0 <0=> Secure <1=> Non-Secure // SPI1 <0=> Secure <1=> Non-Secure // SPI2 <0=> Secure <1=> Non-Secure // SPI3 <0=> Secure <1=> Non-Secure // // UART // UART0 <0=> Secure <1=> Non-Secure // UART1 <0=> Secure <1=> Non-Secure // UART2 <0=> Secure <1=> Non-Secure // UART3 <0=> Secure <1=> Non-Secure // UART4 <0=> Secure <1=> Non-Secure // UART5 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_PNSSET3_VAL 0x00000 /* PNSSET4 */ /* // Module 0..31 // I2C // I2C0 <0=> Secure <1=> Non-Secure // I2C1 <0=> Secure <1=> Non-Secure // I2C2 <0=> Secure <1=> Non-Secure // // Smart Card // SC0 <0=> Secure <1=> Non-Secure // SC1 <0=> Secure <1=> Non-Secure // SC2 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_PNSSET4_VAL 0x0 /* PNSSET5 */ /* // Module 0..31 // CAN0 <0=> Secure <1=> Non-Secure // QEI // QEI0 <0=> Secure <1=> Non-Secure // QEI1 <0=> Secure <1=> Non-Secure // // ECAP // ECAP0 <0=> Secure <1=> Non-Secure // ECAP1 <0=> Secure <1=> Non-Secure // // TRNG <0=> Secure <1=> Non-Secure // LCD <0=> Secure <1=> Non-Secure */ #define SCU_INIT_PNSSET5_VAL 0x0 /* PNSSET6 */ /* // Module 0..31 // USBD <0=> Secure <1=> Non-Secure // USCI // USCI0 <0=> Secure <1=> Non-Secure // USCI1 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_PNSSET6_VAL 0x0 /* // */ /* // GPIO Secure Attribution Configuration */ /* IONSSET */ /* // Bit 0..31 // PA // PA0 <0=> Secure <1=> Non-Secure // PA1 <0=> Secure <1=> Non-Secure // PA2 <0=> Secure <1=> Non-Secure // PA3 <0=> Secure <1=> Non-Secure // PA4 <0=> Secure <1=> Non-Secure // PA5 <0=> Secure <1=> Non-Secure // PA6 <0=> Secure <1=> Non-Secure // PA7 <0=> Secure <1=> Non-Secure // PA8 <0=> Secure <1=> Non-Secure // PA9 <0=> Secure <1=> Non-Secure // PA10 <0=> Secure <1=> Non-Secure // PA11 <0=> Secure <1=> Non-Secure // PA12 <0=> Secure <1=> Non-Secure // PA13 <0=> Secure <1=> Non-Secure // PA14 <0=> Secure <1=> Non-Secure // PA15 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_IONSSET0_VAL 0x00000000 /* // Bit 0..31 // PB // PB0 <0=> Secure <1=> Non-Secure // PB1 <0=> Secure <1=> Non-Secure // PB2 <0=> Secure <1=> Non-Secure // PB3 <0=> Secure <1=> Non-Secure // PB4 <0=> Secure <1=> Non-Secure // PB5 <0=> Secure <1=> Non-Secure // PB6 <0=> Secure <1=> Non-Secure // PB7 <0=> Secure <1=> Non-Secure // PB8 <0=> Secure <1=> Non-Secure // PB9 <0=> Secure <1=> Non-Secure // PB10 <0=> Secure <1=> Non-Secure // PB11 <0=> Secure <1=> Non-Secure // PB12 <0=> Secure <1=> Non-Secure // PB13 <0=> Secure <1=> Non-Secure // PB14 <0=> Secure <1=> Non-Secure // PB15 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_IONSSET1_VAL 0x00000000 /* // Bit 0..31 // PC // PC0 <0=> Secure <1=> Non-Secure // PC1 <0=> Secure <1=> Non-Secure // PC2 <0=> Secure <1=> Non-Secure // PC3 <0=> Secure <1=> Non-Secure // PC4 <0=> Secure <1=> Non-Secure // PC5 <0=> Secure <1=> Non-Secure // PC6 <0=> Secure <1=> Non-Secure // PC7 <0=> Secure <1=> Non-Secure // PC8 <0=> Secure <1=> Non-Secure // PC9 <0=> Secure <1=> Non-Secure // PC10 <0=> Secure <1=> Non-Secure // PC11 <0=> Secure <1=> Non-Secure // PC12 <0=> Secure <1=> Non-Secure // PC13 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_IONSSET2_VAL 0x00000000 /* // Bit 0..31 // PD // PD0 <0=> Secure <1=> Non-Secure // PD1 <0=> Secure <1=> Non-Secure // PD2 <0=> Secure <1=> Non-Secure // PD3 <0=> Secure <1=> Non-Secure // PD4 <0=> Secure <1=> Non-Secure // PD5 <0=> Secure <1=> Non-Secure // PD6 <0=> Secure <1=> Non-Secure // PD7 <0=> Secure <1=> Non-Secure // PD8 <0=> Secure <1=> Non-Secure // PD9 <0=> Secure <1=> Non-Secure // PD10 <0=> Secure <1=> Non-Secure // PD11 <0=> Secure <1=> Non-Secure // PD12 <0=> Secure <1=> Non-Secure // PD14 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_IONSSET3_VAL 0x00000000 /* // Bit 0..31 // PE // PE0 <0=> Secure <1=> Non-Secure // PE1 <0=> Secure <1=> Non-Secure // PE2 <0=> Secure <1=> Non-Secure // PE3 <0=> Secure <1=> Non-Secure // PE4 <0=> Secure <1=> Non-Secure // PE5 <0=> Secure <1=> Non-Secure // PE6 <0=> Secure <1=> Non-Secure // PE7 <0=> Secure <1=> Non-Secure // PE8 <0=> Secure <1=> Non-Secure // PE9 <0=> Secure <1=> Non-Secure // PE10 <0=> Secure <1=> Non-Secure // PE11 <0=> Secure <1=> Non-Secure // PE12 <0=> Secure <1=> Non-Secure // PE13 <0=> Secure <1=> Non-Secure // PE14 <0=> Secure <1=> Non-Secure // PE15 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_IONSSET4_VAL 0x00000000 /* // Bit 0..31 // PF // PF0 <0=> Secure <1=> Non-Secure // PF1 <0=> Secure <1=> Non-Secure // PF2 <0=> Secure <1=> Non-Secure // PF3 <0=> Secure <1=> Non-Secure // PF4 <0=> Secure <1=> Non-Secure // PF5 <0=> Secure <1=> Non-Secure // PF6 <0=> Secure <1=> Non-Secure // PF7 <0=> Secure <1=> Non-Secure // PF8 <0=> Secure <1=> Non-Secure // PF9 <0=> Secure <1=> Non-Secure // PF10 <0=> Secure <1=> Non-Secure // PF11 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_IONSSET5_VAL 0x00000000 /* // Bit 0..31 // PG // PG2 <0=> Secure <1=> Non-Secure // PG3 <0=> Secure <1=> Non-Secure // PG4 <0=> Secure <1=> Non-Secure // PG9 <0=> Secure <1=> Non-Secure // PG10 <0=> Secure <1=> Non-Secure // PG11 <0=> Secure <1=> Non-Secure // PG12 <0=> Secure <1=> Non-Secure // PG13 <0=> Secure <1=> Non-Secure // PG14 <0=> Secure <1=> Non-Secure // PG15 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_IONSSET6_VAL 0x00000000 /* // Bit 0..31 // PH // PH4 <0=> Secure <1=> Non-Secure // PH5 <0=> Secure <1=> Non-Secure // PH6 <0=> Secure <1=> Non-Secure // PH7 <0=> Secure <1=> Non-Secure // PH8 <0=> Secure <1=> Non-Secure // PH9 <0=> Secure <1=> Non-Secure // PH10 <0=> Secure <1=> Non-Secure // PH11 <0=> Secure <1=> Non-Secure // */ #define SCU_INIT_IONSSET7_VAL 0x00000000 /* // */ /* // Assign GPIO Interrupt to Secure or Non-secure Vector */ /* Initialize GPIO ITNS (Interrupts 0..31) */ /* // Bit 0..31 // GPA <0=> Secure <1=> Non-Secure // GPB <0=> Secure <1=> Non-Secure // GPC <0=> Secure <1=> Non-Secure // GPD <0=> Secure <1=> Non-Secure // GPE <0=> Secure <1=> Non-Secure // GPF <0=> Secure <1=> Non-Secure // GPG <0=> Secure <1=> Non-Secure // GPH <0=> Secure <1=> Non-Secure // EINT0 <0=> Secure <1=> Non-Secure // EINT1 <0=> Secure <1=> Non-Secure // EINT2 <0=> Secure <1=> Non-Secure // EINT3 <0=> Secure <1=> Non-Secure // EINT4 <0=> Secure <1=> Non-Secure // EINT5 <0=> Secure <1=> Non-Secure // EINT6 <0=> Secure <1=> Non-Secure // EINT7 <0=> Secure <1=> Non-Secure */ #define SCU_INIT_IONSSET_VAL 0x0000 /* // */ /* ---------------------------------------------------------------------------------------------------- */ /* // Secure Attribute Unit (SAU) Control */ #define SAU_INIT_CTRL 0 /* // Enable SAU // To enable Secure Attribute Unit (SAU). */ #define SAU_INIT_CTRL_ENABLE 1 /* // All Memory Attribute When SAU is disabled // <0=> All Memory is Secure // <1=> All Memory is Non-Secure // To set the ALLNS bit in SAU CTRL. // When all Memory is Non-Secure (ALLNS is 1), IDAU can override memory map configuration. */ #define SAU_INIT_CTRL_ALLNS 0 /* // */ /* // Enable and Set Secure/Non-Secure region */ #define SAU_REGIONS_MAX 8 /* Max. number of SAU regions */ /* // SAU Region 0 // Setup SAU Region 0 */ #define SAU_INIT_REGION0 0 /* // Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START0 0x0003F000 /* start address of SAU region 0 */ /* // End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END0 0x0003FFFF /* end address of SAU region 0 */ /* // Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC0 1 /* // */ /* // SAU Region 1 // Setup SAU Region 1 */ #define SAU_INIT_REGION1 0 /* // Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START1 0x10040000 /* // End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END1 0x1007FFFF /* // Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC1 0 /* // */ /* // SAU Region 2 // Setup SAU Region 2 */ #define SAU_INIT_REGION2 0 /* // Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START2 0x2000F000 /* // End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END2 0x2000FFFF /* // Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC2 1 /* // */ /* // SAU Region 3 // Setup SAU Region 3 */ #define SAU_INIT_REGION3 0 /* // Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START3 0x3f000 /* // End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END3 0x3f7ff /* // Region is // <0=>Non-Secure // <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC3 1 /* // */ /* SAU Region 4 Setup SAU Region 4 */ #define SAU_INIT_REGION4 1 /* Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START4 FMC_NON_SECURE_BASE /* start address of SAU region 4 */ /* End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END4 0x1007FFFF /* end address of SAU region 4 */ /* Region is <0=>Non-Secure <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC4 0 /* */ /* SAU Region 5 Setup SAU Region 5 */ #define SAU_INIT_REGION5 1 /* Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START5 0x00807E00 /* End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END5 0x00807FFF /* Region is <0=>Non-Secure <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC5 1 /* */ /* SAU Region 6 Setup SAU Region 6 */ #define SAU_INIT_REGION6 1 /* Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START6 NON_SECURE_SRAM_BASE /* End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END6 0x30017FFF /* Region is <0=>Non-Secure <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC6 0 /* */ /* SAU Region 7 Setup SAU Region 7 */ #define SAU_INIT_REGION7 1 /* Start Address <0-0xFFFFFFE0> */ #define SAU_INIT_START7 0x50000000 /* End Address <0x1F-0xFFFFFFFF> */ #define SAU_INIT_END7 0x5FFFFFFF /* Region is <0=>Non-Secure <1=>Secure, Non-Secure Callable */ #define SAU_INIT_NSC7 0 /* */ /* // */ /* // Setup behavior of Sleep and Exception Handling */ #define SCB_CSR_AIRCR_INIT 1 /* // Deep Sleep can be enabled by // <0=>Secure and Non-Secure state // <1=>Secure state only // Value for SCB->CSR register bit DEEPSLEEPS */ #define SCB_CSR_DEEPSLEEPS_VAL 0 /* // System reset request accessible from // <0=> Secure and Non-Secure state // <1=> Secure state only // Value for SCB->AIRCR register bit SYSRESETREQS */ #define SCB_AIRCR_SYSRESETREQS_VAL 0 /* // Priority of Non-Secure exceptions is // <0=> Not altered // <1=> Lowered to 0x80-0xFF // Value for SCB->AIRCR register bit PRIS */ #define SCB_AIRCR_PRIS_VAL 0 /* Assign HardFault to be always secure for safe */ #define SCB_AIRCR_BFHFNMINS_VAL 0 /* // */ /* max 128 SAU regions. SAU regions are defined in partition.h */ #define SAU_INIT_REGION(n) \ SAU->RNR = (n & SAU_RNR_REGION_Msk); \ SAU->RBAR = (SAU_INIT_START##n & SAU_RBAR_BADDR_Msk); \ SAU->RLAR = (SAU_INIT_END##n & SAU_RLAR_LADDR_Msk) | \ ((SAU_INIT_NSC##n << SAU_RLAR_NSC_Pos) & SAU_RLAR_NSC_Msk) | 1U #endif /* PARTITION_M2354 */