dzhu / banglejs-emu

An emulator for the Bangle.js 2
Apache License 2.0
8 stars 3 forks source link

Writing large files to flash fails #2

Open derlaft opened 1 year ago

derlaft commented 1 year ago

File: 88848 bytes or larger

dd if=/dev/urandom of=demo.bin bs=88848 count=1

Config:

[storage."map.bin"]
path = "../BangleApps/apps/bitmapmap/demo.bin"

I would expect that this file gets written to flash, but instead it crashes the emulator :)

https://github.com/dzhu/banglejs-emu/blob/2e362526c27182f3a09082a6010eee0b6c5876ca/src/main.rs#L112-L116 Probably this commands requires that the file base64 is able to fit RAM... not sure, maybe it needs to be written in chunks.

dzhu commented 1 year ago

Thanks for the report! I've just pushed cb27bc7c5f20ff0dae9ace823e1d260b3d6613ff, which should fix the issue. Let me know if that works for you!

Loading in large files is still kind of slow; the emulator could implement the storage format directly instead of stuffing everything through the emulated JS code, though I like having the code not have to know about the details of the format. I'll plan to leave it as it is for now, but it probably wouldn't take too much convincing to change my mind if the speed is an issue.