MEGA65 / mega65-core

MEGA65 FPGA core
Other
240 stars 85 forks source link

Removal and reinsert of SD card with mounted disk image causes disk access to hang #586

Open dansanderson opened 2 years ago

dansanderson commented 2 years ago

Test Environment (required)

Describe the bug Removal and reinsertion of the external SD card while a disk image is mounted from the card causes access of the disk image to hang. I don't expect the M65 to access the disk image successfully, but it would be nice if it failed gracefully, such as with a "drive not ready" error.

It would be cool if it could perform some safety checks and automatically re-mount the disk image. Use case: moving the SD card to a PC to make changes in the middle of a sequence of operations on the M65 without having to clear M65 memory. I noticed this while doing some on-PC analysis of files I'm creating and modifying on the M65. (I'm aware of the JTAG tools for file transfer, I just happened to be doing it with the SD card today. :) )

To Reproduce Steps to reproduce the behavior:

  1. Mount a D81 disk image from an external SD card.
  2. DIR: is successful
  3. Remove the SD card
  4. Reinsert the SD card
  5. DIR

Current behavior is to hang, with drive spinning.

Expected behavior If a D81 file with the same name as the previously mounted D81 file is on the re-inserted SD card, re-mount it then continue. If the file no longer exists, cause "Drive not ready" error.

Alternatively, always cause "Drive not ready" error if SD card was removed and reinserted.