-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include binary file for default patches in firmware (#1)
firmware: include binary patch file
- Loading branch information
Showing
7 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/version.h | ||
/default.dexy.h |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" make-binary-inc-file - Convert a binary file to C-compatible data. | ||
Usage: make-binary-inc-file.py <input-filename> ... | ||
For each input file, write an output file with '.h' appended to the name. | ||
The output file contains the binary data from the input file, formatted in a way | ||
that can be #included in a C or C++ declaration. | ||
""" | ||
|
||
import sys | ||
import os | ||
|
||
cmdName, *inputFiles = sys.argv | ||
# Set outputDir to the same directory as this script - that is where output files | ||
# will be written. | ||
# If that's not desired, set outputDir = '' to write output files next to the input files. | ||
outputDir = os.path.dirname(cmdName) | ||
#outputDir = '' | ||
cmdName = os.path.basename(cmdName) | ||
for inputFile in inputFiles: | ||
outputFile = inputFile + '.h' | ||
if outputDir: | ||
outputFile = os.path.join(outputDir, os.path.basename(outputFile)) | ||
try: | ||
with open(inputFile, 'rb') as input: | ||
try: | ||
with open(outputFile, 'w') as output: | ||
i = 0 | ||
while char := input.read(1): | ||
i += 1 | ||
if i % 16 == 0: | ||
endLine = '\n' | ||
else: | ||
endLine = '' | ||
print(f'{ord(char):3}, ', end=endLine, file=output) | ||
print(file=output) | ||
except Exception as ex: | ||
print(f'{cmdName}: {ex}') | ||
except Exception as ex: | ||
print(f'{cmdName}: {ex}') |
Binary file not shown.
Binary file not shown.
Binary file not shown.