• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'''
2Some bootloader's support hashing partitions. This is a great feature for testing
3correctness. However, the format for the way the hash is returned depends on the
4implementation. The hash could be send through an INFO response, or be as part
5of the OKAY response itself. This script is called with the first argument
6as the string mesage from the okay response. The second argument is each
7info response joined by newlines into one argument.
8'''
9
10import sys
11
12
13def main():
14  '''
15  Data is sent back to the parent fuzzy_fastboot process through the stderr pipe.
16  There are two interpretations of this data by FF.
17
18  0 return code:
19    Anything written to STDERR will be interpreted as part of the hash.
20
21  non-zero return code:
22    Anything written to STDERR is part of the error message that will logged by FF
23    to explain why hash extraction failed.
24
25  Feel free to print to to STDOUT with print() as usual to print info to console
26  '''
27  script, response, info = sys.argv
28  # the info responses are concated by newlines
29  infos = [s.strip() for s in info.splitlines()]
30  sys.stderr.write(infos[-1])
31  print("Extracted checksum: '%s'" % infos[-1])
32  # non-zero return code signals error
33  return 0
34
35
36if __name__ == "__main__":
37  sys.exit(main())
38