请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号: LAUNCHXL-F280039C
尊敬的专家:
代表客户发帖。
我遇到的问题如下:我无法使用 CMAC 验证超过 16KB 的闪存。 我遵循应用报告:C2000 器件上的安全启动、其中描述了指示安全启动是否通过的 LED 行为。 在本例中、LED 会保持稳定、但不会开始闪烁、这意味着全闪存 CMAC 身份验证失败。
以下是基于该示例进行了修改的代码:
#include "driverlib.h"
#include "device.h"
//
// Defines
//
#define CMAC_AUTH_PASS 0UL
#define CMAC_AUTH_START_ADDRESS 0x00080000UL
#define CMAC_AUTH_END_ADDRESS 0x000B0000UL
#define CMAC_AUTH_TAG_ADDRESS 0x00084002UL
//
// Globals
//
bool cpu1_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 0x082002 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, 0x084002)
const struct CMAC_TAG cmac_all = { {0}, 0x0 , 0x0};
//
// Function Prototypes
//
uint32_t CPU1BROM_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 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);
//
// 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;
}
这里表示 hex.cmd
/* 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_BANK0_2: o=0x00080000 l=0x00030000, fill = 0xFFFF /* If fill not specified, then default is all 0s */
}
此致、
Marvin
