This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] LAUNCHXL-F280039C:安全启动

Guru**** 2693225 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1590029/launchxl-f280039c-secure-boot

器件型号: 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

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Marvin:

    我已将此主题重新分配给另一位专家、以帮助解决此问题、对延迟的响应表示歉意。

    谢谢您、

    Luke

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你好、Marvin、

    我能够让它在我的设置中正常工作。 需要检查以下几点:

    1. 确保您正在 根据包含的 CMAC 标签对十六进制文件(十六进制实用程序的输出)进行编程  
    2. 为配置器件 安全 引导至闪存 (BOOTDEF 0x0A)

    此致、

    马特