From 1d6e29e42ecfbca2f6f63d9c8231d6f3e4a8dac1 Mon Sep 17 00:00:00 2001 From: Manfred Steiner Date: Sun, 21 Jul 2024 07:42:10 +0200 Subject: [PATCH] bugfixes... --- software/gdb-stub/src/gdb.cpp | 15 ++++++++------- software/gdb-stub/src/gdb.h | 34 ++++++++++++++++++---------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/software/gdb-stub/src/gdb.cpp b/software/gdb-stub/src/gdb.cpp index 66ad7da..64b1e13 100644 --- a/software/gdb-stub/src/gdb.cpp +++ b/software/gdb-stub/src/gdb.cpp @@ -38,7 +38,8 @@ namespace gdb { // const char gdb_QStartNoAckMode[] GDBMEM = "QStartNoAckMode+"; // const char gdb_QXferExecFileRead[] GDBMEM = "qXfer:exec-file:read+"; - const char gdb_mem[] GDBMEM = "$l0x1000x01#"; + //const char gdb_mem[] GDBMEM = "$l0x100'0x01#"; + const char gdb_mem[] GDBMEM = "$l0x100'#"; // struct Gdb gdb; // struct Buffer buf; @@ -108,7 +109,7 @@ namespace gdb { "std Y+36, r27 \n" "ldd r25, Z+7 \n" // restore original r25 - "ldd r27, Z+10 \n" // original (PCH/2) -> r27 (XH) + "ldd r27, Z+10 \n" // original (PCH/2) -> r27 (XH) "ldd r26, Z+11 \n" // original (PCL/2) -> r26 (XL) "adiw r30, 11 \n" // restore SP in stop() (4x push + 3x call) "std Y+32, r30 \n" // save SPL @@ -317,7 +318,7 @@ namespace gdb { pgdb->status.isAppStarted = 0; } - } else if (pgdb->ctrl.notify && pgdb->buffer.state != idle) { + } else if (pgdb->ctrl.notify && pgdb->buffer.state == idle) { pgdb->ctrl.notify = 0; pgdb->timer = 20; xputsmem(gdb_StatusStop); @@ -669,10 +670,10 @@ namespace gdb { } } else { - bootloader::putnc(0, c, 1); - bootloader::putnc(0, ' ', 1); bootloader::putUint8Hex(0, i); - bootloader::putnc(0, ' ',2); bootloader::putUint8Hex(0, sum); - bootloader::putln(0); + // bootloader::putnc(0, c, 1); + // bootloader::putnc(0, ' ', 1); bootloader::putUint8Hex(0, i); + // bootloader::putnc(0, ' ',2); bootloader::putUint8Hex(0, sum); + // bootloader::putln(0); } } diff --git a/software/gdb-stub/src/gdb.h b/software/gdb-stub/src/gdb.h index eb62175..0a13e41 100644 --- a/software/gdb-stub/src/gdb.h +++ b/software/gdb-stub/src/gdb.h @@ -16,8 +16,9 @@ #define GDB_PTR (gdb::Gdb *)(RAMEND - sizeof(gdb::Gdb) + 1) -//#define GDB_BREAKPOINT_PTR (struct gdb::Breakpoint *)(RAMEND - 2 - sizeof(gdb::Control) - sizeof(gdb::Status) - sizeof(gdb::Breakpoint) + 1) +// #define GDB_BREAKPOINT_PTR (struct gdb::Breakpoint *)(RAMEND - 2 - sizeof(gdb::Control) - sizeof(gdb::Status) - sizeof(gdb::Breakpoint)) #define GDB_BREAKPOINT_PTR (struct gdb::Breakpoint *)(RAMEND - 4 - sizeof(gdb::Breakpoint)) +// #define GDB_BREAKPOINT_PTR (struct gdb::Breakpoint *)(RAMEND - 6 - sizeof(gdb::Breakpoint)) namespace gdb { @@ -26,24 +27,25 @@ namespace gdb { enum BufferState { idle = 0, data, esc, chk1, chk2, chk2err, exec, execerr, send, waitack }; - struct Status { // (gdb) print *((struct gdb::Status *)0x8010fb) - uint8_t errorFlags; // @0x18fb - uint8_t isConnected:1; // @0x18fc.0x01, address used in bootloader::jmpTableGdbStopApplication() - uint8_t isAppStarted:1; // @0x18fc.0x02 - uint8_t isStopped:1; // @0x18fc.0x04 - uint8_t isBreakpointValid:1; // @0x18fc.0x08 - uint8_t isSendingNotification:1; // @0x18fc.0x10 + struct Status { // (gdb) print *((struct gdb::Status *)0x8010f9) + uint8_t errorFlags; // @0x10f9 + // int16_t flashPage; // @0x10fa + uint8_t isConnected:1; // @0x10fc.0x01, address used in bootloader::jmpTableGdbStopApplication() + uint8_t isAppStarted:1; // @0x10fc.0x02 + uint8_t isStopped:1; // @0x10fc.0x04 + uint8_t isBreakpointValid:1; // @0x10fc.0x08 + uint8_t isSendingNotification:1; // @0x10fc.0x10 }; struct Control { // (gdb) print *((struct gdb::Control *)0x8010fd) - uint8_t clearErrors:1; // @0x18fd.0x01 - uint8_t interrupt:1; // @0x18fd.0x02 - uint8_t stop:1; // @0x18fd.0x04 - uint8_t proceed:1; // @0x18fd.0x08 - uint8_t kill:1; // @0x18fd.0x10 - uint8_t start:1; // @0x18fd.0x20 - uint8_t reset:1; // @0x18fd.0x40 - uint8_t notify:1; // @0x18fd.0x80 + uint8_t clearErrors:1; // @0x10fd.0x01 + uint8_t interrupt:1; // @0x10fd.0x02 + uint8_t stop:1; // @0x10fd.0x04 + uint8_t proceed:1; // @0x10fd.0x08 + uint8_t kill:1; // @0x10fd.0x10 + uint8_t start:1; // @0x10fd.0x20 + uint8_t reset:1; // @0x10fd.0x40 + uint8_t notify:1; // @0x10fd.0x80 }; struct Buffer { -- 2.39.5