Download tools/build_assets.py from HelloSun/esp32emu: direct link, hf CLI and curl.
- Browser
- Download file 1.68 kB
-
https://huggingface.co/spaces/HelloSun/esp32emu/resolve/main/tools/build_assets.py
- Command line
-
hf download hf://spaces/HelloSun/esp32emu/tools/build_assets.py
-
curl -L -o build_assets.py https://huggingface.co/spaces/HelloSun/esp32emu/resolve/main/tools/build_assets.py
1.68 kB
| #!/usr/bin/env python3 | |
| """Pack ROMs / default boot files / example firmwares into web/assets.js (gzip + base64).""" | |
| import base64, gzip, json, os, sys | |
| root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| web = os.path.join(root, 'web'); fw = os.path.join(root, 'firmware', 'dist') | |
| def pack(path): | |
| data = open(path, 'rb').read() | |
| return base64.b64encode(gzip.compress(data, 9, mtime=0)).decode() | |
| assets = { | |
| 'rom_pro': pack(os.path.join(web, 'rom', 'esp32-v3-rom.bin')), | |
| 'rom_app': pack(os.path.join(web, 'rom', 'esp32-v3-rom-app.bin')), | |
| 'wasm': pack(os.path.join(root, 'wasm', 'xtensa.wasm')), | |
| 'bootloader': pack(os.path.join(fw, 'bootloader.bin')), | |
| 'partitions': pack(os.path.join(fw, 'default_partitions.bin')), | |
| 'boot_app0': pack(os.path.join(fw, 'boot_app0.bin')), | |
| 'examples': [ | |
| {'id': 'dos', 'title': 'FreeDOS 啟動 (FabGL PC 模擬器 on TTGO VGA32)', 'psram': True, 'flash': pack(os.path.join(fw, 'dosvga32.flash.bin'))}, | |
| {'id': 'vga', 'title': 'FabGL VGA 示範 (色塊動畫 + PS/2 鍵盤回顯)', 'psram': False, 'flash': pack(os.path.join(fw, 'vgademo.flash.bin'))}, | |
| {'id': 'echo', 'title': 'Arduino 序列埠回音 + GPIO2 LED 閃爍', 'psram': False, 'flash': pack(os.path.join(fw, 'echo.flash.bin'))}, | |
| {'id': 'hello', 'title': 'Arduino Hello (Serial)', 'psram': False, 'flash': pack(os.path.join(fw, 'hello.flash.bin'))}, | |
| ], | |
| } | |
| out = os.path.join(web, 'assets.js') | |
| with open(out, 'w') as f: | |
| f.write('// generated by tools/build_assets.py - gzip+base64 payloads\nexport const ASSETS = ' + json.dumps(assets) + ';\n') | |
| print('wrote', out, os.path.getsize(out) // 1024, 'KB') | |