-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OTA] Add script for generating OTA image #13547
Conversation
PR #13547: Size comparison from bbf5d40 to a84c3a8 Full report (32 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
f71ea72
to
280c1e1
Compare
PR #13547: Size comparison from 5e61ce9 to 280c1e1 Full report (32 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
Add script for encoding spec-compliant OTA image header and concatenating a set of payload files.
31ef758
to
82add17
Compare
PR #13547: Size comparison from e4faade to 82add17 Full report (32 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
if args.max_version: | ||
fields.update({HeaderTag.MAX_VERSION: uint(args.max_version)}) | ||
|
||
if args.release_notes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Size range is 1..256. Suggest warning if it doesn't start with https://
if args.min_version: | ||
fields.update({HeaderTag.MIN_VERSION: uint(args.min_version)}) | ||
|
||
if args.max_version: | ||
fields.update({HeaderTag.MAX_VERSION: uint(args.max_version)}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must validate the following (depending on presence):
- min_version <= max_version
- max_version < args.version
HeaderTag.VENDOR_ID: uint(args.vendor_id), | ||
HeaderTag.PRODUCT_ID: uint(args.product_id), | ||
HeaderTag.VERSION: uint(args.version), | ||
HeaderTag.VERSION_STRING: args.version_str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must verify length in range 1..64
|
||
fields = { | ||
HeaderTag.VENDOR_ID: uint(args.vendor_id), | ||
HeaderTag.PRODUCT_ID: uint(args.product_id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PID cannot be 0
""" | ||
|
||
fields = { | ||
HeaderTag.VENDOR_ID: uint(args.vendor_id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VID cannot be 0
DIGEST_ALL_ALGORITHMS = hashlib.algorithms_available.intersection( | ||
DIGEST_ALGORITHM_ID.keys()) | ||
|
||
PAYLOAD_BUFFER_SIZE = 16 * 1024 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest adding the comment:
# Buffer size used for file reads to ensure large files do not need to be loaded
# into memory fully before processing.
sha256_128=2, | ||
sha256_120=3, | ||
sha256_96=4, | ||
sha256_64=5, | ||
sha256_32=6, | ||
sha384=7, | ||
sha512=8, | ||
sha3_224=9, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest warning if sha256_x (len < 256 bits) and sha3_224 are used, since:
It is RECOMMENDED that a digest algorithm be chosen that has a minimum digest length of 256 bits, such as
sha-256
(ID 1 in the registry).
|
||
with open(args.image_file, 'rb') as file: | ||
fixed_header_format = '<IQI' | ||
fixed_header = file.read(struct.calcsize(fixed_header_format)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest adding: assert struct.calcsize(fixed_header_format) == 16
Generate OTA image header | ||
""" | ||
|
||
fixed_header_format = '<IQI' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest adding: assert struct.calcsize(fixed_header_format) == 16
Add script for encoding spec-compliant OTA image header and concatenating a set of payload files.
Add script for encoding spec-compliant OTA image header and concatenating a set of payload files.
Problem
No tool for creating spec-compliant OTA images exists.
Change overview
Add script for encoding spec-compliant OTA image header and concatenating a set of payload files.
Additionally the script allows to parse the header and verify the contents were written correctly.
Fixes #2863.
Testing
Generated a sample OTA image and did simple manual verification of the contents.