Created
February 13, 2014 14:53
-
-
Save edy555/8976352 to your computer and use it in GitHub Desktop.
append header onto binary file for writing dfu-util
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import struct | |
| import sys | |
| fin = open(sys.argv[1], 'rb') | |
| fout = open(sys.argv[2], 'wb') | |
| bin = fin.read() | |
| fin.close() | |
| n = (len(bin) + 511) / 512 | |
| fout.write('\32\77%s\0\0\0\0\0\0\0\0\377\377\377\377' % struct.pack('<H', n)) | |
| fout.write(bin) | |
| fout.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment