Created
June 4, 2017 07:19
-
-
Save electronut/72346cfdf39a09a4302beaa780defb72 to your computer and use it in GitHub Desktop.
Uploads DFU OTA bootloader to bluey board
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
""" | |
upload.py | |
Uploads DFU OTA bootloader to bluey board. | |
Electronut Labs | |
electronut.in | |
""" | |
import sys | |
import os | |
# main() function | |
def main(): | |
# use sys.argv if needed | |
if len(sys.argv) < 2: | |
print('Usage: python upload.py PORT') | |
exit(0) | |
port = sys.argv[1] | |
# for stupid windows systems | |
# For ports >= COM10, add the prefix \\.\, for example: | |
# target extended-remote COM3 | |
# target extended-remote \\.\COM10 | |
if port.startswith("COM"): | |
n = int(port[port.find("COM")+3:]) | |
if n >= 10: | |
port = "\\\\.\\" + port | |
print("Using %s..." % (port, )) | |
# create GDB cmd file | |
f = open("bluey_boot.gdb", "w") | |
f.write("target extended-remote %s\n" %(port, )) | |
f.write("monitor swdp_scan\n") | |
f.write("attach 1\n") | |
f.write("load out.hex\n") | |
f.write("detach\n") | |
f.write("quit\n") | |
f.close() | |
print("created bluey_boot.gdb...") | |
print("running: arm-none-eabi-gdb -x bluey_boot.gdb...") | |
os.system("arm-none-eabi-gdb -x bluey_boot.gdb") | |
print("cleaning up...") | |
os.remove("bluey_boot.gdb") | |
print("done.") | |
# call main | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment