diff --git a/Makefile b/Makefile index 589b90f..bc0c8bc 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,10 @@ endif BAUD=115200 DEV=/dev/ttyUSB0 +ocd: all + python3 scripts/telnet.py localhost 4444 \ + "reset init ; flash write_image erase `pwd`/$(PROJ)-$(VER).hex ; reset" + flash: all sudo stm32flash -b $(BAUD) -w $(PROJ)-$(VER).hex $(DEV) diff --git a/scripts/telnet.py b/scripts/telnet.py new file mode 100644 index 0000000..2fc2250 --- /dev/null +++ b/scripts/telnet.py @@ -0,0 +1,9 @@ + +# Send a command over telnet to remote host: +# telnet.py + +import sys +import telnetlib + +with telnetlib.Telnet(sys.argv[1], sys.argv[2]) as t: + t.write((sys.argv[3] + '\n').encode('utf-8'))