Skip to content

ymodem: a file in use does not cancel the batch - #63

Merged
JohnAmadis merged 1 commit into
mainfrom
fix/ymodem-open-retry
Oct 12, 2026
Merged

JohnAmadis merged 1 commit into
mainfrom
fix/ymodem-open-retry

Conversation

@JaxCalder

@JaxCalder JaxCalder commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

ymodem recv cancelled the whole batch when a received file could not be opened for writing. FatFs does not let a file that is open for reading be opened for writing. That can last a moment (a view being loaded) or as long as another program keeps the file open (the MP3 being played), so uploading a music folder stopped at the track that was playing.

  • A moment: the receiver tries again every 100 ms for up to 2 s. The header is complete at that point, so the line is quiet (WAIT_START) and the helper thread sends no NAK meanwhile. The sender (ymodem_send.py) waits 3 s for the header's answer and retries it ten times.
  • Longer: the file is received anyway, its blocks are not written, and the batch goes on. The file on the card stays as it was. The summary names what was not written:
    ymodem: 1 file(s), 13 bytes; 1 not written (in use?): Alexander.mp3
    
    dmod-boot's ymodem_send.py (Upload to the SD card the device has, not to /mnt/dmsdio0_0p1 dmod-boot#127) shows this and exits with an error.

The real cause of the first case, a view kept open for seconds while it was being made, is fixed in choco-technologies/dmview#20.

Test plan

  • Builds for Cortex-M7
  • STM32F746G-DISCO (in dmod-boot's image): all 46 files of build/sdcard go through right after a reset
  • The MP3 being played plus a small file: the small file is written, the MP3 is reported as not written, and the sender exits 1. A track that was not playing (9.4 MB) is overwritten.

🤖 Generated with Claude Code

A file another program reads just then - a view being shown - does not
open for writing until it is closed (FatFs locks it), and the transfer
was cancelled at once. It is tried again every 100 ms for 2 s: the sender
waits for the answer to the header longer (3 s, ten times).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JohnAmadis
JohnAmadis merged commit 4f2a551 into main Oct 12, 2026
1 check passed
@JaxCalder JaxCalder changed the title ymodem: try a file that does not open again, for 2 s ymodem: a file in use does not cancel the batch Oct 12, 2026
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