pico-emu 1.0.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 +22 -0
- package/README.md +95 -0
- package/adc_rv32.uf2 +0 -0
- package/adc_test.uf2 +0 -0
- package/adc_test_pico2.uf2 +0 -0
- package/ble_adv.uf2 +0 -0
- package/ble_adv_pico2.uf2 +0 -0
- package/cli.js +247 -0
- package/clocks_rv32.uf2 +0 -0
- package/clocks_test.uf2 +0 -0
- package/clocks_test_pico2.uf2 +0 -0
- package/dma_rv32.uf2 +0 -0
- package/dma_test.uf2 +0 -0
- package/dma_test_pico2.uf2 +0 -0
- package/dualcore_rv32.uf2 +0 -0
- package/eth_dhcp.uf2 +0 -0
- package/eth_dhcp6300.uf2 +0 -0
- package/eth_dhcp6300_pico2.uf2 +0 -0
- package/eth_dhcp6300_rv32.uf2 +0 -0
- package/eth_dhcp_pico2.uf2 +0 -0
- package/eth_dhcp_rv32.uf2 +0 -0
- package/eth_http.uf2 +0 -0
- package/eth_http6300.uf2 +0 -0
- package/eth_http6300_pico2.uf2 +0 -0
- package/eth_http6300_rv32.uf2 +0 -0
- package/eth_http_pico2.uf2 +0 -0
- package/eth_http_rv32.uf2 +0 -0
- package/ethdhcp6300_arduino.uf2 +0 -0
- package/ethdhcp6300_arduino_pico2.uf2 +0 -0
- package/examples/adc_rv32.uf2 +0 -0
- package/examples/adc_test.uf2 +0 -0
- package/examples/adc_test_pico2.uf2 +0 -0
- package/examples/ble_adv.uf2 +0 -0
- package/examples/ble_adv_pico2.uf2 +0 -0
- package/examples/clocks_rv32.uf2 +0 -0
- package/examples/clocks_test.uf2 +0 -0
- package/examples/clocks_test_pico2.uf2 +0 -0
- package/examples/dma_rv32.uf2 +0 -0
- package/examples/dma_test.uf2 +0 -0
- package/examples/dma_test_pico2.uf2 +0 -0
- package/examples/dualcore_rv32.uf2 +0 -0
- package/examples/eth_dhcp.uf2 +0 -0
- package/examples/eth_dhcp6300.uf2 +0 -0
- package/examples/eth_dhcp6300_pico2.uf2 +0 -0
- package/examples/eth_dhcp6300_rv32.uf2 +0 -0
- package/examples/eth_dhcp_pico2.uf2 +0 -0
- package/examples/eth_dhcp_rv32.uf2 +0 -0
- package/examples/eth_http.uf2 +0 -0
- package/examples/eth_http6300.uf2 +0 -0
- package/examples/eth_http6300_pico2.uf2 +0 -0
- package/examples/eth_http6300_rv32.uf2 +0 -0
- package/examples/eth_http_pico2.uf2 +0 -0
- package/examples/eth_http_rv32.uf2 +0 -0
- package/examples/fp_test.uf2 +0 -0
- package/examples/fp_test_pico2.uf2 +0 -0
- package/examples/gpio_rv32.uf2 +0 -0
- package/examples/gpio_test.uf2 +0 -0
- package/examples/gpio_test_pico2.uf2 +0 -0
- package/examples/hello_rv32.uf2 +0 -0
- package/examples/hello_usb.uf2 +0 -0
- package/examples/hello_world.uf2 +0 -0
- package/examples/hello_world_pico2.uf2 +0 -0
- package/examples/i2c_rv32.uf2 +0 -0
- package/examples/i2c_test.uf2 +0 -0
- package/examples/i2c_test_pico2.uf2 +0 -0
- package/examples/interrupt_rv32.uf2 +0 -0
- package/examples/interrupt_test.uf2 +0 -0
- package/examples/interrupt_test_pico2.uf2 +0 -0
- package/examples/littleos.uf2 +0 -0
- package/examples/littleos_pico2.uf2 +0 -0
- package/examples/littleos_pico2_riscv.uf2 +0 -0
- package/examples/micropython_rp2040.uf2 +0 -0
- package/examples/micropython_rp2350.uf2 +0 -0
- package/examples/name_prompt.uf2 +0 -0
- package/examples/name_prompt_pico2.uf2 +0 -0
- package/examples/name_prompt_rv32.uf2 +0 -0
- package/examples/pio_rv32.uf2 +0 -0
- package/examples/pio_test.uf2 +0 -0
- package/examples/pio_test_pico2.uf2 +0 -0
- package/examples/psm_rv32.uf2 +0 -0
- package/examples/psm_test.uf2 +0 -0
- package/examples/psm_test_pico2.uf2 +0 -0
- package/examples/pwm_rv32.uf2 +0 -0
- package/examples/pwm_test.uf2 +0 -0
- package/examples/pwm_test_pico2.uf2 +0 -0
- package/examples/rtc_rv32.uf2 +0 -0
- package/examples/rtc_test.uf2 +0 -0
- package/examples/rtc_test_pico2.uf2 +0 -0
- package/examples/spi_rv32.uf2 +0 -0
- package/examples/spi_test.uf2 +0 -0
- package/examples/spi_test_pico2.uf2 +0 -0
- package/examples/timer_rv32.uf2 +0 -0
- package/examples/timer_test.uf2 +0 -0
- package/examples/timer_test_pico2.uf2 +0 -0
- package/examples/uart_echo.uf2 +0 -0
- package/examples/uart_echo_pico2.uf2 +0 -0
- package/examples/uart_echo_rv32.uf2 +0 -0
- package/examples/usb_rv32.uf2 +0 -0
- package/examples/usb_test.uf2 +0 -0
- package/examples/usb_test_pico2.uf2 +0 -0
- package/examples/wifi_ble_adv_rv32.uf2 +0 -0
- package/examples/wifi_ble_gatt_rv32.uf2 +0 -0
- package/examples/wifi_join_rv32.uf2 +0 -0
- package/examples/wifi_ping.uf2 +0 -0
- package/examples/wifi_ping6_rv32.uf2 +0 -0
- package/examples/wifi_ping_pico2.uf2 +0 -0
- package/examples/wifi_ping_rv32.uf2 +0 -0
- package/examples/wifi_rv32.uf2 +0 -0
- package/examples/wifi_scan.uf2 +0 -0
- package/examples/wifi_scan_pico2.uf2 +0 -0
- package/examples/wifi_scan_rv32.uf2 +0 -0
- package/examples/wifi_webserver.uf2 +0 -0
- package/examples/wifi_webserver_pico2.uf2 +0 -0
- package/examples/wifi_webserver_rv32.uf2 +0 -0
- package/examples/ws2812_rv32.uf2 +0 -0
- package/examples/ws2812_test.uf2 +0 -0
- package/examples/ws2812_test_pico2.uf2 +0 -0
- package/fp_test.uf2 +0 -0
- package/fp_test_pico2.uf2 +0 -0
- package/gpio_rv32.uf2 +0 -0
- package/gpio_test.uf2 +0 -0
- package/gpio_test_pico2.uf2 +0 -0
- package/hello_rv32.uf2 +0 -0
- package/hello_usb.uf2 +0 -0
- package/hello_world.uf2 +0 -0
- package/hello_world_pico2.uf2 +0 -0
- package/i2c_rv32.uf2 +0 -0
- package/i2c_test.uf2 +0 -0
- package/i2c_test_pico2.uf2 +0 -0
- package/index.html +1055 -0
- package/interrupt_rv32.uf2 +0 -0
- package/interrupt_test.uf2 +0 -0
- package/interrupt_test_pico2.uf2 +0 -0
- package/littleos.uf2 +0 -0
- package/littleos_pico2.uf2 +0 -0
- package/littleos_pico2_riscv.uf2 +0 -0
- package/micropython_rp2040.uf2 +0 -0
- package/micropython_rp2350.uf2 +0 -0
- package/name_prompt.uf2 +0 -0
- package/name_prompt_pico2.uf2 +0 -0
- package/name_prompt_rv32.uf2 +0 -0
- package/package.json +27 -0
- package/picoemu.wasm.js +2 -0
- package/picoemu.wasm.threads.js +2 -0
- package/picoemu.wasm.threads.wasm +0 -0
- package/picoemu.wasm.wasm +0 -0
- package/picoemu_worker.js +81 -0
- package/pio_rv32.uf2 +0 -0
- package/pio_test.uf2 +0 -0
- package/pio_test_pico2.uf2 +0 -0
- package/psm_rv32.uf2 +0 -0
- package/psm_test.uf2 +0 -0
- package/psm_test_pico2.uf2 +0 -0
- package/pwm_rv32.uf2 +0 -0
- package/pwm_test.uf2 +0 -0
- package/pwm_test_pico2.uf2 +0 -0
- package/rtc_rv32.uf2 +0 -0
- package/rtc_test.uf2 +0 -0
- package/rtc_test_pico2.uf2 +0 -0
- package/spi_rv32.uf2 +0 -0
- package/spi_test.uf2 +0 -0
- package/spi_test_pico2.uf2 +0 -0
- package/timer_rv32.uf2 +0 -0
- package/timer_test.uf2 +0 -0
- package/timer_test_pico2.uf2 +0 -0
- package/uart_echo.uf2 +0 -0
- package/uart_echo_pico2.uf2 +0 -0
- package/uart_echo_rv32.uf2 +0 -0
- package/usb_rv32.uf2 +0 -0
- package/usb_test.uf2 +0 -0
- package/usb_test_pico2.uf2 +0 -0
- package/wifi_ble_adv_rv32.uf2 +0 -0
- package/wifi_ble_gatt_rv32.uf2 +0 -0
- package/wifi_join_rv32.uf2 +0 -0
- package/wifi_ping.uf2 +0 -0
- package/wifi_ping6_rv32.uf2 +0 -0
- package/wifi_ping_pico2.uf2 +0 -0
- package/wifi_ping_rv32.uf2 +0 -0
- package/wifi_rv32.uf2 +0 -0
- package/wifi_scan.uf2 +0 -0
- package/wifi_scan_pico2.uf2 +0 -0
- package/wifi_scan_rv32.uf2 +0 -0
- package/wifi_webserver.uf2 +0 -0
- package/wifi_webserver_pico2.uf2 +0 -0
- package/wifi_webserver_rv32.uf2 +0 -0
- package/ws2812_rv32.uf2 +0 -0
- package/ws2812_test.uf2 +0 -0
- package/ws2812_test_pico2.uf2 +0 -0
|
Binary file
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* Pico-emu WASM worker: runs emulation off main thread.
|
|
2
|
+
* Main thread keeps UI + serial/GPIO; worker steps WASM and posts results.
|
|
3
|
+
* Falls back to main-thread cooperative stepping when SAB unavailable.
|
|
4
|
+
*
|
|
5
|
+
* Protocol (main -> worker): {cmd:'init', arch}, {cmd:'load', data, name},
|
|
6
|
+
* {cmd:'run', on}, {cmd:'step', n}, {cmd:'uart', ch}, {cmd:'set', k, v}
|
|
7
|
+
* Protocol (worker -> main): {type:'uart', data}, {type:'state', pc, sp, halted, mips},
|
|
8
|
+
* {type:'gpio', out, oe}, {type:'gdb', data}, {type:'ready'}
|
|
9
|
+
*/
|
|
10
|
+
let mod = null;
|
|
11
|
+
let running = false;
|
|
12
|
+
let total = 0;
|
|
13
|
+
|
|
14
|
+
async function ensureMod() {
|
|
15
|
+
if (mod) return mod;
|
|
16
|
+
const { default: PicoemuModule } = await import('./picoemu.wasm.js');
|
|
17
|
+
mod = await PicoemuModule({ print: () => {}, printErr: () => {} });
|
|
18
|
+
return mod;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
self.onmessage = async (e) => {
|
|
22
|
+
const m = e.data;
|
|
23
|
+
try {
|
|
24
|
+
if (m.cmd === 'init') {
|
|
25
|
+
await ensureMod();
|
|
26
|
+
mod._picoemu_init(m.arch || 0);
|
|
27
|
+
self.postMessage({ type: 'ready' });
|
|
28
|
+
} else if (m.cmd === 'load') {
|
|
29
|
+
await ensureMod();
|
|
30
|
+
const u8 = new Uint8Array(m.data);
|
|
31
|
+
const ptr = mod._malloc(u8.length);
|
|
32
|
+
mod.HEAPU8.set(u8, ptr);
|
|
33
|
+
let r;
|
|
34
|
+
if ((m.name || '').endsWith('.uf2')) r = mod._picoemu_load_uf2(ptr, u8.length);
|
|
35
|
+
else r = mod._picoemu_load_elf(ptr, u8.length);
|
|
36
|
+
mod._free(ptr);
|
|
37
|
+
mod._picoemu_reset();
|
|
38
|
+
total = 0;
|
|
39
|
+
self.postMessage({ type: 'loaded', blocks: r });
|
|
40
|
+
} else if (m.cmd === 'run') {
|
|
41
|
+
running = !!m.on;
|
|
42
|
+
} else if (m.cmd === 'step') {
|
|
43
|
+
await ensureMod();
|
|
44
|
+
const n = m.n || 2500000;
|
|
45
|
+
const s = mod._picoemu_step(n);
|
|
46
|
+
total += s;
|
|
47
|
+
const out = [];
|
|
48
|
+
let ch;
|
|
49
|
+
while ((ch = mod._picoemu_read_uart(0)) !== -1) out.push(ch);
|
|
50
|
+
// core state
|
|
51
|
+
const pcP = mod._malloc(4), spP = mod._malloc(4);
|
|
52
|
+
mod._picoemu_get_core_state(0, pcP, spP);
|
|
53
|
+
const pc = mod.HEAPU32[pcP >> 2], sp = mod.HEAPU32[spP >> 2];
|
|
54
|
+
mod._free(pcP); mod._free(spP);
|
|
55
|
+
self.postMessage({
|
|
56
|
+
type: 'frame', steps: s, total,
|
|
57
|
+
uart: out, pc, sp,
|
|
58
|
+
halted: mod._picoemu_is_halted(),
|
|
59
|
+
out: mod._picoemu_get_gpio_out ? mod._picoemu_get_gpio_out() : 0,
|
|
60
|
+
});
|
|
61
|
+
} else if (m.cmd === 'uart') {
|
|
62
|
+
await ensureMod();
|
|
63
|
+
mod._picoemu_write_uart(m.ch);
|
|
64
|
+
}
|
|
65
|
+
} catch (err) {
|
|
66
|
+
self.postMessage({ type: 'error', message: String(err && err.message || err) });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// auto-run loop when running=true (cooperative inside worker)
|
|
71
|
+
setInterval(async () => {
|
|
72
|
+
if (!running || !mod) return;
|
|
73
|
+
try {
|
|
74
|
+
const s = mod._picoemu_step(2500000);
|
|
75
|
+
total += s;
|
|
76
|
+
const out = [];
|
|
77
|
+
let ch, guard = 0;
|
|
78
|
+
while ((ch = mod._picoemu_read_uart(0)) !== -1 && guard++ < 4096) out.push(ch);
|
|
79
|
+
if (out.length || s > 0) self.postMessage({ type: 'frame', steps: s, total, uart: out });
|
|
80
|
+
} catch (e) {}
|
|
81
|
+
}, 16);
|
package/pio_rv32.uf2
ADDED
|
Binary file
|
package/pio_test.uf2
ADDED
|
Binary file
|
|
Binary file
|
package/psm_rv32.uf2
ADDED
|
Binary file
|
package/psm_test.uf2
ADDED
|
Binary file
|
|
Binary file
|
package/pwm_rv32.uf2
ADDED
|
Binary file
|
package/pwm_test.uf2
ADDED
|
Binary file
|
|
Binary file
|
package/rtc_rv32.uf2
ADDED
|
Binary file
|
package/rtc_test.uf2
ADDED
|
Binary file
|
|
Binary file
|
package/spi_rv32.uf2
ADDED
|
Binary file
|
package/spi_test.uf2
ADDED
|
Binary file
|
|
Binary file
|
package/timer_rv32.uf2
ADDED
|
Binary file
|
package/timer_test.uf2
ADDED
|
Binary file
|
|
Binary file
|
package/uart_echo.uf2
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/usb_rv32.uf2
ADDED
|
Binary file
|
package/usb_test.uf2
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/wifi_ping.uf2
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/wifi_rv32.uf2
ADDED
|
Binary file
|
package/wifi_scan.uf2
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/ws2812_rv32.uf2
ADDED
|
Binary file
|
package/ws2812_test.uf2
ADDED
|
Binary file
|
|
Binary file
|