Friday, March 25, 2016

Recovery from failed fastboot flash (return to 'DROIDBOOT PROVISION OS' from 'white USB symbol' problem)

I have made the dangerous attempt of trying to flash a 'fastboot droidboot.img' from a similar specs ZenFone 2, for which people already figured out how to unlock the bootloader without waiting for Asus.

That work was reported here.

and I've seen that the official firmware for the ZenFone 2 ZE551ML (downloaded from here ) contains indeed a 'droidboot.img' file which the ZenPad S8.0 CA allows to flash, without complaints about signatures.

However, upon rebooting via 'reboot bootloader', the 'Droidboot provision PS' no longer shows up. The screen shows a white USB symbol, no more, and is no longer visible from a PC through 'adb devices' or 'fastboot devices'. The rest still works; but have we lost fastboot forever?

NO: if the device was rooted before (strongly advised...), a trick allows to flash without passing from 'fastboot' at all.

1) Get the official full firmware archive from Asus ( file ), and copy it on the device.
2) run:
$ adb shell
3) became root:
$ su
4) move that archive on a 'safe' place, i.e. /data
# mv /storage/emulated/0/ /data

5) magic trick: create a recovery command via:
# cat > /cache/recovery/command <PRESS ENTER, CONTINUE WRITING UNDERNEATH>
--update_package=/data/ <ENTER>

6) restart and go through that script:
# reboot recovery

The device will reboot, and start a reinstallation which will, in particular, restore the Droidboot system and get rid of the white USB symbol.

Fastboot is back with us! ;-)
$ adb reboot bootloader

Saturday, February 13, 2016

De-bloating / customized stock ROM HOWTO

De-bloating / customized ZenPad Z580CA stock ROM HOWTO

Get the reference full firmware (not just the over-the-air (OTA) patch) from Asus (will be mirrored here)

Unzip it; start modifications:

1) Debloating: remove from system/app and system/priv-app the unwanted subdirectories. Compare the original lists:

AffiliateLauncher             AWS                   DMClient                   IBook                 Music2                    PicoTts                           Stk                      WeatherTime
AsusAs                        BasicDreams           DocumentsUI                InstantPage           MyASUS                    PlayTo                            Street                   WebViewGoogle
ASUSBrowser                   BbblerActors          DownloadProviderUi         IntelCamera           MyFrame                   PlusOne                           StylusDataService        WhatsNext
AsusConfigUpdater             Bluetooth             DrBooster                  IrisService           MyWater                   PowerHistory                      Syndor                   Yahoo
AsusDrawRes                   BookLiveDownloader    Drive                      Keyboard              NoiseField                PowerSaving2                      SystemUpdate             YouTube
AsusMirror                    BrowserProviderProxy  DriveActivator             KeyChain              Omlet-stub                PrintSpooler                      talkback                 ZenUIHelp
AsusSensorService             CaptivePortalLogin    Flipfont                   Kindle                PackageInstaller          PuffinBrowser                     TaskManager              ZinioReader
AsusSetupWizard               CertInstaller         Galaxy4                    LatinImeGoogle        PacProcessor              QuickMemo                         Transformer              ZinioSettingsProvider
AsusSplendidCommandAgent      Chrome                Gmail2                     LiveWallpapers        PAIStub                   QuickMemoService                  Tripadvisor
AsusVisualMasterCommandAgent  CleanMaster           GoogleCalendarSyncAdapter  LiveWallpapersPicker  PartnerBookmarksProvider  QuickPanel                        UpdateLauncher
ASUSWebView                   ConfigUpdater         GoogleContactsSyncAdapter  LocationPicker        PCLinkBinary              QuickSearch                       UserDictionaryProvider
ATOKIME                       CWSClientService      Hangouts                   Lockscreen            PCLinkManager             RemoteLink                        Videos
AudioWizard                   DataTransfor          HdmiSettings               Maps                  PhaseBeam                 SensorCal                         VisualizationWallpapers
AudioWizardView               DeskClock             HoloSpiralWallpaper        MobileManager         PhotoFrameWidget          sl_installer                      VppSettings
AwareResource                 DLNAService           HTMLViewer                 MobileManagerService  PhotoTable                SMMI_TEST_V5.1.13_CSC_L1L2_Z580C  WAPPushManager

AppLocker                   AsusEasyLauncher     AsusLiveDemoUI    AsusSystemUI               ContactsProvider         GoogleBackupTransport     ituxd                ProxyHandler         SuperNote          ZenCircle
ASUSAppInstallationService  AsusEmail            AsusMusic         AsusTask                   DefaultContainerService  GoogleFeedback            ManagedProvisioning  SettingsProvider     Telecom
AsusBackup                  ASUSGallery          AsusPhotoCollage  AsusVisualMaster           DownloadProvider         GoogleLoginService        MediaProvider        SetupWizard          TelephonyProvider
AsusCalculator              ASUSGalleryBurst     AsusQuickSearch   AsusZenUIServices          ExternalStorageProvider  GoogleOneTimeInitializer  MicroFilm            SharedStorageBackup  TeleService
AsusCalendar                AsusKidsLauncher     AsusSettings      BackupRestoreConfirmation  FileManager2             GooglePartnerSetup        MmsService           ShareRimBinary       Velvet
AsusCamera                  AsusLauncher         AsusSmartCrop     CalendarProvider           FusedLocation            GoogleServicesFramework   MusicFX              Shell                VpnDialogs
AsusContacts                AsusLiveDemoService  AsusSplendid      CMSKeyV3                   GmsCore                  InputDevices              Phonesky             SoundRecorder        WallpaperCropper

and a debloated, but still pretty fat one:

AffiliateLauncher             ATOKIME               CaptivePortalLogin  DocumentsUI                IBook           Maps                      PlusOne           RemoteLink         TaskManager              WebViewGoogle
AsusAs                        AudioWizard           CertInstaller       DownloadProviderUi         InstantPage     MobileManager             PowerHistory      SensorCal          Transformer              WhatsNext
AsusConfigUpdater             AudioWizardView       Chrome              Drive                      IntelCamera     MobileManagerService      PowerSaving2      sl_installer       Tripadvisor              YouTube
AsusDrawRes                   AwareResource         CleanMaster         Flipfont                   IrisService     PackageInstaller          PrintSpooler      Stk                UpdateLauncher           ZenUIHelp
AsusMirror                    AWS                   ConfigUpdater       Gmail2                     Keyboard        PacProcessor              PuffinBrowser     Street             UserDictionaryProvider
AsusSensorService             BasicDreams           CWSClientService    GoogleCalendarSyncAdapter  KeyChain        PAIStub                   QuickMemo         StylusDataService  Videos
AsusSetupWizard               Bluetooth             DataTransfor        GoogleContactsSyncAdapter  LatinImeGoogle  PartnerBookmarksProvider  QuickMemoService  Syndor             VisualizationWallpapers
AsusSplendidCommandAgent      BookLiveDownloader    DLNAService         HdmiSettings               LocationPicker  PicoTts                   QuickPanel        SystemUpdate       VppSettings
AsusVisualMasterCommandAgent  BrowserProviderProxy  DMClient            HTMLViewer                 Lockscreen      PlayTo                    QuickSearch       talkback           WAPPushManager

AppLocker            AsusSettings   AsusVisualMaster           ContactsProvider         GmsCore                   GooglePartnerSetup       MediaProvider  ProxyHandler         Shell              TeleService
AsusLauncher         AsusSmartCrop  AsusZenUIServices          DefaultContainerService  GoogleBackupTransport     GoogleServicesFramework  MicroFilm      SettingsProvider     SoundRecorder      Velvet
AsusLiveDemoService  AsusSplendid   BackupRestoreConfirmation  DownloadProvider         GoogleFeedback            InputDevices             MmsService     SetupWizard          SuperNote          VpnDialogs
AsusLiveDemoUI       AsusSystemUI   CalendarProvider           ExternalStorageProvider  GoogleLoginService        ituxd                    MusicFX        SharedStorageBackup  Telecom            WallpaperCropper
AsusQuickSearch      AsusTask       CMSKeyV3                   FusedLocation            GoogleOneTimeInitializer  ManagedProvisioning      Phonesky       ShareRimBinary       TelephonyProvider

2) Manually change the build restrictions/details as desired (allow tethering; remove fake shutter sound upon taking photos etc.):
edit the file system/build.prop

3) Recompress the image: from within its root directory containing:
$ ls
boot.img  droidboot.img  file_contexts  l_recovery.fstab  META-INF  partition.tbl  recovery  splash.img  system

$ zip ../ -r *
For the above selection of utilties, a debloated 4.6.1 stock ROM is made available here.

4) Prepare a fat32 (i.e. not an 'extended FAT': better compatibility) microSD card:
# cfdisk /dev/mmcblk0
then 'New', 'Change type' to: b (W95 fat32), 'Write' and 'Quit'

# mkfs.vfat /dev/mmcblk0p1 -n SD16GB_fat

5) Copy there the zipped image. Add any additional extras desired, like SuperSU to root the device:

6) Umount the microSD card and place it back into the device. Reboot it into Droidboot: either connect via USB (after enabling 'USB debugging' under 'Settings'->'Developer mode') and issue:
$ adb reboot bootloader

or reboot it, keeping Volume UP and Power pressed together, until the android logo with service hat shows up.

7) Download the Intel Fastboot Tethered Temporary Recovery Session Launcher (FBRL; mirror of the relevant files here) and unpack i.e. under /tmp/FBRL the files:

-rw-r--r-- 1 root root  410105 May 16  2015 recovery.launcher
(MD5SUM: 572cc4351881656cf4df7d538f60dd7f)
-rw-r--r-- 1 root root  183198 May 16  2015
(MD5SUM: d3c12ee127f87437a8e94470f193dc57)
-rw-r--r-- 1 root root  174902 May 16  2015 recovery.trigger.original
(MD5SUM: a1047156addd80ae14284816e0de94df)
-rw-r--r-- 1 root root 3560544 Dec 27  2014
(MD5SUM: 49e8bb46834dccb1ef95a2bb9b55a9db)

8) Connect the USB cable, and from such directory issue:

# fastboot devices (verify connectivity. If nothing shows up, an obsolete version of the utility may be installed. Get a new one, for instance a recent Debian package for your desktop architecture).

Then, if things seem fine:
# fastboot flash /tmp/
# fastboot flash /tmp/recovery.launcher recovery.launcher
# fastboot flash /system/bin/cp recovery.trigger.original
# fastboot oem backup_factory

Device will reboot into a custom CWM recovery, and show (slowly, line after line):
Tethered Recovery Launcher Concept
social-design-concepts. 05/16/2015
After some more information listing, it will refresh and show a new menu in blue.

9) Select:
9a) Wipe data/factory reset;
9b) Advanced->wipe Dalvik cache->Yes - Wipe Dalvik Cache
9c) Mounts and Storage -> Format /system -> Yes - Format
9d) Format /data and /data/media (/sdcard) -> Yes - Format
go back;
9e) install zip -> choose zip from external card -> Select -> Yes - Install
(it will take some minutes - BE PATIENT!)
9f) Repeat with any desired additional zip file placed into the microSD (i.e. the last stable (mirror here) for root access), and go back;

10) Reboot system now -> Yes - fix root
The device will restart; the message 'Android is upgrading' will show up shortly. All done! ;-)


1) I've tried to make initially even Gmail optional; this seems to work at first, however it will soon require the user to upgrade 'Google Play Services' from the Play Store. Which works... except that then the service will keep crashing and restarting, with the error message 'Unfortunately Google Play services has stopped'.

2) Minor annoyance: many removed package will be still automatically downloaded at the first boot; but they can be now cleanly removed.

3) After debloating, the /system partition does not need to be so large. As shipped, 'df' at 'adb shell' gives (as root) it to be around 2.8GiB, but it could be now wiser to reduce its size.

I haven't touched the partiton table yet, just to keep on the safe side. The file 'partition.tbl' would allow to simply reduce its default size (just changing the number of blocks (in units of 512 bytes?) where /system should end, and hence /data begins). It is called by the script: 'META-INF/com/google/android/updater-script', but only if the is_osip function returns 'true' (see i.e. this presentation)

However, a following OTA update will expect to find enough space, and thus break if these parameters are modified.

Enjoy a cleaner device! Mirror copy of the above debloated & /system/etc/hosts -filtered stock ROM is here.

Sunday, February 7, 2016

Rooting the Asus ZenPad S 8.0 Z580CA tablet

Rooting the ZenPad S 8.0 Z580CA tablet

Asus ZenPad S 8.0 Z580CA product shot


The tablet in subject is a very slim and portable high resolution 8' 4:3 device by Asus. Different variants are available; here the model with an Intel Atom Z3560 and 2GB RAM / 16 GB SSD will be considered (full specifications: here).

Instructions are provided for a standard Linux desktop, in particular a Debian stable 8.3 distribution "Jessie". For Windows, see i.e. here. Japanese notes: here.

Enable "Developer mode" on the tablet: "Settings" -> "About device" -> tap "Build number" many times. Confirm and look for the new "Developer options" entry appearing among the "Settings". Tap the "USB Debugging" box to enable it.
Download or copy into the device (mirror here).

Connect the provided USB cable to an available desktop port, and verify that root can see the device: issue (as root) on a desktop terminal the command:
# adb devices 

Reboot into the bootloader:

# adb reboot bootloader

Verify that fastboot can still see the device:
# fastboot devices

If lsusb shows it but fastboot returns nothing, it can be a known issue with the utility version provided by the desktop Linux distribution is too old. Try a more recent one from Debian 'testing' for instance, or a recompiled i686 binary is provided here (mirror) from the XDA forum by senior developer Vampirefo (but beware of the security risks - safe hex is better! ;-).

Download on the desktop the last Intel Fastboot Tethered Temporary Recovery Session Launcher (FBRL; mirror here) and unpack it under /tmp/FBRL/.

Move to such directory and issue (as root) on a desktop terminal the following 4 commands:

# fastboot flash /tmp/
# fastboot flash /tmp/recovery.launcher recovery.launcher
# fastboot flash /system/bin/cp recovery.trigger.original
# fastboot oem backup_factory

... and check on the device screen that each one completes without problems. Select 'Reboot' to continue.

Insert a microSD card (important: make sure it is formatted as 'FAT32', not 'exFAT', for compatibility reasons: under Linux, the filesystem must be created with mkfs.vfat, not mkfs.exfat) in which the binary 

Select: Install zip, read it in from 'External SD', proceed with installation and then reboot into the new, rooted state.
Enjoy things like i.e. Linux Deploy for availability of a really open source, complete system!