Skip to content

Enhance Kindle Disk Filler Utility with improved device detection and MTP support - #7

Open
vinaooo wants to merge 2 commits into
iiroak:mainfrom
vinaooo:MTP_detection_and_execution
Open

Enhance Kindle Disk Filler Utility with improved device detection and MTP support#7
vinaooo wants to merge 2 commits into
iiroak:mainfrom
vinaooo:MTP_detection_and_execution

Conversation

@vinaooo

@vinaooo vinaooo commented Jul 27, 2025

Copy link
Copy Markdown

Pull Request: Add MTP Support for Modern Kindle Devices

PROBLEM
The original script only worked with older Kindles that mount as Mass Storage Devices. Modern Kindles use MTP protocol, making the tool incompatible with newer devices.

SOLUTION
Added automatic detection and support for both Mass Storage and MTP protocols while maintaining full backward compatibility.

KEY CHANGES

Automatic Protocol Detection

  • Uses lsusb to detect Amazon devices (Vendor ID 1949)
  • Automatically determines Mass Storage vs MTP connection type
  • Preserves original behavior for older Kindles

Enhanced File Transfer Strategy

  • Creates files locally in /tmp/ first, then transfers to Kindle
  • Prevents partial files and reduces transfer failures
  • Immediate cleanup after successful transfer

MTP Support Implementation

  • Uses gio commands for MTP file operations
  • GVFS fallback for improved connection stability
  • Retry logic for unstable MTP connections
  • Automatic "Internal Storage" directory detection

Improved Robustness

  • Pre-flight connectivity validation
  • Enhanced error handling and user feedback
  • Automatic cleanup on script exit

TECHNICAL DETAILS

  • New Functions: detect_kindle(), enhanced detect_connection_type(), protocol-aware file operations
  • Flow: Device detection → Protocol determination → Local file creation → Transfer → Cleanup
  • Requirements: gio and GVFS MTP support for modern devices

TESTING
✅ Tested on: Amazon Kindle Colorsoft Signature Edition (MTP mode)

  • Device detection, file transfer, space monitoring, and cleanup all working correctly

⚠️ Limitation: Only tested on modern MTP device. Additional testing needed on older Mass Storage Kindles to verify backward compatibility.

COMPATIBILITY

  • Fully backward compatible with existing Mass Storage devices
  • Identical user interface and experience
  • Automatic protocol selection - no user intervention required

BENEFITS

  • Universal support for old and modern Kindle devices
  • Enhanced reliability with multiple fallback mechanisms
  • Efficient resource usage with local file creation
  • Guaranteed cleanup of temporary files

@vinaooo

vinaooo commented Jul 27, 2025

Copy link
Copy Markdown
Author

I tested with 7th gen Kindle
Also I forgot to explain, you don't need to coppy the sh file to Kindle. You can execute sh file from your computer, it will detect Kindle automatically.

I also did some changes to better handle older kindles

@alikhil

alikhil commented Dec 8, 2025

Copy link
Copy Markdown

@vinaooo thanks for the improved script!
Do you think it could be improved by creating temp file in host machine only once? Now it's created on each transfer

@vinaooo

vinaooo commented Dec 8, 2025

Copy link
Copy Markdown
Author

@vinaooo thanks for the improved script!
Do you think it could be improved by creating temp file in host machine only once? Now it's created on each transfer

can you be more specific? what exactly is going on? by running the script twice the second time it is recreating each file? is this filling up the host storage? is there any abnormal behavior associated with this?

@alikhil

alikhil commented Dec 10, 2025

Copy link
Copy Markdown

After running the script myself, I first noticed in the logs that it was creating a 100-MB temp file each time. That initially made me wonder whether it might be more efficient to create that file only once on the host. I also suspected that the file might not be getting cleaned up after the transfer, which could eventually fill up the host storage.

After taking a closer look at the code again, I realized that the temporary file is actually removed after each copy. Because of that, the host filesystem won’t accumulate leftover data, so there’s no risk of it filling up.

And given that the script also supports dynamically sizing the temp file based on the remaining available space, managing a single persistent file would add more complexity than benefit. Keeping the current behavior is probably the simplest and cleanest approach.

So, apologies for the false alert — everything is working as intended.

@iiroak

iiroak commented Mar 9, 2026

Copy link
Copy Markdown
Owner

I apologize for the inactivity; I'll work on this today and figure out how to simulate this to test it properly.

@SotoAugusto

Copy link
Copy Markdown

Thanks for this @vinaooo , worked as expected in paperwhite 12th gen in linux

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.

4 participants