Download tools/clk.mjs from HelloSun/esp32emu: direct link, hf CLI and curl.
- Browser
- Download file 945 Bytes
-
https://huggingface.co/spaces/HelloSun/esp32emu/resolve/main/tools/clk.mjs
- Command line
-
hf download hf://spaces/HelloSun/esp32emu/tools/clk.mjs
-
curl -L -o clk.mjs https://huggingface.co/spaces/HelloSun/esp32emu/resolve/main/tools/clk.mjs
945 Bytes
| 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(true); | |
| soc.reset('power'); | |
| const oc = soc.setClocks.bind(soc); | |
| soc.setClocks = (c, a) => { console.log('setClocks', c, a, 'at', soc.timeNs / 1e6, 'ms'); return oc(c, a); }; | |
| const ow = soc.rtc.write.bind(soc.rtc); | |
| soc.rtc.write = (off, v) => { if (off === 0x70) console.log('RTC CLK_CONF', (v>>>0).toString(16)); return ow(off, v); }; | |
| const odw = soc.dportWrite.bind(soc); | |
| soc.dportWrite = (c, a, s, v) => { if ((a - 0x3ff00000) === 0x3c) console.log('DPORT 3c', v); return odw(c, a, s, v); }; | |
| while (soc.timeNs < 6e9) soc.run(100000); | |
| console.log('cpuHz', soc.cpuHz, 'socClk', soc.rtc.socClk, 'per', soc.cpuPerSel); | |