12-24-2011, 03:50 AM | #1 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Kindle Touch serial port recovery.
NEWS FLASH: A Kindle Touch can now be debricked in cases like mine by using only the USB Drive, even if it is only visible to the host PC for a few seconds during the reboot cycle like mine was. It has been reported to work if your Kindle is stuck at the startup screen with no progress bar, and it also works if you kindle is stuck at the dreaded "Repair Needed" screen (like mine was). No serial port connection is required, so no need to open up the Kindle back cover.
UPDATE: Success! My kindle touch works again. I was able to repair my "bricked" (unbootable) kindle touch without using a backup copy of the root partition (mmcblk0p1). Read the rest of this thread for history and details of this technical adventure. Let's begin this story at the beginning: Yes, I need it. I did something stupid and now my Touch will not boot. It sticks at the "Repair Needed" screen. EDIT: There are reports that at least three developers have bricked their kindle touch after making small changes to startup scripts (like I did). I do have a backup copy of my root partition, which I was sure to do before making any of my own changes to root. Anyway, while it is booting, the USB drive is visible for about 10 seconds. By testing in a loop for a file to show up in the mount for the USB drive, then creating an ENABLE_DIAGS file, I was able to boot to the diagnostics partition. Not much useful there, unlike the Kindle 4. Time to crack it open and make a serial cable. After many hours of messing around with little success, and even after building level converters for 1.8v TTL TxD to 3.3v TTL RxD, and 3.3v TTL TxD to 1.8v TTL RxD, it still did not work. Time to get out the oscilloscope. With the scope I could see that when attached to the USB serial adapter, the kindle TxD output logic zero was way too high. After much testing, I discovered that the USB serial adapter had an LED attached directly to the RxD pin with no buffer or isolation. The 1.8v TTL TxD from the kindle could not sink that much current. It could only get what should be near 0v down to about 2.5v. I then unsoldered the surface mount LED on the USB adapter. Then the adapter needed an external pullup resistor, which was 2.2K ohms in my level shifter circuit. Even without the LED, the kindle could only get the output down to about 1.8v. I increased the value of the pullup resistor to 22K ohms, and now the kindle could get the logic 0 down to about 0.7v, and (finally) there was serial data on my terminal screen. Here it is: Spoiler:
Next step: use this working serial port to do the recovery, but I need some sleep before I do something even more stupid. Stupid is as stupid does, and all that... By the way, being in a hurry and not having an official connector, I first tried cutting down a microSDHC adapter that had the same pin spacing. No obvious way to attach it though. Next I cut down a telephone extension cord plug (USA style pinout). After test fitting, I could see that it would snap in place and stay, if only I had cut off just a little less plastic in a couple of carefully controlled locations. I ended up using some old IDE ribbon cable (a strip of 3 wires about 6 inches long). I stripped and solder-tinned both ends, then soldered one end to the pins in the kindle socket. The other end went first to my adaptor, then later to my level shifter circuit. The circuit uses open space (rat's nest, or point-to-point) wiring method, which works fine if the component leads are cut short enough and spaced safely apart. That is the way TVs and radios were wired in the old vacuum tube days, with the assistance of terminal strips where needed. The 3-wire ribbon cable is held in place with some tape. I think I will leave it attached and tucked safely inside when I replace my back cover. I will post my progress when I resume this recovery after some sleep. Last edited by geekmaster; 12-31-2011 at 07:55 AM. |
12-24-2011, 04:48 AM | #2 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
And here is the script that was damaged, and has now been restored:
[root@kindle root]# cat /etc/upstart/framework Spoiler:
It still does not boot though... I wonder if it has a permissions problem... EDIT: I just rebooted and checked the file: ls -al /etc/upstart/framework -rwxr-xr-x 1 root root 3611 Nov 3 2011 /etc/upstart/framework That looks okay to me. I am certain that it has been put back to the way it was before I changed anything on the root partition. That is the original file that had been renamed and replaced by an editted copy. It was restored by deleting the copy and renaming the original file back to its original name. Does anybody have any ideas why it still won't boot? Last edited by geekmaster; 12-24-2011 at 04:54 AM. |
Advert | |
|
12-24-2011, 09:46 AM | #3 |
Kindle Dissector
Posts: 662
Karma: 475607
Join Date: Jul 2010
Device: Amazon Kindle 3
|
When in doubt restore mmcblk0p1 from backup and nuke mmcblk0p3
|
12-24-2011, 02:03 PM | #4 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
I was able to boot to diagnostic mode by putting ENABLE_DIAGS on the USB Drive. Then in the "Exit, Reboot or Disable Diags" menu there is an option to exit to a Login Prompt. I selected that and now my serial port has a root shell booted from the diagnostic partition.
[root@kindle /]# mount Code:
rootfs on / type rootfs (rw) /dev/root on / type ext3 (ro,noatime,nodiratime,data=writeback) proc on /proc type proc (rw,relatime) sysfs on /sys type sysfs (rw,relatime) tmpfs on /dev type tmpfs (rw,relatime,mode=755) tmpfs on /dev/shm type tmpfs (rw,relatime) devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620) tmpfs on /var type tmpfs (rw,relatime,size=0k) /dev/mmcblk0p3 on /var/local type ext3 (rw,relatime,errors=continue,data=writeback) /dev/loop/0 on /mnt/base-us type vfat (rw,noexec,noatime,nodiratime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro) fsp on /mnt/us type fuse.fsp (rw,nosuid,nodev,noatime,user_id=0,group_id=0) I have some Christmas shopping to do now, so I will continue this recovery later. Last edited by geekmaster; 12-24-2011 at 02:21 PM. |
12-25-2011, 12:26 AM | #5 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
So far, I can run framebuffer-based apps booted from the diag partition. Way more available resources than in the "gui framework" partition. Still have not figured out how to reset the "unsuccessful sequential reboots" counter to below the maximum allowed, so I can boot past the "repair needed" screen on the main partition.
The simple brute-force "nuclear option" would be to reformat the /var partition, but I am seeking a "kindler gentler" way. I can always use the "nuke mmcblk0p3" option later if necessary. Last edited by geekmaster; 12-25-2011 at 12:28 AM. |
Advert | |
|
12-25-2011, 03:29 AM | #6 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
It is all fixed now. I repaired my kindle touch using the serial port. I did NOT restore my backup copy of the root partition (mmcblk0p1). That means that if you "slightly" break your startup scripts, you can boot to diag mode and repair them. In my case, I made a backup copy of the script before I changed it, but without a backup you could still manually edit out your damaging changes.
A complication was that I had to reset a boot counter manually. The file /var/local/upstart/lab126_gui.restarts had the value "2" in it. I did "echo 0 > /var/local/upstart/lab126_gui.restarts" to reset the boot counter. [Thanks for the suggestion, nueva!] I had also cleaned up my USB drive from an export in diags (a bit too thoroughly). I had deleted an xml file needed to exit diags mode. I was able to force normal boot mode with the idme command, and I got my desktop back. I tried diags again, but it still could not exit. I replaced the missing xml file from a backup copy to the diags usb export drive, then exited properly. All is well now, and I can exit diags correctly without forcing it with the idme command. I will [maybe] do a video like seaniko7 did for the k3, where I intentionally damage my scripts so it gets stuck in the "Repair Needed" screen at bootup. Then I will repair it WITHOUT a root partition backup copy. (After the holiday rush). EDIT: Now that the cover is back on my Kindle Touch, going through all this again just for a video seems like it would consume a lot of time that I would rather spend developing new code, so I may postpone this until I *accidentally* brick my touch again. I plan to do another thing that seaniko7 did for his own personal use -- add usbserial to my startup scripts, exept that my version will be conditional on a trigger file (ENABLE_USBSERIAL). That should allow doing all this repair stuff over usbserial (not usbnet) instead of using a serial cable. If that works, a packaged USBSERIAL hack would be an excellent add-on for all kindles (conditional on the trigger file, like how NiLuJe's USBNET works), as a safety precaution for "easy" debricking without opening the kindle. Last edited by geekmaster; 12-28-2011 at 01:16 AM. |
12-25-2011, 12:16 PM | #7 | |
(offline)
Posts: 2,907
Karma: 6736094
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
Quote:
So +1 from my side, most definitely. |
|
12-25-2011, 10:04 PM | #8 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
In retrospect, the "right" (but slow) way to go would have been to order the parts I need instead of just hacking something together with the parts I already had.
In particular, it would be a lot easier to just order a known-working 1.8v USB serial adapter instead of attaching resistors and diodes to a 3.3v USB adapter to shift the logic voltage levels. In addition to shifting logic levels, the USB adapter also had to be modified to allow the kindle TxD output to pull the adapter RxD input down to a logic zero (by removing an LED). Also, it would be much more "professional" to use the right connector instead of soldering wires to the serial port pins inside the kindle. But a quick hack often gets the job done much faster than waiting for the "right" parts to arrive (especially cheap parts from China). The serial cable has now been unsoldered from my kindle touch, and the back cover is installed. Now I can hopefully leave the back cover on it for awhile. Last edited by geekmaster; 12-25-2011 at 10:27 PM. |
12-27-2011, 11:24 PM | #9 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Because the kindle touch GUI environment does not leave much RAM memory for native mode apps, especially when using a loop mounted file system, my current plans are to use only the USB Drive partition, and use only apps that will run from /mnt/us/bin and do not depend on symlinks (such as static-linked linux apps).
For development, I am using nano and tcc, which both run fine without needing any symlinks. I *really* do not want to go through this again, even though I actually know how to fix it and it would be relatively fast and painless next time. I would rather spend my spare time making new stuff. Last edited by geekmaster; 12-28-2011 at 01:22 AM. |
12-28-2011, 12:59 PM | #10 |
(offline)
Posts: 2,907
Karma: 6736094
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
Any news on that usbserial recovery mode idea?
I'm not savvy enough to implement it, but I'm sure that it would be terribly helpful for the folks out there trying to un-brick their devices... Like https://www.mobileread.com/forums/sho...9&postcount=19 for example. We're still poking around in thin air when we don't know what the device is doing |
12-28-2011, 04:41 PM | #11 |
Enthusiast
Posts: 27
Karma: 10
Join Date: Dec 2011
Device: Kindle Touch
|
And I thought "just translating" stuff is an easy way to get firm with the device.
I also thought it's a brick safe method - but I was wrong |
12-28-2011, 06:42 PM | #12 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
I think that the startup scripts check the md5sum on some things to make sure they did not get "corrupted". Any changes you make to protected stuff would need to have their md5sum recomputed and stored, or it the boot process may abort.
At least that is what it *looked* like it was doing when I looked in there... A *lot* of developers are bricking their kindle touch lately. It is way too easy to do that... Last edited by geekmaster; 12-28-2011 at 07:46 PM. |
12-28-2011, 07:06 PM | #13 |
Kindle Dissector
Posts: 662
Karma: 475607
Join Date: Jul 2010
Device: Amazon Kindle 3
|
People are bricking because upstart is very delicate. If one process fails, the rest won't even start (since most depend upon one another). There's no corruption check. People are just modifying files which causes some upstart script to fail.
|
12-28-2011, 07:51 PM | #14 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
I downloaded the upstart PDF manual. I am reading it now. I need to understand this before I touch any more scripts in the upstart directory...
< upstart Last edited by geekmaster; 12-28-2011 at 09:13 PM. |
12-30-2011, 11:05 AM | #15 |
Enthusiast
Posts: 27
Karma: 10
Join Date: Dec 2011
Device: Kindle Touch
|
About the 1.8V USB <-> serial adapter:
Any suggestion about how I can detect if it's compatible (1.8V) adapter? What about the "Digitus DA-70156"? (e.g. from German Amzon: Digitus DA-70156) Or any other suggestions? |
Tags |
kindle, recovery, root, serial, touch |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Kindle Touch: Anyway to go to Recovery Mode??? | JRyn | Kindle Developer's Corner | 4 | 12-17-2011 02:11 PM |
Kindle Touch Serial. is it US or International. | rbuljo | Amazon Kindle | 13 | 12-16-2011 02:52 PM |
Kindle 3 Recovery Menu | scenox | Kindle Developer's Corner | 6 | 03-11-2011 01:23 AM |
Help with unbricking kindle via serial port | yifanlu | Kindle Developer's Corner | 12 | 03-10-2011 08:51 AM |
Internals & serial port | dottedmag | Netronix | 1 | 05-12-2008 06:38 PM |