uuu
uuu (Universal Update Utility), mfgtools 3.0
Toggle main menu visibility
Loading...
Searching...
No Matches
ffu_format.h
Go to the documentation of this file.
1
/*
2
* Copyright 2020 NXP.
3
*
4
* Redistribution and use in source and binary forms, with or without modification,
5
* are permitted provided that the following conditions are met:
6
*
7
* Redistributions of source code must retain the above copyright notice, this
8
* list of conditions and the following disclaimer.
9
*
10
* Redistributions in binary form must reproduce the above copyright notice, this
11
* list of conditions and the following disclaimer in the documentation and/or
12
* other materials provided with the distribution.
13
*
14
* Neither the name of the NXP Semiconductor nor the names of its
15
* contributors may be used to endorse or promote products derived from this
16
* software without specific prior written permission.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
* POSSIBILITY OF SUCH DAMAGE.
29
*
30
*/
31
32
//ref: https://docs.microsoft.com/en-us/windows-hardware/manufacture/mobile/ffu-image-format
33
34
#ifndef LIBSPARSE_FFU_FORMAT_H
35
#define LIBSPARSE_FFU_FORMAT_H
36
37
#include <cstdint>
38
39
#define FFU_SECURITY_SIGNATURE "SignedImage "
40
41
#pragma pack(1)
42
43
typedef
struct
_FFU_SECURITY_HEADER
44
{
45
uint32_t
cbSize
;
// size of struct, overall
46
uint8_t
signature
[12];
// "SignedImage "
47
uint32_t
dwChunkSizeInKb
;
// size of a hashed chunk within the image
48
uint32_t
dwAlgId
;
// algorithm used to hash
49
uint32_t
dwCatalogSize
;
// size of catalog to validate
50
uint32_t
dwHashTableSize
;
// size of hash table
51
}
FFU_SECURITY_HEADER
;
52
53
#define FFU_SIGNATURE "ImageFlash "
54
55
typedef
struct
_IMAGE_HEADER
56
{
57
uint32_t
cbSize
;
// sizeof(ImageHeader)
58
uint8_t
Signature
[12];
// "ImageFlash "
59
uint32_t
ManifestLength
;
// in bytes
60
uint32_t
dwChunkSize
;
// Used only during image generation.
61
}
FFU_IMAGE_HEADER
;
62
63
typedef
struct
_STORE_HEADER
64
{
65
uint32_t
dwUpdateType
;
// indicates partial or full flash
66
uint16_t
MajorVersion
,
MinorVersion
;
// used to validate struct
67
uint16_t
FullFlashMajorVersion
,
FullFlashMinorVersion
;
// FFU version, i.e. the image format
68
uint8_t
szPlatformId
[192];
// string which indicates what device this FFU is intended to be written to
69
uint32_t
dwBlockSizeInBytes
;
// size of an image block in bytes - the device's actual sector size may differ
70
uint32_t
dwWriteDescriptorCount
;
// number of write descriptors to iterate through
71
uint32_t
dwWriteDescriptorLength
;
// total size of all the write descriptors, in bytes (included so they can be read out up front and interpreted later)
72
uint32_t
dwValidateDescriptorCount
;
// number of validation descriptors to check
73
uint32_t
dwValidateDescriptorLength
;
// total size of all the validation descriptors, in bytes
74
uint32_t
dwInitialTableIndex
;
// block index in the payload of the initial (invalid) GPT
75
uint32_t
dwInitialTableCount
;
// count of blocks for the initial GPT, i.e. the GPT spans blockArray[idx..(idx + count -1)]
76
uint32_t
dwFlashOnlyTableIndex
;
// first block index in the payload of the flash-only GPT (included so safe flashing can be accomplished)
77
uint32_t
dwFlashOnlyTableCount
;
// count of blocks in the flash-only GPT
78
uint32_t
dwFinalTableIndex
;
// index in the table of the real GPT
79
uint32_t
dwFinalTableCount
;
// number of blocks in the real GPT
80
uint16_t
NumOfStores
;
// Total number of stores (V2 only)
81
uint16_t
StoreIndex
;
// Current store index, 1-based (V2 only)
82
uint64_t
StorePayloadSize
;
// Payload data only, excludes padding (V2 only)
83
uint16_t
DevicePathLength
;
// Length of the device path (V2 only)
84
uint16_t
DevicePath
[1];
// Device path has no NUL at then end (V2 only)
85
}
FFU_STORE_HEADER
;
86
87
typedef
struct
_VALIDATION_ENTRY
88
{
89
uint32_t
dwSectorIndex
;
90
uint32_t
dwSectorOffset
;
91
uint32_t
dwByteCount
;
92
uint8_t
rgCompareData
[1];
// size is dwByteCount
93
}
FFU_VALIDATION_ENTRY
;
94
95
enum
DISK_ACCESS_METHOD
96
{
97
DISK_BEGIN
= 0,
98
DISK_END
= 2
99
};
100
101
typedef
struct
_DISK_LOCATION
102
{
103
uint32_t
dwDiskAccessMethod
;
104
uint32_t
dwBlockIndex
;
105
}
FFU_DISK_LOCATION
;
106
107
typedef
struct
_BLOCK_DATA_ENTRY
108
{
109
uint32_t
dwLocationCount
;
110
uint32_t
dwBlockCount
;
111
FFU_DISK_LOCATION
rgDiskLocations
[1];
112
}
FFU_BLOCK_DATA_ENTRY
;
113
#pragma pack()
114
115
#endif
// LIBSPARSE_FFU_FORMAT_H
FFU_STORE_HEADER
struct _STORE_HEADER FFU_STORE_HEADER
DISK_ACCESS_METHOD
DISK_ACCESS_METHOD
Definition
ffu_format.h:96
DISK_BEGIN
@ DISK_BEGIN
Definition
ffu_format.h:97
DISK_END
@ DISK_END
Definition
ffu_format.h:98
FFU_DISK_LOCATION
struct _DISK_LOCATION FFU_DISK_LOCATION
FFU_SECURITY_HEADER
struct _FFU_SECURITY_HEADER FFU_SECURITY_HEADER
FFU_BLOCK_DATA_ENTRY
struct _BLOCK_DATA_ENTRY FFU_BLOCK_DATA_ENTRY
FFU_VALIDATION_ENTRY
struct _VALIDATION_ENTRY FFU_VALIDATION_ENTRY
FFU_IMAGE_HEADER
struct _IMAGE_HEADER FFU_IMAGE_HEADER
_BLOCK_DATA_ENTRY
Definition
ffu_format.h:108
_BLOCK_DATA_ENTRY::dwLocationCount
uint32_t dwLocationCount
Definition
ffu_format.h:109
_BLOCK_DATA_ENTRY::dwBlockCount
uint32_t dwBlockCount
Definition
ffu_format.h:110
_BLOCK_DATA_ENTRY::rgDiskLocations
FFU_DISK_LOCATION rgDiskLocations[1]
Definition
ffu_format.h:111
_DISK_LOCATION
Definition
ffu_format.h:102
_DISK_LOCATION::dwBlockIndex
uint32_t dwBlockIndex
Definition
ffu_format.h:104
_DISK_LOCATION::dwDiskAccessMethod
uint32_t dwDiskAccessMethod
Definition
ffu_format.h:103
_FFU_SECURITY_HEADER
Definition
ffu_format.h:44
_FFU_SECURITY_HEADER::cbSize
uint32_t cbSize
Definition
ffu_format.h:45
_FFU_SECURITY_HEADER::dwChunkSizeInKb
uint32_t dwChunkSizeInKb
Definition
ffu_format.h:47
_FFU_SECURITY_HEADER::dwCatalogSize
uint32_t dwCatalogSize
Definition
ffu_format.h:49
_FFU_SECURITY_HEADER::dwHashTableSize
uint32_t dwHashTableSize
Definition
ffu_format.h:50
_FFU_SECURITY_HEADER::dwAlgId
uint32_t dwAlgId
Definition
ffu_format.h:48
_FFU_SECURITY_HEADER::signature
uint8_t signature[12]
Definition
ffu_format.h:46
_IMAGE_HEADER
Definition
ffu_format.h:56
_IMAGE_HEADER::dwChunkSize
uint32_t dwChunkSize
Definition
ffu_format.h:60
_IMAGE_HEADER::Signature
uint8_t Signature[12]
Definition
ffu_format.h:58
_IMAGE_HEADER::ManifestLength
uint32_t ManifestLength
Definition
ffu_format.h:59
_IMAGE_HEADER::cbSize
uint32_t cbSize
Definition
ffu_format.h:57
_STORE_HEADER
Definition
ffu_format.h:64
_STORE_HEADER::dwValidateDescriptorLength
uint32_t dwValidateDescriptorLength
Definition
ffu_format.h:73
_STORE_HEADER::dwUpdateType
uint32_t dwUpdateType
Definition
ffu_format.h:65
_STORE_HEADER::dwFlashOnlyTableIndex
uint32_t dwFlashOnlyTableIndex
Definition
ffu_format.h:76
_STORE_HEADER::dwInitialTableCount
uint32_t dwInitialTableCount
Definition
ffu_format.h:75
_STORE_HEADER::dwValidateDescriptorCount
uint32_t dwValidateDescriptorCount
Definition
ffu_format.h:72
_STORE_HEADER::dwFlashOnlyTableCount
uint32_t dwFlashOnlyTableCount
Definition
ffu_format.h:77
_STORE_HEADER::DevicePath
uint16_t DevicePath[1]
Definition
ffu_format.h:84
_STORE_HEADER::MajorVersion
uint16_t MajorVersion
Definition
ffu_format.h:66
_STORE_HEADER::dwWriteDescriptorCount
uint32_t dwWriteDescriptorCount
Definition
ffu_format.h:70
_STORE_HEADER::szPlatformId
uint8_t szPlatformId[192]
Definition
ffu_format.h:68
_STORE_HEADER::StorePayloadSize
uint64_t StorePayloadSize
Definition
ffu_format.h:82
_STORE_HEADER::dwInitialTableIndex
uint32_t dwInitialTableIndex
Definition
ffu_format.h:74
_STORE_HEADER::dwBlockSizeInBytes
uint32_t dwBlockSizeInBytes
Definition
ffu_format.h:69
_STORE_HEADER::NumOfStores
uint16_t NumOfStores
Definition
ffu_format.h:80
_STORE_HEADER::StoreIndex
uint16_t StoreIndex
Definition
ffu_format.h:81
_STORE_HEADER::dwFinalTableIndex
uint32_t dwFinalTableIndex
Definition
ffu_format.h:78
_STORE_HEADER::DevicePathLength
uint16_t DevicePathLength
Definition
ffu_format.h:83
_STORE_HEADER::dwWriteDescriptorLength
uint32_t dwWriteDescriptorLength
Definition
ffu_format.h:71
_STORE_HEADER::dwFinalTableCount
uint32_t dwFinalTableCount
Definition
ffu_format.h:79
_STORE_HEADER::MinorVersion
uint16_t MinorVersion
Definition
ffu_format.h:66
_STORE_HEADER::FullFlashMinorVersion
uint16_t FullFlashMinorVersion
Definition
ffu_format.h:67
_STORE_HEADER::FullFlashMajorVersion
uint16_t FullFlashMajorVersion
Definition
ffu_format.h:67
_VALIDATION_ENTRY
Definition
ffu_format.h:88
_VALIDATION_ENTRY::dwSectorOffset
uint32_t dwSectorOffset
Definition
ffu_format.h:90
_VALIDATION_ENTRY::dwByteCount
uint32_t dwByteCount
Definition
ffu_format.h:91
_VALIDATION_ENTRY::dwSectorIndex
uint32_t dwSectorIndex
Definition
ffu_format.h:89
_VALIDATION_ENTRY::rgCompareData
uint8_t rgCompareData[1]
Definition
ffu_format.h:92
libuuu
ffu_format.h
Generated by
1.18.0