Skip to content

Instantly share code, notes, and snippets.

@HerrSpace
Forked from plushvoxel/spi_to_bin.py
Created February 12, 2016 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HerrSpace/4f922116bf0230891e97 to your computer and use it in GitHub Desktop.
Save HerrSpace/4f922116bf0230891e97 to your computer and use it in GitHub Desktop.
write shit to binary
#!/usr/bin/env python2
import time
import serial
import struct
import binascii
mem_addr = 0x80000000
ser= serial.Serial('/dev/ttyUSB0', 115200, timeout=1)
f = open("./dump.bin", "wb")
while mem_addr < 0x83ffffff:
to_send = hex(mem_addr)[2:] + '\r'
ser.write(to_send)
_ = ser.readline()
result = ser.readline()
value = result[19:27]
_ = ser.readline()
#print(hex(mem_addr)+"\t"+value+"\t"+str(int(value,16)))
#data = chr(int(value[0:1], 16))+chr(int(value[2:3], 16))+chr(int(value[4:5], 16))+chr(int(value[6:7], 16))
data = binascii.a2b_hex(value)
f.write(data)
mem_addr += 4
if mem_addr % 256 == 0: print hex(mem_addr)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment