[sane-devel] [PATCHes] Snapscan: EPSON Perfection 3490 Photo fixes
Krzysztof Hałasa
khalasa at piap.pl
Sun Sep 21 20:35:55 BST 2025
Hello,
I think it's the first time I'm trying to post patches to sane-devel,
so please bear with me.
I'm a long time user of EPSON 3490 Perfection scanner. It basically
works fine with out-of-the-box SANE packaged by Fedora, but there are
issues with firmware downloading, which I'm finally trying to
eliminate (I used to download firmware with separate utility).
The scanner is using the snapscan backend, it's a Hi-Speed USB 2.0
device based on the ALi M5623 scanner chip. The scanner is using some
sort of SCSI over USB protocol. The chip contains a clone of the old
8-bit Intel 8032 microcontroller (maybe 8052), using an external 2 MB
of SDRAM (plus motor and CCD circuitry etc).
I don't have access to M5623 datasheet (anyone?), but from the 2-page
brief I understand the chip contains a flash or similar memory
(writable at least once) which is used to initialize USB interface,
present itself as some sort of non-functional scanner (with early
version of firmware), and download and run the real firmware.
Because there are 3 patch files, I'm attaching them (as inline text).
Please let me know if it's not appropriate.
The patches are tested with SANE v. 1.4.0.
1. The debugging output (SANE_DEBUG_SNAPSCAN=255) may be a bit
misleading. I'm also fixing debug formatting issues:
[snapscan] usb_cmd: cmdlen=6, datalen=0
-[snapscan] usb_write: writing: 0x12 0x00 0x00 0x00 0x24 0x00
+[snapscan] usb_write: writing: 0x12 0x00 0x00 0x00 0x24 0x00
[snapscan] Written 6 bytes
-[snapscan] usb_read: reading: 0xf9 0x00 0x00 0x00 0x00 0x00 0x00 0x00
-[snapscan] Read 8 bytes
+[snapscan] usb_read: received 8 bytes: 0xf9 0x00 0x00 0x00 0x00 0x00 0x00 0x00
The bogus 0xf8 ... is no more:
-[snapscan] usb_read Only 0 bytes read
-[snapscan] usb_read: reading: 0xf8 0x00 0x00 0x00 0x00 0x00 0x00 0x00
-[snapscan] Read 0 bytes
+[snapscan] usb_read: received 0 bytes
+[snapscan] usb_read: only 0 bytes read <<<<< this is an error
There are no changes to any communication over USB etc. - purely
cosmetics.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: snapscan-better-USB-debugging.patch
Type: text/x-patch
Size: 2805 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20250921/6a078f80/attachment.bin>
-------------- next part --------------
2. Simplifying usb_read_status(). The "scsistatus" is never used, the
"transaction_status" is always used - no need for NULL checking.
This patch is needed for #3.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: snapscan-simplify-usb_read_status.patch
Type: text/x-patch
Size: 2641 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20250921/6a078f80/attachment-0001.bin>
-------------- next part --------------
3. This patch fixes the firmware loading and running problem.
It appears that there is some timing issue in the scanner boot
firmware, which causes the final SCSI command (0x2A = SEND, data type
code = 0x87 = vendor specific) to not get the response (apparently
the scanner jumps to the new firmware without waiting for the response
to be collected over USB by the host). Sometimes (very rarely) the
response gets through.
[snapscan] Downloading /lib/firmware/Esfw52.bin
[snapscan] Size of firmware: 63239
[snapscan] snapscan_cmd
[snapscan] snapscani_usb_cmd(0,0x1a7a1500,63249,0x0,0x0 (0))
[snapscan] atomic_usb_cmd(0,0x1a7a1500,63249,0x0,0x0 (0))
[snapscan] usb_cmd(0,0x1a7a1500,63249,0x0,0x0 (0))
[snapscan] usb_cmd: cmdlen=10, datalen=63239
[snapscan] usb_write: writing: 0x2a 0x00 0x87 0x00 0x00 0x00 0x00 0xf7 0x07 0x00
[snapscan] Written 10 bytes
[snapscan] usb_read: received 8 bytes: 0xf8 0x00 0x00 0x00 0x00 0x00 0x00 0x00
[snapscan] usb_write: writing: 0x02 0xf2 0xd5 0x32 0xff 0xff 0xff 0xff 0xff 0xff ...
[snapscan] Written 63239 bytes
-[60 seconds]
+[2 seconds]
[snapscan] usb_read: received 0 bytes
[snapscan] usb_read: only 0 bytes read
-[snapscan] sane_snapscan_open: download_firmware command failed: Error during device I/O
-scanimage: open of device snapscan:libusb:001:043 failed: Error during device I/O
+[snapscan] wait_scanner_ready
+[snapscan] test_unit_ready
+[snapscan] snapscan_cmd
These 3 patches don't fix all problems I can see (e.g. error handling),
but the scanner now downloads firmware reliably.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: snapscan-fix-firmware-upload.patch
Type: text/x-patch
Size: 2029 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20250921/6a078f80/attachment-0002.bin>
-------------- next part --------------
--
Krzysztof "Chris" Ha?asa
More information about the sane-devel
mailing list