-alias reset = set *((uint8_t *)0x8008fd) = 0x40
-alias startapp = set *((uint8_t *)0x8008fd) = 0x20
-alias killapp = set *((uint8_t *)0x8008fd) = 0x10
+alias reset = set *((uint8_t *)0x8010fd) = 0x40
+alias startapp = set *((uint8_t *)0x8010fd) = 0x20
+alias killapp = set *((uint8_t *)0x8010fd) = 0x10
set history save on
set history size unlimited
set history remove-duplicates unlimited
set pagination off
set non-stop 1
-#file dist/gdb-stub-sm_atmega324p.elf
-#target remote localhost:2424
+file dist/gdb-stub_atmega644p.elf
+
+set serial baud 115200
+target remote /dev/ttyUSB1
--log none
#--nosync
dist/gdb-stub_atmega644p.elf
-../test-2024-07-02/dist/test-nano-644.elf
+../test-2024-07-02/sim/test-nano-644.elf
"files.trimTrailingWhitespace": true,
"editor.tabSize": 4,
"editor.insertSpaces": false,
+ "[markdown]": {
+ "files.trimTrailingWhitespace": false
+ },
"cSpell.words": [
"adiw",
"APPINIT",
LFLAGS = -gdwarf-2
LFLAGS += -Wl,-Tldscripts/ldscript_atmega644p.x
-CFLAGS_SIM = -g -DF_CPU=12000000L -Os -Wall -gdwarf-2
+CFLAGS_SIM = -g -DF_CPU=12000000L -Og -Wall -gdwarf-2
CFLAGS_SIM += -DSIMAVR
LFLAGS_SIM = -gdwarf-2
-LFLAGS_SIM += -Wl,-Tldscripts/ldscript_atmega644p_sim.x
+#LFLAGS_SIM += -Wl,-Tldscripts/ldscript_atmega644p_sim.x
+LFLAGS_SIM += -Wl,-Tldscripts/ldscript_atmega644p.x
DEVICE = atmega644p
Programmiere EEPROM Adresse 0 mit 0x00 (im gdb-stub dauerhaft bleiben):
```
-avrdude -c usbasp -p atmega324p -U eeprom:w:0x00:m
+avrdude -c usbasp -p atmega644p -U eeprom:w:0x00:m
```
Programmier EEPROM Adresse 0 mit 0xff (gdb-stub sofoert verlassen und Applikation starten):
* `--->` Request from *avr-gdb* to *gdb-stub* (in µC)
* `<---` Response from *gdb-stub* (in µC) to *avr-gdb*
-## Request/Response 1
+## 1 Request/Response
[https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qSupported-packet](https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qSupported-packet)
```
------------------------------------------------------------
-## Request/Response 2
+## 2 Request/Response
[https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packets.html#index-vMustReplyEmpty-packet](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packets.html#index-vMustReplyEmpty-packet)
------------------------------------------------------------
-## Request/Response 3
+## 3 Request/Response
Set thread for subsequent operations (‘m’, ‘M’, ‘g’, ‘G’, et.al.):
[https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-H-packet](https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-H-packet)
------------------------------------------------------------
-## Request/Response 4
+## 4 Request/Response
[https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html#index-QNonStop-packet](https://sourceware.org/gdb/current/onlinedocs/gdb.html/General-Query-Packets.html#index-QNonStop-packet)
------------------------------------------------------------
-## Request/Response 5
+## 5 Request/Response
[https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qfThreadInfo-packet](https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qfThreadInfo-packet)
------------------------------------------------------------
-## Request/Response 6
+## 6 Request/Response
[https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qfThreadInfo-packet](https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qfThreadInfo-packet)
------------------------------------------------------------
-## Request/Response 7
+## 7 Request/Response
[https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qAttached-packet](https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qAttached-packet)
------------------------------------------------------------
-## Request/Response 8
+## 8 Request/Response
[https://sourceware.org/gdb/onlinedocs/gdb/Tracepoint-Packets.html#index-qTStatus-packet](https://sourceware.org/gdb/onlinedocs/gdb/Tracepoint-Packets.html#index-qTStatus-packet)
------------------------------------------------------------
-## Request/Response 9
+## 9 Request/Response
[https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-_003f-packet](https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-_003f-packet)
------------------------------------------------------------
-## Request/Response 10
+## 10 Request/Response
[https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-vCont_003f-packet](https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-vCont_003f-packet)
------------------------------------------------------------
-## Request/Response 11
+## 11 Request/Response
[https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-vCont-packet](https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-vCont-packet)
Resume the inferior, specifying different actions for each thread.
+* `c` Continue.
+* `C sig` Continue with signal sig. The signal sig should be two hex digits.
+* `s` Step.
+* `S sig` Step with signal sig. The signal sig should be two hex digits.
+* **`t` Stop.**
+
+==> STOP the application
+==> gdb-stub sends status packet "%..." when STOP is executed
```
---> $vCont;t:1#24
------------------------------------------------------------
-## Request/Response 12
+## 12 Notification Stop
+
+[https://sourceware.org/gdb/current/onlinedocs/gdb.html/Notification-Packets.html#Notification-Packets](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Notification-Packets.html#Notification-Packets)
+
+The GDB remote serial protocol includes notifications, packets that require no acknowledgment.
+
+After receiving a notification, GDB shall acknowledge it by sending a ack packet as a regular, synchronous request to the stub. Such acknowledgment is not required to happen immediately, as GDB is permitted to send other, unrelated packets to the stub first, which the stub should process normally.
+
+```
+<--- %Stop:T00thread:1;#b2
+```
+
+------------------------------------------------------------
+
+## 13 Request/Response
[https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qSymbol-packet](https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qSymbol-packet)
<--- $OK#9a
---> +
```
+
+------------------------------------------------------------
+
+## 14 Acknowledge for Stop-Notification (12)
+
+[https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packets.html#index-vStopped-packet](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packets.html#index-vStopped-packet)
+
+
+
+```
+---> $vStopped#55
+<--- +
+<--- $OK#9a
+---> +
+```
+
+------------------------------------------------------------
+
+## 15 Request/Response
+
+[https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-H-packet](https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-H-packet)
+
+Set thread for subsequent operations (‘m’, ‘M’, ‘g’, ‘G’, et.al.).
+Use ‘g’ for other operations.
+
+
+```
+---> $Hg1#e0
+<--- +
+<--- $OK#9a
+---> +
+```
+
+------------------------------------------------------------
+
+## 16 Request/Response
+
+[https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-g-packet](https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-g-packet)
+
+Read general registers (used on gdb command load)
+
+```
+---> $g#67
+<--- +
+<--- $000000000000000000000000000000000000000000000000000000000000000000000000000000#a0
+--> +
+```
+
+oder:
+
+```
+---> $g#67
+<--- +
+<--- $0*j#c4
+---> +
+```
+
+------------------------------------------------------------
+
+## 17 Request/Response
+
+[https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-vCont-packet](https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-vCont-packet)
+
+Resume the inferior, specifying different actions for each thread.
+* `c` Continue.
+* `C sig` Continue with signal sig. The signal sig should be two hex digits.
+* `s` Step.
+* `S sig` Step with signal sig. The signal sig should be two hex digits.
+* **`t` Stop.**
+
+```
+---> $vCont;c#a8
+<--- +
+<--- $OK#9a
+---> +
+```
--- /dev/null
+alias reset = set *((uint8_t *)0x8008fd) = 0x40
+alias startapp = set *((uint8_t *)0x8008fd) = 0x20
+alias killapp = set *((uint8_t *)0x8008fd) = 0x10
+
+set history save on
+set history size unlimited
+set history remove-duplicates unlimited
+set pagination off
+#set non-stop 1
+file dist/gdb-stub_atmega644p.axf
+br src/gdb.cpp:315
+target remote localhost:1234
+layout split
--- /dev/null
+#--board nano-644
+--pc 0xe000
+--frequency 12000000
+--mmcu atmega644p
+#--log trace
+--log none
+#--nosync
+dist/gdb-stub_atmega644p.elf
+../../test-2024-07-02/sim/test-nano-644.elf
+
gdb::executeControl();
gdb::handleGdbRequest();
if (pgdb->ctrl.start) {
+ setLedOrange(1);
pgdb->ctrl.start = 0;
startProgram = 0;
+ eepromByteAddrZero = 0xff;
}
if (startProgram == 0 || TCNT1 >= 0x16E3) { // 499,966ms
toggleLedRed();
uint8_t b = pgm_read_byte(0x0000); // check if app in non bootloader flash
- setLedOrange(1);
if (b != 0xff) {
+ setLedOrange(0);
+ setLedGreen(1);
struct gdb::Gdb *pgdb = GDB_PTR;
pgdb->status.isAppStarted = 1;
pgdb->status.isStopped = 0;
gdb::handleGdbRequest();
}
}
- toggleLedGreen();
putln(stdoutUart);
// make sure that last UART Bytes are sent completely
TCNT1 = 0;
}
}
+ void putStatus (int8_t uart) {
+ // struct gdb::Gdb *pgdb = GDB_PTR;
+ // putln(uart);
+ // printChar(uart, 'S');
+ // printChar(uart, '-');
+ // printChar(uart, pgdb->status.isAppStarted ? 'A' : 'a');
+ // printChar(uart, pgdb->status.isStopped ? 'S' : 's');
+ // printChar(uart, pgdb->status.isConnected ? 'C' : 'x');
+ // printChar(uart, pgdb->status.isBreakpointValid ? 'B' : 'b');
+ // putln(uart);
+
+ struct gdb::Gdb *pgdb = GDB_PTR;
+ putln(uart);
+ printChar(uart, 'S');
+ printChar(uart, '-');
+ putUint8Hex(0, (uint8_t)(((uint16_t)(void *)&pgdb->ctrl) >> 8) );
+ putUint8Hex(0, (uint8_t)((uint16_t)(void *)&pgdb->ctrl) );
+ putln(uart);
+ }
+
void memputc (int8_t uart, PGM_P p) {
char c = pgm_read_byte(p);
printChar(uart, c);
void memputs (int8_t uart, PGM_P p) ATT_OPTIMIZE ATT_SECTION_BOOTLOADER;
int getc (int8_t uart) ATT_OPTIMIZE ATT_SECTION_BOOTLOADER;
+ // for development
+ void putStatus (int8_t uart) ATT_OPTIMIZE ATT_SECTION_BOOTLOADER;
+
uint8_t eepromReadByte (const uint8_t *p) ATT_OPTIMIZE ATT_SECTION_BOOTLOADER __attribute__ ((naked));
void eepromWriteByte (uint8_t *p, uint8_t value) ATT_OPTIMIZE ATT_SECTION_BOOTLOADER __attribute__ ((naked));
const char gdb_QNonStop[] GDBMEM = "QNonStop+";
const char gdb_QXferMemoryMapRead[] GDBMEM = "qXfer:memory-map:read+";
const char gdb_vCont[] GDBMEM = "$vCont;c;t;#";
+ const char gdb_StatusStop[] GDBMEM = "\%Stop:T00thread:1;#";
// const char gdb_QStartNoAckMode[] GDBMEM = "QStartNoAckMode+";
// const char gdb_QXferExecFileRead[] GDBMEM = "qXfer:exec-file:read+";
}
void xputsStop () {
- xputc('%');
- xputc('#');
+ xputsmem(gdb_StatusStop);
}
// ATTENTION: static data not initialized when application not started !!
// return;
// }
+ case 'g': {
+ // https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-g-packet
+ // Read general registers (used on gdb command load)
+ xputc('$');
+ for (i = 0; i < 78; i++) {
+ xputc('0');
+ }
+ // or "$0*j#"
+ xputc('#');
+ return;
+ }
+
case 'm': {
// https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-m-packet
volatile uint8_t *pFrom = (volatile uint8_t *)(p->buffer + i + j + 1);
volatile uint8_t *pTo = (volatile uint8_t *)(address & 0xffff);
uint8_t addH = (address >> 16) & 0xff;
+
for (j = 0; j < l; j++) {
uint8_t vx = *pFrom++;
if (addH == 0) {
xputsmem(gdb_OK);
return;
}
- if ( (uint16_t)pTo >= 0x900) {
+ if ( (uint16_t)pTo >= 0xf000) {
// eeprom
- bootloader::eepromWriteByte((uint8_t *)(pTo - 0x900), vx);
+ bootloader::eepromWriteByte((uint8_t *)(pTo - 0xf000), vx);
} else if ( (uint16_t)pTo >= 0x100) {
// sram
// https://sourceware.org/gdb/onlinedocs/gdb/General-Query-Packets.html#index-qSupported-packet
// Tell the remote stub about features supported by GDB, and query the stub for features it supports.
xputc('$');
- xputsmem(gdb_QXferMemoryMapRead);
- xputc(';'); xputsmem(gdb_QNonStop);
+ xputsmem(gdb_QNonStop);
+ // xputc(';'); xputsmem(gdb_QXferMemoryMapRead);
// xputc(';'); xputsmem(gdb_QStartNoAckMode);
// xputc(';'); xputsmem(gdb_QXferExecFileRead);
xputc('#');
xputsmem(gdb_vCont);
return;
- // } else if (i == 6 && sum == 0xa8) { // vCont;c
- // // https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-vCont-packet
- // // Resume the inferior, specifying different actions for each thread.
- // xputsmem(gdb_OK);
- // return;
+ } else if (i == 6 && sum == 0xa8) { // vCont;c
+ // https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-vCont-packet
+ // Resume the inferior, specifying different actions for each thread.
+ pgdb->ctrl.proceed = 1;
+ xputsmem(gdb_OK);
+ return;
} else if (
(i == 6 && sum == 0xb9) // vCont;t (https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#index-vCont-packet -> Resume the inferior, specifying different actions for each thread.)
// case 2: gdb.ctrl.continueApplication = 1; break;
// case 3: gdb.ctrl.continueInterrupts = 1; break;
// }
+ bootloader::putStatus(0);
+ pgdb->ctrl.stop = 1;
xputsmem(gdb_OK);
return;