none
WEC2013 如何生成类型为BOOT_BIN_SIGNATURE_STORE签名的bin,即bootloader下载后是写入存储而不是直接载入RAM RRS feed

  • 问题

  • Windows embedded compact 2013如何生成类型为BOOT_BIN_SIGNATURE_STORE签名的bin,即bootloader下载后是写入存储而不是直接载入RAM。

    我采用ceboot bootloader。是从WEC7之后才增加的新的bootloader类型。

    我研究了ceboot架构的bootloader开机流程。发现可以支持下载后写入存储。 该boot流程会检验bin的签名部分,需要开始6个字节是D000FF,即BOOT_BIN_SIGNATURE_STORE类型。

    #define BOOT_BIN_SIGNATURE_RAM              "B000FF\x0A"
    #define BOOT_BIN_SIGNATURE_SIGNED_RAM       "S000FF\x0A"
    #define BOOT_BIN_SIGNATURE_RAW              "N000FF\x0A"
    #define BOOT_BIN_SIGNATURE_SIGNED_RAW       "R000FF\x0A"
    #define BOOT_BIN_SIGNATURE_STORE            "D000FF\x0A"
    #define BOOT_BIN_SIGNATURE_JUMP             "J00000\x0A"

    这是所有的类型。

    ceboot的流程可以参考源码$(_TARGETPLATROOT)\src\boot\bldr\download.c中BootLoaderDownload function。其中做类型的判断的function BootDownloadImageType我分析过,就是下载前边header的7个字节,然后判断这个签名。

    当进入BOOT_DOWNLOAD_IMAGE_STORE分支后,StoreImage function会根据bin的头部信息分区和格式化存储,并将下载的segment写入存储中。

    这一流程是完整的,我透过直接修改bin文件的签名字节,可以让bootloader进入该流程,可以证明boot流程的正确。

    我是在windows virtual pc上测试,存储驱动什么的支持都没有问题。我能够将nk.bin放到VHD上,直接load执行。

    经过以上分析,我认为是RomImage过程的配置需要调整,但是我不知道要如何做才能生成这种STORE类型。 希望大家指点。 谢谢关注




    2013年12月19日 3:30

答案

  • bigwatercar 你好,

    我对于这个问题不是很熟悉。但是我帮你找了一段代码,不知道能不能帮助到你。

    //
    // Copyright (c) Microsoft Corporation.  All rights reserved.
    //
    //
    // Use of this sample source code is subject to the terms of the Microsoft
    // license agreement under which you licensed this sample source code. If
    // you did not accept the terms of the license agreement, you are not
    // authorized to use this sample source code. For the terms of the license,
    // please see the license agreement between you and Microsoft or, if applicable,
    // see the LICENSE.RTF on your install media or the root of your tools installation.
    // THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
    //
    #ifndef __BOOT_DOWNLOAD_BIN_FORMAT_H
    #define __BOOT_DOWNLOAD_BIN_FORMAT_H
    
    #include "bootTypes.h"
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #pragma pack(push, 1)
    
    //------------------------------------------------------------------------------
    
    #define BOOT_BIN_SIGNATURE_RAM              "B000FF\x0A"
    #define BOOT_BIN_SIGNATURE_SIGNED_RAM       "S000FF\x0A"
    #define BOOT_BIN_SIGNATURE_RAW              "N000FF\x0A"
    #define BOOT_BIN_SIGNATURE_SIGNED_RAW       "R000FF\x0A"
    #define BOOT_BIN_SIGNATURE_STORE            "D000FF\x0A"
    #define BOOT_BIN_SIGNATURE_JUMP             "J00000\x0A"
    
    //------------------------------------------------------------------------------
    
    typedef struct BootBinFormatRamHeader_t {
        uint32_t start;
        uint32_t size;
    } BootBinFormatRamHeader_t;
    
    typedef struct BootBinFormatRamRecordHeader_t {
        uint32_t address;
        uint32_t length;
        uint32_t checksum;
    } BootBinFormatRamRecordHeader_t;
    
    //------------------------------------------------------------------------------
    
    typedef struct BootBinFormatSignature_t {
        uint8_t signature[7];
    } BootBinFormatSignature_t;
    
    enum BootBinFormatFlags_e {
        BOOT_BIN_FORMAT_FLAG_CLEAN = (1 << 0)
    };
    
    //------------------------------------------------------------------------------
    
    enum BootBinFormatHashType_e {
        BOOT_BIN_FORMAT_HASH_SUM    = 0,
        BOOT_BIN_FORMAT_HASH_SHA1   = 1,
        BOOT_BIN_FORMAT_HASH_SHA256 = 2,
        
        BOOT_BIN_FORMAT_HASH_OEM = 0x8000
        // OEM can define new hashing algorithms in their own platform-specific
        // BSPs. The definitions must start at BOOT_BIN_FORMAT_HASH_OEM, e.g.
        //    BOOT_BIN_FORMAT_HASH_ALG1 = BOOT_BIN_FORMAT_HASH_OEM + 0,
        //    BOOT_BIN_FORMAT_HASH_ALG2 = BOOT_BIN_FORMAT_HASH_OEM + 1
    };
    //------------------------------------------------------------------------------
    
    typedef struct BootBinFormatStoreHeader_t {
        uint32_t flags;
        uint32_t sectorSize;
        uint32_t sectors;
        uint32_t segments;
        uint32_t hashType;
        uint32_t hashSize;
        uint32_t hashInfoSize;
    } BootBinFormatStoreHeader_t, *BootBinFormatStoreHeader;    
    
    typedef struct BootBinFormatStoreSha1Info_t {
        uint32_t publicKeySize;
        uint32_t seedSize;
    /*
        uint8_t  publicKey[publicKeySize];
        uint8_t  seed[seedSize];
    */
    } BootBinFormatStoreSha1Info_t;
    
    enum BootBinFormatStoreSegmentType_e {
        BOOT_BIN_FORMAT_STORE_SEGMENT_BINARY    = 1,
        BOOT_BIN_FORMAT_STORE_SEGMENT_RESERVED  = 2,
        BOOT_BIN_FORMAT_STORE_SEGMENT_PARTITION = 3
    };
    
    typedef struct BootBinFormatStoreSegmentHeader_t {
        uint32_t type;
        uint32_t sectors;
        uint32_t infoSize;
    } BootBinFormatStoreSegmentHeader_t, *BootBinFormatStoreSegmentHeader;
    
    typedef struct BootBinFormatStoreSegmentBinaryInfo_t {
        uint8_t index;
    } BootBinFormatStoreSegmentBinaryInfo_t;
    
    typedef struct BootBinFormatStoreSegmentReservedInfo_t {
        char name[8];
    } BootBinFormatStoreSegmentReservedInfo_t;
    
    typedef struct BootBinFormatStoreSegmentPartitionInfo_t {
        uint8_t fileSystem;
        uint8_t index;
    } BootBinFormatStoreSegmentPartitionInfo_t;
    
    typedef struct BootBinFormatStoreRecordHeader_t {
        uint32_t segment;
        uint32_t sector;
        uint32_t sectors;
    } BootBinFormatStoreRecordHeader_t;
    
    /*
       This is pseudo-C definition of store format
    
    typedef struct BootBinFormatStore_t {
        uint8_t signature[7];
        BootBinFormatStoreHeader_t header;
        uint8_t hashInfo[header.hashInfoSize];
        struct {
            BootBinFormatStoreSegmentHeader_t segmentHeader;
            union {
                BootBinFormatStoreSegmentBinaryInfo_t binaryInfo;
                BootBinFormatStoreSegmentReservedInfo_t reservedInfo;
                BootBinFormatStoreSegmentPartitionInfo_t partitionInfo;
            };
        } segment[header.segments];
        uint8_t hash[header.hashSize];      // Header hash/checksum
        struct {
            BootBinFormatStoreRecordHeader_t recordHeader;
            uint8_t recordData[recordHeader.sectors * header.sectorSize];
            uint8_t recordHash[header.hashSize];
        } record[];        
    } BootBinFormatStore_t;
    
    */
    //------------------------------------------------------------------------------
    
    #pragma pack(pop)
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif // __BOOT_DOWNLOAD_BIN_FORMAT_H


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2013年12月20日 9:12
    版主