From 00eb4ab7f5549758c36ce944841cdd2727422f81 Mon Sep 17 00:00:00 2001 From: Prutonis <133200738+prutonis@users.noreply.github.com> Date: Mon, 30 Dec 2024 23:43:37 +0200 Subject: [PATCH 1/2] Update magboot.py for python3 --- magboot.py | 73 +++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/magboot.py b/magboot.py index 376facd..1db3e5c 100755 --- a/magboot.py +++ b/magboot.py @@ -45,47 +45,50 @@ def usage(*args): sys.stdout = sys.stderr - print __doc__ + print(__doc__) for msg in args: - print msg + print(msg) sys.exit(2) -def do_cmd(str, expect_reply=True): - ser.write(str) +def do_cmd(val, expect_reply=True): + if isinstance(val, str): + val = val.encode('latin1') + ser.write(val) if not expect_reply: - print "> OK" + print("> OK") return reply = ser.read() if (len(reply) == 0): - print "> FAILED (TIMEOUT)" + print("> FAILED (TIMEOUT)") sys.exit(1) - + reply = reply.decode() if (reply == 'Y'): - print "> OK" + print("> OK") return if (reply == 'N'): - print "> FAILED" + print("> FAILED") else: - print "> FAILED (UNKNOWN):" + print("> FAILED (UNKNOWN):") while (len(reply) == 1): - print reply + print(reply) reply = ser.read() sys.exit(1) def cmd_device_id(): - print "ID" + print("ID") do_cmd('I' + dev['signature']) def cmd_load_addr(addr): - print "LOAD_ADDR" + print("LOAD_ADDR") # Little-endian, 16-bit uint load address load_addr = pack(' Date: Mon, 30 Dec 2024 23:44:44 +0200 Subject: [PATCH 2/2] Minor change in test program --- testapp/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/testapp/main.c b/testapp/main.c index 23e86fd..2c043a6 100644 --- a/testapp/main.c +++ b/testapp/main.c @@ -27,10 +27,13 @@ int main(void) { LED_DIR |= _BV(LED_BIT); LED_PORT ^= _BV(LED_BIT); + + // wdt_enable(WDTO_250MS); - wdt_enable(WDTO_250MS); - - while (1); /* Watchdog bite */ + while (1) { + _delay_ms(1000); + LED_PORT ^= _BV(LED_BIT); + } return 0; }