![]() |
Kinetis Bootloader Host
2.0.0
Host Tools for Kinetis devices
|
SB Format (SB) source file. More...
#include <SBSourceFile.h>
Inheritance diagram for blfwk::SBSourceFile:
Collaboration diagram for blfwk::SBSourceFile:Classes | |
| struct | boot_image_header_t |
| Header for the entire boot image. More... | |
| union | boot_image_header_t.__unnamed__ |
| struct | boot_image_header_t.__unnamed__.__unnamed__ |
| class | SBFileException |
| Simple exception thrown to indicate an error in the input SB file format. More... | |
| struct | version_t |
| Same version struct used for 3600 boot image. More... | |
Public Member Functions | |
| SBSourceFile (const std::string &path) | |
| Default constructor. | |
| virtual | ~SBSourceFile () |
| Destructor. | |
Data source creation | |
| virtual DataSource * | createDataSource () |
| Creates an unmapped data source from the entire file. | |
Public Member Functions inherited from blfwk::BinarySourceFile | |
| BinarySourceFile (const std::string &path, source_file_t sourceFileType=kBinarySourceFile) | |
| Default constructor. | |
| virtual bool | supportsNamedSections () const |
| virtual bool | supportsNamedSymbols () const |
| void | guessEntryPointAndStackPointer () |
| Initialize entry point and stack pointer from assumed vetcor table at the beginning of the file. | |
| virtual bool | hasEntryPoint () |
| Returns true if an entry point was set in the file. | |
| virtual uint32_t | getEntryPointAddress () |
| Returns the entry point address. | |
| uint32_t | getStackPointer () |
| Returns the stack pointer. | |
Public Member Functions inherited from blfwk::SourceFile | |
| SourceFile (const std::string &path, source_file_t filetype) | |
| Default constructor. | |
| virtual | ~SourceFile () |
| Destructor. More... | |
| void | setOptions (OptionContext *context) |
| Set the option context. More... | |
| const OptionContext * | getOptions () const |
| Return the option context. | |
| source_file_t | getFileType () const |
| Return the file type. | |
| const std::string & | getPath () const |
| Returns the path to the file. | |
| unsigned | getSize () const |
| Get the size in bytes of the file. | |
| virtual void | open () |
| Opens the file. More... | |
| virtual void | close () |
| Closes the file. | |
| virtual bool | isOpen () const |
| Returns whether the file is already open. | |
| virtual DataSource * | createDataSource (StringMatcher &matcher) |
| Creates a data source out of one or more sections of the file. More... | |
| virtual DataSource * | createDataSource (const std::string §ion) |
| Creates a data source out of one section of the file. More... | |
| virtual DataTarget * | createDataTargetForSection (const std::string §ion) |
| virtual DataTarget * | createDataTargetForSymbol (const std::string &symbol) |
| virtual DataTarget * | createDataTargetForEntryPoint () |
| virtual bool | hasSymbol (const std::string &name) |
| Returns whether a symbol exists in the source file. | |
| virtual uint32_t | getSymbolValue (const std::string &name) |
| Returns the value of a symbol. | |
| virtual unsigned | getSymbolSize (const std::string &name) |
| Returns the size of a symbol. | |
Static Public Member Functions | |
| static bool | isSBFile (std::istream &stream) |
| Identifies whether the stream contains an SB file. More... | |
Static Public Member Functions inherited from blfwk::SourceFile | |
| static SourceFile * | openFile (const std::string &path) |
Protected Types | |
| typedef uint8_t | cipher_block_t[16] |
| An AES-128 cipher block is 16 bytes. | |
| typedef uint8_t | sha1_digest_t[20] |
| A SHA-1 digest is 160 bits, or 20 bytes. | |
| typedef uint32_t | section_id_t |
| Unique identifier type for a section. | |
Additional Inherited Members | |
Public Types inherited from blfwk::SourceFile | |
| enum | source_file_t { kBinarySourceFile, kELFSourceFile, kIntelHexSourceFile, kSBSourceFile, kSRecordSourceFile } |
| Set of supported executable image file formats. More... | |
Protected Member Functions inherited from blfwk::SourceFile | |
| std::ifstream * | getStream () |
| Internal access to the input stream object. | |
Protected Attributes inherited from blfwk::BinarySourceFile | |
| uint32_t | m_entry_point |
| uint32_t | m_stack_pointer |
Protected Attributes inherited from blfwk::SourceFile | |
| std::string | m_path |
| Path to the file. | |
| smart_ptr< std::ifstream > | m_stream |
| File stream, or NULL if file is closed. | |
| smart_ptr< OptionContext > | m_options |
| Table of option values. | |
| source_file_t | m_filetype |
| Image file type. | |
| unsigned | m_size |
| The size in bytes of the file. | |
SB Format (SB) source file.
| struct blfwk::SBSourceFile::boot_image_header_t |
Header for the entire boot image.
Fields of this header are arranged so that those used by the bootloader ROM all come first. They are also set up so that all fields are not split across cipher block boundaries. The fields not used by the bootloader are not subject to this restraint.
Image header size is always a round number of cipher blocks. The same also applies to the boot image itself. The padding, held in #blfwk::EncoreBootImage::boot_image_header_t::m_padding0 and #blfwk::EncoreBootImage::boot_image_header_t::m_padding1 is filled with random bytes.
The DEK dictionary, section table, and each section data region must all start on cipher block boundaries.
This header is not encrypted in the image file.
The m_digest field contains a SHA-1 digest of the fields of the header that follow it. It is the first field in the header so it doesn't change position or split the header in two if fields are added to the header.
Collaboration diagram for blfwk::SBSourceFile::boot_image_header_t:| Class Members | ||
|---|---|---|
| union boot_image_header_t | __unnamed__ | |
| version_t | m_componentVersion | Component version. |
| uint16_t | m_driveTag | Drive tag for the system drive which this boot image belongs to. |
| section_id_t | m_firstBootableSectionID | ID of section to start booting from. |
| uint32_t | m_firstBootTagBlock | Offset from start of file to the first boot tag, in blocks. |
| uint16_t | m_flags | Flags or options associated with the entire image. |
| uint16_t | m_headerBlocks | Size of this header, including this size word, in blocks. |
| uint32_t | m_imageBlocks | Size of entire image in blocks. |
| uint16_t | m_keyCount | Number of entries in DEK dictionary. |
| uint16_t | m_keyDictionaryBlock | Starting block number for the key dictionary. |
| uint8_t | m_majorVersion | Major version for the image format, see #ROM_BOOT_IMAGE_MAJOR_VERSION. |
| uint8_t | m_minorVersion | Minor version of the boot image format, see #ROM_BOOT_IMAGE_MINOR_VERSION. |
| uint8_t | m_padding0[2] | Padding to align m_timestamp to long word. |
| uint8_t | m_padding1[6] | Padding to round up to next cipher block. |
| version_t | m_productVersion | Product version. |
| uint16_t | m_sectionCount | Number of section headers in this table. |
| uint16_t | m_sectionHeaderSize | Size in blocks of a section header. |
| uint8_t | m_signature[4] | 'STMP', see #ROM_IMAGE_HEADER_SIGNATURE. |
| uint8_t | m_signature2[4] |
Second signature to distinguish this .sb format from the 36xx format, see #ROM_IMAGE_HEADER_SIGNATURE2. |
| uint64_t | m_timestamp | Timestamp when image was generated in microseconds since 1-1-2000. |
| union blfwk::SBSourceFile::boot_image_header_t.__unnamed__ |
| Class Members | ||
|---|---|---|
| __unnamed__ | __unnamed__ | |
| sha1_digest_t | m_digest | SHA-1 digest of image header. Also used as the crypto IV. |
| struct blfwk::SBSourceFile::boot_image_header_t.__unnamed__.__unnamed__ |
| Class Members | ||
|---|---|---|
| uint8_t | m_extra[4] | The leftover top four bytes of the SHA-1 digest. |
| cipher_block_t | m_iv | The first 16 bytes of the digest form the initialization vector. |
| struct blfwk::SBSourceFile::version_t |
|
static |
Identifies whether the stream contains an SB file.
< Header from the SB boot image.