View Single Post
Old 12-06-2011, 06:07 PM   #196
yifanlu
Kindle Dissector
yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.yifanlu can program the VCR without an owner's manual.
 
Posts: 662
Karma: 170717
Join Date: Jul 2010
Device: Amazon Kindle 3
I won't have free time for a while, so I'll dump some stuff I've learned so far here and hope someone can make some progress while I'm gone.

First of all: The Kindle 4 and Kindle Touch contains "fastboot". This is a program usually found in Android phones installed in the bootloader. It allows you to flash kernels, system images, and stuff. On Android phones, this is what most people mean by "rooting" or "unlocking the bootloader". It's to get fastboot access and flash custom images. We have known that the new kindles have fastboot for a while now since we have the bootloader source code from amazon. However, I found out two things 1) unlike what I previously though, you CAN access fastboot without serial access. 2) the bootloader is unlocked so you CAN flash custom images/kernels/etc (however I have not explored this so there may be other limitations that are currently unknown).

Firstly, accessing fastboot:
IMPORTANT!!! When you put the Kindle into fastboot mode, you CANNOT exit it until you run the fastboot tool on your computer and reset the bootmode (or use the serial console). This tool is very unfinished and has only been tested on my OSX computer so don't do this unless you know what you're doing!!!
1) Plug in the device into your computer and in the mounted USB drive, make a blank file named "ENABLE_DIAGS" (just like previous Kindles)
2) Remove the usb cable and restart the kindle through the settings menu.
3) Once you have booted into diags mode, choose "Exit, Reboot or Disable Diags" either by tapping on it (touch) or scrolling to it (kindle 4)
4) Choose "Fastboot Bundle Install" and confirm your choice
5) The screen will now freeze. It is in fastboot mode. You can plug in your device to your computer. I don't know if you need drivers on windows or not, if so try a fastboot driver from some phone. On osx/linux you do not need drivers.

Secondly, using fastboot:
I ported the fastboot tool from the android SDK to work with the Kindle (and removed support for other devices to make things easier): https://github.com/yifanlu/Fastboot-Kindle
It is highly alpha and I have not compiled it for any other platforms yet. Once you compile it, you can run it on your computer. I'll post the commands here:
Code:
usage: fastboot [ <option> ] <command>

commands:
  getvar <variable>                        display a bootloader or idme variable
  setvar <variable> <value>                sets an idme variable
  download <filename>                      download data to memory for use with 
                                             future commands
  verify <partition> [ <filename> ]        verify downloaded data. required if 
                                             bootloader is secure
  flash <partition> [ <filename> ]         flash downloaded data
  eraseall                                 wipe the entire flash memory
  erase <partition>                        erase a flash partition
  check <partition>                        crc32 hash test the flash memory
  boot [ <filename> ]                      boot downloaded data
  continue                                 exit fastboot and return to 
                                             bootloader
  reboot                                   reboot the device
  powerdown                                shuts down the device
  pass                                     sets LED to green
  fail                                     sets LED to red

variables:
  version-bootloader                       (read only) version string for the 
                                             bootloader
  version                                  (read only) version of fastboot 
                                             protocol supported
  product                                  (read only) name of the product
  serialno                                 (read only) fastboot serial number
  secure                                   (read only) if "yes" boot images 
                                             must be signed
  serial                                   (read write) serial number
  accel                                    (read write) accelerometer 
                                             calibration data
  mac                                      (read write) MAC address
  sec                                      (read write) manufacturing code
  pcbsn                                    (read write) PCB serial number
  bootmode                                 (read write) diags, fastboot, 
                                             factory, reset, or main (default)
  postmode                                 (read write) slow, factory, or 
                                             normal (default)

partitions:
  bootloader                               bootloader, 376KiB
  prod                                     overlaps bootloader, 120KiB
  bist                                     bist, 256KiB
  userdata                                 userdata, 5KiB
  userpartition                            userpartition
  mbr                                      master boot record
  kernel                                   primary kernel
  diags_kernel                             diags kernel
  system                                   main system (root) partition
  diags                                    secondary system (diags) partition
  data                                     user data

options:
  -s <serial number>                       specify device serial number
  -i <vendor id>                           specify a custom USB vendor id
(I know I don't have to say this if you're experienced enough to run the tool, but note that you WILL brick your device if you flash the wrong image or flash to the wrong partition, or if my tool is coded improperly and breaks so have your serial cable ready)

To get out of fastboot, run "fastboot setvar bootmode main" and you may need to delete the "ENABLE_DIAGS" file or it might go back to diags mode.

I wrote the commands list based on the Kindle bootloader source, so all commands might not work. You can also see that you can also see that you can write the serial number and MAC address. I hesitated to put those options in, but I figured that if you're smart enough to compile the tool and get everything working, you will find out yourself anyways. That being said, don't be naughty.

When I have the time, I might write an "autoroot" kernel that you can flash and it'll install SSH or something on startup. However, as you can see, it would be very complicated to install so if I do this, it will most likely be a "developer unlock" or something for experienced users so developers can get a head start writing Kindle Touch apps (I've already expressed my excitement at the extendibility of the operating system).

P.S: If anyone know anything about autorooting kernels, tell me, because I sure as hell don't.
yifanlu is offline   Reply With Quote