Skip to content

Instantly share code, notes, and snippets.

@qwerty12
Created September 1, 2013 00:41
Show Gist options
  • Save qwerty12/6401600 to your computer and use it in GitHub Desktop.
Save qwerty12/6401600 to your computer and use it in GitHub Desktop.
Script to create a C header with the contents of the AR3011 firmware for ioath3kfirmware
#!/usr/bin/env python
#atheros-fw.py > OS-X-Atheros-3k-Firmware/IOath3kfrmwr/ath3k-1fw.h
import sys
import binascii
with open("AtherosBT.bin", "rb") as f:
bytes = f.read()
size = len(bytes)
sys.stdout.write("\n/* ath3k-1-linux-git.h begin binary data: */\n")
sys.stdout.write("char firmware_buf[] = /* %d */\n{" % size)
sys.stdout.write("0x%s" % binascii.hexlify(bytes[0]).upper())
for i in xrange(1, size):
if i % 15 == 0:
sys.stdout.write("\n")
sys.stdout.write(",0x%s" % binascii.hexlify(bytes[i]).upper())
sys.stdout.write("};\n")
sys.stdout.write("/* end binary data. size = %d bytes */\n\n" % size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment