Download tools/echo_test.mjs from HelloSun/esp32emu: direct link, hf CLI and curl.
- Browser
- Download file 760 Bytes
-
https://huggingface.co/spaces/HelloSun/esp32emu/resolve/main/tools/echo_test.mjs
- Command line
-
hf download hf://spaces/HelloSun/esp32emu/tools/echo_test.mjs
-
curl -L -o echo_test.mjs https://huggingface.co/spaces/HelloSun/esp32emu/resolve/main/tools/echo_test.mjs
760 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.onUart = (n, b) => process.stdout.write(String.fromCharCode(b)); | |
| soc.reset('power'); | |
| let sent = false, led = []; | |
| while (soc.timeNs < 4e9) { | |
| soc.run(100000); | |
| if (!sent && soc.timeNs > 1.7e9) { sent = true; soc.uart[0].rxPush(Buffer.from('hello esp32\n')); } | |
| } | |
| console.log('GPIO2 level', soc.gpio.level(2)); | |