Skip to content

Commit

Permalink
feat(demo): MicroPython REPL works!
Browse files Browse the repository at this point in the history
update README with relevant instructions
  • Loading branch information
urish committed May 27, 2021
1 parent 8386d1e commit f4b8921
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
# rp2040js

A Raspberry Pi Pico Emulator (WiP). It (almost) blinks!
A Raspberry Pi Pico Emulator (WiP). It blinks, runs Arduino code, and even the MicroPython REPL!

## Enjoy the wonders
## Run the demo project

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:

```
npm install
npm start
```

To run the micropython demo, first download [rp2040-micropython-uart-47e6c52f0c.hex](https://raw.githubusercontent.com/wokwi/firmware-assets/gh-pages/rp2040-micropython-uart-47e6c52f0c.hex), rename it to `micropython.hex` and place it in the rp2040js root directory, then run:

```
npm install
npm run start:micropython
```

and enjoy the MicroPython REPL! Quit the REPL with Ctrl+D.

## Learn more

- [Live-coding stream playlist](https://www.youtube.com/playlist?list=PLLomdjsHtJTxT-vdJHwa3z62dFXZnzYBm)
Expand Down
2 changes: 1 addition & 1 deletion demo/emulator-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const gdbServer = new GDBTCPServer(mcu, 3333);
console.log(`RP2040 GDB Server ready! Listening on port ${gdbServer.port}`);

mcu.uart[0].onByte = (value) => {
console.log('UART sent: ', String.fromCharCode(value));
process.stdout.write(new Uint8Array([value]));
};

mcu.PC = 0x10000000;
Expand Down
9 changes: 9 additions & 0 deletions demo/micropython-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ console.log(`RP2040 GDB Server ready! Listening on port ${gdbServer.port}`);
mcu.uart[0].onByte = (value) => {
process.stdout.write(new Uint8Array([value]));
};
process.stdin.setRawMode(true);
process.stdin.on('data', (chunk) => {
if (chunk[0] === 4) {
process.exit(0);
}
for (const byte of chunk) {
mcu.uart[0].feedByte(byte);
}
});

mcu.PC = 0x10000000;
mcu.execute();

0 comments on commit f4b8921

Please sign in to comment.