Update repo
This commit is contained in:
+78
@@ -0,0 +1,78 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="boot_ex1_cpu1_cpu2_cm_secure_flash_cpu1"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
enableHexTool="True"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --define=_FLASH --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 " hexBuildOptions="--image --cmac="${PROJECT_ROOT}/boot_ex1_user_cmac_key.txt" --memwidth=16 --romwidth=16 "${PROJECT_ROOT}\boot_ex1_flash_hex_lnk_cpu1.cmd" --outfile "${BuildArtifactFileBaseName}.hex"" />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="link" path="../../../../../../libraries/boot_rom/f2838x/revA/rom_symbol_libs/cpu1/secureZoneCode/F2838xCPU1_SecureZoneCode_Symbols_fpu32.lib" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_cpu1_cpu2_cm_secure_flash_cpu1.c" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_flash_hex_lnk_cpu1.cmd" targetDirectory="" excludeFromBuild="True" />
|
||||
<file action="copy" path="../boot_ex1_user_cmac_key.txt" targetDirectory="" excludeFromBuild="True" />
|
||||
</project>
|
||||
<project
|
||||
name="boot_ex1_cpu1_cpu2_cm_secure_flash_cpu2"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
enableHexTool="True"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU2_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --define=_FLASH --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU2 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x100 --heap_size=0x200 " hexBuildOptions="--image --cmac="${PROJECT_ROOT}/boot_ex1_user_cmac_key.txt" --memwidth=16 --romwidth=16 "${PROJECT_ROOT}\boot_ex1_flash_hex_lnk_cpu2.cmd" --outfile "${BuildArtifactFileBaseName}.hex""/>
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu2.cmd" targetDirectory="" applicableConfigurations="CPU2_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="link" path="../../../../../../libraries/boot_rom/f2838x/revA/rom_symbol_libs/cpu2/secureZoneCode/F2838xCPU2_SecureZoneCode_Symbols_fpu32.lib" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_cpu1_cpu2_cm_secure_flash_cpu2.c" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_flash_hex_lnk_cpu2.cmd" targetDirectory="" excludeFromBuild="True" />
|
||||
<file action="copy" path="../boot_ex1_user_cmac_key.txt" targetDirectory="" excludeFromBuild="True" />
|
||||
</project>
|
||||
<project
|
||||
name="boot_ex1_cpu1_cpu2_cm_secure_flash_cm"
|
||||
device="Cortex M.TMS320F28388D"
|
||||
cgtVersion="20.2.7.LTS"
|
||||
products="C2000WARE"
|
||||
endianness="little"
|
||||
launchWizard="False"
|
||||
enableHexTool="True"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CM_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=DEBUG --float_support=none --define=_FLASH -mv7M4 -me --diag_warning=225 " linkerBuildOptions="--stack_size=512 --heap_size=1024 --library=libc.a " hexBuildOptions="--image --cmac="${PROJECT_ROOT}/boot_ex1_user_cmac_key.txt" --memwidth=8 --romwidth=8 "${PROJECT_ROOT}\boot_ex1_flash_hex_lnk_cm.cmd" --outfile "${BuildArtifactFileBaseName}.hex""/>
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib_cm/" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib_cm.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/cm.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/cm.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_secure_boot_lnk_cm.cmd" targetDirectory="" applicableConfigurations="CM_FLASH" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib_cm/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib_cm/ccs/Debug/driverlib_cm.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/startup_cm.c" targetDirectory="" />
|
||||
<file action="link" path="../../../../../../libraries/boot_rom/f2838x/revA/rom_symbol_libs/cm/secureZoneCode/F2838xCM_SecureZoneCode_Symbols.lib" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_cpu1_cpu2_cm_secure_flash_cm.c" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_secure_startup_cm.asm" targetDirectory="" />
|
||||
<file action="copy" path="../boot_ex1_flash_hex_lnk_cm.cmd" targetDirectory="" excludeFromBuild="True" />
|
||||
<file action="copy" path="../boot_ex1_user_cmac_key.txt" targetDirectory="" excludeFromBuild="True" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: boot_ex1_cpu1_cpu2_cm_secure_flash_cm.c
|
||||
//
|
||||
// TITLE: Secure Flash Boot Example
|
||||
//! <h1> CM Secure Flash Boot </h1>
|
||||
//!
|
||||
//! This example demonstrates how to use the secure flash boot mode for CM.
|
||||
//! (Requires CPU1 example application)
|
||||
//!
|
||||
//! Secure flash boot performs a CMAC authentication on the entry sector of
|
||||
//! flash upon device boot up. If authentication passes, the application will
|
||||
//! begin execution. Learn more on the secure flash boot mode in the device
|
||||
//! technical reference manual.
|
||||
//!
|
||||
//! This project shows how to use the C2000 HEX Utility to generate a CMAC Tag
|
||||
//! based on a user CMAC key and embed the value into the flash application.
|
||||
//! Additionally, the example details the method to call the CMAC API from
|
||||
//! the user application to calculate CMAC on other flash sectors beyond the
|
||||
//! the application entry flash sector.
|
||||
//!
|
||||
//! Determining Pass/Fail without debugger connected:
|
||||
//! CM - ControlCARD LED3.
|
||||
//! - LED off = Secure Boot failed
|
||||
//! - LED On (Solid) = Secure Boot Passed, Full Flash CMAC failed
|
||||
//! - LED Blinking = Secure Boot Passed and Full Flash CMAC passed
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - None.
|
||||
//!
|
||||
//!
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib_cm.h"
|
||||
#include "cm.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define DEVICE_GPIO_PIN_LED3 145U
|
||||
#define CMAC_AUTH_PASS 0UL
|
||||
#define CMAC_AUTH_START_ADDRESS 0x00200000UL
|
||||
#define CMAC_AUTH_END_ADDRESS 0x00280000UL
|
||||
#define CMAC_AUTH_TAG_ADDRESS 0x00204004UL
|
||||
|
||||
//
|
||||
// Structure required for CMAC symbol reserving in memory.
|
||||
// Required for performing CMAC on non-entry sector of flash.
|
||||
//
|
||||
// Read more in the Assembly Language Tools User's Guide
|
||||
//
|
||||
struct CMAC_TAG
|
||||
{
|
||||
uint8_t tag[16];
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
};
|
||||
|
||||
//
|
||||
// Create CMAC symbol for flash entry point 1 (0x00200000).
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_sb_1)
|
||||
#pragma LOCATION(cmac_sb_1, 0x00200004)
|
||||
const uint8_t cmac_sb_1[16] = { 0 };
|
||||
|
||||
//
|
||||
// Create CMAC symbol for full length flash authentication.
|
||||
// The start and end CMAC_TAG struct members are zero, therefore
|
||||
// the CMAC algorithm runs over entire memory region specified in
|
||||
// the HEX directive.
|
||||
//
|
||||
// Note that the location 0x00204004 can be set to anywhere as long
|
||||
// as it is within the specified CMAC authentication memory.
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_all)
|
||||
#pragma LOCATION(cmac_all, 0x00204004)
|
||||
const struct CMAC_TAG cmac_all = {{ 0 }, 0x0, 0x0};
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
uint32_t CMBROM_calculateCMAC(uint32_t startAddress,
|
||||
uint32_t endAddress,
|
||||
uint32_t tagAddress);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint32_t applicationCMACStatus = CMAC_AUTH_PASS;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
CM_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure the GPIO pin as a push-pull output
|
||||
//
|
||||
// This is configured by CPU1
|
||||
|
||||
//
|
||||
// Turn on LED3 to indicate CM has entered application
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED3, 1);
|
||||
|
||||
//
|
||||
// Call CMAC Authentication API to verify contents of all of
|
||||
// device flash.
|
||||
//
|
||||
// Upon failure, enter infinite loop.
|
||||
//
|
||||
applicationCMACStatus = CMBROM_calculateCMAC(CMAC_AUTH_START_ADDRESS,
|
||||
CMAC_AUTH_END_ADDRESS,
|
||||
CMAC_AUTH_TAG_ADDRESS);
|
||||
|
||||
if(CMAC_AUTH_PASS != applicationCMACStatus)
|
||||
{
|
||||
//
|
||||
// Application will get stuck here upon failure
|
||||
//
|
||||
while(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPC_setFlagLtoR(IPC_CM_L_CPU1_R, IPC_FLAG1);
|
||||
}
|
||||
|
||||
//
|
||||
// Loop Forever
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Turn on LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED3, 1);
|
||||
|
||||
//
|
||||
// Delay for 500000uS.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
|
||||
//
|
||||
// Turn off LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED3, 0);
|
||||
|
||||
//
|
||||
// Delay for 500000uS.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
+311
@@ -0,0 +1,311 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: boot_ex1_cpu1_cpu2_cm_secure_flash_cpu1.c
|
||||
//
|
||||
// TITLE: Secure Flash Boot Example
|
||||
//
|
||||
//! \addtogroup driver_example_list
|
||||
//! <h1> CPU1 Secure Flash Boot </h1>
|
||||
//!
|
||||
//! This example demonstrates how to use the secure flash boot mode for CPU1
|
||||
//! as well as release CPU2 and CM for secure flash boot.
|
||||
//!
|
||||
//! Secure flash boot performs a CMAC authentication on the entry sector of
|
||||
//! flash upon device boot up. If authentication passes, the application will
|
||||
//! begin execution. Learn more on the secure flash boot mode in the device
|
||||
//! technical reference manual.
|
||||
//!
|
||||
//! This project shows how to use the C2000 HEX Utility to generate a CMAC Tag
|
||||
//! based on a user CMAC key and embed the value into the flash application.
|
||||
//! Additionally, the example details the method to call the CMAC API from
|
||||
//! the user application to calculate CMAC on other flash sectors beyond the
|
||||
//! the application entry flash sector.
|
||||
//!
|
||||
//! How to Run:
|
||||
//! - Load application into CPU1 flash (as well as CPU2 and CM applications)
|
||||
//! - Disconnect and reconnect to only CPU1
|
||||
//! - In memory window, set address 0xD00/D01 to 0x5AFFFFFF and address 0xD04 to
|
||||
//! 0x000A (This sets emulation boot to secure flash boot)
|
||||
//! - Reset CPU1 via CCS and click resume
|
||||
//! - Observe the LEDs
|
||||
//!
|
||||
//! Determining Pass/Fail without debugger connected:
|
||||
//! \b CPU1 - ControlCARD LED1.
|
||||
//! - LED off = Secure Boot failed
|
||||
//! - LED On (Solid) = Secure Boot Passed, Full Flash CMAC failed
|
||||
//! - LED Blinking = Secure Boot Passed and Full Flash CMAC passed
|
||||
//! \b CPU2 - ControlCARD LED2.
|
||||
//! - LED off = Secure Boot failed
|
||||
//! - LED On (Solid) = Secure Boot Passed, Full Flash CMAC failed
|
||||
//! - LED Blinking = Secure Boot Passed and Full Flash CMAC passed
|
||||
//! \b CM - ControlCARD LED3.
|
||||
//! - LED off = Secure Boot failed
|
||||
//! - LED On (Solid) = Secure Boot Passed, Full Flash CMAC failed
|
||||
//! - LED Blinking = Secure Boot Passed and Full Flash CMAC passed
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - cpu1_SuccessfullyBooted - True when CPU1 full flash CMAC authentication
|
||||
//! passes. Otherwise, false.
|
||||
//! - cpu2_SuccessfullyBooted - True when CPU2 full flash CMAC authentication
|
||||
//! passes and CPU1 receives IPC. Otherwise, false.
|
||||
//! - cm_SuccessfullyBooted - True when CM full flash CMAC authentication
|
||||
//! passes and CPU1 receives IPC. Otherwise, false.
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define CMAC_AUTH_PASS 0UL
|
||||
#define CMAC_AUTH_START_ADDRESS 0x00080000UL
|
||||
#define CMAC_AUTH_END_ADDRESS 0x000C0000UL
|
||||
#define CMAC_AUTH_TAG_ADDRESS 0x00087002UL
|
||||
|
||||
//
|
||||
// Globals
|
||||
//
|
||||
bool cpu1_SuccessfullyBooted = false;
|
||||
bool cpu2_SuccessfullyBooted = false;
|
||||
bool cm_SuccessfullyBooted = false;
|
||||
|
||||
//
|
||||
// Structure required for CMAC symbol reserving in memory.
|
||||
// Required for performing CMAC on non-entry sector of flash.
|
||||
//
|
||||
// Read more in the Assembly Language Tools User's Guide
|
||||
//
|
||||
struct CMAC_TAG
|
||||
{
|
||||
char tag[8];
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
};
|
||||
|
||||
//
|
||||
// Create CMAC symbol for flash entry point 1 (0x80000).
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_sb_1)
|
||||
#pragma LOCATION(cmac_sb_1, 0x080002)
|
||||
const char cmac_sb_1[8] = { 0 };
|
||||
|
||||
//
|
||||
// Create CMAC symbol for full length flash authentication.
|
||||
// The start and end CMAC_TAG struct members are zero, therefore
|
||||
// the CMAC algorithm runs over entire memory region specified in
|
||||
// the HEX directive.
|
||||
//
|
||||
// Note that the location 0x087002 can be set to anywhere as long
|
||||
// as it is within the specified CMAC authentication memory.
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_all)
|
||||
#pragma LOCATION(cmac_all, 0x087002)
|
||||
const struct CMAC_TAG cmac_all = {{ 0 }, 0x0, 0x0};
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
uint32_t CPU1BROM_calculateCMAC(uint32_t startAddress,
|
||||
uint32_t endAddress,
|
||||
uint32_t tagAddress);
|
||||
__interrupt void appIPCHandler(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint32_t applicationCMACStatus = CMAC_AUTH_PASS;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure the GPIO pins as a push-pull output
|
||||
//
|
||||
Device_initGPIO();
|
||||
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED1, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED1, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED2, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED2, GPIO_DIR_MODE_OUT);
|
||||
GPIO_setPadConfig(DEVICE_GPIO_PIN_LED3, GPIO_PIN_TYPE_STD);
|
||||
GPIO_setDirectionMode(DEVICE_GPIO_PIN_LED3, GPIO_DIR_MODE_OUT);
|
||||
|
||||
//
|
||||
// Turn LEDS off and Allocate LED GPIOs to CPU2 and CM
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED3, 0);
|
||||
GPIO_setMasterCore(DEVICE_GPIO_PIN_LED2, GPIO_CORE_CPU2);
|
||||
GPIO_setMasterCore(DEVICE_GPIO_PIN_LED3, GPIO_CORE_CM);
|
||||
|
||||
//
|
||||
// Turn on LED1 to indicate CPU1 has entered application
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
|
||||
|
||||
//
|
||||
// Call CMAC Authentication API to verify contents of all of
|
||||
// device flash.
|
||||
//
|
||||
// Upon failure, enter infinite loop.
|
||||
//
|
||||
applicationCMACStatus = CPU1BROM_calculateCMAC(CMAC_AUTH_START_ADDRESS,
|
||||
CMAC_AUTH_END_ADDRESS,
|
||||
CMAC_AUTH_TAG_ADDRESS);
|
||||
|
||||
if(CMAC_AUTH_PASS != applicationCMACStatus)
|
||||
{
|
||||
//
|
||||
// Application will get stuck here upon failure
|
||||
//
|
||||
while(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cpu1_SuccessfullyBooted = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Secure Boot CPU2 core
|
||||
//
|
||||
Device_bootCPU2(BOOTMODE_BOOT_TO_SECURE_FLASH_SECTOR0);
|
||||
|
||||
//
|
||||
// Secure Boot CM core
|
||||
//
|
||||
Device_bootCM(BOOTMODE_BOOT_TO_SECURE_FLASH_SECTOR0);
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Configure and Enable IPC interrupts
|
||||
//
|
||||
IPC_registerInterrupt(IPC_CPU1_L_CPU2_R, IPC_INT0, appIPCHandler);
|
||||
IPC_registerInterrupt(IPC_CPU1_L_CM_R, IPC_INT1, appIPCHandler);
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop Forever - Blink LED to indicate full flash CMAC has passed
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Turn on LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 0);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
|
||||
//
|
||||
// Turn off LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED1, 1);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// appIPCHandler - Handle notifications from CPU2 and CM when
|
||||
// their applications complete successfully
|
||||
//
|
||||
__interrupt void appIPCHandler(void)
|
||||
{
|
||||
if(IPC_isFlagBusyRtoL(IPC_CPU1_L_CPU2_R, IPC_FLAG0))
|
||||
{
|
||||
cpu2_SuccessfullyBooted = true;
|
||||
IPC_ackFlagRtoL(IPC_CPU1_L_CPU2_R, IPC_FLAG0);
|
||||
}
|
||||
else if(IPC_isFlagBusyRtoL(IPC_CPU1_L_CM_R, IPC_FLAG1))
|
||||
{
|
||||
cm_SuccessfullyBooted = true;
|
||||
IPC_ackFlagRtoL(IPC_CPU1_L_CM_R, IPC_FLAG1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// No action
|
||||
}
|
||||
|
||||
//
|
||||
// Acknowledge this interrupt located in PIE group 1
|
||||
//
|
||||
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: boot_ex1_cpu1_cpu2_cm_secure_flash_cpu2.c
|
||||
//
|
||||
// TITLE: Secure Flash Boot Example
|
||||
//! <h1> CPU2 Secure Flash Boot </h1>
|
||||
//!
|
||||
//! This example demonstrates how to use the secure flash boot mode for CPU2.
|
||||
//! (Requires CPU1 example application)
|
||||
//!
|
||||
//! Secure flash boot performs a CMAC authentication on the entry sector of
|
||||
//! flash upon device boot up. If authentication passes, the application will
|
||||
//! begin execution. Learn more on the secure flash boot mode in the device
|
||||
//! technical reference manual.
|
||||
//!
|
||||
//! This project shows how to use the C2000 HEX Utility to generate a CMAC Tag
|
||||
//! based on a user CMAC key and embed the value into the flash application.
|
||||
//! Additionally, the example details the method to call the CMAC API from
|
||||
//! the user application to calculate CMAC on other flash sectors beyond the
|
||||
//! the application entry flash sector.
|
||||
//!
|
||||
//! Determining Pass/Fail without debugger connected:
|
||||
//! CPU2 - ControlCARD LED2.
|
||||
//! - LED off = Secure Boot failed
|
||||
//! - LED On (Solid) = Secure Boot Passed, Full Flash CMAC failed
|
||||
//! - LED Blinking = Secure Boot Passed and Full Flash CMAC passed
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - None.
|
||||
//!
|
||||
//!
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
//
|
||||
// Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
//
|
||||
// Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
//
|
||||
// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
// its contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
//
|
||||
// Included Files
|
||||
//
|
||||
#include "driverlib.h"
|
||||
#include "device.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define CMAC_AUTH_PASS 0UL
|
||||
#define CMAC_AUTH_START_ADDRESS 0x00080000UL
|
||||
#define CMAC_AUTH_END_ADDRESS 0x000C0000UL
|
||||
#define CMAC_AUTH_TAG_ADDRESS 0x00087002UL
|
||||
|
||||
//
|
||||
// Structure required for CMAC symbol reserving in memory.
|
||||
// Required for performing CMAC on non-entry sector of flash.
|
||||
//
|
||||
// Read more in the Assembly Language Tools User's Guide
|
||||
//
|
||||
struct CMAC_TAG
|
||||
{
|
||||
char tag[8];
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
};
|
||||
|
||||
//
|
||||
// Create CMAC symbol for flash entry point 1 (0x80000).
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_sb_1)
|
||||
#pragma LOCATION(cmac_sb_1, 0x080002)
|
||||
const char cmac_sb_1[8] = { 0 };
|
||||
|
||||
//
|
||||
// Create CMAC symbol for full length flash authentication.
|
||||
// The start and end CMAC_TAG struct members are zero, therefore
|
||||
// the CMAC algorithm runs over entire memory region specified in
|
||||
// the HEX directive.
|
||||
//
|
||||
// Note that the location 0x087002 can be set to anywhere as long
|
||||
// as it is within the specified CMAC authentication memory.
|
||||
//
|
||||
// Reserves memory for storing the golden CMAC tag that gets
|
||||
// generated by the HEX Utility.
|
||||
//
|
||||
#pragma RETAIN(cmac_all)
|
||||
#pragma LOCATION(cmac_all, 0x087002)
|
||||
const struct CMAC_TAG cmac_all = {{ 0 }, 0x0, 0x0};
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
uint32_t CPU2BROM_calculateCMAC(uint32_t startAddress,
|
||||
uint32_t endAddress,
|
||||
uint32_t tagAddress);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint32_t applicationCMACStatus = CMAC_AUTH_PASS;
|
||||
|
||||
//
|
||||
// Initialize device clock and peripherals
|
||||
//
|
||||
Device_init();
|
||||
|
||||
//
|
||||
// Initialize GPIO and configure the GPIO pin as a push-pull output
|
||||
//
|
||||
// This is configured by CPU1
|
||||
|
||||
//
|
||||
// Turn on LED2 to indicate CPU2 has entered application
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);
|
||||
|
||||
//
|
||||
// Call CMAC Authentication API to verify contents of all of
|
||||
// device flash.
|
||||
//
|
||||
// Upon failure, enter infinite loop.
|
||||
//
|
||||
applicationCMACStatus = CPU2BROM_calculateCMAC(CMAC_AUTH_START_ADDRESS,
|
||||
CMAC_AUTH_END_ADDRESS,
|
||||
CMAC_AUTH_TAG_ADDRESS);
|
||||
|
||||
if(CMAC_AUTH_PASS != applicationCMACStatus)
|
||||
{
|
||||
//
|
||||
// Application will get stuck here upon failure
|
||||
//
|
||||
while(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
IPC_setFlagLtoR(IPC_CPU2_L_CPU1_R, IPC_FLAG0);
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
|
||||
//
|
||||
Interrupt_initModule();
|
||||
|
||||
//
|
||||
// Initialize the PIE vector table with pointers to the shell Interrupt
|
||||
// Service Routines (ISR).
|
||||
//
|
||||
Interrupt_initVectorTable();
|
||||
|
||||
//
|
||||
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
|
||||
//
|
||||
EINT;
|
||||
ERTM;
|
||||
|
||||
//
|
||||
// Loop Forever
|
||||
//
|
||||
for(;;)
|
||||
{
|
||||
//
|
||||
// Turn on LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 0);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
|
||||
//
|
||||
// Turn off LED
|
||||
//
|
||||
GPIO_writePin(DEVICE_GPIO_PIN_LED2, 1);
|
||||
|
||||
//
|
||||
// Delay for a bit.
|
||||
//
|
||||
DEVICE_DELAY_US(500000);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
@@ -0,0 +1,8 @@
|
||||
/* CM Flash sectors */
|
||||
|
||||
/* HEX directive required by HEX utility to generate the golden CMAC tag */
|
||||
/* with one entry that represents all the allocated flash memory */
|
||||
ROMS
|
||||
{
|
||||
FLASH_SECTOR0_13: o=0x00200000 l=0x00080000, fill = 0xFFFFFFFF /* If fill not specified, then default is all 0s */
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/* CPU1 Flash sectors */
|
||||
|
||||
/* HEX directive required by HEX utility to generate the golden CMAC tag */
|
||||
/* with one entry that represents all the allocated flash memory */
|
||||
ROMS
|
||||
{
|
||||
FLASH_SECTOR0_13: o=0x00080000 l=0x00040000, fill = 0xFFFF /* If fill not specified, then default is all 0s */
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/* CPU2 Flash sectors */
|
||||
|
||||
/* HEX directive required by HEX utility to generate the golden CMAC tag */
|
||||
/* with one entry that represents all the allocated flash memory */
|
||||
ROMS
|
||||
{
|
||||
FLASH_SECTOR0_13: o=0x00080000 l=0x00040000, fill = 0xFFFF /* If fill not specified, then default is all 0s */
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
;;###########################################################################
|
||||
;;
|
||||
;; FILE: secure_startup_cm.asm
|
||||
;;
|
||||
;; TITLE: Application Reset Branch for Secure Flash Boot Entry Point
|
||||
;;
|
||||
;;###########################################################################
|
||||
;;
|
||||
;// C2000Ware v5.04.00.00
|
||||
;//Copyright (C) 2024 Texas Instruments Incorporated - http://www.ti.com
|
||||
;//
|
||||
;// Redistribution and use in source and binary forms, with or without
|
||||
;// modification, are permitted provided that the following conditions
|
||||
;// are met:
|
||||
;//
|
||||
;// Redistributions of source code must retain the above copyright
|
||||
;// notice, this list of conditions and the following disclaimer.
|
||||
;//
|
||||
;// Redistributions in binary form must reproduce the above copyright
|
||||
;// notice, this list of conditions and the following disclaimer in the
|
||||
;// documentation and/or other materials provided with the
|
||||
;// distribution.
|
||||
;//
|
||||
;// Neither the name of Texas Instruments Incorporated nor the names of
|
||||
;// its contributors may be used to endorse or promote products derived
|
||||
;// from this software without specific prior written permission.
|
||||
;//
|
||||
;// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
;// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
;// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
;// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
;// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
;// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
;// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
;// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
;// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
;// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
;// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
;// $
|
||||
;;###########################################################################
|
||||
.global _c_int00
|
||||
|
||||
;
|
||||
; This is the code that gets called when the processor first starts execution
|
||||
; following a reset event.
|
||||
;
|
||||
.retain ".secureReset"
|
||||
.sect ".secureReset"
|
||||
b.w _c_int00
|
||||
@@ -0,0 +1 @@
|
||||
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
Reference in New Issue
Block a user