import fs from 'fs'; import { ESP32 } from '../web/js/soc.js'; import { Syms } from './sym.mjs'; const romDir = new URL('../web/rom/', import.meta.url).pathname; const soc = new ESP32({}); 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'); soc.cpus[0].enableTrace(); const syms = new Syms(['/tmp/opencode/vgademo.syms', '/tmp/opencode/rom.syms']); const ow = soc.dportWrite.bind(soc); soc.dportWrite = (cpu, a, s, v) => { const o = a - 0x3ff00000; if (o === 0x104 + 46 * 4 || o === 0x218 + 46 * 4) if (v===2 && cpu.id===0) { const tr = cpu.getTrace(4000); let last=''; const seq=[]; for (const p of tr) { const n = syms.name(p).replace(/\+.*/,''); if (n!==last) { seq.push(n); last=n; } } console.log('SEQ', seq.slice(-25).join(' > ')); } console.log(`map src46 ${o < 0x218 ? 'PRO' : 'APP'} <= ${v} by cpu${cpu.id} at ${syms.name(cpu.pc)} t=${(soc.timeNs/1e6).toFixed(1)}ms`); return ow(cpu, a, s, v); }; while (soc.timeNs < 1.0e9) soc.run(20000);