koreader / koreader

An ebook reader application supporting PDF, DjVu, EPUB, FB2 and many more formats, running on Cervantes, Kindle, Kobo, PocketBook and Android devices
http://koreader.rocks/
GNU Affero General Public License v3.0
16.84k stars 1.26k forks source link

`Start USB storage` freezes #8896

Closed JakubGIT closed 2 years ago

JakubGIT commented 2 years ago

Issue

USB Storage connection freezes (always) immediatelly after the computer is connected

Steps to reproduce

  1. connect the device to a computer
  2. confirm USB connection on the device

or

  1. menu/Start USB storage
  2. connect the device to a computer
crash.log (if applicable)

crash.log

NiLuJe commented 2 years ago

Freezes on which screen?

JakubGIT commented 2 years ago

Freezes on which screen?

"Starting usb connection" or "establishing usb connection" or how exactly it is called.

Before the last KOReader update an error page was shown ("could not start usb connection"), now it simply freezes.

NiLuJe commented 2 years ago

I'm going to need live system logs, c.f., https://github.com/koreader/koreader/issues/6582#issuecomment-683297132 this old comment (except, well, with sensible final steps for your own issue ;p).

A cat /usr/local/KoboUSBMS.log after the fact might also yield valuable information ;).

JakubGIT commented 2 years ago

live log

/usr/local/KoboUSBMS.log

+ '[' true '=' true ]
+ set -o pipefail
+ basename /mnt/usbms/scripts/start-usbms.sh
+ SCRIPT_NAME=start-usbms.sh
+ grep -q -e ^g_file_storage -e ^g_mass_storage /proc/modules
+ USB_VENDOR_ID=0x2237
+ VERSION_TAG=/mnt/onboard/.kobo/version
+ '[' -f /mnt/onboard/.kobo/version ]
+ cut -f1 -d, /mnt/onboard/.kobo/version
+ SERIAL_NUMBER=N4181900XXXXX
+ cut -f3 -d, /mnt/onboard/.kobo/version
+ FW_VERSION=4.31.19086
+ DISK=/dev/mmcblk
+ PARTITIONS=/dev/mmcblk0p3
+ '[' -e /dev/mmcblk1p1 ]
+ sync
+ echo 3
+ DIR=/mnt/sd
+ grep -q /mnt/sd /proc/mounts
+ DIR=/mnt/onboard
+ grep -q /mnt/onboard /proc/mounts
+ umount /mnt/onboard
+ MODULES_PATH=/drivers/mx6sll-ntx
+ GADGETS_PATH=/drivers/mx6sll-ntx/usb/gadget
+ '[' -e /drivers/mx6sll-ntx/g_mass_storage.ko ]
+ '[' mx6sll-ntx '=' mx6sll-ntx ]
+ PARAMS='idVendor=0x2237 idProduct=0x4234 iManufacturer=Kobo iProduct=eReader-4                                                                                                                                            .31.19086 iSerialNumber=N418190093026'
+ insmod /drivers/mx6sll-ntx/usb/gadget/configfs.ko
NiLuJe commented 2 years ago

Do NOT use KOReader's SSHD. Use KoboStuff's, as mentioned in the message I linked ;).

The script's log would imply some kind of hang during the module insert (yaaaaay'), curious if it's just hanging in there, or if the device froze, which you'll know once you get a shell running (i.e., it'll either hang, or not ^^).

NiLuJe commented 2 years ago

Much like in your other issue, I wouldn't mind having the kernel logs in there (so, run klogd once before everything).

NiLuJe commented 2 years ago

In case it wasn't clear, the Libra 2 is a weird crashy beast, and FW 4.31 is a trainwreck, so, you got a two for one in there ;).

NiLuJe commented 2 years ago

Note to self: hell, for all I know, it might be a Libra 2 special EPDC hang because of the status bar refreshes?

JakubGIT commented 2 years ago

Ok, I'll try :-)

This is my second installation of KOReader on this device. I updated Nickel, so I had to reinstall. The first installation on an earlier version of Nickel (I cannot say which one it was) didn't have the problem with usb (but it froze quite often in the dictionary)

JakubGIT commented 2 years ago

So.

  1. ssh per Kobo Stuff
  2. klogd
  3. logread -F
  4. Start USB Session
  5. Error: "could not end the session, turning off in 90s"(!)
  6. ctrl +
  7. logread

but - this was the second try, the first time I didn't let putty log itself and copied from the screen, which made the earlier messages disappear, that's why I repeated. But the first time, the USB connection worked!!! But nevertheless it crashed after I safely removed the device and plugged off the usb cable

also interesting

nickel doesn't connect to pc either has KOReader already run. The device must be rebooted to achieve the normal functionality

DongRih commented 2 years ago

the USB connection worked!!! But nevertheless it crashed after I safely removed the device and plugged off the usb cable

Interesting. #8910

NiLuJe commented 2 years ago

Does this help, too?

JakubGIT commented 2 years ago

unfortunatelly not

2 times it didn't crash but closed the connection itself very quickly (I believe the conneciton was there for a second or so) immediatelly after that, koreader has offered a new connection, which I accepted the third time it crashed

putty03-17-075935.log

NiLuJe commented 2 years ago

Err, what do you mean by "the connection"? The actual USB storage pop-up in KOReader? Because that would be fairly orthogonal to the issue I'm looking at ;p'

JakubGIT commented 2 years ago

I mean, I think I saw an external drive on my.pc for a sec

NiLuJe commented 2 years ago

Oh, hey, a kernel OOPS (what a surprise...).

I don't really have any other Libra 2 logs to compare to, but this one looks super fishy, so much so that I wouldn't exclude a dodgy cable and/or port (on either side of the connection).

NiLuJe commented 2 years ago

i.e., this is an open call to Libra 2 users to come and test to see if this is a localized issue or not ;).

JakubGIT commented 2 years ago

Oh, hey, a kernel OOPS (what a surprise...).

I don't really have any other Libra 2 logs to compare to, but this one looks super fishy, so much so that I wouldn't exclude a dodgy cable and/or port (on either side of the connection).

I've tested with two cables and two PCs

PC2

so...

great job

NiLuJe commented 2 years ago
* there is definitely a difference between starting usbms from the menu or first plugging a cable

Ha! That's a very interesting distinction: I was always wondering why my cowboy method of hoping for the best appeared to behave so far ;).

By which I mean, we currently start the session as soon as the kernel tells us "hey, usb cable!". Knowing NTX boards (and... embedded USB controllers in general, to be honest), that may be a tad optimistic ;).

It would probably not be completely stupid to simply wait for a second or two for things to actually settle properly.

I'll give you a test binary later tonight, thanks for the detailed rundown of your experiments, that was very helpful ;).

Case in point: I actually started delaying the "USB" popup inside KOReader when working on the Sage, because stuff was looking hella wonky, so we're effectively already doing that in the second case (even if there weren't the actual delay of stopping KOReader and starting USBMS ^^) ;).

NiLuJe commented 2 years ago

Okay, realized that we were skipping the charger type check in the "plugged in after startup" case, which was... possibly not great, but not necessarily critical here, because it appears to be set fairly erratically on your device (which, err, might be an issue in and of itself, but possibly not entirely relevant here).

Anyway, here's a test binary that takes a more defensive approach to this use-case (replace the koreader/data/KoboUSBMS.tar.gz file w/ it).

KoboUSBMS.tar.gz

JakubGIT commented 2 years ago

Okay, realized that we were skipping the charger type check in the "plugged in after startup" case, which was... possibly not great, but not necessarily critical here, because it appears to be set fairly erratically on your device (which, err, might be an issue in and of itself, but possibly not entirely relevant here).

Anyway, here's a test binary that takes a more defensive approach to this use-case (replace the koreader/data/KoboUSBMS.tar.gz file w/ it).

KoboUSBMS.tar.gz

YES!

great job, thanks!

NiLuJe commented 2 years ago

Random stupid test, because I switched tacks to handle the initial module loading issue ;).

Does this binary still work?

KoboUSBMS.tar.gz

JakubGIT commented 2 years ago

yes it does.

I had some problems as I tested but I cannot replicate them now though and I believe it was the pc/trend micro causing them

On Thu, Mar 24, 2022 at 12:13 AM NiLuJe @.***> wrote:

Random stupid test, because I switched tacks to handle the initial module loading issue ;).

Does this binary still work?

KoboUSBMS.tar.gz https://github.com/koreader/koreader/files/8337215/KoboUSBMS.tar.gz

— Reply to this email directly, view it on GitHub https://github.com/koreader/koreader/issues/8896#issuecomment-1076908414, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY2UTLVJIFTMCBFSMS6IXLVBOQSBANCNFSM5QTNNZDA . You are receiving this because you authored the thread.Message ID: @.***>

NiLuJe commented 2 years ago

Cool, thanks! (what kind of problems, though?).

JakubGIT commented 2 years ago

No connection at all. usbms stopped the connection immediatelly or said it is only a power source. Nickel couldn't connect either.

I believe Trend Micro blocked the MAC Address of the device

On Sat, 26 Mar 2022, 13:24 NiLuJe @.***> wrote:

Cool, thanks! (what kind of problems, though?).

— Reply to this email directly, view it on GitHub https://github.com/koreader/koreader/issues/8896#issuecomment-1079678398, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALY2UTLLBWORJ3AS26PCGGTVB36YFANCNFSM5QTNNZDA . You are receiving this because you authored the thread.Message ID: @.***>