Skip to content

libdmview_open: read the view whole, close it, then make the view - #20

Merged
JohnAmadis merged 1 commit into
mainfrom
fix/view-file-closed-early
Oct 12, 2026
Merged

JohnAmadis merged 1 commit into
mainfrom
fix/view-file-closed-early

Conversation

@JaxCalder

Copy link
Copy Markdown

Summary

libdmview_open() kept the .dmv open for the whole time the view was being made of it. That includes loading its fonts and images, which takes seconds at a board's start.

FatFs (FF_FS_LOCK) does not let a file that is open for reading be opened for writing. So sending a new view to the card right after the board started (dmod-boot's install-all) was cancelled at carhmi.dmv, which dmview was opening just then:

ymodem_send: the device cancelled (views/carhmi_view/carhmi.dmv: header)

Now the file is read whole into memory and closed, and the view is made from that buffer; the buffer is freed afterwards. The file is locked only while it is read (≈85 KB for carhmi's view). Fonts and images were already opened, read and closed one by one.

Test plan

  • ctest: all pass
  • STM32F746G-DISCO: reset, then ymodem_send.py --wait 90 build/sdcard straight away (what install-all does). Without the fix this is cancelled at carhmi.dmv: header, reproduced. With it, all 46 files go through, twice in a row.

🤖 Generated with Claude Code

The .dmv stayed open while the view was made of it - which loads its
fonts and images, seconds at a board's start. FatFs locks a file open for
reading against writing: sending a new view to the card (dmod-boot's
install-all, right after the board started) was cancelled at carhmi.dmv,
being shown just then. The file is read into memory and closed first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JohnAmadis
JohnAmadis merged commit 05a4366 into main Oct 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants