rp2040js 1.3.1 → 1.3.2

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2021 Uri Shaked
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Uri Shaked
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,128 +1,128 @@
1
- ![](../../actions/workflows/ci-test.yml/badge.svg) ![](../../actions/workflows/ci-micropython.yml/badge.svg) ![](../../actions/workflows/ci-pico-sdk.yml/badge.svg)
2
-
3
- # rp2040js
4
-
5
- Raspberry Pi Pico Emulator for the [Wokwi Simulation Platform](https://wokwi.com). It blinks, runs Arduino code, and even the MicroPython REPL!
6
-
7
- ## Online examples
8
-
9
- If you are just looking to play around with the Raspberry Pi Pico Simulator, check out the Wokwi Simulator:
10
-
11
- - [Raspberry Pi Pico Traffic Light](https://wokwi.com/arduino/projects/297322571959894536)
12
- - [LCD1602 Hello World](https://wokwi.com/arduino/projects/297323005822894602)
13
- - [MicroPython Blink](https://wokwi.com/arduino/projects/300504213470839309)
14
- - [MicroPython 7-Segment Counter](https://wokwi.com/arduino/projects/300210834979684872)
15
-
16
- For more information, take a look at the [wokwi-pi-pico docs](https://docs.wokwi.com/parts/wokwi-pi-pico) and the [Pi Pico MicroPython Guide](https://docs.wokwi.com/guides/micropython).
17
-
18
- If you want to develop your own application using the Raspberry Pi Pico simulator, the following examples may be helpful:
19
-
20
- - [Blink LEDs with RP2040js, from scratch](https://stackblitz.com/edit/rp2040js-blink?file=index.ts) - Press "Run" and patiently wait for the code to compile ;-)
21
-
22
- ## Run the demo project
23
-
24
- ### Native code
25
-
26
- You'd need to get `hello_uart.hex` by building it from the [pico-examples repo](https://github.com/raspberrypi/pico-examples/tree/master/uart/hello_uart), then copy it to the rp2040js root directory and run:
27
-
28
- ```
29
- npm install
30
- npm start
31
- ```
32
-
33
- You can also specify the path to the image on the command line and/or load an UF2 image:
34
-
35
- ```sh
36
- npm run start -- --image ./my-pico-project.uf2
37
- ```
38
-
39
- A GDB server will be available on port 3333, and the data written to UART0 will be printed
40
- to the console.
41
-
42
- ### MicroPython code
43
-
44
- To run the MicroPython demo, first download [RPI_PICO-20230426-v1.20.0.uf2](https://micropython.org/resources/firmware/RPI_PICO-20230426-v1.20.0.uf2), place it in the rp2040js root directory, then run:
45
-
46
- ```
47
- npm install
48
- npm run start:micropython
49
- ```
50
-
51
- and enjoy the MicroPython REPL! Quit the REPL with Ctrl+X. A different MicroPython UF2 image can be loaded by supplying the `--image` option:
52
-
53
- ```
54
- npm run start:micropython -- --image=my_image.uf2
55
- ```
56
-
57
- A GDB server on port 3333 can be enabled by specifying the `--gdb` flag:
58
-
59
- ```
60
- npm run start:micropython -- --gdb
61
- ```
62
-
63
- For using the MicroPython demo code in tests, the `--expect-text` can come handy: it will look for the given text in the serial output and exit with code 0 if found, or 1 if not found. You can find an example in [the MicroPython CI test](./.github/workflows/ci-micropython.yml).
64
-
65
- #### Filesystem support
66
-
67
- With MicroPython, you can use the filesystem on the Pico. This becomes useful as more than one script file is used in your code. Just put a [LittleFS](https://github.com/littlefs-project/littlefs) formatted filesystem image called `littlefs.img` into the rp2040js root directory, and your `main.py` will be automatically started from there.
68
-
69
- A simple way to create a suitable LittleFS image containing your script files is outlined in [create_littlefs_image.py](https://github.com/tomods/GrinderController/blob/358ad3e0f795d8cc0bdf4f21bb35f806871d433f/tools/create_littlefs_image.py).
70
- So, using [littlefs-python](https://pypi.org/project/littlefs-python/), you can do the following:
71
-
72
- ```python
73
- from littlefs import LittleFS
74
- files = ['your.py', 'files.py', 'here.py', 'main.py']
75
- output_image = 'output/littlefs.img' # symlinked/copied to rp2040js root directory
76
- lfs = LittleFS(block_size=4096, block_count=352, prog_size=256)
77
- for filename in files:
78
- with open(filename, 'rb') as src_file, lfs.open(filename, 'w') as lfs_file:
79
- lfs_file.write(src_file.read())
80
- with open(output_image, 'wb') as fh:
81
- fh.write(lfs.context.buffer)
82
- ```
83
-
84
- Other ways of creating LittleFS images can be found [here](https://github.com/wokwi/littlefs-wasm) or [here](https://github.com/littlefs-project/littlefs#related-projects).
85
-
86
- Currently, the filesystem is not writeable, as the SSI peripheral required for flash writing is not implemented yet. If you're interested in hacking, see the discussion in https://github.com/wokwi/rp2040js/issues/88 for a workaround.
87
-
88
- ### CircuitPython code
89
-
90
- To run the CircuitPython demo, you can follow the directions above for MicroPython, except download [adafruit-circuitpython-raspberry_pi_pico-en_US-8.0.2.uf2](https://adafruit-circuit-python.s3.amazonaws.com/bin/raspberry_pi_pico/en_US/adafruit-circuitpython-raspberry_pi_pico-en_US-8.0.2.uf2) instead of the MicroPython UF2 file. Place it in the rp2040js root directory, then run:
91
-
92
- ```
93
- npm install
94
- npm run start:circuitpython
95
- ```
96
-
97
- and start the CircuitPython REPL! The rest of the experience is the same as the MicroPython demo (Ctrl+X to exit, using the `--image` and
98
- `--gdb` options, etc).
99
-
100
- #### Filesystem support
101
-
102
- For CircuitPython, you can create a FAT12 filesystem in Linux using the `truncate` and `mkfs.vfat` utilities:
103
-
104
- ```shell
105
- truncate fat12.img -s 1M # make the image file
106
- mkfs.vfat -F12 -S512 fat12.img # create the FAT12 filesystem
107
- ```
108
-
109
- You can then mount the filesystem image and add files to it:
110
-
111
- ```shell
112
- mkdir fat12 # create the mounting folder if needed
113
- sudo mount -o loop fat12.img fat12/ # mount the filesystem to the folder
114
- sudo cp code.py fat12/ # copy code.py to the filesystem
115
- sudo umount fat12/ # unmount the filesystem
116
- ```
117
-
118
- While CircuitPython does not typically use a writeable filesystem, note that this functionality is unavailable (see MicroPython filesystem
119
- support section for more details).
120
-
121
- ## Learn more
122
-
123
- - [Live-coding stream playlist](https://www.youtube.com/playlist?list=PLLomdjsHtJTxT-vdJHwa3z62dFXZnzYBm)
124
- - [Hackaday project page](https://hackaday.io/project/177082-raspberry-pi-pico-emulator)
125
-
126
- ## License
127
-
128
- Released under the MIT licence. Copyright (c) 2021-2023, Uri Shaked.
1
+ ![](../../actions/workflows/ci-test.yml/badge.svg) ![](../../actions/workflows/ci-micropython.yml/badge.svg) ![](../../actions/workflows/ci-pico-sdk.yml/badge.svg)
2
+
3
+ # rp2040js
4
+
5
+ Raspberry Pi Pico Emulator for the [Wokwi Simulation Platform](https://wokwi.com). It blinks, runs Arduino code, and even the MicroPython REPL!
6
+
7
+ ## Online examples
8
+
9
+ If you are just looking to play around with the Raspberry Pi Pico Simulator, check out the Wokwi Simulator:
10
+
11
+ - [Raspberry Pi Pico Traffic Light](https://wokwi.com/arduino/projects/297322571959894536)
12
+ - [LCD1602 Hello World](https://wokwi.com/arduino/projects/297323005822894602)
13
+ - [MicroPython Blink](https://wokwi.com/arduino/projects/300504213470839309)
14
+ - [MicroPython 7-Segment Counter](https://wokwi.com/arduino/projects/300210834979684872)
15
+
16
+ For more information, take a look at the [wokwi-pi-pico docs](https://docs.wokwi.com/parts/wokwi-pi-pico) and the [Pi Pico MicroPython Guide](https://docs.wokwi.com/guides/micropython).
17
+
18
+ If you want to develop your own application using the Raspberry Pi Pico simulator, the following examples may be helpful:
19
+
20
+ - [Blink LEDs with RP2040js, from scratch](https://stackblitz.com/edit/rp2040js-blink?file=index.ts) - Press "Run" and patiently wait for the code to compile ;-)
21
+
22
+ ## Run the demo project
23
+
24
+ ### Native code
25
+
26
+ You'd need to get `hello_uart.hex` by building it from the [pico-examples repo](https://github.com/raspberrypi/pico-examples/tree/master/uart/hello_uart), then copy it to the rp2040js root directory and run:
27
+
28
+ ```
29
+ npm install
30
+ npm start
31
+ ```
32
+
33
+ You can also specify the path to the image on the command line and/or load an UF2 image:
34
+
35
+ ```sh
36
+ npm run start -- --image ./my-pico-project.uf2
37
+ ```
38
+
39
+ A GDB server will be available on port 3333, and the data written to UART0 will be printed
40
+ to the console.
41
+
42
+ ### MicroPython code
43
+
44
+ To run the MicroPython demo, first download [RPI_PICO-20230426-v1.20.0.uf2](https://micropython.org/resources/firmware/RPI_PICO-20230426-v1.20.0.uf2), place it in the rp2040js root directory, then run:
45
+
46
+ ```
47
+ npm install
48
+ npm run start:micropython
49
+ ```
50
+
51
+ and enjoy the MicroPython REPL! Quit the REPL with Ctrl+X. A different MicroPython UF2 image can be loaded by supplying the `--image` option:
52
+
53
+ ```
54
+ npm run start:micropython -- --image=my_image.uf2
55
+ ```
56
+
57
+ A GDB server on port 3333 can be enabled by specifying the `--gdb` flag:
58
+
59
+ ```
60
+ npm run start:micropython -- --gdb
61
+ ```
62
+
63
+ For using the MicroPython demo code in tests, the `--expect-text` can come handy: it will look for the given text in the serial output and exit with code 0 if found, or 1 if not found. You can find an example in [the MicroPython CI test](./.github/workflows/ci-micropython.yml).
64
+
65
+ #### Filesystem support
66
+
67
+ With MicroPython, you can use the filesystem on the Pico. This becomes useful as more than one script file is used in your code. Just put a [LittleFS](https://github.com/littlefs-project/littlefs) formatted filesystem image called `littlefs.img` into the rp2040js root directory, and your `main.py` will be automatically started from there.
68
+
69
+ A simple way to create a suitable LittleFS image containing your script files is outlined in [create_littlefs_image.py](https://github.com/tomods/GrinderController/blob/358ad3e0f795d8cc0bdf4f21bb35f806871d433f/tools/create_littlefs_image.py).
70
+ So, using [littlefs-python](https://pypi.org/project/littlefs-python/), you can do the following:
71
+
72
+ ```python
73
+ from littlefs import LittleFS
74
+ files = ['your.py', 'files.py', 'here.py', 'main.py']
75
+ output_image = 'output/littlefs.img' # symlinked/copied to rp2040js root directory
76
+ lfs = LittleFS(block_size=4096, block_count=352, prog_size=256)
77
+ for filename in files:
78
+ with open(filename, 'rb') as src_file, lfs.open(filename, 'w') as lfs_file:
79
+ lfs_file.write(src_file.read())
80
+ with open(output_image, 'wb') as fh:
81
+ fh.write(lfs.context.buffer)
82
+ ```
83
+
84
+ Other ways of creating LittleFS images can be found [here](https://github.com/wokwi/littlefs-wasm) or [here](https://github.com/littlefs-project/littlefs#related-projects).
85
+
86
+ Currently, the filesystem is not writeable, as the SSI peripheral required for flash writing is not implemented yet. If you're interested in hacking, see the discussion in https://github.com/wokwi/rp2040js/issues/88 for a workaround.
87
+
88
+ ### CircuitPython code
89
+
90
+ To run the CircuitPython demo, you can follow the directions above for MicroPython, except download [adafruit-circuitpython-raspberry_pi_pico-en_US-8.0.2.uf2](https://adafruit-circuit-python.s3.amazonaws.com/bin/raspberry_pi_pico/en_US/adafruit-circuitpython-raspberry_pi_pico-en_US-8.0.2.uf2) instead of the MicroPython UF2 file. Place it in the rp2040js root directory, then run:
91
+
92
+ ```
93
+ npm install
94
+ npm run start:circuitpython
95
+ ```
96
+
97
+ and start the CircuitPython REPL! The rest of the experience is the same as the MicroPython demo (Ctrl+X to exit, using the `--image` and
98
+ `--gdb` options, etc).
99
+
100
+ #### Filesystem support
101
+
102
+ For CircuitPython, you can create a FAT12 filesystem in Linux using the `truncate` and `mkfs.vfat` utilities:
103
+
104
+ ```shell
105
+ truncate fat12.img -s 1M # make the image file
106
+ mkfs.vfat -F12 -S512 fat12.img # create the FAT12 filesystem
107
+ ```
108
+
109
+ You can then mount the filesystem image and add files to it:
110
+
111
+ ```shell
112
+ mkdir fat12 # create the mounting folder if needed
113
+ sudo mount -o loop fat12.img fat12/ # mount the filesystem to the folder
114
+ sudo cp code.py fat12/ # copy code.py to the filesystem
115
+ sudo umount fat12/ # unmount the filesystem
116
+ ```
117
+
118
+ While CircuitPython does not typically use a writeable filesystem, note that this functionality is unavailable (see MicroPython filesystem
119
+ support section for more details).
120
+
121
+ ## Learn more
122
+
123
+ - [Live-coding stream playlist](https://www.youtube.com/playlist?list=PLLomdjsHtJTxT-vdJHwa3z62dFXZnzYBm)
124
+ - [Hackaday project page](https://hackaday.io/project/177082-raspberry-pi-pico-emulator)
125
+
126
+ ## License
127
+
128
+ Released under the MIT licence. Copyright (c) 2021-2023, Uri Shaked.
@@ -32,37 +32,37 @@ const registers = [
32
32
  `name:pc;bitsize:32;offset:60;encoding:int;format:hex;set:General Purpose Registers;generic:pc;alt-name:r15;gcc:15;dwarf:15;`,
33
33
  `name:cpsr;bitsize:32;offset:64;encoding:int;format:hex;set:General Purpose Registers;generic:flags;alt-name:psr;gcc:16;dwarf:16;`,
34
34
  ];
35
- const targetXML = `<?xml version="1.0"?>
36
- <!DOCTYPE target SYSTEM "gdb-target.dtd">
37
- <target version="1.0">
38
- <architecture>arm</architecture>
39
- <feature name="org.gnu.gdb.arm.m-profile">
40
- <reg name="r0" bitsize="32" regnum="0" save-restore="yes" type="int" group="general"/>
41
- <reg name="r1" bitsize="32" regnum="1" save-restore="yes" type="int" group="general"/>
42
- <reg name="r2" bitsize="32" regnum="2" save-restore="yes" type="int" group="general"/>
43
- <reg name="r3" bitsize="32" regnum="3" save-restore="yes" type="int" group="general"/>
44
- <reg name="r4" bitsize="32" regnum="4" save-restore="yes" type="int" group="general"/>
45
- <reg name="r5" bitsize="32" regnum="5" save-restore="yes" type="int" group="general"/>
46
- <reg name="r6" bitsize="32" regnum="6" save-restore="yes" type="int" group="general"/>
47
- <reg name="r7" bitsize="32" regnum="7" save-restore="yes" type="int" group="general"/>
48
- <reg name="r8" bitsize="32" regnum="8" save-restore="yes" type="int" group="general"/>
49
- <reg name="r9" bitsize="32" regnum="9" save-restore="yes" type="int" group="general"/>
50
- <reg name="r10" bitsize="32" regnum="10" save-restore="yes" type="int" group="general"/>
51
- <reg name="r11" bitsize="32" regnum="11" save-restore="yes" type="int" group="general"/>
52
- <reg name="r12" bitsize="32" regnum="12" save-restore="yes" type="int" group="general"/>
53
- <reg name="sp" bitsize="32" regnum="13" save-restore="yes" type="data_ptr" group="general"/>
54
- <reg name="lr" bitsize="32" regnum="14" save-restore="yes" type="int" group="general"/>
55
- <reg name="pc" bitsize="32" regnum="15" save-restore="yes" type="code_ptr" group="general"/>
56
- <reg name="xPSR" bitsize="32" regnum="16" save-restore="yes" type="int" group="general"/>
57
- </feature>
58
- <feature name="org.gnu.gdb.arm.m-system">
59
- <reg name="msp" bitsize="32" regnum="17" save-restore="yes" type="data_ptr" group="system"/>
60
- <reg name="psp" bitsize="32" regnum="18" save-restore="yes" type="data_ptr" group="system"/>
61
- <reg name="primask" bitsize="1" regnum="19" save-restore="yes" type="int8" group="system"/>
62
- <reg name="basepri" bitsize="8" regnum="20" save-restore="yes" type="int8" group="system"/>
63
- <reg name="faultmask" bitsize="1" regnum="21" save-restore="yes" type="int8" group="system"/>
64
- <reg name="control" bitsize="2" regnum="22" save-restore="yes" type="int8" group="system"/>
65
- </feature>
35
+ const targetXML = `<?xml version="1.0"?>
36
+ <!DOCTYPE target SYSTEM "gdb-target.dtd">
37
+ <target version="1.0">
38
+ <architecture>arm</architecture>
39
+ <feature name="org.gnu.gdb.arm.m-profile">
40
+ <reg name="r0" bitsize="32" regnum="0" save-restore="yes" type="int" group="general"/>
41
+ <reg name="r1" bitsize="32" regnum="1" save-restore="yes" type="int" group="general"/>
42
+ <reg name="r2" bitsize="32" regnum="2" save-restore="yes" type="int" group="general"/>
43
+ <reg name="r3" bitsize="32" regnum="3" save-restore="yes" type="int" group="general"/>
44
+ <reg name="r4" bitsize="32" regnum="4" save-restore="yes" type="int" group="general"/>
45
+ <reg name="r5" bitsize="32" regnum="5" save-restore="yes" type="int" group="general"/>
46
+ <reg name="r6" bitsize="32" regnum="6" save-restore="yes" type="int" group="general"/>
47
+ <reg name="r7" bitsize="32" regnum="7" save-restore="yes" type="int" group="general"/>
48
+ <reg name="r8" bitsize="32" regnum="8" save-restore="yes" type="int" group="general"/>
49
+ <reg name="r9" bitsize="32" regnum="9" save-restore="yes" type="int" group="general"/>
50
+ <reg name="r10" bitsize="32" regnum="10" save-restore="yes" type="int" group="general"/>
51
+ <reg name="r11" bitsize="32" regnum="11" save-restore="yes" type="int" group="general"/>
52
+ <reg name="r12" bitsize="32" regnum="12" save-restore="yes" type="int" group="general"/>
53
+ <reg name="sp" bitsize="32" regnum="13" save-restore="yes" type="data_ptr" group="general"/>
54
+ <reg name="lr" bitsize="32" regnum="14" save-restore="yes" type="int" group="general"/>
55
+ <reg name="pc" bitsize="32" regnum="15" save-restore="yes" type="code_ptr" group="general"/>
56
+ <reg name="xPSR" bitsize="32" regnum="16" save-restore="yes" type="int" group="general"/>
57
+ </feature>
58
+ <feature name="org.gnu.gdb.arm.m-system">
59
+ <reg name="msp" bitsize="32" regnum="17" save-restore="yes" type="data_ptr" group="system"/>
60
+ <reg name="psp" bitsize="32" regnum="18" save-restore="yes" type="data_ptr" group="system"/>
61
+ <reg name="primask" bitsize="1" regnum="19" save-restore="yes" type="int8" group="system"/>
62
+ <reg name="basepri" bitsize="8" regnum="20" save-restore="yes" type="int8" group="system"/>
63
+ <reg name="faultmask" bitsize="1" regnum="21" save-restore="yes" type="int8" group="system"/>
64
+ <reg name="control" bitsize="2" regnum="22" save-restore="yes" type="int8" group="system"/>
65
+ </feature>
66
66
  </target>`;
67
67
  const LOG_NAME = 'GDBServer';
68
68
  class GDBServer {
@@ -3,6 +3,7 @@ export { GDBServer } from './gdb/gdb-server.js';
3
3
  export { GPIOPin, GPIOPinState } from './gpio-pin.js';
4
4
  export { I2CMode, I2CSpeed, RPI2C } from './peripherals/i2c.js';
5
5
  export { BasePeripheral, type Peripheral } from './peripherals/peripheral.js';
6
+ export { RPPIO, StateMachine } from './peripherals/pio.js';
6
7
  export { RPUSBController } from './peripherals/usb.js';
7
8
  export { RP2040 } from './rp2040.js';
8
9
  export { Simulator } from './simulator.js';
@@ -10,4 +11,5 @@ export { USBCDC } from './usb/cdc.js';
10
11
  export { DataDirection, DescriptorType, SetupRecipient, SetupRequest, SetupType, type ISetupPacketParams, } from './usb/interfaces.js';
11
12
  export { createSetupPacket, getDescriptorPacket, setDeviceAddressPacket, setDeviceConfigurationPacket, } from './usb/setup.js';
12
13
  export { StandardRequest, DescriptorType as USBDescriptorType, parseSetupPacket, type USBDevice, type USBTransferResult, type USBTransferStatus, } from './usb/usb-device.js';
14
+ export { FIFO } from './utils/fifo.js';
13
15
  export { ConsoleLogger, LogLevel, type Logger } from './utils/logging.js';
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LogLevel = exports.ConsoleLogger = exports.parseSetupPacket = exports.setDeviceConfigurationPacket = exports.setDeviceAddressPacket = exports.getDescriptorPacket = exports.createSetupPacket = exports.SetupType = exports.SetupRequest = exports.SetupRecipient = exports.DescriptorType = exports.DataDirection = exports.USBCDC = exports.Simulator = exports.RP2040 = exports.RPUSBController = exports.BasePeripheral = exports.RPI2C = exports.I2CSpeed = exports.I2CMode = exports.GPIOPinState = exports.GPIOPin = exports.GDBServer = exports.GDBConnection = void 0;
3
+ exports.LogLevel = exports.ConsoleLogger = exports.FIFO = exports.parseSetupPacket = exports.setDeviceConfigurationPacket = exports.setDeviceAddressPacket = exports.getDescriptorPacket = exports.createSetupPacket = exports.SetupType = exports.SetupRequest = exports.SetupRecipient = exports.DescriptorType = exports.DataDirection = exports.USBCDC = exports.Simulator = exports.RP2040 = exports.RPUSBController = exports.StateMachine = exports.RPPIO = exports.BasePeripheral = exports.RPI2C = exports.I2CSpeed = exports.I2CMode = exports.GPIOPinState = exports.GPIOPin = exports.GDBServer = exports.GDBConnection = void 0;
4
4
  var gdb_connection_js_1 = require("./gdb/gdb-connection.js");
5
5
  Object.defineProperty(exports, "GDBConnection", { enumerable: true, get: function () { return gdb_connection_js_1.GDBConnection; } });
6
6
  var gdb_server_js_1 = require("./gdb/gdb-server.js");
@@ -14,6 +14,9 @@ Object.defineProperty(exports, "I2CSpeed", { enumerable: true, get: function ()
14
14
  Object.defineProperty(exports, "RPI2C", { enumerable: true, get: function () { return i2c_js_1.RPI2C; } });
15
15
  var peripheral_js_1 = require("./peripherals/peripheral.js");
16
16
  Object.defineProperty(exports, "BasePeripheral", { enumerable: true, get: function () { return peripheral_js_1.BasePeripheral; } });
17
+ var pio_js_1 = require("./peripherals/pio.js");
18
+ Object.defineProperty(exports, "RPPIO", { enumerable: true, get: function () { return pio_js_1.RPPIO; } });
19
+ Object.defineProperty(exports, "StateMachine", { enumerable: true, get: function () { return pio_js_1.StateMachine; } });
17
20
  var usb_js_1 = require("./peripherals/usb.js");
18
21
  Object.defineProperty(exports, "RPUSBController", { enumerable: true, get: function () { return usb_js_1.RPUSBController; } });
19
22
  var rp2040_js_1 = require("./rp2040.js");
@@ -35,6 +38,8 @@ Object.defineProperty(exports, "setDeviceAddressPacket", { enumerable: true, get
35
38
  Object.defineProperty(exports, "setDeviceConfigurationPacket", { enumerable: true, get: function () { return setup_js_1.setDeviceConfigurationPacket; } });
36
39
  var usb_device_js_1 = require("./usb/usb-device.js");
37
40
  Object.defineProperty(exports, "parseSetupPacket", { enumerable: true, get: function () { return usb_device_js_1.parseSetupPacket; } });
41
+ var fifo_js_1 = require("./utils/fifo.js");
42
+ Object.defineProperty(exports, "FIFO", { enumerable: true, get: function () { return fifo_js_1.FIFO; } });
38
43
  var logging_js_1 = require("./utils/logging.js");
39
44
  Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return logging_js_1.ConsoleLogger; } });
40
45
  Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return logging_js_1.LogLevel; } });
@@ -29,37 +29,37 @@ const registers = [
29
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
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
31
  ];
32
- const targetXML = `<?xml version="1.0"?>
33
- <!DOCTYPE target SYSTEM "gdb-target.dtd">
34
- <target version="1.0">
35
- <architecture>arm</architecture>
36
- <feature name="org.gnu.gdb.arm.m-profile">
37
- <reg name="r0" bitsize="32" regnum="0" save-restore="yes" type="int" group="general"/>
38
- <reg name="r1" bitsize="32" regnum="1" save-restore="yes" type="int" group="general"/>
39
- <reg name="r2" bitsize="32" regnum="2" save-restore="yes" type="int" group="general"/>
40
- <reg name="r3" bitsize="32" regnum="3" save-restore="yes" type="int" group="general"/>
41
- <reg name="r4" bitsize="32" regnum="4" save-restore="yes" type="int" group="general"/>
42
- <reg name="r5" bitsize="32" regnum="5" save-restore="yes" type="int" group="general"/>
43
- <reg name="r6" bitsize="32" regnum="6" save-restore="yes" type="int" group="general"/>
44
- <reg name="r7" bitsize="32" regnum="7" save-restore="yes" type="int" group="general"/>
45
- <reg name="r8" bitsize="32" regnum="8" save-restore="yes" type="int" group="general"/>
46
- <reg name="r9" bitsize="32" regnum="9" save-restore="yes" type="int" group="general"/>
47
- <reg name="r10" bitsize="32" regnum="10" save-restore="yes" type="int" group="general"/>
48
- <reg name="r11" bitsize="32" regnum="11" save-restore="yes" type="int" group="general"/>
49
- <reg name="r12" bitsize="32" regnum="12" save-restore="yes" type="int" group="general"/>
50
- <reg name="sp" bitsize="32" regnum="13" save-restore="yes" type="data_ptr" group="general"/>
51
- <reg name="lr" bitsize="32" regnum="14" save-restore="yes" type="int" group="general"/>
52
- <reg name="pc" bitsize="32" regnum="15" save-restore="yes" type="code_ptr" group="general"/>
53
- <reg name="xPSR" bitsize="32" regnum="16" save-restore="yes" type="int" group="general"/>
54
- </feature>
55
- <feature name="org.gnu.gdb.arm.m-system">
56
- <reg name="msp" bitsize="32" regnum="17" save-restore="yes" type="data_ptr" group="system"/>
57
- <reg name="psp" bitsize="32" regnum="18" save-restore="yes" type="data_ptr" group="system"/>
58
- <reg name="primask" bitsize="1" regnum="19" save-restore="yes" type="int8" group="system"/>
59
- <reg name="basepri" bitsize="8" regnum="20" save-restore="yes" type="int8" group="system"/>
60
- <reg name="faultmask" bitsize="1" regnum="21" save-restore="yes" type="int8" group="system"/>
61
- <reg name="control" bitsize="2" regnum="22" save-restore="yes" type="int8" group="system"/>
62
- </feature>
32
+ const targetXML = `<?xml version="1.0"?>
33
+ <!DOCTYPE target SYSTEM "gdb-target.dtd">
34
+ <target version="1.0">
35
+ <architecture>arm</architecture>
36
+ <feature name="org.gnu.gdb.arm.m-profile">
37
+ <reg name="r0" bitsize="32" regnum="0" save-restore="yes" type="int" group="general"/>
38
+ <reg name="r1" bitsize="32" regnum="1" save-restore="yes" type="int" group="general"/>
39
+ <reg name="r2" bitsize="32" regnum="2" save-restore="yes" type="int" group="general"/>
40
+ <reg name="r3" bitsize="32" regnum="3" save-restore="yes" type="int" group="general"/>
41
+ <reg name="r4" bitsize="32" regnum="4" save-restore="yes" type="int" group="general"/>
42
+ <reg name="r5" bitsize="32" regnum="5" save-restore="yes" type="int" group="general"/>
43
+ <reg name="r6" bitsize="32" regnum="6" save-restore="yes" type="int" group="general"/>
44
+ <reg name="r7" bitsize="32" regnum="7" save-restore="yes" type="int" group="general"/>
45
+ <reg name="r8" bitsize="32" regnum="8" save-restore="yes" type="int" group="general"/>
46
+ <reg name="r9" bitsize="32" regnum="9" save-restore="yes" type="int" group="general"/>
47
+ <reg name="r10" bitsize="32" regnum="10" save-restore="yes" type="int" group="general"/>
48
+ <reg name="r11" bitsize="32" regnum="11" save-restore="yes" type="int" group="general"/>
49
+ <reg name="r12" bitsize="32" regnum="12" save-restore="yes" type="int" group="general"/>
50
+ <reg name="sp" bitsize="32" regnum="13" save-restore="yes" type="data_ptr" group="general"/>
51
+ <reg name="lr" bitsize="32" regnum="14" save-restore="yes" type="int" group="general"/>
52
+ <reg name="pc" bitsize="32" regnum="15" save-restore="yes" type="code_ptr" group="general"/>
53
+ <reg name="xPSR" bitsize="32" regnum="16" save-restore="yes" type="int" group="general"/>
54
+ </feature>
55
+ <feature name="org.gnu.gdb.arm.m-system">
56
+ <reg name="msp" bitsize="32" regnum="17" save-restore="yes" type="data_ptr" group="system"/>
57
+ <reg name="psp" bitsize="32" regnum="18" save-restore="yes" type="data_ptr" group="system"/>
58
+ <reg name="primask" bitsize="1" regnum="19" save-restore="yes" type="int8" group="system"/>
59
+ <reg name="basepri" bitsize="8" regnum="20" save-restore="yes" type="int8" group="system"/>
60
+ <reg name="faultmask" bitsize="1" regnum="21" save-restore="yes" type="int8" group="system"/>
61
+ <reg name="control" bitsize="2" regnum="22" save-restore="yes" type="int8" group="system"/>
62
+ </feature>
63
63
  </target>`;
64
64
  const LOG_NAME = 'GDBServer';
65
65
  export class GDBServer {
@@ -3,6 +3,7 @@ export { GDBServer } from './gdb/gdb-server.js';
3
3
  export { GPIOPin, GPIOPinState } from './gpio-pin.js';
4
4
  export { I2CMode, I2CSpeed, RPI2C } from './peripherals/i2c.js';
5
5
  export { BasePeripheral, type Peripheral } from './peripherals/peripheral.js';
6
+ export { RPPIO, StateMachine } from './peripherals/pio.js';
6
7
  export { RPUSBController } from './peripherals/usb.js';
7
8
  export { RP2040 } from './rp2040.js';
8
9
  export { Simulator } from './simulator.js';
@@ -10,4 +11,5 @@ export { USBCDC } from './usb/cdc.js';
10
11
  export { DataDirection, DescriptorType, SetupRecipient, SetupRequest, SetupType, type ISetupPacketParams, } from './usb/interfaces.js';
11
12
  export { createSetupPacket, getDescriptorPacket, setDeviceAddressPacket, setDeviceConfigurationPacket, } from './usb/setup.js';
12
13
  export { StandardRequest, DescriptorType as USBDescriptorType, parseSetupPacket, type USBDevice, type USBTransferResult, type USBTransferStatus, } from './usb/usb-device.js';
14
+ export { FIFO } from './utils/fifo.js';
13
15
  export { ConsoleLogger, LogLevel, type Logger } from './utils/logging.js';
package/dist/esm/index.js CHANGED
@@ -3,6 +3,7 @@ export { GDBServer } from './gdb/gdb-server.js';
3
3
  export { GPIOPin, GPIOPinState } from './gpio-pin.js';
4
4
  export { I2CMode, I2CSpeed, RPI2C } from './peripherals/i2c.js';
5
5
  export { BasePeripheral } from './peripherals/peripheral.js';
6
+ export { RPPIO, StateMachine } from './peripherals/pio.js';
6
7
  export { RPUSBController } from './peripherals/usb.js';
7
8
  export { RP2040 } from './rp2040.js';
8
9
  export { Simulator } from './simulator.js';
@@ -10,4 +11,5 @@ export { USBCDC } from './usb/cdc.js';
10
11
  export { DataDirection, DescriptorType, SetupRecipient, SetupRequest, SetupType, } from './usb/interfaces.js';
11
12
  export { createSetupPacket, getDescriptorPacket, setDeviceAddressPacket, setDeviceConfigurationPacket, } from './usb/setup.js';
12
13
  export { parseSetupPacket, } from './usb/usb-device.js';
14
+ export { FIFO } from './utils/fifo.js';
13
15
  export { ConsoleLogger, LogLevel } from './utils/logging.js';
package/package.json CHANGED
@@ -1,88 +1,88 @@
1
- {
2
- "name": "rp2040js",
3
- "version": "1.3.1",
4
- "description": "Raspberry Pi Pico (RP2040) Emulator",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/wokwi/rp2040js.git"
8
- },
9
- "keywords": [
10
- "rp2040",
11
- "raspberry pi pico",
12
- "emulator"
13
- ],
14
- "files": [
15
- "dist"
16
- ],
17
- "author": "Uri Shaked <uri@wokwi.com>",
18
- "license": "MIT",
19
- "type": "module",
20
- "main": "./dist/cjs/index.js",
21
- "module": "./dist/esm/index.js",
22
- "typings": "./dist/cjs/index.d.ts",
23
- "engines": {
24
- "node": ">=18.0.0"
25
- },
26
- "exports": {
27
- ".": {
28
- "import": {
29
- "types": "./dist/esm/index.d.ts",
30
- "default": "./dist/esm/index.js"
31
- },
32
- "require": {
33
- "types": "./dist/cjs/index.d.ts",
34
- "default": "./dist/cjs/index.js"
35
- }
36
- },
37
- "./gdb-tcp-server": {
38
- "import": {
39
- "types": "./dist/esm/gdb/gdb-tcp-server.d.ts",
40
- "default": "./dist/esm/gdb/gdb-tcp-server.js"
41
- },
42
- "require": {
43
- "types": "./dist/cjs/gdb/gdb-tcp-server.d.ts",
44
- "default": "./dist/cjs/gdb/gdb-tcp-server.js"
45
- }
46
- }
47
- },
48
- "scripts": {
49
- "build": "rimraf dist && tsc && tsc -p tsconfig.cjs.json && node build-scripts/dist-package-json",
50
- "prepublish": "npm run build",
51
- "prepare": "husky install",
52
- "format:check": "prettier --check **/*.{ts,js} !**/dist/** !**/node_modules/**",
53
- "lint": "eslint . --ext .ts",
54
- "start": "tsx demo/emulator-run.ts",
55
- "start:micropython": "tsx demo/micropython-run.ts",
56
- "start:circuitpython": "tsx demo/micropython-run.ts --circuitpython",
57
- "start:gdbdiff": "tsx debug/gdbdiff.ts",
58
- "test": "vitest run",
59
- "test:watch": "vitest",
60
- "test:micropython-spi": "tsx test/micropython-spi-test.ts"
61
- },
62
- "devDependencies": {
63
- "@types/minimist": "^1.2.2",
64
- "@types/node": "^18",
65
- "@typescript-eslint/eslint-plugin": "^6.7.3",
66
- "@typescript-eslint/parser": "^6.7.3",
67
- "eslint": "^8.50.0",
68
- "husky": "^8.0.3",
69
- "lint-staged": "^15.4.3",
70
- "minimist": "^1.2.7",
71
- "prettier": "^3.0.3",
72
- "prettier-plugin-organize-imports": "^4.3.0",
73
- "rimraf": "^5.0.5",
74
- "tsx": "^4.19.3",
75
- "typescript": "^5.7.3",
76
- "uf2": "^1.0.0",
77
- "vitest": "^3.0.6"
78
- },
79
- "lint-staged": {
80
- "**/*.ts": [
81
- "eslint --fix",
82
- "prettier --write"
83
- ],
84
- "**/*.js": [
85
- "prettier --write"
86
- ]
87
- }
88
- }
1
+ {
2
+ "name": "rp2040js",
3
+ "version": "1.3.2",
4
+ "description": "Raspberry Pi Pico (RP2040) Emulator",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/wokwi/rp2040js.git"
8
+ },
9
+ "keywords": [
10
+ "rp2040",
11
+ "raspberry pi pico",
12
+ "emulator"
13
+ ],
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "author": "Uri Shaked <uri@wokwi.com>",
18
+ "license": "MIT",
19
+ "type": "module",
20
+ "main": "./dist/cjs/index.js",
21
+ "module": "./dist/esm/index.js",
22
+ "typings": "./dist/cjs/index.d.ts",
23
+ "engines": {
24
+ "node": ">=18.0.0"
25
+ },
26
+ "exports": {
27
+ ".": {
28
+ "import": {
29
+ "types": "./dist/esm/index.d.ts",
30
+ "default": "./dist/esm/index.js"
31
+ },
32
+ "require": {
33
+ "types": "./dist/cjs/index.d.ts",
34
+ "default": "./dist/cjs/index.js"
35
+ }
36
+ },
37
+ "./gdb-tcp-server": {
38
+ "import": {
39
+ "types": "./dist/esm/gdb/gdb-tcp-server.d.ts",
40
+ "default": "./dist/esm/gdb/gdb-tcp-server.js"
41
+ },
42
+ "require": {
43
+ "types": "./dist/cjs/gdb/gdb-tcp-server.d.ts",
44
+ "default": "./dist/cjs/gdb/gdb-tcp-server.js"
45
+ }
46
+ }
47
+ },
48
+ "scripts": {
49
+ "build": "rimraf dist && tsc && tsc -p tsconfig.cjs.json && node build-scripts/dist-package-json",
50
+ "prepublish": "npm run build",
51
+ "prepare": "husky install",
52
+ "format:check": "prettier --check **/*.{ts,js} !**/dist/** !**/node_modules/**",
53
+ "lint": "eslint . --ext .ts",
54
+ "start": "tsx demo/emulator-run.ts",
55
+ "start:micropython": "tsx demo/micropython-run.ts",
56
+ "start:circuitpython": "tsx demo/micropython-run.ts --circuitpython",
57
+ "start:gdbdiff": "tsx debug/gdbdiff.ts",
58
+ "test": "vitest run",
59
+ "test:watch": "vitest",
60
+ "test:micropython-spi": "tsx test/micropython-spi-test.ts"
61
+ },
62
+ "devDependencies": {
63
+ "@types/minimist": "^1.2.2",
64
+ "@types/node": "^18",
65
+ "@typescript-eslint/eslint-plugin": "^6.7.3",
66
+ "@typescript-eslint/parser": "^6.7.3",
67
+ "eslint": "^8.50.0",
68
+ "husky": "^8.0.3",
69
+ "lint-staged": "^15.4.3",
70
+ "minimist": "^1.2.7",
71
+ "prettier": "^3.0.3",
72
+ "prettier-plugin-organize-imports": "^4.3.0",
73
+ "rimraf": "^5.0.5",
74
+ "tsx": "^4.19.3",
75
+ "typescript": "^5.7.3",
76
+ "uf2": "^1.0.0",
77
+ "vitest": "^3.0.6"
78
+ },
79
+ "lint-staged": {
80
+ "**/*.ts": [
81
+ "eslint --fix",
82
+ "prettier --write"
83
+ ],
84
+ "**/*.js": [
85
+ "prettier --write"
86
+ ]
87
+ }
88
+ }