import fs from 'fs'; import { ESP32 } from '../web/js/soc.js'; 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.onUart = (n, b) => process.stdout.write(String.fromCharCode(b)); soc.reset('power'); const c = soc.cpus[0]; c.trace = []; for (let i = 0; i < parseInt(process.argv[3] || '20'); i++) { soc.run(1); } console.log(c.trace.slice(-60).map(x => (x >>> 0).toString(16)).join(' ')); console.log('pc', (c.pc>>>0).toString(16), 'time', soc.timeNs); const i = c.trace.indexOf(0x4000fdc7); console.log('first fail idx', i, c.trace.slice(Math.max(0,i-40), i+1).map(x=>(x>>>0).toString(16)).join(' '));