rp2040js 0.19.3 → 0.19.4

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.
@@ -1,11 +1,11 @@
1
1
  export { GDBConnection } from './gdb/gdb-connection.js';
2
2
  export { GDBServer } from './gdb/gdb-server.js';
3
3
  export { GPIOPin, GPIOPinState } from './gpio-pin.js';
4
- export { BasePeripheral, Peripheral } from './peripherals/peripheral.js';
4
+ export { BasePeripheral, type Peripheral } from './peripherals/peripheral.js';
5
5
  export { RPI2C, I2CSpeed, I2CMode } from './peripherals/i2c.js';
6
6
  export { RPUSBController } from './peripherals/usb.js';
7
7
  export { RP2040 } from './rp2040.js';
8
8
  export { USBCDC } from './usb/cdc.js';
9
- export { DataDirection, DescriptorType, ISetupPacketParams, SetupRecipient, SetupRequest, SetupType, } from './usb/interfaces.js';
9
+ export { DataDirection, DescriptorType, type ISetupPacketParams, SetupRecipient, SetupRequest, SetupType, } from './usb/interfaces.js';
10
10
  export { createSetupPacket, getDescriptorPacket, setDeviceAddressPacket, setDeviceConfigurationPacket, } from './usb/setup.js';
11
- export { ConsoleLogger, Logger, LogLevel } from './utils/logging.js';
11
+ export { ConsoleLogger, type Logger, LogLevel } from './utils/logging.js';
@@ -14,6 +14,7 @@ import { RPUSBController } from './peripherals/usb.js';
14
14
  import { RPSIO } from './sio.js';
15
15
  import { Logger } from './utils/logging.js';
16
16
  export declare const FLASH_START_ADDRESS = 268435456;
17
+ export declare const FLASH_END_ADDRESS = 335544320;
17
18
  export declare const RAM_START_ADDRESS = 536870912;
18
19
  export declare const APB_START_ADDRESS = 1073741824;
19
20
  export declare const DPRAM_START_ADDRESS = 1343225856;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RP2040 = exports.SIO_START_ADDRESS = exports.DPRAM_START_ADDRESS = exports.APB_START_ADDRESS = exports.RAM_START_ADDRESS = exports.FLASH_START_ADDRESS = void 0;
3
+ exports.RP2040 = exports.SIO_START_ADDRESS = exports.DPRAM_START_ADDRESS = exports.APB_START_ADDRESS = exports.RAM_START_ADDRESS = exports.FLASH_END_ADDRESS = exports.FLASH_START_ADDRESS = void 0;
4
4
  const realtime_clock_js_1 = require("./clock/realtime-clock.js");
5
5
  const cortex_m0_core_js_1 = require("./cortex-m0-core.js");
6
6
  const gpio_pin_js_1 = require("./gpio-pin.js");
@@ -30,6 +30,7 @@ const watchdog_js_1 = require("./peripherals/watchdog.js");
30
30
  const sio_js_1 = require("./sio.js");
31
31
  const logging_js_1 = require("./utils/logging.js");
32
32
  exports.FLASH_START_ADDRESS = 0x10000000;
33
+ exports.FLASH_END_ADDRESS = 0x14000000;
33
34
  exports.RAM_START_ADDRESS = 0x20000000;
34
35
  exports.APB_START_ADDRESS = 0x40000000;
35
36
  exports.DPRAM_START_ADDRESS = 0x50100000;
@@ -188,9 +189,14 @@ class RP2040 {
188
189
  if (address < bootrom.length * 4) {
189
190
  return bootrom[address / 4];
190
191
  }
191
- else if (address >= exports.FLASH_START_ADDRESS &&
192
- address < exports.FLASH_START_ADDRESS + this.flash.length) {
193
- return this.flashView.getUint32(address - exports.FLASH_START_ADDRESS, true);
192
+ else if (address >= exports.FLASH_START_ADDRESS && address < exports.FLASH_END_ADDRESS) {
193
+ // Flash is mirrored four times:
194
+ // - 0x10000000 XIP
195
+ // - 0x11000000 XIP_NOALLOC
196
+ // - 0x12000000 XIP_NOCACHE
197
+ // - 0x13000000 XIP_NOCACHE_NOALLOC
198
+ const offset = address & 16777215;
199
+ return this.flashView.getUint32(offset, true);
194
200
  }
195
201
  else if (address >= exports.RAM_START_ADDRESS && address < exports.RAM_START_ADDRESS + this.sram.length) {
196
202
  return this.sramView.getUint32(address - exports.RAM_START_ADDRESS, true);
@@ -1,11 +1,11 @@
1
1
  export { GDBConnection } from './gdb/gdb-connection.js';
2
2
  export { GDBServer } from './gdb/gdb-server.js';
3
3
  export { GPIOPin, GPIOPinState } from './gpio-pin.js';
4
- export { BasePeripheral, Peripheral } from './peripherals/peripheral.js';
4
+ export { BasePeripheral, type Peripheral } from './peripherals/peripheral.js';
5
5
  export { RPI2C, I2CSpeed, I2CMode } from './peripherals/i2c.js';
6
6
  export { RPUSBController } from './peripherals/usb.js';
7
7
  export { RP2040 } from './rp2040.js';
8
8
  export { USBCDC } from './usb/cdc.js';
9
- export { DataDirection, DescriptorType, ISetupPacketParams, SetupRecipient, SetupRequest, SetupType, } from './usb/interfaces.js';
9
+ export { DataDirection, DescriptorType, type ISetupPacketParams, SetupRecipient, SetupRequest, SetupType, } from './usb/interfaces.js';
10
10
  export { createSetupPacket, getDescriptorPacket, setDeviceAddressPacket, setDeviceConfigurationPacket, } from './usb/setup.js';
11
- export { ConsoleLogger, Logger, LogLevel } from './utils/logging.js';
11
+ export { ConsoleLogger, type Logger, LogLevel } from './utils/logging.js';
@@ -14,6 +14,7 @@ import { RPUSBController } from './peripherals/usb.js';
14
14
  import { RPSIO } from './sio.js';
15
15
  import { Logger } from './utils/logging.js';
16
16
  export declare const FLASH_START_ADDRESS = 268435456;
17
+ export declare const FLASH_END_ADDRESS = 335544320;
17
18
  export declare const RAM_START_ADDRESS = 536870912;
18
19
  export declare const APB_START_ADDRESS = 1073741824;
19
20
  export declare const DPRAM_START_ADDRESS = 1343225856;
@@ -27,6 +27,7 @@ import { RPWatchdog } from './peripherals/watchdog.js';
27
27
  import { RPSIO } from './sio.js';
28
28
  import { ConsoleLogger, LogLevel } from './utils/logging.js';
29
29
  export const FLASH_START_ADDRESS = 0x10000000;
30
+ export const FLASH_END_ADDRESS = 0x14000000;
30
31
  export const RAM_START_ADDRESS = 0x20000000;
31
32
  export const APB_START_ADDRESS = 0x40000000;
32
33
  export const DPRAM_START_ADDRESS = 0x50100000;
@@ -185,9 +186,14 @@ export class RP2040 {
185
186
  if (address < bootrom.length * 4) {
186
187
  return bootrom[address / 4];
187
188
  }
188
- else if (address >= FLASH_START_ADDRESS &&
189
- address < FLASH_START_ADDRESS + this.flash.length) {
190
- return this.flashView.getUint32(address - FLASH_START_ADDRESS, true);
189
+ else if (address >= FLASH_START_ADDRESS && address < FLASH_END_ADDRESS) {
190
+ // Flash is mirrored four times:
191
+ // - 0x10000000 XIP
192
+ // - 0x11000000 XIP_NOALLOC
193
+ // - 0x12000000 XIP_NOCACHE
194
+ // - 0x13000000 XIP_NOCACHE_NOALLOC
195
+ const offset = address & 16777215;
196
+ return this.flashView.getUint32(offset, true);
191
197
  }
192
198
  else if (address >= RAM_START_ADDRESS && address < RAM_START_ADDRESS + this.sram.length) {
193
199
  return this.sramView.getUint32(address - RAM_START_ADDRESS, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rp2040js",
3
- "version": "0.19.3",
3
+ "version": "0.19.4",
4
4
  "description": "Raspberry Pi Pico (RP2040) Emulator",
5
5
  "repository": "https://github.com/wokwi/rp2040js",
6
6
  "keywords": [
@@ -48,13 +48,13 @@
48
48
  "prepare": "husky install",
49
49
  "format:check": "prettier --check **/*.{ts,js} !**/dist/** !**/node_modules/**",
50
50
  "lint": "eslint . --ext .ts",
51
- "start": "ts-node --esm demo/emulator-run.ts",
52
- "start:micropython": "ts-node --esm demo/micropython-run.ts",
53
- "start:circuitpython": "ts-node --esm demo/micropython-run.ts --circuitpython",
54
- "start:gdbdiff": "ts-node --esm debug/gdbdiff.ts",
51
+ "start": "tsx demo/emulator-run.ts",
52
+ "start:micropython": "tsx demo/micropython-run.ts",
53
+ "start:circuitpython": "tsx demo/micropython-run.ts --circuitpython",
54
+ "start:gdbdiff": "tsx debug/gdbdiff.ts",
55
55
  "test": "vitest run",
56
56
  "test:watch": "vitest",
57
- "test:micropython-spi": "ts-node --esm test/micropython-spi-test.ts"
57
+ "test:micropython-spi": "tsx test/micropython-spi-test.ts"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/minimist": "^1.2.2",
@@ -67,7 +67,7 @@
67
67
  "minimist": "^1.2.7",
68
68
  "prettier": "^3.0.3",
69
69
  "rimraf": "^5.0.5",
70
- "ts-node": "^10.9.1",
70
+ "tsx": "^4.6.2",
71
71
  "typescript": "^5.2.2",
72
72
  "uf2": "^1.0.0",
73
73
  "vitest": "^0.34.5"