rp2040js 0.17.17 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/clock/clock.d.ts +11 -11
- package/dist/cjs/clock/clock.js +2 -2
- package/dist/cjs/clock/mock-clock.d.ts +17 -17
- package/dist/cjs/clock/mock-clock.js +52 -52
- package/dist/cjs/clock/realtime-clock.d.ts +23 -23
- package/dist/cjs/clock/realtime-clock.js +73 -73
- package/dist/cjs/cortex-m0-core.d.ts +87 -87
- package/dist/cjs/cortex-m0-core.js +1251 -1251
- package/dist/cjs/gdb/gdb-connection.d.ts +11 -11
- package/dist/cjs/gdb/gdb-connection.js +57 -57
- package/dist/cjs/gdb/gdb-server.d.ts +23 -23
- package/dist/cjs/gdb/gdb-server.js +232 -232
- package/dist/cjs/gdb/gdb-tcp-server.d.ts +10 -10
- package/dist/cjs/gdb/gdb-tcp-server.js +34 -34
- package/dist/cjs/gdb/gdb-utils.d.ts +9 -9
- package/dist/cjs/gdb/gdb-utils.js +48 -48
- package/dist/cjs/gpio-pin.d.ts +56 -56
- package/dist/cjs/gpio-pin.js +216 -216
- package/dist/cjs/index.d.ts +11 -11
- package/dist/cjs/index.js +36 -36
- package/dist/cjs/interpolator.d.ts +36 -36
- package/dist/cjs/interpolator.js +150 -150
- package/dist/cjs/irq.d.ts +29 -29
- package/dist/cjs/irq.js +33 -33
- package/dist/cjs/peripherals/adc.d.ts +52 -52
- package/dist/cjs/peripherals/adc.js +261 -261
- package/dist/cjs/peripherals/busctrl.d.ts +10 -10
- package/dist/cjs/peripherals/busctrl.js +84 -84
- package/dist/cjs/peripherals/clocks.d.ts +9 -9
- package/dist/cjs/peripherals/clocks.js +42 -42
- package/dist/cjs/peripherals/dma.d.ts +109 -109
- package/dist/cjs/peripherals/dma.js +520 -520
- package/dist/cjs/peripherals/i2c.d.ts +54 -54
- package/dist/cjs/peripherals/i2c.js +458 -458
- package/dist/cjs/peripherals/io.d.ts +11 -11
- package/dist/cjs/peripherals/io.js +100 -100
- package/dist/cjs/peripherals/pads.d.ts +13 -13
- package/dist/cjs/peripherals/pads.js +58 -58
- package/dist/cjs/peripherals/peripheral.d.ts +22 -22
- package/dist/cjs/peripherals/peripheral.js +61 -61
- package/dist/cjs/peripherals/pio.d.ts +120 -120
- package/dist/cjs/peripherals/pio.js +1086 -1086
- package/dist/cjs/peripherals/ppb.d.ts +25 -25
- package/dist/cjs/peripherals/ppb.js +229 -229
- package/dist/cjs/peripherals/pwm.d.ts +65 -65
- package/dist/cjs/peripherals/pwm.js +372 -372
- package/dist/cjs/peripherals/reset.d.ts +8 -8
- package/dist/cjs/peripherals/reset.js +40 -40
- package/dist/cjs/peripherals/rtc.d.ts +10 -10
- package/dist/cjs/peripherals/rtc.js +74 -74
- package/dist/cjs/peripherals/spi.d.ts +38 -38
- package/dist/cjs/peripherals/spi.js +240 -240
- package/dist/cjs/peripherals/ssi.d.ts +6 -6
- package/dist/cjs/peripherals/ssi.js +43 -43
- package/dist/cjs/peripherals/syscfg.d.ts +5 -5
- package/dist/cjs/peripherals/syscfg.js +26 -26
- package/dist/cjs/peripherals/sysinfo.d.ts +4 -4
- package/dist/cjs/peripherals/sysinfo.js +22 -22
- package/dist/cjs/peripherals/tbman.d.ts +4 -4
- package/dist/cjs/peripherals/tbman.js +17 -17
- package/dist/cjs/peripherals/timer.d.ts +18 -18
- package/dist/cjs/peripherals/timer.js +156 -156
- package/dist/cjs/peripherals/uart.d.ts +31 -31
- package/dist/cjs/peripherals/uart.js +132 -132
- package/dist/cjs/peripherals/usb.d.ts +29 -29
- package/dist/cjs/peripherals/usb.js +309 -309
- package/dist/cjs/rp2040.d.ts +71 -71
- package/dist/cjs/rp2040.js +361 -361
- package/dist/cjs/sio.d.ts +21 -21
- package/dist/cjs/sio.js +425 -425
- package/dist/cjs/usb/cdc.d.ts +20 -20
- package/dist/cjs/usb/cdc.js +126 -126
- package/dist/cjs/usb/interfaces.d.ts +47 -47
- package/dist/cjs/usb/interfaces.js +46 -46
- package/dist/cjs/usb/setup.d.ts +5 -5
- package/dist/cjs/usb/setup.js +53 -53
- package/dist/cjs/utils/assembler.d.ts +79 -79
- package/dist/cjs/utils/assembler.js +328 -328
- package/dist/cjs/utils/bit.d.ts +3 -3
- package/dist/cjs/utils/bit.js +15 -15
- package/dist/cjs/utils/fifo.d.ts +15 -15
- package/dist/cjs/utils/fifo.js +56 -56
- package/dist/cjs/utils/logging.d.ts +23 -23
- package/dist/cjs/utils/logging.js +48 -48
- package/dist/cjs/utils/pio-assembler.d.ts +45 -45
- package/dist/cjs/utils/pio-assembler.js +87 -87
- package/dist/cjs/utils/time.d.ts +2 -2
- package/dist/cjs/utils/time.js +32 -32
- package/dist/cjs/utils/timer32.d.ts +57 -57
- package/dist/cjs/utils/timer32.js +208 -208
- package/dist/esm/clock/clock.d.ts +11 -11
- package/dist/esm/clock/clock.js +1 -1
- package/dist/esm/clock/mock-clock.d.ts +17 -17
- package/dist/esm/clock/mock-clock.js +47 -47
- package/dist/esm/clock/realtime-clock.d.ts +23 -23
- package/dist/esm/clock/realtime-clock.js +68 -68
- package/dist/esm/cortex-m0-core.d.ts +87 -87
- package/dist/esm/cortex-m0-core.js +1247 -1247
- package/dist/esm/gdb/gdb-connection.d.ts +11 -11
- package/dist/esm/gdb/gdb-connection.js +53 -53
- package/dist/esm/gdb/gdb-server.d.ts +23 -23
- package/dist/esm/gdb/gdb-server.js +228 -228
- package/dist/esm/gdb/gdb-tcp-server.d.ts +10 -10
- package/dist/esm/gdb/gdb-tcp-server.js +30 -30
- package/dist/esm/gdb/gdb-utils.d.ts +9 -9
- package/dist/esm/gdb/gdb-utils.js +36 -36
- package/dist/esm/gpio-pin.d.ts +56 -56
- package/dist/esm/gpio-pin.js +212 -212
- package/dist/esm/index.d.ts +11 -11
- package/dist/esm/index.js +11 -11
- package/dist/esm/interpolator.d.ts +36 -36
- package/dist/esm/interpolator.js +145 -145
- package/dist/esm/irq.d.ts +29 -29
- package/dist/esm/irq.js +30 -30
- package/dist/esm/peripherals/adc.d.ts +52 -52
- package/dist/esm/peripherals/adc.js +257 -257
- package/dist/esm/peripherals/busctrl.d.ts +10 -10
- package/dist/esm/peripherals/busctrl.js +80 -80
- package/dist/esm/peripherals/clocks.d.ts +9 -9
- package/dist/esm/peripherals/clocks.js +38 -38
- package/dist/esm/peripherals/dma.d.ts +109 -109
- package/dist/esm/peripherals/dma.js +515 -515
- package/dist/esm/peripherals/i2c.d.ts +54 -54
- package/dist/esm/peripherals/i2c.js +454 -454
- package/dist/esm/peripherals/io.d.ts +11 -11
- package/dist/esm/peripherals/io.js +96 -96
- package/dist/esm/peripherals/pads.d.ts +13 -13
- package/dist/esm/peripherals/pads.js +54 -54
- package/dist/esm/peripherals/peripheral.d.ts +22 -22
- package/dist/esm/peripherals/peripheral.js +55 -55
- package/dist/esm/peripherals/pio.d.ts +120 -120
- package/dist/esm/peripherals/pio.js +1081 -1081
- package/dist/esm/peripherals/ppb.d.ts +25 -25
- package/dist/esm/peripherals/ppb.js +225 -225
- package/dist/esm/peripherals/pwm.d.ts +65 -65
- package/dist/esm/peripherals/pwm.js +368 -368
- package/dist/esm/peripherals/reset.d.ts +8 -8
- package/dist/esm/peripherals/reset.js +36 -36
- package/dist/esm/peripherals/rtc.d.ts +10 -10
- package/dist/esm/peripherals/rtc.js +70 -70
- package/dist/esm/peripherals/spi.d.ts +38 -38
- package/dist/esm/peripherals/spi.js +236 -236
- package/dist/esm/peripherals/ssi.d.ts +6 -6
- package/dist/esm/peripherals/ssi.js +39 -39
- package/dist/esm/peripherals/syscfg.d.ts +5 -5
- package/dist/esm/peripherals/syscfg.js +22 -22
- package/dist/esm/peripherals/sysinfo.d.ts +4 -4
- package/dist/esm/peripherals/sysinfo.js +18 -18
- package/dist/esm/peripherals/tbman.d.ts +4 -4
- package/dist/esm/peripherals/tbman.js +13 -13
- package/dist/esm/peripherals/timer.d.ts +18 -18
- package/dist/esm/peripherals/timer.js +152 -152
- package/dist/esm/peripherals/uart.d.ts +31 -31
- package/dist/esm/peripherals/uart.js +128 -128
- package/dist/esm/peripherals/usb.d.ts +29 -29
- package/dist/esm/peripherals/usb.js +305 -305
- package/dist/esm/rp2040.d.ts +71 -71
- package/dist/esm/rp2040.js +357 -357
- package/dist/esm/sio.d.ts +21 -21
- package/dist/esm/sio.js +421 -421
- package/dist/esm/usb/cdc.d.ts +20 -20
- package/dist/esm/usb/cdc.js +121 -121
- package/dist/esm/usb/interfaces.d.ts +47 -47
- package/dist/esm/usb/interfaces.js +43 -43
- package/dist/esm/usb/setup.d.ts +5 -5
- package/dist/esm/usb/setup.js +46 -46
- package/dist/esm/utils/assembler.d.ts +79 -79
- package/dist/esm/utils/assembler.js +245 -245
- package/dist/esm/utils/bit.d.ts +3 -3
- package/dist/esm/utils/bit.js +9 -9
- package/dist/esm/utils/fifo.d.ts +15 -15
- package/dist/esm/utils/fifo.js +52 -52
- package/dist/esm/utils/logging.d.ts +23 -23
- package/dist/esm/utils/logging.js +44 -44
- package/dist/esm/utils/pio-assembler.d.ts +45 -45
- package/dist/esm/utils/pio-assembler.js +75 -75
- package/dist/esm/utils/time.d.ts +2 -2
- package/dist/esm/utils/time.js +27 -27
- package/dist/esm/utils/timer32.d.ts +57 -57
- package/dist/esm/utils/timer32.js +203 -203
- package/package.json +38 -27
- package/dist/esm/package.json +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { GDBServer } from './gdb-server';
|
|
2
|
-
export
|
|
3
|
-
export declare class GDBConnection {
|
|
4
|
-
private server;
|
|
5
|
-
private onResponse;
|
|
6
|
-
readonly rp2040: import("../rp2040").RP2040;
|
|
7
|
-
private buf;
|
|
8
|
-
constructor(server: GDBServer, onResponse: GDBResponseHandler);
|
|
9
|
-
feedData(data: string): void;
|
|
10
|
-
onBreakpoint(): void;
|
|
11
|
-
}
|
|
1
|
+
import { GDBServer } from './gdb-server.js';
|
|
2
|
+
export type GDBResponseHandler = (value: string) => void;
|
|
3
|
+
export declare class GDBConnection {
|
|
4
|
+
private server;
|
|
5
|
+
private onResponse;
|
|
6
|
+
readonly rp2040: import("../rp2040.js").RP2040;
|
|
7
|
+
private buf;
|
|
8
|
+
constructor(server: GDBServer, onResponse: GDBResponseHandler);
|
|
9
|
+
feedData(data: string): void;
|
|
10
|
+
onBreakpoint(): void;
|
|
11
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { STOP_REPLY_SIGINT, STOP_REPLY_TRAP } from './gdb-server';
|
|
2
|
-
import { gdbChecksum, gdbMessage } from './gdb-utils';
|
|
3
|
-
export class GDBConnection {
|
|
4
|
-
constructor(server, onResponse) {
|
|
5
|
-
this.server = server;
|
|
6
|
-
this.onResponse = onResponse;
|
|
7
|
-
this.rp2040 = this.server.rp2040;
|
|
8
|
-
this.buf = '';
|
|
9
|
-
server.addConnection(this);
|
|
10
|
-
onResponse('+');
|
|
11
|
-
}
|
|
12
|
-
feedData(data) {
|
|
13
|
-
const { onResponse } = this;
|
|
14
|
-
if (data.charCodeAt(0) === 3) {
|
|
15
|
-
this.server.info('BREAK');
|
|
16
|
-
this.rp2040.stop();
|
|
17
|
-
onResponse(gdbMessage(STOP_REPLY_SIGINT));
|
|
18
|
-
data = data.slice(1);
|
|
19
|
-
}
|
|
20
|
-
this.buf += data;
|
|
21
|
-
for (;;) {
|
|
22
|
-
const dolla = this.buf.indexOf('$');
|
|
23
|
-
const hash = this.buf.indexOf('#', dolla + 1);
|
|
24
|
-
if (dolla < 0 || hash < 0 || hash + 2 > this.buf.length) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const cmd = this.buf.substring(dolla + 1, hash);
|
|
28
|
-
const cksum = this.buf.substr(hash + 1, 2);
|
|
29
|
-
this.buf = this.buf.substr(hash + 2);
|
|
30
|
-
if (gdbChecksum(cmd) !== cksum) {
|
|
31
|
-
this.server.warn(`GDB checksum error in message: ${cmd}`);
|
|
32
|
-
onResponse('-');
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
onResponse('+');
|
|
36
|
-
this.server.debug(`>${cmd}`);
|
|
37
|
-
const response = this.server.processGDBMessage(cmd);
|
|
38
|
-
if (response) {
|
|
39
|
-
this.server.debug(`<${response}`);
|
|
40
|
-
onResponse(response);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
onBreakpoint() {
|
|
46
|
-
try {
|
|
47
|
-
this.onResponse(gdbMessage(STOP_REPLY_TRAP));
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
this.server.removeConnection(this);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
import { STOP_REPLY_SIGINT, STOP_REPLY_TRAP } from './gdb-server.js';
|
|
2
|
+
import { gdbChecksum, gdbMessage } from './gdb-utils.js';
|
|
3
|
+
export class GDBConnection {
|
|
4
|
+
constructor(server, onResponse) {
|
|
5
|
+
this.server = server;
|
|
6
|
+
this.onResponse = onResponse;
|
|
7
|
+
this.rp2040 = this.server.rp2040;
|
|
8
|
+
this.buf = '';
|
|
9
|
+
server.addConnection(this);
|
|
10
|
+
onResponse('+');
|
|
11
|
+
}
|
|
12
|
+
feedData(data) {
|
|
13
|
+
const { onResponse } = this;
|
|
14
|
+
if (data.charCodeAt(0) === 3) {
|
|
15
|
+
this.server.info('BREAK');
|
|
16
|
+
this.rp2040.stop();
|
|
17
|
+
onResponse(gdbMessage(STOP_REPLY_SIGINT));
|
|
18
|
+
data = data.slice(1);
|
|
19
|
+
}
|
|
20
|
+
this.buf += data;
|
|
21
|
+
for (;;) {
|
|
22
|
+
const dolla = this.buf.indexOf('$');
|
|
23
|
+
const hash = this.buf.indexOf('#', dolla + 1);
|
|
24
|
+
if (dolla < 0 || hash < 0 || hash + 2 > this.buf.length) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const cmd = this.buf.substring(dolla + 1, hash);
|
|
28
|
+
const cksum = this.buf.substr(hash + 1, 2);
|
|
29
|
+
this.buf = this.buf.substr(hash + 2);
|
|
30
|
+
if (gdbChecksum(cmd) !== cksum) {
|
|
31
|
+
this.server.warn(`GDB checksum error in message: ${cmd}`);
|
|
32
|
+
onResponse('-');
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
onResponse('+');
|
|
36
|
+
this.server.debug(`>${cmd}`);
|
|
37
|
+
const response = this.server.processGDBMessage(cmd);
|
|
38
|
+
if (response) {
|
|
39
|
+
this.server.debug(`<${response}`);
|
|
40
|
+
onResponse(response);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
onBreakpoint() {
|
|
46
|
+
try {
|
|
47
|
+
this.onResponse(gdbMessage(STOP_REPLY_TRAP));
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
this.server.removeConnection(this);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RP2040 GDB Server
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2021, Uri Shaked
|
|
5
|
-
*/
|
|
6
|
-
import { RP2040 } from '../rp2040';
|
|
7
|
-
import { Logger } from '../utils/logging';
|
|
8
|
-
import { GDBConnection } from './gdb-connection';
|
|
9
|
-
export declare const STOP_REPLY_SIGINT = "S02";
|
|
10
|
-
export declare const STOP_REPLY_TRAP = "S05";
|
|
11
|
-
export declare class GDBServer {
|
|
12
|
-
readonly rp2040: RP2040;
|
|
13
|
-
logger: Logger;
|
|
14
|
-
private readonly connections;
|
|
15
|
-
constructor(rp2040: RP2040);
|
|
16
|
-
processGDBMessage(cmd: string): string | undefined;
|
|
17
|
-
addConnection(connection: GDBConnection): void;
|
|
18
|
-
removeConnection(connection: GDBConnection): void;
|
|
19
|
-
debug(msg: string): void;
|
|
20
|
-
info(msg: string): void;
|
|
21
|
-
warn(msg: string): void;
|
|
22
|
-
error(msg: string): void;
|
|
23
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* RP2040 GDB Server
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2021, Uri Shaked
|
|
5
|
+
*/
|
|
6
|
+
import { RP2040 } from '../rp2040.js';
|
|
7
|
+
import { Logger } from '../utils/logging.js';
|
|
8
|
+
import { GDBConnection } from './gdb-connection.js';
|
|
9
|
+
export declare const STOP_REPLY_SIGINT = "S02";
|
|
10
|
+
export declare const STOP_REPLY_TRAP = "S05";
|
|
11
|
+
export declare class GDBServer {
|
|
12
|
+
readonly rp2040: RP2040;
|
|
13
|
+
logger: Logger;
|
|
14
|
+
private readonly connections;
|
|
15
|
+
constructor(rp2040: RP2040);
|
|
16
|
+
processGDBMessage(cmd: string): string | undefined;
|
|
17
|
+
addConnection(connection: GDBConnection): void;
|
|
18
|
+
removeConnection(connection: GDBConnection): void;
|
|
19
|
+
debug(msg: string): void;
|
|
20
|
+
info(msg: string): void;
|
|
21
|
+
warn(msg: string): void;
|
|
22
|
+
error(msg: string): void;
|
|
23
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RP2040 GDB Server
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 2021, Uri Shaked
|
|
5
|
-
*/
|
|
6
|
-
import { SYSM_CONTROL, SYSM_MSP, SYSM_PRIMASK, SYSM_PSP } from '../cortex-m0-core';
|
|
7
|
-
import { ConsoleLogger, LogLevel } from '../utils/logging';
|
|
8
|
-
import { decodeHexBuf, encodeHexBuf, encodeHexByte, encodeHexUint32, gdbMessage, } from './gdb-utils';
|
|
9
|
-
export const STOP_REPLY_SIGINT = 'S02';
|
|
10
|
-
export const STOP_REPLY_TRAP = 'S05';
|
|
11
|
-
/* string value: armv6m-none-unknown-eabi */
|
|
12
|
-
const lldbTriple = '61726d76366d2d6e6f6e652d756e6b6e6f776e2d65616269';
|
|
13
|
-
const registers = [
|
|
14
|
-
`name:r0;bitsize:32;offset:0;encoding:int;format:hex;set:General Purpose Registers;generic:arg1;gcc:0;dwarf:0;`,
|
|
15
|
-
`name:r1;bitsize:32;offset:4;encoding:int;format:hex;set:General Purpose Registers;generic:arg2;gcc:1;dwarf:1;`,
|
|
16
|
-
`name:r2;bitsize:32;offset:8;encoding:int;format:hex;set:General Purpose Registers;generic:arg3;gcc:2;dwarf:2;`,
|
|
17
|
-
`name:r3;bitsize:32;offset:12;encoding:int;format:hex;set:General Purpose Registers;generic:arg4;gcc:3;dwarf:3;`,
|
|
18
|
-
`name:r4;bitsize:32;offset:16;encoding:int;format:hex;set:General Purpose Registers;gcc:4;dwarf:4;`,
|
|
19
|
-
`name:r5;bitsize:32;offset:20;encoding:int;format:hex;set:General Purpose Registers;gcc:5;dwarf:5;`,
|
|
20
|
-
`name:r6;bitsize:32;offset:24;encoding:int;format:hex;set:General Purpose Registers;gcc:6;dwarf:6;`,
|
|
21
|
-
`name:r7;bitsize:32;offset:28;encoding:int;format:hex;set:General Purpose Registers;gcc:7;dwarf:7;`,
|
|
22
|
-
`name:r8;bitsize:32;offset:32;encoding:int;format:hex;set:General Purpose Registers;gcc:8;dwarf:8;`,
|
|
23
|
-
`name:r9;bitsize:32;offset:36;encoding:int;format:hex;set:General Purpose Registers;gcc:9;dwarf:9;`,
|
|
24
|
-
`name:r10;bitsize:32;offset:40;encoding:int;format:hex;set:General Purpose Registers;gcc:10;dwarf:10;`,
|
|
25
|
-
`name:r11;bitsize:32;offset:44;encoding:int;format:hex;set:General Purpose Registers;generic:fp;gcc:11;dwarf:11;`,
|
|
26
|
-
`name:r12;bitsize:32;offset:48;encoding:int;format:hex;set:General Purpose Registers;gcc:12;dwarf:12;`,
|
|
27
|
-
`name:sp;bitsize:32;offset:52;encoding:int;format:hex;set:General Purpose Registers;generic:sp;alt-name:r13;gcc:13;dwarf:13;`,
|
|
28
|
-
`name:lr;bitsize:32;offset:56;encoding:int;format:hex;set:General Purpose Registers;generic:ra;alt-name:r14;gcc:14;dwarf:14;`,
|
|
29
|
-
`name:pc;bitsize:32;offset:60;encoding:int;format:hex;set:General Purpose Registers;generic:pc;alt-name:r15;gcc:15;dwarf:15;`,
|
|
30
|
-
`name:cpsr;bitsize:32;offset:64;encoding:int;format:hex;set:General Purpose Registers;generic:flags;alt-name:psr;gcc:16;dwarf:16;`,
|
|
31
|
-
];
|
|
1
|
+
/**
|
|
2
|
+
* RP2040 GDB Server
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2021, Uri Shaked
|
|
5
|
+
*/
|
|
6
|
+
import { SYSM_CONTROL, SYSM_MSP, SYSM_PRIMASK, SYSM_PSP } from '../cortex-m0-core.js';
|
|
7
|
+
import { ConsoleLogger, LogLevel } from '../utils/logging.js';
|
|
8
|
+
import { decodeHexBuf, encodeHexBuf, encodeHexByte, encodeHexUint32, gdbMessage, } from './gdb-utils.js';
|
|
9
|
+
export const STOP_REPLY_SIGINT = 'S02';
|
|
10
|
+
export const STOP_REPLY_TRAP = 'S05';
|
|
11
|
+
/* string value: armv6m-none-unknown-eabi */
|
|
12
|
+
const lldbTriple = '61726d76366d2d6e6f6e652d756e6b6e6f776e2d65616269';
|
|
13
|
+
const registers = [
|
|
14
|
+
`name:r0;bitsize:32;offset:0;encoding:int;format:hex;set:General Purpose Registers;generic:arg1;gcc:0;dwarf:0;`,
|
|
15
|
+
`name:r1;bitsize:32;offset:4;encoding:int;format:hex;set:General Purpose Registers;generic:arg2;gcc:1;dwarf:1;`,
|
|
16
|
+
`name:r2;bitsize:32;offset:8;encoding:int;format:hex;set:General Purpose Registers;generic:arg3;gcc:2;dwarf:2;`,
|
|
17
|
+
`name:r3;bitsize:32;offset:12;encoding:int;format:hex;set:General Purpose Registers;generic:arg4;gcc:3;dwarf:3;`,
|
|
18
|
+
`name:r4;bitsize:32;offset:16;encoding:int;format:hex;set:General Purpose Registers;gcc:4;dwarf:4;`,
|
|
19
|
+
`name:r5;bitsize:32;offset:20;encoding:int;format:hex;set:General Purpose Registers;gcc:5;dwarf:5;`,
|
|
20
|
+
`name:r6;bitsize:32;offset:24;encoding:int;format:hex;set:General Purpose Registers;gcc:6;dwarf:6;`,
|
|
21
|
+
`name:r7;bitsize:32;offset:28;encoding:int;format:hex;set:General Purpose Registers;gcc:7;dwarf:7;`,
|
|
22
|
+
`name:r8;bitsize:32;offset:32;encoding:int;format:hex;set:General Purpose Registers;gcc:8;dwarf:8;`,
|
|
23
|
+
`name:r9;bitsize:32;offset:36;encoding:int;format:hex;set:General Purpose Registers;gcc:9;dwarf:9;`,
|
|
24
|
+
`name:r10;bitsize:32;offset:40;encoding:int;format:hex;set:General Purpose Registers;gcc:10;dwarf:10;`,
|
|
25
|
+
`name:r11;bitsize:32;offset:44;encoding:int;format:hex;set:General Purpose Registers;generic:fp;gcc:11;dwarf:11;`,
|
|
26
|
+
`name:r12;bitsize:32;offset:48;encoding:int;format:hex;set:General Purpose Registers;gcc:12;dwarf:12;`,
|
|
27
|
+
`name:sp;bitsize:32;offset:52;encoding:int;format:hex;set:General Purpose Registers;generic:sp;alt-name:r13;gcc:13;dwarf:13;`,
|
|
28
|
+
`name:lr;bitsize:32;offset:56;encoding:int;format:hex;set:General Purpose Registers;generic:ra;alt-name:r14;gcc:14;dwarf:14;`,
|
|
29
|
+
`name:pc;bitsize:32;offset:60;encoding:int;format:hex;set:General Purpose Registers;generic:pc;alt-name:r15;gcc:15;dwarf:15;`,
|
|
30
|
+
`name:cpsr;bitsize:32;offset:64;encoding:int;format:hex;set:General Purpose Registers;generic:flags;alt-name:psr;gcc:16;dwarf:16;`,
|
|
31
|
+
];
|
|
32
32
|
const targetXML = `<?xml version="1.0"?>
|
|
33
33
|
<!DOCTYPE target SYSTEM "gdb-target.dtd">
|
|
34
34
|
<target version="1.0">
|
|
@@ -60,200 +60,200 @@ const targetXML = `<?xml version="1.0"?>
|
|
|
60
60
|
<reg name="faultmask" bitsize="1" regnum="21" save-restore="yes" type="int8" group="system"/>
|
|
61
61
|
<reg name="control" bitsize="2" regnum="22" save-restore="yes" type="int8" group="system"/>
|
|
62
62
|
</feature>
|
|
63
|
-
</target>`;
|
|
64
|
-
const LOG_NAME = 'GDBServer';
|
|
65
|
-
export class GDBServer {
|
|
66
|
-
constructor(rp2040) {
|
|
67
|
-
this.rp2040 = rp2040;
|
|
68
|
-
this.logger = new ConsoleLogger(LogLevel.Warn, true);
|
|
69
|
-
this.connections = new Set();
|
|
70
|
-
}
|
|
71
|
-
processGDBMessage(cmd) {
|
|
72
|
-
const { rp2040 } = this;
|
|
73
|
-
const { core } = rp2040;
|
|
74
|
-
if (cmd === 'Hg0') {
|
|
75
|
-
return gdbMessage('OK');
|
|
76
|
-
}
|
|
77
|
-
switch (cmd[0]) {
|
|
78
|
-
case '?':
|
|
79
|
-
return gdbMessage(STOP_REPLY_TRAP);
|
|
80
|
-
case 'q':
|
|
81
|
-
// Query things
|
|
82
|
-
if (cmd.startsWith('qSupported:')) {
|
|
83
|
-
return gdbMessage('PacketSize=4000;vContSupported+;qXfer:features:read+');
|
|
84
|
-
}
|
|
85
|
-
if (cmd === 'qAttached') {
|
|
86
|
-
return gdbMessage('1');
|
|
87
|
-
}
|
|
88
|
-
if (cmd.startsWith('qXfer:features:read:target.xml')) {
|
|
89
|
-
return gdbMessage('l' + targetXML);
|
|
90
|
-
}
|
|
91
|
-
if (cmd.startsWith('qRegisterInfo')) {
|
|
92
|
-
const index = parseInt(cmd.substring(13), 16);
|
|
93
|
-
const register = registers[index];
|
|
94
|
-
if (register) {
|
|
95
|
-
return gdbMessage(register);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
return gdbMessage(`E45`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (cmd === 'qHostInfo') {
|
|
102
|
-
return gdbMessage(`triple:${lldbTriple};endian:little;ptrsize:4;`);
|
|
103
|
-
}
|
|
104
|
-
if (cmd === 'qProcessInfo') {
|
|
105
|
-
return gdbMessage('pid:1;endian:little;ptrsize:4;');
|
|
106
|
-
}
|
|
107
|
-
return gdbMessage('');
|
|
108
|
-
case 'v':
|
|
109
|
-
if (cmd === 'vCont?') {
|
|
110
|
-
return gdbMessage('vCont;c;C;s;S');
|
|
111
|
-
}
|
|
112
|
-
if (cmd.startsWith('vCont;c')) {
|
|
113
|
-
if (!rp2040.executing) {
|
|
114
|
-
rp2040.execute();
|
|
115
|
-
}
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (cmd.startsWith('vCont;s')) {
|
|
119
|
-
rp2040.step();
|
|
120
|
-
const registerStatus = [];
|
|
121
|
-
for (let i = 0; i < 17; i++) {
|
|
122
|
-
const value = i === 16 ? core.xPSR : core.registers[i];
|
|
123
|
-
registerStatus.push(`${encodeHexByte(i)}:${encodeHexUint32(value)}`);
|
|
124
|
-
}
|
|
125
|
-
return gdbMessage(`T05${registerStatus.join(';')};reason:trace;`);
|
|
126
|
-
}
|
|
127
|
-
break;
|
|
128
|
-
case 'c':
|
|
129
|
-
if (!rp2040.executing) {
|
|
130
|
-
rp2040.execute();
|
|
131
|
-
}
|
|
132
|
-
return gdbMessage('OK');
|
|
133
|
-
case 'g': {
|
|
134
|
-
// Read registers
|
|
135
|
-
const buf = new Uint32Array(17);
|
|
136
|
-
buf.set(core.registers);
|
|
137
|
-
buf[16] = core.xPSR;
|
|
138
|
-
return gdbMessage(encodeHexBuf(new Uint8Array(buf.buffer)));
|
|
139
|
-
}
|
|
140
|
-
case 'p': {
|
|
141
|
-
// Read register
|
|
142
|
-
const registerIndex = parseInt(cmd.substr(1), 16);
|
|
143
|
-
if (registerIndex >= 0 && registerIndex <= 15) {
|
|
144
|
-
return gdbMessage(encodeHexUint32(core.registers[registerIndex]));
|
|
145
|
-
}
|
|
146
|
-
const specialRegister = (sysm) => gdbMessage(encodeHexUint32(core.readSpecialRegister(sysm)));
|
|
147
|
-
switch (registerIndex) {
|
|
148
|
-
case 0x10:
|
|
149
|
-
return gdbMessage(encodeHexUint32(core.xPSR));
|
|
150
|
-
case 0x11:
|
|
151
|
-
return specialRegister(SYSM_MSP);
|
|
152
|
-
case 0x12:
|
|
153
|
-
return specialRegister(SYSM_PSP);
|
|
154
|
-
case 0x13:
|
|
155
|
-
return specialRegister(SYSM_PRIMASK);
|
|
156
|
-
case 0x14:
|
|
157
|
-
this.logger.warn(LOG_NAME, 'TODO BASEPRI');
|
|
158
|
-
return gdbMessage(encodeHexUint32(0)); // TODO BASEPRI
|
|
159
|
-
case 0x15:
|
|
160
|
-
this.logger.warn(LOG_NAME, 'TODO faultmask');
|
|
161
|
-
return gdbMessage(encodeHexUint32(0)); // TODO faultmask
|
|
162
|
-
case 0x16:
|
|
163
|
-
return specialRegister(SYSM_CONTROL);
|
|
164
|
-
}
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
case 'P': {
|
|
168
|
-
// Write register
|
|
169
|
-
const params = cmd.substr(1).split('=');
|
|
170
|
-
const registerIndex = parseInt(params[0], 16);
|
|
171
|
-
const registerValue = params[1].trim();
|
|
172
|
-
const registerBytes = registerIndex > 0x12 ? 1 : 4;
|
|
173
|
-
const decodedValue = decodeHexBuf(registerValue);
|
|
174
|
-
if (registerIndex < 0 || registerIndex > 0x16 || decodedValue.length !== registerBytes) {
|
|
175
|
-
return gdbMessage('E00');
|
|
176
|
-
}
|
|
177
|
-
const valueBuffer = new Uint8Array(4);
|
|
178
|
-
valueBuffer.set(decodedValue.slice(0, 4));
|
|
179
|
-
const value = new DataView(valueBuffer.buffer).getUint32(0, true);
|
|
180
|
-
switch (registerIndex) {
|
|
181
|
-
case 0x10:
|
|
182
|
-
core.xPSR = value;
|
|
183
|
-
break;
|
|
184
|
-
case 0x11:
|
|
185
|
-
core.writeSpecialRegister(SYSM_MSP, value);
|
|
186
|
-
break;
|
|
187
|
-
case 0x12:
|
|
188
|
-
core.writeSpecialRegister(SYSM_PSP, value);
|
|
189
|
-
break;
|
|
190
|
-
case 0x13:
|
|
191
|
-
core.writeSpecialRegister(SYSM_PRIMASK, value);
|
|
192
|
-
break;
|
|
193
|
-
case 0x14:
|
|
194
|
-
this.logger.warn(LOG_NAME, 'TODO BASEPRI');
|
|
195
|
-
break; // TODO BASEPRI
|
|
196
|
-
case 0x15:
|
|
197
|
-
this.logger.warn(LOG_NAME, 'TODO faultmask');
|
|
198
|
-
break; // TODO faultmask
|
|
199
|
-
case 0x16:
|
|
200
|
-
core.writeSpecialRegister(SYSM_CONTROL, value);
|
|
201
|
-
break;
|
|
202
|
-
default:
|
|
203
|
-
core.registers[registerIndex] = value;
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
return gdbMessage('OK');
|
|
207
|
-
}
|
|
208
|
-
case 'm': {
|
|
209
|
-
// Read memory
|
|
210
|
-
const params = cmd.substr(1).split(',');
|
|
211
|
-
const address = parseInt(params[0], 16);
|
|
212
|
-
const length = parseInt(params[1], 16);
|
|
213
|
-
let result = '';
|
|
214
|
-
for (let i = 0; i < length; i++) {
|
|
215
|
-
result += encodeHexByte(rp2040.readUint8(address + i));
|
|
216
|
-
}
|
|
217
|
-
return gdbMessage(result);
|
|
218
|
-
}
|
|
219
|
-
case 'M': {
|
|
220
|
-
// Write memory
|
|
221
|
-
const params = cmd.substr(1).split(/[,:]/);
|
|
222
|
-
const address = parseInt(params[0], 16);
|
|
223
|
-
const length = parseInt(params[1], 16);
|
|
224
|
-
const data = decodeHexBuf(params[2].substr(0, length * 2));
|
|
225
|
-
for (let i = 0; i < data.length; i++) {
|
|
226
|
-
this.debug(`Write ${data[i].toString(16)} to ${(address + i).toString(16)}`);
|
|
227
|
-
rp2040.writeUint8(address + i, data[i]);
|
|
228
|
-
}
|
|
229
|
-
return gdbMessage('OK');
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
return gdbMessage('');
|
|
233
|
-
}
|
|
234
|
-
addConnection(connection) {
|
|
235
|
-
this.connections.add(connection);
|
|
236
|
-
this.rp2040.onBreak = () => {
|
|
237
|
-
this.rp2040.stop();
|
|
238
|
-
this.rp2040.core.PC -= this.rp2040.core.breakRewind;
|
|
239
|
-
for (const connection of this.connections) {
|
|
240
|
-
connection.onBreakpoint();
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
removeConnection(connection) {
|
|
245
|
-
this.connections.delete(connection);
|
|
246
|
-
}
|
|
247
|
-
debug(msg) {
|
|
248
|
-
this.logger.debug(LOG_NAME, msg);
|
|
249
|
-
}
|
|
250
|
-
info(msg) {
|
|
251
|
-
this.logger.info(LOG_NAME, msg);
|
|
252
|
-
}
|
|
253
|
-
warn(msg) {
|
|
254
|
-
this.logger.warn(LOG_NAME, msg);
|
|
255
|
-
}
|
|
256
|
-
error(msg) {
|
|
257
|
-
this.logger.error(LOG_NAME, msg);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
63
|
+
</target>`;
|
|
64
|
+
const LOG_NAME = 'GDBServer';
|
|
65
|
+
export class GDBServer {
|
|
66
|
+
constructor(rp2040) {
|
|
67
|
+
this.rp2040 = rp2040;
|
|
68
|
+
this.logger = new ConsoleLogger(LogLevel.Warn, true);
|
|
69
|
+
this.connections = new Set();
|
|
70
|
+
}
|
|
71
|
+
processGDBMessage(cmd) {
|
|
72
|
+
const { rp2040 } = this;
|
|
73
|
+
const { core } = rp2040;
|
|
74
|
+
if (cmd === 'Hg0') {
|
|
75
|
+
return gdbMessage('OK');
|
|
76
|
+
}
|
|
77
|
+
switch (cmd[0]) {
|
|
78
|
+
case '?':
|
|
79
|
+
return gdbMessage(STOP_REPLY_TRAP);
|
|
80
|
+
case 'q':
|
|
81
|
+
// Query things
|
|
82
|
+
if (cmd.startsWith('qSupported:')) {
|
|
83
|
+
return gdbMessage('PacketSize=4000;vContSupported+;qXfer:features:read+');
|
|
84
|
+
}
|
|
85
|
+
if (cmd === 'qAttached') {
|
|
86
|
+
return gdbMessage('1');
|
|
87
|
+
}
|
|
88
|
+
if (cmd.startsWith('qXfer:features:read:target.xml')) {
|
|
89
|
+
return gdbMessage('l' + targetXML);
|
|
90
|
+
}
|
|
91
|
+
if (cmd.startsWith('qRegisterInfo')) {
|
|
92
|
+
const index = parseInt(cmd.substring(13), 16);
|
|
93
|
+
const register = registers[index];
|
|
94
|
+
if (register) {
|
|
95
|
+
return gdbMessage(register);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return gdbMessage(`E45`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (cmd === 'qHostInfo') {
|
|
102
|
+
return gdbMessage(`triple:${lldbTriple};endian:little;ptrsize:4;`);
|
|
103
|
+
}
|
|
104
|
+
if (cmd === 'qProcessInfo') {
|
|
105
|
+
return gdbMessage('pid:1;endian:little;ptrsize:4;');
|
|
106
|
+
}
|
|
107
|
+
return gdbMessage('');
|
|
108
|
+
case 'v':
|
|
109
|
+
if (cmd === 'vCont?') {
|
|
110
|
+
return gdbMessage('vCont;c;C;s;S');
|
|
111
|
+
}
|
|
112
|
+
if (cmd.startsWith('vCont;c')) {
|
|
113
|
+
if (!rp2040.executing) {
|
|
114
|
+
rp2040.execute();
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (cmd.startsWith('vCont;s')) {
|
|
119
|
+
rp2040.step();
|
|
120
|
+
const registerStatus = [];
|
|
121
|
+
for (let i = 0; i < 17; i++) {
|
|
122
|
+
const value = i === 16 ? core.xPSR : core.registers[i];
|
|
123
|
+
registerStatus.push(`${encodeHexByte(i)}:${encodeHexUint32(value)}`);
|
|
124
|
+
}
|
|
125
|
+
return gdbMessage(`T05${registerStatus.join(';')};reason:trace;`);
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case 'c':
|
|
129
|
+
if (!rp2040.executing) {
|
|
130
|
+
rp2040.execute();
|
|
131
|
+
}
|
|
132
|
+
return gdbMessage('OK');
|
|
133
|
+
case 'g': {
|
|
134
|
+
// Read registers
|
|
135
|
+
const buf = new Uint32Array(17);
|
|
136
|
+
buf.set(core.registers);
|
|
137
|
+
buf[16] = core.xPSR;
|
|
138
|
+
return gdbMessage(encodeHexBuf(new Uint8Array(buf.buffer)));
|
|
139
|
+
}
|
|
140
|
+
case 'p': {
|
|
141
|
+
// Read register
|
|
142
|
+
const registerIndex = parseInt(cmd.substr(1), 16);
|
|
143
|
+
if (registerIndex >= 0 && registerIndex <= 15) {
|
|
144
|
+
return gdbMessage(encodeHexUint32(core.registers[registerIndex]));
|
|
145
|
+
}
|
|
146
|
+
const specialRegister = (sysm) => gdbMessage(encodeHexUint32(core.readSpecialRegister(sysm)));
|
|
147
|
+
switch (registerIndex) {
|
|
148
|
+
case 0x10:
|
|
149
|
+
return gdbMessage(encodeHexUint32(core.xPSR));
|
|
150
|
+
case 0x11:
|
|
151
|
+
return specialRegister(SYSM_MSP);
|
|
152
|
+
case 0x12:
|
|
153
|
+
return specialRegister(SYSM_PSP);
|
|
154
|
+
case 0x13:
|
|
155
|
+
return specialRegister(SYSM_PRIMASK);
|
|
156
|
+
case 0x14:
|
|
157
|
+
this.logger.warn(LOG_NAME, 'TODO BASEPRI');
|
|
158
|
+
return gdbMessage(encodeHexUint32(0)); // TODO BASEPRI
|
|
159
|
+
case 0x15:
|
|
160
|
+
this.logger.warn(LOG_NAME, 'TODO faultmask');
|
|
161
|
+
return gdbMessage(encodeHexUint32(0)); // TODO faultmask
|
|
162
|
+
case 0x16:
|
|
163
|
+
return specialRegister(SYSM_CONTROL);
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case 'P': {
|
|
168
|
+
// Write register
|
|
169
|
+
const params = cmd.substr(1).split('=');
|
|
170
|
+
const registerIndex = parseInt(params[0], 16);
|
|
171
|
+
const registerValue = params[1].trim();
|
|
172
|
+
const registerBytes = registerIndex > 0x12 ? 1 : 4;
|
|
173
|
+
const decodedValue = decodeHexBuf(registerValue);
|
|
174
|
+
if (registerIndex < 0 || registerIndex > 0x16 || decodedValue.length !== registerBytes) {
|
|
175
|
+
return gdbMessage('E00');
|
|
176
|
+
}
|
|
177
|
+
const valueBuffer = new Uint8Array(4);
|
|
178
|
+
valueBuffer.set(decodedValue.slice(0, 4));
|
|
179
|
+
const value = new DataView(valueBuffer.buffer).getUint32(0, true);
|
|
180
|
+
switch (registerIndex) {
|
|
181
|
+
case 0x10:
|
|
182
|
+
core.xPSR = value;
|
|
183
|
+
break;
|
|
184
|
+
case 0x11:
|
|
185
|
+
core.writeSpecialRegister(SYSM_MSP, value);
|
|
186
|
+
break;
|
|
187
|
+
case 0x12:
|
|
188
|
+
core.writeSpecialRegister(SYSM_PSP, value);
|
|
189
|
+
break;
|
|
190
|
+
case 0x13:
|
|
191
|
+
core.writeSpecialRegister(SYSM_PRIMASK, value);
|
|
192
|
+
break;
|
|
193
|
+
case 0x14:
|
|
194
|
+
this.logger.warn(LOG_NAME, 'TODO BASEPRI');
|
|
195
|
+
break; // TODO BASEPRI
|
|
196
|
+
case 0x15:
|
|
197
|
+
this.logger.warn(LOG_NAME, 'TODO faultmask');
|
|
198
|
+
break; // TODO faultmask
|
|
199
|
+
case 0x16:
|
|
200
|
+
core.writeSpecialRegister(SYSM_CONTROL, value);
|
|
201
|
+
break;
|
|
202
|
+
default:
|
|
203
|
+
core.registers[registerIndex] = value;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
return gdbMessage('OK');
|
|
207
|
+
}
|
|
208
|
+
case 'm': {
|
|
209
|
+
// Read memory
|
|
210
|
+
const params = cmd.substr(1).split(',');
|
|
211
|
+
const address = parseInt(params[0], 16);
|
|
212
|
+
const length = parseInt(params[1], 16);
|
|
213
|
+
let result = '';
|
|
214
|
+
for (let i = 0; i < length; i++) {
|
|
215
|
+
result += encodeHexByte(rp2040.readUint8(address + i));
|
|
216
|
+
}
|
|
217
|
+
return gdbMessage(result);
|
|
218
|
+
}
|
|
219
|
+
case 'M': {
|
|
220
|
+
// Write memory
|
|
221
|
+
const params = cmd.substr(1).split(/[,:]/);
|
|
222
|
+
const address = parseInt(params[0], 16);
|
|
223
|
+
const length = parseInt(params[1], 16);
|
|
224
|
+
const data = decodeHexBuf(params[2].substr(0, length * 2));
|
|
225
|
+
for (let i = 0; i < data.length; i++) {
|
|
226
|
+
this.debug(`Write ${data[i].toString(16)} to ${(address + i).toString(16)}`);
|
|
227
|
+
rp2040.writeUint8(address + i, data[i]);
|
|
228
|
+
}
|
|
229
|
+
return gdbMessage('OK');
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return gdbMessage('');
|
|
233
|
+
}
|
|
234
|
+
addConnection(connection) {
|
|
235
|
+
this.connections.add(connection);
|
|
236
|
+
this.rp2040.onBreak = () => {
|
|
237
|
+
this.rp2040.stop();
|
|
238
|
+
this.rp2040.core.PC -= this.rp2040.core.breakRewind;
|
|
239
|
+
for (const connection of this.connections) {
|
|
240
|
+
connection.onBreakpoint();
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
removeConnection(connection) {
|
|
245
|
+
this.connections.delete(connection);
|
|
246
|
+
}
|
|
247
|
+
debug(msg) {
|
|
248
|
+
this.logger.debug(LOG_NAME, msg);
|
|
249
|
+
}
|
|
250
|
+
info(msg) {
|
|
251
|
+
this.logger.info(LOG_NAME, msg);
|
|
252
|
+
}
|
|
253
|
+
warn(msg) {
|
|
254
|
+
this.logger.warn(LOG_NAME, msg);
|
|
255
|
+
}
|
|
256
|
+
error(msg) {
|
|
257
|
+
this.logger.error(LOG_NAME, msg);
|
|
258
|
+
}
|
|
259
|
+
}
|