diff options
author | Álvaro Fernández Rojas <noltari@gmail.com> | 2020-06-02 12:50:37 +0200 |
---|---|---|
committer | Álvaro Fernández Rojas <noltari@gmail.com> | 2020-06-02 13:06:42 +0200 |
commit | 35d7f92c60efb161fec26313ea47895197da4506 (patch) | |
tree | e9ea1bb8284378d13dc0c82ca15ee51225f71284 /scripts | |
parent | a47acae319c9b49c2737bbcc6302678d4706df3e (diff) | |
download | upstream-35d7f92c60efb161fec26313ea47895197da4506.tar.gz upstream-35d7f92c60efb161fec26313ea47895197da4506.tar.bz2 upstream-35d7f92c60efb161fec26313ea47895197da4506.zip |
scripts: support Sercomm load tags
Header consists in Sercomm PID bytes, followed by a SHA256 hash of the
input binary.
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/config/mconf_check | 0 | ||||
-rwxr-xr-x | scripts/sercomm-payload.py | 56 |
2 files changed, 56 insertions, 0 deletions
diff --git a/scripts/config/mconf_check b/scripts/config/mconf_check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/scripts/config/mconf_check diff --git a/scripts/sercomm-payload.py b/scripts/sercomm-payload.py new file mode 100755 index 0000000000..5193069b6c --- /dev/null +++ b/scripts/sercomm-payload.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +import argparse +import hashlib +import os + +def create_output(args): + in_st = os.stat(args.input_file) + in_size = in_st.st_size + + in_f = open(args.input_file, 'r+b') + in_bytes = in_f.read(in_size) + in_f.close() + + sha256 = hashlib.sha256() + sha256.update(in_bytes) + + out_f = open(args.output_file, 'w+b') + out_f.write(bytes.fromhex(args.pid)) + out_f.write(sha256.digest()) + out_f.write(in_bytes) + out_f.close() + +def main(): + global args + + parser = argparse.ArgumentParser(description='') + + parser.add_argument('--input-file', + dest='input_file', + action='store', + type=str, + help='Input file') + + parser.add_argument('--output-file', + dest='output_file', + action='store', + type=str, + help='Output file') + + parser.add_argument('--pid', + dest='pid', + action='store', + type=str, + help='Sercomm PID') + + args = parser.parse_args() + + if ((not args.input_file) or + (not args.output_file) or + (not args.pid)): + parser.print_help() + + create_output(args) + +main() |