esp32emu / tools /ps2dbg2.mjs
HelloSun's picture
ESP32 emulator update
8d577f5 verified
Raw History Blame Contribute Delete
938 Bytes
import fs from 'fs';
import { createESP32 } from '../web/js/soc.js';
const romDir = new URL('../web/rom/', import.meta.url).pathname;
const wasmBytes = fs.readFileSync(new URL('../wasm/xtensa.wasm', import.meta.url));
const soc = await createESP32({ wasmBytes });
soc.loadRoms(fs.readFileSync(romDir + 'esp32-v3-rom.bin'), fs.readFileSync(romDir + 'esp32-v3-rom-app.bin'));
soc.setFlash(fs.readFileSync(process.argv[2])); soc.enablePsram(false);
soc.reset('power');
const ev = [];
soc.gpio.listeners.push((n, l) => { if ((n === 33 || n === 32) && ev.length < 40) ev.push(`${(soc.timeNs / 1e3).toFixed(1)}us ${n === 33 ? 'CLK' : 'DAT'}=${l}`); });
while (soc.timeNs < 1.0e9) soc.run(20000);
console.log(ev.join('\n')); console.log('rtc en', soc.rtcio.en.toString(16), 'out', soc.rtcio.out.toString(16));
const m = (i) => soc.rtcSlow32[0x200 + i] & 0xffff; console.log('mem', Array.from({length:16},(_, i) => m(i).toString(16)).join(' '));