mirror of
https://github.com/MCKero6423/uv-k5-v3-emulator.git
synced 2026-10-02 03:15:36 +00:00
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:
1 parent
c64b5e6ad8
commit
d76d95851f
8 files changed
+299
-4
No files matched your search
@@ -571,6 +571,24 @@ region is found the same way the screen buffers were: from the firmware's own co
|
||||
not from a guess -- the first version of the header here was 60 bytes because a field
|
||||
(`vma`) was missing, and the real `Beam.app` bytes said so immediately.
|
||||
|
||||
The page writes them through three endpoints (`GET /api/apps`, `POST /api/apps/<n>`,
|
||||
`POST /api/apps/<n>/erase`), all of which edit the flash image the emulator boots from --
|
||||
so this is page-operable with no WebSerial, no browser permission and no serial protocol.
|
||||
|
||||
Two things measured while wiring it up, both of which changed the code:
|
||||
|
||||
* **The region can already hold something.** On a real image every one of the 16 slots read
|
||||
back as data that is neither empty nor an app -- the factory resource block of a localised
|
||||
build overlaps `0x102000`. Installing there would have destroyed it in silence, so
|
||||
`install` now refuses a slot that holds anything other than an app unless it is asked to
|
||||
overwrite (`--force` on the tool, `?force=1` on the endpoint). The refusal names what is
|
||||
there and where the slot is.
|
||||
* **The edit does not land in the file you passed.** `_edit_flash` copies the image and
|
||||
repoints the slot at the copy, deliberately, so a running emulator cannot have the file
|
||||
under it rewritten. A first test asserted the original file had changed, saw zero
|
||||
differing bytes and read as "the install did nothing" -- the bytes were in the copy. Check
|
||||
`FlashSlot.path`, not the path you handed in.
|
||||
|
||||
## The keypad: two real bugs, both fixed
|
||||
|
||||
The old note here said "keys reach the firmware but the UI does not react" and
|
||||
|
||||
Reference in new issue
Block a user