Kinetis Bootloader  2.0.0
Common bootloader for Kinetis devices
sb_file_format.h
1 /*
2  * Copyright (c) 2013, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #if !defined(_SB_FILE_FORMAT_H_)
31 #define _SB_FILE_FORMAT_H_
32 
33 #include "bootloader_common.h"
34 
37 
39 // Definitions
41 
42 #pragma pack(push)
43 #pragma pack(1)
44 
46 enum
47 {
48  ROM_DISPLAY_PROGRESS = (1 << 0),
50 };
51 
53 typedef struct _sb_version
54 {
55  uint16_t m_major;
56  uint16_t m_pad0;
57  uint16_t m_minor;
58  uint16_t m_pad1;
59  uint16_t m_revision;
60  uint16_t m_pad2;
61 } sb_version_t;
62 
82 typedef struct _sb_image_header
83 {
84  uint8_t m_digest[20]; // !< SHA-1 digest of image header. Also used as the crypto IV.
85  uint32_t m_signature; // !< 'STMP', see #BOOT_SIGNATURE.
86  uint8_t m_majorVersion; // !< Major version for the image format, see #SB_FILE_MAJOR_VERSION.
87  uint8_t m_minorVersion; // !< Minor version of the boot image format.
88  uint16_t m_flags; // !< Flags or options associated with the entire image.
89  uint32_t m_imageBlocks; // !< Size of entire image in blocks.
90  uint32_t m_firstBootTagBlock; // !< Offset from start of file to the first boot tag, in blocks.
91  uint32_t m_firstBootableSectionID; // !< ID of section to start booting from.
92  uint16_t m_keyCount; // !< Number of entries in DEK dictionary.
93  uint16_t m_keyDictionaryBlock; // !< Starting block number for the key dictionary.
94  uint16_t m_headerBlocks; // !< Size of this header, including this size word, in blocks.
95  uint16_t m_sectionCount; // !< Number of section headers in this table.
96  uint16_t m_sectionHeaderSize; // !< Size in blocks of a section header.
97  uint8_t m_padding0[2]; // !< Padding to align #m_timestamp to long word.
98  uint32_t
99  m_signature2; // !< Second signature to distinguish this .sb format from the 36xx format, see #BOOT_SIGNATURE2.
100  uint64_t m_timestamp; // !< Timestamp when image was generated in microseconds since 1-1-2000.
101  sb_version_t m_productVersion; // !< Product version.
102  sb_version_t m_componentVersion; // !< Component version.
103  uint16_t m_driveTag; // !< Drive tag for the system drive which this boot image belongs to.
104  uint8_t m_padding1[6]; // !< Padding to round up to next cipher block.
106 
111 typedef struct _sb_dek_dictionary_entry
112 {
113  uint8_t m_mac[16];
114  uint8_t m_dek[16];
116 
118 typedef struct _sb_dek_dictionary
119 {
120  sb_dek_dictionary_entry_t m_entries[1];
122 
124 enum
125 {
126  ROM_SECTION_BOOTABLE = (1 << 0),
128  (1 << 1)
129 };
130 
133 typedef struct _sb_section_header
134 {
135  uint32_t m_tag;
136  uint32_t m_offset;
137  uint32_t m_length;
138  uint32_t m_flags;
140 
157 typedef struct _sb_section_table
158 {
159  sb_section_header_t m_sections[1];
161 
162 #pragma pack(pop)
163 
165 
166 #endif // _SB_FILE_FORMAT_H_
167 // EOF
Print progress reports.
Definition: sb_file_format.h:48
An index of all sections within the boot image.
Definition: sb_file_format.h:157
uint32_t m_flags
Section flags.
Definition: sb_file_format.h:138
Progress reports are verbose.
Definition: sb_file_format.h:49
uint32_t m_length
Size of section data in blocks.
Definition: sb_file_format.h:137
The section contains bootloader commands.
Definition: sb_file_format.h:126
uint32_t m_tag
Unique identifier for this section. High bit must be zero.
Definition: sb_file_format.h:135
uint32_t m_offset
Offset to section data from start of image in blocks.
Definition: sb_file_format.h:136
Header for the entire boot image.
Definition: sb_file_format.h:82
Entry in sb_dek_dictionary_t.
Definition: sb_file_format.h:111
Information about each section, held in the section table.
Definition: sb_file_format.h:133
The section is unencrypted. Applies only if the rest of the boot image is encrypted.
Definition: sb_file_format.h:127
Version struct used in SB files.
Definition: sb_file_format.h:53
The DEK dictionary always follows the image header, in the next cipher block.
Definition: sb_file_format.h:118