Created
April 27, 2021 23:57
-
-
Save LeoDJ/624ac80ca8efa2b5b16abf7bc1c348de to your computer and use it in GitHub Desktop.
Convert XPV/XDV files to binary (CSR Blueflash Bluecore firmware files)
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 python3 | |
# Convert XPV/XDV files to binary (CSR Blueflash / Bluecore firmware files) | |
# Quickly hacked together by LeoDJ | |
import sys | |
import os | |
def xpv2bin(input_file, output_file): | |
with open(input_file) as f_in, open(output_file, "wb") as f_out: | |
for line in f_in: | |
part = line.split(' ') | |
addr = int(part[0][1:], 16) # ignore @ | |
data = bytes.fromhex(part[1]) # convert 2 byte hex string to bytes | |
f_out.seek(addr * 2) # seek to correct address | |
f_out.write(data) # write data (is endianness correct?) | |
filename_in = sys.argv[1] # specify filename as first parameter | |
xpv2bin(filename_in, filename_in + '.bin') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment