uuu
uuu (Universal Update Utility), mfgtools 3.0
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
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
52
53#define FFU_SIGNATURE "ImageFlash "
54
55typedef 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.
62
63typedef 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)
86
87typedef struct _VALIDATION_ENTRY
88{
89 uint32_t dwSectorIndex;
91 uint32_t dwByteCount;
92 uint8_t rgCompareData[1]; // size is dwByteCount
94
100
106
113#pragma pack()
114
115#endif // LIBSPARSE_FFU_FORMAT_H
struct _STORE_HEADER FFU_STORE_HEADER
DISK_ACCESS_METHOD
Definition ffu_format.h:96
@ DISK_BEGIN
Definition ffu_format.h:97
@ DISK_END
Definition ffu_format.h:98
struct _DISK_LOCATION FFU_DISK_LOCATION
struct _FFU_SECURITY_HEADER FFU_SECURITY_HEADER
struct _BLOCK_DATA_ENTRY FFU_BLOCK_DATA_ENTRY
struct _VALIDATION_ENTRY FFU_VALIDATION_ENTRY
struct _IMAGE_HEADER FFU_IMAGE_HEADER
Definition ffu_format.h:108
uint32_t dwLocationCount
Definition ffu_format.h:109
uint32_t dwBlockCount
Definition ffu_format.h:110
FFU_DISK_LOCATION rgDiskLocations[1]
Definition ffu_format.h:111
Definition ffu_format.h:102
uint32_t dwBlockIndex
Definition ffu_format.h:104
uint32_t dwDiskAccessMethod
Definition ffu_format.h:103
Definition ffu_format.h:44
uint32_t cbSize
Definition ffu_format.h:45
uint32_t dwChunkSizeInKb
Definition ffu_format.h:47
uint32_t dwCatalogSize
Definition ffu_format.h:49
uint32_t dwHashTableSize
Definition ffu_format.h:50
uint32_t dwAlgId
Definition ffu_format.h:48
uint8_t signature[12]
Definition ffu_format.h:46
Definition ffu_format.h:56
uint32_t dwChunkSize
Definition ffu_format.h:60
uint8_t Signature[12]
Definition ffu_format.h:58
uint32_t ManifestLength
Definition ffu_format.h:59
uint32_t cbSize
Definition ffu_format.h:57
Definition ffu_format.h:64
uint32_t dwValidateDescriptorLength
Definition ffu_format.h:73
uint32_t dwUpdateType
Definition ffu_format.h:65
uint32_t dwFlashOnlyTableIndex
Definition ffu_format.h:76
uint32_t dwInitialTableCount
Definition ffu_format.h:75
uint32_t dwValidateDescriptorCount
Definition ffu_format.h:72
uint32_t dwFlashOnlyTableCount
Definition ffu_format.h:77
uint16_t DevicePath[1]
Definition ffu_format.h:84
uint16_t MajorVersion
Definition ffu_format.h:66
uint32_t dwWriteDescriptorCount
Definition ffu_format.h:70
uint8_t szPlatformId[192]
Definition ffu_format.h:68
uint64_t StorePayloadSize
Definition ffu_format.h:82
uint32_t dwInitialTableIndex
Definition ffu_format.h:74
uint32_t dwBlockSizeInBytes
Definition ffu_format.h:69
uint16_t NumOfStores
Definition ffu_format.h:80
uint16_t StoreIndex
Definition ffu_format.h:81
uint32_t dwFinalTableIndex
Definition ffu_format.h:78
uint16_t DevicePathLength
Definition ffu_format.h:83
uint32_t dwWriteDescriptorLength
Definition ffu_format.h:71
uint32_t dwFinalTableCount
Definition ffu_format.h:79
uint16_t MinorVersion
Definition ffu_format.h:66
uint16_t FullFlashMinorVersion
Definition ffu_format.h:67
uint16_t FullFlashMajorVersion
Definition ffu_format.h:67
Definition ffu_format.h:88
uint32_t dwSectorOffset
Definition ffu_format.h:90
uint32_t dwByteCount
Definition ffu_format.h:91
uint32_t dwSectorIndex
Definition ffu_format.h:89
uint8_t rgCompareData[1]
Definition ffu_format.h:92