mediatek: mt7988a: sync dts compatible string
[openwrt/staging/stintel.git] / scripts / sercomm-payload.py
1 #!/usr/bin/env python3
2
3 import argparse
4 import hashlib
5 import os
6
7 def create_output(args):
8 in_st = os.stat(args.input_file)
9 in_size = in_st.st_size
10
11 in_f = open(args.input_file, 'r+b')
12 in_bytes = in_f.read(in_size)
13 in_f.close()
14
15 sha256 = hashlib.sha256()
16 sha256.update(in_bytes)
17
18 out_f = open(args.output_file, 'w+b')
19 out_f.write(bytes.fromhex(args.pid))
20 out_f.write(sha256.digest())
21 out_f.write(in_bytes)
22 out_f.close()
23
24 def main():
25 global args
26
27 parser = argparse.ArgumentParser(description='')
28
29 parser.add_argument('--input-file',
30 dest='input_file',
31 action='store',
32 type=str,
33 help='Input file')
34
35 parser.add_argument('--output-file',
36 dest='output_file',
37 action='store',
38 type=str,
39 help='Output file')
40
41 parser.add_argument('--pid',
42 dest='pid',
43 action='store',
44 type=str,
45 help='Sercomm PID')
46
47 args = parser.parse_args()
48
49 if ((not args.input_file) or
50 (not args.output_file) or
51 (not args.pid)):
52 parser.print_help()
53
54 create_output(args)
55
56 main()