Apps on the page: list, install and erase overlay apps in the flash image

The Labs edition's apps live in the external flash, in the region its own App/apps/app_overlay.h defines (16 slots of 8 KiB from 0x102000, a 64-byte FAP1 header at the slot base, code one 4 KiB sector later), and upstream installs them from UVStudio over WebSerial. The page owns the image, so this adds GET /api/apps, POST /api/apps/<n> and POST /api/apps/<n>/erase, which put the same bytes at the same offsets with no serial protocol and no browser permission.

Measured on a real image while wiring it up: every one of the 16 slots already held data that is neither empty nor an app -- the localised build's factory resource block overlaps 0x102000 -- so install now refuses to overwrite anything that is not an app unless asked (--force, ?force=1), naming what is there. And _edit_flash edits a copy, which is why the source image shows no changed bytes; the first test read that as 'the install did nothing' and now checks FlashSlot.path. Tests: test_uvk5_apps grew to 20, test_webui.TestAppEndpoints adds 7 over the endpoints.
This commit is contained in:
mckero committed 2026-10-01 17:09:00 +08:00
1 parent c64b5e6ad8
commit d76d95851f
8 files changed
+299 -4

No files matched your search

+14
View File
@@ -462,6 +462,20 @@ BroadcastFM)。上游是用 UVStudio 通过 WebSerial 装进去的;在我们
另外,这块区域和屏幕缓冲一样,是**从固件自己的常量里读出来的**而非猜的:这里头结构的第一版是 60 字节,
因为漏了一个字段(`vma`),而真实的 `Beam.app` 字节当场就指出了这一点。
页面通过三个接口写入(`GET /api/apps`、`POST /api/apps/<n>`、`POST /api/apps/<n>/erase`),
它们改的都是模拟器启动用的那个 flash 镜像 —— 所以这一切在网页上就能做,**不需要 WebSerial、
不需要浏览器授权、也不需要串口协议**。
接进去的过程中量到两件事,两件都改了代码:
* **那块区域可能本来就有东西。** 在真实镜像上,16 个槽读回来全是"既不是空、也不是应用"的数据 ——
汉化版构建的工厂资源块**压在 `0x102000` 上**。在那里安装会**无声地毁掉它**,所以 `install`
现在会拒绝装有非应用内容的槽,除非明确要求覆盖(工具用 `--force`,接口用 `?force=1`)。
拒绝时会说清那里是什么、槽在哪。
* **改动不会落在你传进去的那个文件上。** `_edit_flash` 会**复制**镜像并把槽指向副本 —— 这是故意的,
以免正在运行的模拟器脚下的文件被改写。第一版测试断言原文件变了,看到 0 字节差异,读起来像
"安装什么都没做" —— 其实字节在副本里。要检查 `FlashSlot.path`,不是你传进去的路径。
## 键盘:两个真 bug,都已修复
这里原来的笔记写的是"按键到达了固件但界面不反应",并且归咎于机器模型。结果发现有**两个