Installing Recovery for Amazon Kindle Fire

Root Device and Install Custom Bootloader

1. Root the device (http://rootkindlefire.com/category/kindle-fire-root/) and install the FireFireFire custom bootloader (http://forum.xda-developers.com/showthread.php?p=23492717). FireFireFire will enable easy booting to recovery.

Download Recovery Image

2. Download a suitable recovery image (e.g. openrecovery-twrp-2.5.0.0-otter.img from http://techerrata.com/browse/twrp2/blaze/).

Boot to Fastboot

3. Change boot mode so that the device will boot to fastboot.

$ sudo ./adb shell
# idme bootmode 4002
<idme> write 4002 to offset 0x1000

4. Reboot device to enter fastboot.

Install Recovery

5. Flash device with the downloaded recovery image.

$ sudo ./fastboot -i 0x1949 flash recovery openrecovery-twrp-2.5.0.0-otter.img
sending 'recovery' (6144 KB)...
OKAY [  1.540s]
writing 'recovery'...
OKAY [  0.691s]
finished. total time: 2.231s

where openrecovery-twrp-2.5.0.0-otter.img is the downloaded image.

6. Change back the boot mode.

$ sudo ./fastboot -i 0x1949 oem idme bootmode 4000
...
OKAY [  0.080s]
finished. total time: 0.080s

Boot to Recovery

7. Reboot device. To boot to recovery, press the power button when the FireFireFire appears upon device start up.

References

[1] http://rootkindlefire.com/category/kindle-fire-root/
[2] http://forum.xda-developers.com/showthread.php?p=23492717
[3] http://techerrata.com/browse/twrp2/blaze/
[4] http://forum.xda-developers.com/showthread.php?t=1369405

Advertisements

Fixing Issue With Missing Kernel Headers When Installing VMware Tools in Linux Virtual Machine

When installing VMware Tools in more recent Linux releases, the following error would occur even when the kernel headers were already installed.

Searching for a valid kernel header path...
The path "" is not a valid path to the 3.8.0-19-generic kernel headers.
Would you like to change it? [yes] yes

Enter the path to the kernel header files for the 3.8.0-19-generic kernel? /lib/modules/3.8.0-19-generic/build/include

The path "/lib/modules/3.8.0-19-generic/build/include" is not a valid path to
the 3.8.0-19-generic kernel headers.
Would you like to change it? [yes]

The installer would not find the header files even when the correct path was manually provided.

The reason is that, in version 3.7 of the Linux kernel, the version.h file needed by the VMware Tools installer have been relocated from /usr/src/linux-headers-$(uname -r)/include/linux to /usr/src/linux-headers-$(uname -r)/include/generated/uapi/linux, and the installer has not been updated to handle that.

The solution would be to create a symbolic link to version.h at the location where VMware Tools installer expects it.

$ ln -s /usr/src/linux-headers-$(uname -r)/include/generated/uapi/linux/version.h /usr/src/linux-headers-$(uname -r)/include/linux/version.h

References

[1] https://cmanios.wordpress.com/2013/06/12/fix-vmware-tools-kernel-header-path-is-not-valid-error/
[2] http://askubuntu.com/questions/131351/how-to-install-vmware-tools/286003#286003
[3] https://lkml.org/lkml/2012/7/20/419

Installing CyanogenMod 10.1 on HTC One X

Backup

1. Backup applications and settings using Titanium Backup, do a NANDroid backup in recovery, and/or do a manual backup of the sdcard partition.

Check and Upgrade Bootloader (HBOOT) Version

2. Check the bootloader version using adb.

$ sudo ./adb shell
shell@android:/ $ getprop ro.bootloader
1.27.0000
shell@android:/ $ exit

If the bootloader version number (1.27.0000 in this case) is lower than 1.28.0000, then it needs to be updated.

3. Check the device carrier ID using fastboot.

$ sudo ./fastboot oem readcid
...
(bootloader) DEBUG: cid: HTC__044
OKAY [  0.015s]
finished. total time: 0.015s

In this case, the carrier ID is HTC__044.

4. Download the firmware corresponding to the device carrier ID (HTC__044) from http://forum.xda-developers.com/showthread.php?t=1957376.

5. If the bootloader has previously been unlocked, it needs to be re-locked using fastboot.

$ sudo ./fastboot oem lock
...
(bootloader) Lock successfully...
OKAY [  0.143s]
finished. total time: 0.146s

6. Reboot the RUU using fastboot.

$ sudo ./fastboot oem rebootRUU
...
(bootloader) Save data from original MSC...
(bootloader) Save data from SIF...
(bootloader) Update partition data to SIF partition
(bootloader) offset = 0
(bootloader) Update partition data from original MSC...
(bootloader) offset = 0
(bootloader) [MSG] OKAY
OKAY [  0.210s]
finished. total time: 0.210s

7. Flash the device with the downloaded firmware using fastboot.

$ sudo ./fastboot flash zip firmware.zip
sending 'zip' (12875 KB)...
OKAY [  1.619s]
writing 'zip'...
(bootloader) adopting the signature contained in this image...
(bootloader) signature checking...
(bootloader) checking model ID...
(bootloader) checking custom ID...
(bootloader) checking main version...
(bootloader) checking hboot version...
(bootloader) start image[boot] unzipping & flushing...
(bootloader) Format partition LNX done
(bootloader) [RUU]WP,boot,100
(bootloader) start image[recovery] unzipping & flushing...
(bootloader) Format partition SOS done
(bootloader) [RUU]WP,recovery,100
(bootloader) ERASE backup cid
OKAY [  3.170s]
finished. total time: 4.790s

where firmware.zip is the downloaded firmware package.
IMPORTANT: If this step fails, repeat the command (to flash the device) IMMEDIATELY.

Unlock Bootloader

8. Unlock the bootloader using fastboot.

$ sudo ./fastboot flash unlocktoken Unlock_code.bin
sending 'unlocktoken' (0 KB)...
OKAY [  0.008s]
writing 'unlocktoken'...
(bootloader) unlock token check successfully
FAILED (status read failed (No such device))
finished. total time: 19.736s

where Unlock_code.bin is the unlock code from HTC. The bootloader is now unlocked again.

Install Recovery

9. Flash the device with the recovery image using fastboot.

$ sudo ./fastboot flash recovery recovery-clockwork-touch-5.8.4.0-endeavoru.img 
sending 'recovery' (5742 KB)...
OKAY [  0.731s]
writing 'recovery'...
(bootloader) Format partition SOS done
OKAY [  0.552s]
finished. total time: 1.283s

where recovery-clockwork-touch-5.8.4.0-endeavoru.img is the recovery image (in this case, ClockworkMod 5.8.4.0 for HTC One X).

Install CyanogenMod

10. Download the CyanogenMod package from http://download.cyanogenmod.org/?type=stable&device=endeavoru.

11. Flash the device with the boot image from the CyanogenMod package using fastboot.

$ sudo ./fastboot flash boot boot.img 
sending 'boot' (4960 KB)...
OKAY [  0.626s]
writing 'boot'...
(bootloader) Format partition LNX done
OKAY [  0.493s]
finished. total time: 1.119s

12. Boot into recovery and flash the device with the CyanogenMod package.

13. Restore the backups if necessary.

References

[1] http://wiki.cyanogenmod.org/w/Endeavoru_Info
[2] http://download.cyanogenmod.org/?type=stable&device=endeavoru
[3] http://forum.xda-developers.com/showpost.php?p=37930062&postcount=1161
[4] http://forum.xda-developers.com/showthread.php?t=1957376

ln -s “BASH Dropbox Uploader” .

http://www.andreafabrizi.it/?dropbox_uploader

A Dropbox synchronisation tool implemented as a BASH script (curl is used for the Dropbox API HTTP calls). Contrary to the name of the application, it is also able to perform downloads, as well as various remote operations such as file deletion, directory creation and directory deletion. Authentication is done using Dropbox’s official OAuth API.

Adding an Auto Shutdown Feature to the End of a Script

Whole Script

# Main Script Function ...

# Shutdown Option
export DISPLAY=:0.0;
if [ `/usr/bin/xprintidle` -gt 60000 ]; then
    /usr/bin/zenity --question --title="Job Completed" --timeout=60 \
                    --text="Job Completed; Proceed to Shutdown?" \
                    --ok-label="Yes" --cancel-label="No";
    if [ "$?" -eq "5" ]; then
        # Proceed to Shutdown
        /sbin/shutdown -h now;
    fi
fi

Explanations

export DISPLAY=:0.0;

This is necessary if the script is run outside of an X session (e.g. as a cron job), so that xprintidle can get the correct X session idle time, and zenity can show the dialog on the correct X server display.

if [ `/usr/bin/xprintidle` -gt 60000 ]; then

Gets the X session idle time, and presents the shutdown option if the X session has been inactive for some time (in this case, 60000 milliseconds). Otherwise, it is assumed that the user is active and does not want the system to shutdown.

/usr/bin/zenity --question --title="Job Completed" --timeout=60 \
                --text="Job Completed; Proceed to Shutdown?" \
                --ok-label="Yes" --cancel-label="No";

Displays the shutdown option dialog with the specified title, text, and options. If none of the options is selected within the timeout period (in this case, 60 seconds), the dialog closes with the “Yes” option selected by default.

if [ "$?" -eq "5" ]; then

Shuts down the system if the “Yes” option was selected, or if no option was selected within the timeout period (hence defaulting to the “Yes” option). Otherwise (i.e. the “No” option was selected within the timeout period), the system does not shut down.

/sbin/shutdown -h now;

Shuts down the system.

Note: xprintidle and zenity may not be present in a default installation. They can be installed through the package manager.

References

[1] https://www.linuxquestions.org/questions/linux-newbie-8/export-display%3D-0-0-a-682926/
[2] http://freecode.com/projects/xprintidle
[3] https://help.gnome.org/users/zenity/stable/

Installing Raspbian on the Raspberry Pi

Download Image

1. Download the latest Raspbian release (Wheezy) from http://www.raspberrypi.org/downloads (e.g. 2013-05-25-wheezy-raspbian.zip).

2. Check that the hash of the downloaded file matches the one on the download site.

$ sha1sum 2013-05-25-wheezy-raspbian.zip
131f2810b1871a032dd6d1482dfba10964b43bd2  2013-05-25-wheezy-raspbian.zip

Write Image to SD Card

3. Extract the SD card image file from the archive.

$ unzip 2013-05-25-wheezy-raspbian.zip

4. Write the image to the SD card.

$ sudo dd bs=4M if=2013-05-25-wheezy-raspbian.img of=/dev/sdc

where /dev/sdc is the path to the SD card device.
IMPORTANT: The path varies; using the wrong path would cause the wrong disk to be overwritten.

Resize Root Partition on SD Card

5. Run parted on /dev/sdc.

$ sudo parted /dev/sdc

6. Print the partition table.

(parted) unit chs
(parted) print
Model: Generic STORAGE DEVICE (scsi)
Disk /dev/sdc: 482,18,47
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 482,255,63.  Each cylinder is 8225kB.
Partition Table: msdos

Number  Start     End         Type     File system  Flags
 1      0,130,2   7,165,29    primary  fat16        lba
 2      7,165,30  235,214,42  primary  ext4

7. Remove the existing root partition.

(parted) rm 2

8. Re-create the partition, filling the entire disk.

(parted) mkpart primary 7,165,30 482,18,47
(parted) quit

where 7,165,30 is the starting chs (cylinder, head, sector) number of the original (deleted) partition, and 482,18,47 is the ending chs number of the disk. The information is available in the original partition table.

9. Check and repair the root partition.

$ sudo e2fsck -f /dev/sdc2

10. Resize the root partition.

$ sudo resize2fs /dev/sdc2

Login to Raspberry Pi

11. Insert the SD card into the Raspberry Pi and switch it on.

12. Access the Raspberry Pi remotely using SSH.

$ ssh pi@192.168.1.2

where 192.168.1.2 is the IP address assigned to the device. The default username is pi, and the password is raspberry.

References

[1] http://www.raspberrypi.org/downloads
[2] http://elinux.org/RPi_Easy_SD_Card_Setup
[3] http://elinux.org/RPi_Resize_Flash_Partitions