[+]RESTOCK - stock restore, repartition, repair and reset, including USB driver fix

Search This thread

k23m

Senior Member
Jan 3, 2016
1,001
594
RESTOCK is a new Nexus 7 2013 repair and factory reset tool for Windows. The NRT app (Nexus Root Toolkit) is similar but is old, closed-source, unsupported, abandoned, does no eMMC diagnostics and most importantly - it offers no repartitioning. Unlike NRT, Restock is specialized and optimized for Nexus 7'13 only, with streamlined operation and minimal user input.

If fastboot mode is available, then no matter what software problems like bootloops or softbricks are observed, or what custom ROM you had used before - Restock will restore your tablet to original, latest stock image, factory setup in 10 minutes (more time for one-off components download if necessary). Unforeseen issues should be reported in this thread and hopefully will be resolved within 24 hours.

If fastboot mode is not available, try the unbricking guide first.

For hardware issues, check this thread.

FEATURES

  • supports both flo and deb variants
  • small app download size (2.5MB)
  • automatic latest stock image (mob30x) and USB driver download from official google.com locations
  • robust, reliable USB device detection and driver installation - tested on Windows: XP-32, W7-32/64, W10-64(1809)
  • eMMC memory test and diagnostics
  • automatic device unlocking
  • option of repartition to original factory layout
    - precise and reliable for any eMMC size, including 64GB and 128GB mods
    - required for repartition scripts which check for original layout and flashing specific custom ROMs like e.g. Ubuntu Touch
    - advised for selling in original factory condition and resolving difficult ROM flashing issues and starting from scratch
  • minimal user interaction and fully scripted auto-processing
  • the Restock script is open for inspection, corrections and improvements; post your comments and suggestions here
USAGE

  1. download the attached zip file
  2. unzip it
  3. double-click on "restock.bat"
  4. follow the prompts
SAMPLE OUTPUT
Code:
Nexus 7'13 Restock v1 @2019 k23m
SUPPORT - http://bit.ly/2C35sLZ
WARNING - installing factory image will ERASE ALL DATA from the device
Enter device name [flo OR deb]: flo

Downloading USB drivers and the latest factory image.
If not deleted, will not be downloaded again.

--  https://dl-ssl.google.com/android/repository/latest_usb_driver_windows.zip
Resolving dl-ssl.google.com... 74.125.24.190, 74.125.24.91, 74.125.24.93, ...
Connecting to dl-ssl.google.com|74.125.24.190|:443... connected.
WARNING: cannot verify dl-ssl.google.com's certificate, issued by 'CN=GTS CA 1O1,O=Google Trust Services,C=US':
  Unable to locally verify the issuer's authority.
HTTP request sent, awaiting response... 200 OK
Length: 8682859 (8.3M) [application/zip]
Saving to: 'latest_usb_driver_windows.zip'
latest_usb_driver_windows.zip  14%[======>                              ]   1.21M   383KB/s    eta 19s
...

--  https://dl.google.com/dl/android/aosp/razor-mob30x-factory-52684dff.zip
Resolving dl.google.com... 172.217.25.46
Connecting to dl.google.com|172.217.25.46|:443... connected.
WARNING: cannot verify dl.google.com's certificate, issued by 'CN=GTS CA 1O1,O=Google Trust Services,C=US':
  Unable to locally verify the issuer's authority.
HTTP request sent, awaiting response... 200 OK
Length: 505296115 (482M) [application/zip]
Saving to: 'razor-mob30x-factory-52684dff.zip'

razor-mob30x-factory-52684dff  86%[=============================>       ] 417.98M   410KB/s    eta 2m 57s
...

1. boot the Nexus in fastboot mode: when OFF press POWER + VOLUME DOWN
2. when in the bootloader menu, connect it to your PC
3. wait a few seconds, then...
Press any key to continue . . .
...
...
INFO:   Successfull installation of 'd:\restock\data\usb_driver\android_winusb.inf'.
INFO:   Returning with code 0x1

Device not found...
1. disconnect it from PC
2. reboot to bootloader again
3. reconnect it to PC
Press any key to continue . . .

Verify...
eMMC test...
If it freezes here, the chip is faulty and needs replacement.
eMMC OK
Lock status...
GPT...

Partitions had been changed.
Restore original partitions? [y/n]: y
Wait...
sending 'bootloader' (3911 KB)...
OKAY [  0.141s]
writing 'bootloader'...
OKAY [  1.518s]
finished. total time: 1.658s
rebooting into bootloader...
OKAY [ -0.000s]
finished. total time: 0.008s
Wait...
sending 'gpt' (35 KB)...
OKAY [  0.016s]
writing 'gpt'...
OKAY [  0.109s]
finished. total time: 0.141s
rebooting into bootloader...
OKAY [ -0.000s]
finished. total time: 0.012s

If error, copy and post it, include restock.log

http://bit.ly/2C35sLZ

Note: Android flash takes 2 minutes, initial boot takes 7 minutes.

Press any key to continue . . .
sending 'bootloader' (3915 KB)...
OKAY [  0.125s]
writing 'bootloader'...
OKAY [  1.377s]
finished. total time: 1.502s
rebooting into bootloader...
OKAY [  0.000s]
finished. total time: 0.007s
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
--------------------------------------------
Bootloader Version...: FLO-04.08
Baseband Version.....: none
Serial Number........: xxxxxxxxx
--------------------------------------------
checking product...
OKAY [  0.016s]
checking version-bootloader...
OKAY [  0.000s]
sending 'boot' (7422 KB)...
OKAY [  0.234s]
writing 'boot'...
OKAY [  1.000s]
sending 'recovery' (8166 KB)...
OKAY [  0.266s]
writing 'recovery'...
OKAY [  0.328s]
erasing 'system'...
OKAY [  1.143s]
sending 'system' (843549 KB)...
OKAY [ 26.516s]
writing 'system'...
OKAY [ 39.986s]
erasing 'userdata'...
OKAY [ 23.750s]
formatting 'userdata' partition...
Creating filesystem with parameters:
    Size: 28856791040
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8192
    Inode size: 256
    Journal blocks: 32768
    Label:
    Blocks: 7045115
    Block groups: 215
    Reserved block group size: 1024
Created filesystem with 11/1761280 inodes and 154578/7045115 blocks
sending 'userdata' (139085 KB)...
writing 'userdata'...
OKAY [ 12.434s]
erasing 'cache'...
OKAY [  0.437s]
formatting 'cache' partition...
Creating filesystem with parameters:
    Size: 587202560
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 7168
    Inode size: 256
    Journal blocks: 2240
    Label:
    Blocks: 143360
    Block groups: 5
    Reserved block group size: 39
Created filesystem with 11/35840 inodes and 4616/143360 blocks
sending 'cache' (10984 KB)...
writing 'cache'...
OKAY [  0.891s]
rebooting...
finished. total time: 107.057s
Press any key to exit...



RESTOCK 2

SCRIPTS
  • restock.bat - the main script: stock install, repair, repartition and factory reset
  • addons.bat - install TWRP custom recovery, mob30x-fix1, root/Magisk, ElementalX-N7-6.17 kernel
  • fstrim.bat - faster eMMC writes: dispatches TRIM command for all unused filesystem blocks
  • safe-unlock.bat - unlock without data loss
  • getlog.bat - diagnostics #1
  • relog.bat - diagnostics #2
ADDONS
These addons should be installed immediately after RESTOCK and before Android setup:
  1. TWRP deb/flo custom recovery (it must be flashed before the other addon options)
  2. MOB30X-FIX1 - improved Android 6.0.1 stock MOB30X installation, info: https://forum.xda-developers.com/showthread.php?t=4021757 In short, it adds WiFi 'Skip' setup option and removes old GApps to increase space on the system partition
  3. root/Magisk - https://github.com/topjohnwu/Magisk
  4. ElementalX-N7-6.17 custom kernel - I recommend to preset "doubletap2wake" and "battery life extender". For car use also preset "USB OTG + charge mode", info: https://forum.xda-developers.com/showthread.php?t=2389022
ERRORS
If you see errors, copy and report them. Run getlog.bat and include "getlog.log" in your post. If possible, also run relog.bat and attach "relog-xxxxxx.zip" to your post.

FSTRIM
For optimal eMMC performance run fstrim.bat from time to time.

SAFE UNLOCK
Unlock your device without data loss. MiFlash is described in the Unbricking Guide:
https://forum.xda-developers.com/showpost.php?p=75360854&postcount=199
Do not proceed unless you have read the unbricking guide and downloaded all components.



OPTIONS

Try mob30x-fix1 for improved Android 6.0.1 stock installation.

Next consider CROSS : 1-click installation of secure, up-to-date Android 7-to-11 custom ROMs, including TWRP, repartition, root, etc. as easily as RESTOCK.



NOTE

If Android is stuck on boot logo, with TWRP flash k23m-persist-fix2.zip
 

Attachments

  • Restock1.zip
    2.5 MB · Views: 6,235
  • Restock2.zip
    3 MB · Views: 4,020
  • k23m-persist-fix2.zip
    1.9 KB · Views: 1,737
Last edited:

Aprate

Senior Member
Mar 25, 2008
123
15
Did not even realize this was new! Thanks for making such a wonderfull tool! Currently using it to flash flo, and it works great!
Will install lineage after this tho :p

Code:
1. boot the Nexus in fastboot mode: when OFF press POWER + VOLUME DOWN
2. when in the bootloader menu, connect it to your PC
3. wait a few seconds, then...
Press any key to continue . . .
Verify...
eMMC test...
If it freezes here, the chip is faulty and needs replacement.
eMMC OK
Lock status...
GPT...

If error, copy and post it, include restock.log

[url]http://bit.ly/2C35sLZ[/url]

Note: Android flash takes 2 minutes, initial boot takes 7 minutes.
Press any key to continue . . .
sending 'bootloader' (3915 KB)...
OKAY [  0.131s]
writing 'bootloader'...
OKAY [  1.581s]
finished. total time: 1.719s
rebooting into bootloader...
OKAY [  0.009s]
finished. total time: 0.014s
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
--------------------------------------------
Bootloader Version...: FLO-04.08
Baseband Version.....: none
Serial Number........: 07206d7c
--------------------------------------------
checking product...
OKAY [  0.003s]
checking version-bootloader...
OKAY [  0.004s]
sending 'boot' (7422 KB)...
OKAY [  0.239s]
writing 'boot'...
OKAY [  0.397s]
sending 'recovery' (8166 KB)...
OKAY [  0.265s]
writing 'recovery'...
OKAY [  0.448s]
erasing 'system'...
OKAY [  0.743s]
sending 'system' (843549 KB)...
OKAY [ 26.422s]
writing 'system'...
OKAY [ 51.719s]
erasing 'userdata'...
OKAY [  9.570s]
formatting 'userdata' partition...
Creating filesystem with parameters:
    Size: 13342060544
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8144
    Inode size: 256
    Journal blocks: 32768
    Label:
    Blocks: 3257339
    Block groups: 100
    Reserved block group size: 799
Created filesystem with 11/814400 inodes and 91881/3257339 blocks
sending 'userdata' (137198 KB)...
writing 'userdata'...
OKAY [ 12.298s]
erasing 'cache'...
OKAY [  0.051s]
formatting 'cache' partition...
Creating filesystem with parameters:
    Size: 587202560
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 7168
    Inode size: 256
    Journal blocks: 2240
    Label:
    Blocks: 143360
    Block groups: 5
    Reserved block group size: 39
Created filesystem with 11/35840 inodes and 4616/143360 blocks
sending 'cache' (10984 KB)...
writing 'cache'...
OKAY [  1.029s]
rebooting...

finished. total time: 103.239s
Press any key to exit...
 
  • Like
Reactions: vahesalu and k23m

hamhead

Member
Aug 27, 2010
26
1
wow my nexus 7 was in boot loop and i had an old NRT tool which wouldnt work at all.

computer wouldnt detect next 7 2013 thru usb cable
cannot mount usb-otg in TWRP
boot loop in custom rom

your tool fixed it so fast and easy.

THANKS SO MUCH FOR YOUR TOOL!!!
 
  • Like
Reactions: vahesalu

Tmzdroid

Senior Member
Thanks for this k23m although I hope to never have to use it. My Kingston equipped Nexus 7 is still going strong and it's my most used android device. If I run the emmc memory test and diagnostics would it tell me if the emmc is about to die and determine its overall wear and health?
 
Last edited:
  • Like
Reactions: vahesalu

k23m

Senior Member
Jan 3, 2016
1,001
594
Thanks for this k23m although I hope to never have to use it. My Kingston equipped Nexus 7 is still going strong and it's my most used android device. If I run the emmc memory test and diagnostics would it tell me if the emmc is about to die and determine its overall wear and health?
Hello Tmzdroid, your Kingston was from a newer production batch and probably is OK but maybe do not try any major OS/ROM changes as this most recent case demonstrates. The eMMC generation used in N7 has no "SMART" flash wear diagnostics like in SSD. This feature was introduced in eMMC v5+. Restock can identify Kingston if it has standard partitions and checks for the terminal, most common, read-only condition Kingstons suffer from. In short, the test can not indicate eMMC degradation level. The only forewarning you may get is a period of slow-downs prior to going read-only. If you feel it is happening, do fastboot format cache and if it takes longer than 2 seconds, it is almost the end and time to get your data out of the tablet, while you still can.

:highfive:
 
  • Like
Reactions: Tmzdroid

drinkypoo

Senior Member
Jun 4, 2009
283
34
Albion, CA
hyperlogos.org
I'm getting "Incorrect device" trying to use Restock to recover from flo-deb_clamor_repartition. It's definitely flo, I am looking at the bootloader right now. fastboot format cache completes in 0.086 seconds. flo 32G, rev_e, bootloader FLO-04.08, no carrier, secure boot enabled, lock state unlocked.

edit: got going again with https://forum.xda-developers.com/showthread.php?t=2381582
 
Last edited:

k23m

Senior Member
Jan 3, 2016
1,001
594
Thank you for this! It fixed my deb model <3

Thank you for confirming that it works on deb. I have 3 flo's but no deb to test.


I'm getting "Incorrect device" trying to use Restock to recover from flo-deb_clamor_repartition. It's definitely flo, I am looking at the bootloader right now. fastboot format cache completes in 0.086 seconds. flo 32G, rev_e, bootloader FLO-04.08, no carrier, secure boot enabled, lock state unlocked. edit: got going again with https://forum.xda-developers.com/showthread.php?t=2381582

Would you be able to post a log from the attached script? Unzip and run it in Restock's folder.
:fingers-crossed:
 

Attachments

  • getlog.zip
    757 bytes · Views: 76

drinkypoo

Senior Member
Jun 4, 2009
283
34
Albion, CA
hyperlogos.org
Would you be able to post a log from the attached script? Unzip and run it in Restock's folder.
:fingers-crossed:

Strangely, it won't run unless I run as administrator. I double-click it and nothing happens. If I run as administrator then it runs in c:\windows\system32 and doesn't list the contents of the directory you want... I even tried moving restock's folder into my user dir instead of under downloads just in case something about the path was causing problems. No idea WTF that is about. Perms look good. I went ahead and just ran the commands manually from a CMD shell in the proper directory, looks like they produced the output you were looking for... except the find command doesn't work there. Maybe it would work in command.com, dunno.

I'm not sure how much help this will be since I used other tools since trying to use restock, but here it is anyway.
 

Attachments

  • getloglog.zip
    3.4 KB · Views: 36

k23m

Senior Member
Jan 3, 2016
1,001
594
Strangely, it won't run unless I run as administrator. I double-click it and nothing happens. If I run as administrator then it runs in c:\windows\system32 and doesn't list the contents of the directory you want... I even tried moving restock's folder into my user dir instead of under downloads just in case something about the path was causing problems. No idea WTF that is about. Perms look good. I went ahead and just ran the commands manually from a CMD shell in the proper directory, looks like they produced the output you were looking for... except the find command doesn't work there. Maybe it would work in command.com, dunno. I'm not sure how much help this will be since I used other tools since trying to use restock, but here it is anyway.
It seems your Path env exceeds the limit:
Code:
Path=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python27\;C:\Python27\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\WinAVR-20100110\bin;C:\WinAVR-20100110\utils\bin;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\PuTTY;C:\Programs\Argyll_V1.7.0\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\GitExtensions\;C:\Program Files\Git\cmd;C:\Windows;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Calibre2\;C:\Program Files (x86)\sbt\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Users\drink\AppData\Local\Android\Sdk\platform-tools;C:\Program Files (x86)\GNU Tools ARM Embedded\5.4 2016q3\bin;C:\Users\drink\AppData\Local\Android\Sdk\platform-tools;C:\Program Files (x86)\Nmap;C:\Programs\ffmpeg-20190208\bin;C:\Program Files (x86)\Atmel\Flip 3.4.7\bin;c:\programs\fastboot;C:\programs;"%~dp0data"
My path has only:
Code:
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\
Please do:
  • Edit the path - Control Panel / System / Advanced System Settings / Advanced tab / Environment Variables button / in System Variables select Path / click Edit
  • copy original and save for reuse later
  • replace it with: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\
  • save
  • reboot
  • run Restock
It should work now. As your N7 is already fixed, just close the window when it stops at "Note: Android flash takes 2 minutes, initial boot takes 7 minutes" and nothing will be flashed. Also, don't go ahead with "Restore original partitions? [y/n]" if it is offered.

If it still does not work, login to Windows with an admin account and then run Restock.
 

Jay Rock

Senior Member
Sep 27, 2011
2,235
316
27
Chula Vista
I was just thinking I want to restore my Nexus back to 100% stock, and magically this recent thread appears. Worked perfectly. Thank you.
 

bamsbamx

Senior Member
Aug 2, 2011
572
591
Bilbo
livenfun.com
Strangely, only custom ROMs are working for me. I always get bootloop whenever I flash any of the razor Nexus Factory Images. I also tried the script you provided and finishes successfully, but when booting, it always end in bootloop with Google logo on it. I have access to fastboot and even can flash and boot to TWRP with no problemas. Any idea?

EDIT: Attached logs after re-running the script
 

Attachments

  • restock-26728.log
    14.5 KB · Views: 29
  • restock-18917.log
    14.8 KB · Views: 20
  • restock-2053.log
    14.8 KB · Views: 22
Last edited:

k23m

Senior Member
Jan 3, 2016
1,001
594
Strangely, only custom ROMs are working for me. I always get bootloop whenever I flash any of the razor Nexus Factory Images. I also tried the script you provided and finishes successfully, but when booting, it always end in bootloop with Google logo on it. I have access to fastboot and even can flash and boot to TWRP with no problemas. Any idea?
EDIT: Attached logs after re-running the script
It is a very interesting case. We need internal logs, please 'install' get-logs-sdcard.zip in TWRP, find 'logs.tgz' in the root of internal storage and post it here.
 

bamsbamx

Senior Member
Aug 2, 2011
572
591
Bilbo
livenfun.com
It is a very interesting case. We need internal logs, please 'install' get-logs-sdcard.zip in TWRP, find 'logs.tgz' in the root of internal storage and post it here.

Thanks for the quick reply, here I attach the logs... Seems like the /persist partition is empty, maybe thats the cause of the problem?

However, I can understand why that happened, maybe because I used the /system partition script for increasing its size...

EDIT: Somehow the XDA file uploader says invalid file for .tgz format, I recompressed the folder to a .zip file
 

Attachments

  • tmp.zip
    51.7 KB · Views: 34

k23m

Senior Member
Jan 3, 2016
1,001
594
Thanks for the quick reply, here I attach the logs... Seems like the /persist partition is empty, maybe thats the cause of the problem?
However, I can understand why that happened, maybe because I used the /system partition script for increasing its size...
EDIT: Somehow the XDA file uploader says invalid file for .tgz format, I recompressed the folder to a .zip file
The 'persist' partition is not empty, you can see its contents in the log's 'ls_persist' file, but its SELinux contexts appear incorrect. Try this:
  1. in TWRP backup your original 'persist' with the attached p4-backup-int.zip
  2. go to my old post here, get those files and restore my 'persist' partition
  3. boot stock ROM
:fingers-crossed:
 

Attachments

  • p4-backup-int.zip
    1.1 KB · Views: 42
  • p4-restore-int.zip
    1.1 KB · Views: 43

bamsbamx

Senior Member
Aug 2, 2011
572
591
Bilbo
livenfun.com
The 'persist' partition is not empty, you can see its contents in the log's 'ls_persist' file, but its SELinux contexts appear incorrect. Try this:
  1. in TWRP backup your original 'persist' with the attached p4-backup-int.zip
  2. go to my old post here, get those files and restore my 'persist' partition
  3. boot stock ROM
:fingers-crossed:

Still no luck. I have re-run the get-logs script and some file permissions have changed in le_persist (checked with a diff comparer), as well as new file called settings. Flashed factory image MOB30X and bootloop, then flash UnLegacy rom android 8.1.0 and boots with no problem. Cant understand what is happening... Maybe it is possible to use UART debugging to get some logs?

EDIT: Attached the new logs
 

Attachments

  • tmp2.zip
    50.6 KB · Views: 21

k23m

Senior Member
Jan 3, 2016
1,001
594
Still no luck. I have re-run the get-logs script and some file permissions have changed in le_persist (checked with a diff comparer), as well as new file called settings. Flashed factory image MOB30X and bootloop, then flash UnLegacy rom android 8.1.0 and boots with no problem. Cant understand what is happening... Maybe it is possible to use UART debugging to get some logs?
EDIT: Attached the new logs
This new log is much better. The timing was right and it had captured 'last_kmsg' with mob30x bootloop log, note:
Code:
[    4.865234] init: Starting service 'logd'...
[    4.873748] EXT4-fs error (device mmcblk0p23): ext4_mb_generate_buddy:741: group 1, 32282 clusters in bitmap, 32356 in gd
[    4.873962] Aborting journal on device mmcblk0p23-8.
[    4.874664] Kernel panic - not syncing: EXT4-fs (device mmcblk0p23): panic forced after error
...
[    7.987304] Rebooting in 5 seconds..
[   12.994476] Going down for restart now
[   12.994628] in panic
It can't use mmcblk0p23 - the cache partition, and has to restart. New custom ROMs no longer use the cache partition and that's why they work. For comparison here is my 'last_kmsg' with mob30x...
Code:
[    7.072235] EXT4-fs (mmcblk0p23): recovery complete
[    7.077087] EXT4-fs (mmcblk0p23): mounted filesystem with ordered data mode. Opts: nomblk_io_submit,errors=remount-ro
[    7.086883] fs_mgr: check_fs(): mount(/dev/block/platform/msm_sdcc.1/by-name/cache,/cache,ext4)=0: Success
[    7.162567] fs_mgr: check_fs(): unmount(/cache) succeeded
[    7.171722] fs_mgr: Running /system/bin/e2fsck on /dev/block/platform/msm_sdcc.1/by-name/cache
[    7.264678] e2fsck: e2fsck 1.42.9 (28-Dec-2013)
[    7.269744] e2fsck: /dev/block/platform/msm_sdcc.1/by-name/cache: clean, 23/35840 files, 4726/143360 blocks
[    7.285522] EXT4-fs (mmcblk0p23): mounted filesystem with ordered data mode. Opts: barrier=1,data=ordered,nomblk_io_submit,errors=panic
[    7.296874] fs_mgr: __mount(source=/dev/block/platform/msm_sdcc.1/by-name/cache,target=/cache,type=ext4)=0
...
[    8.289031] init: Starting service 'logd'...
[    8.302368] SELinux:  Context u:object_r:cache_recovery_file:s0 is not valid (left unmapped).
[    8.312286] SELinux:  Context u:object_r:cache_private_backup_file:s0 is not valid (left unmapped).
[    8.342254] init: (Loading properties from /system/build.prop took 0.01s.)
[    8.348266] init: (Loading properties from /vendor/build.prop took 0.00s.)
[    8.355133] init: (Loading properties from /factory/factory.prop took 0.00s.)
[    8.369842] init: Starting service 'vold'...
[    8.373321] logd.auditd: start

Run fastboot format cache and compare it to the 'sample output' from the first post.
There may be a partial eMMC hardware fault affecting the cache partition.
If you wish to investigate it with UART, please check my post on the subject.
:highfive:
 
  • Like
Reactions: bamsbamx

bamsbamx

Senior Member
Aug 2, 2011
572
591
Bilbo
livenfun.com
This new log is much better. The timing was right and it had captured 'last_kmsg' with mob30x bootloop log, note:
Code:
[    4.865234] init: Starting service 'logd'...
[    4.873748] EXT4-fs error (device mmcblk0p23): ext4_mb_generate_buddy:741: group 1, 32282 clusters in bitmap, 32356 in gd
[    4.873962] Aborting journal on device mmcblk0p23-8.
[    4.874664] Kernel panic - not syncing: EXT4-fs (device mmcblk0p23): panic forced after error
...
[    7.987304] Rebooting in 5 seconds..
[   12.994476] Going down for restart now
[   12.994628] in panic
It can't use mmcblk0p23 - the cache partition, and has to restart. New custom ROMs no longer use the cache partition and that's why they work. For comparison here is my 'last_kmsg' with mob30x...
Code:
[    7.072235] EXT4-fs (mmcblk0p23): recovery complete
[    7.077087] EXT4-fs (mmcblk0p23): mounted filesystem with ordered data mode. Opts: nomblk_io_submit,errors=remount-ro
[    7.086883] fs_mgr: check_fs(): mount(/dev/block/platform/msm_sdcc.1/by-name/cache,/cache,ext4)=0: Success
[    7.162567] fs_mgr: check_fs(): unmount(/cache) succeeded
[    7.171722] fs_mgr: Running /system/bin/e2fsck on /dev/block/platform/msm_sdcc.1/by-name/cache
[    7.264678] e2fsck: e2fsck 1.42.9 (28-Dec-2013)
[    7.269744] e2fsck: /dev/block/platform/msm_sdcc.1/by-name/cache: clean, 23/35840 files, 4726/143360 blocks
[    7.285522] EXT4-fs (mmcblk0p23): mounted filesystem with ordered data mode. Opts: barrier=1,data=ordered,nomblk_io_submit,errors=panic
[    7.296874] fs_mgr: __mount(source=/dev/block/platform/msm_sdcc.1/by-name/cache,target=/cache,type=ext4)=0
...
[    8.289031] init: Starting service 'logd'...
[    8.302368] SELinux:  Context u:object_r:cache_recovery_file:s0 is not valid (left unmapped).
[    8.312286] SELinux:  Context u:object_r:cache_private_backup_file:s0 is not valid (left unmapped).
[    8.342254] init: (Loading properties from /system/build.prop took 0.01s.)
[    8.348266] init: (Loading properties from /vendor/build.prop took 0.00s.)
[    8.355133] init: (Loading properties from /factory/factory.prop took 0.00s.)
[    8.369842] init: Starting service 'vold'...
[    8.373321] logd.auditd: start

Run fastboot format cache and compare it to the 'sample output' from the first post.
There may be a partial eMMC hardware fault affecting the cache partition.
If you wish to investigate it with UART, please check my post on the subject.
:highfive:

Yeah, I had the idea of checking last_kmsg just after my previous post. Saw that mounting mmcblk0p30 was causing kernel panic. Ran TWRP Format Cache and err well... Bootloop was now in the boot animation (maybe I had to reflash factory image, which I didnt). Didnt see about mmcblk0p24, will format cache and post feedback. Thank you!
:highfive:
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    I have 2 Nexus 7 debs which are rooted and running Followmsi's custom Lineage 20-20230507-UNOFFICIAL-deb ROM based on Android 13. I've used Restock several times, but my debs are really slow and plagued with the three following error messages: Settings, System UI, and Process System "isn't responding." Is there something I can do to go back to original status while cleaning up all the anomalies, above, at the same time, so it performs as it should, and then root it again and install a custom ROM?
    Thanks
    Post #114

    I made a script file for it. 😉
    fstrim - [github] - Link

    Cheers. :cowboy:
    1
    Post #114

    I made a script file for it. 😉
    fstrim - [github] - Link

    Cheers. :cowboy:
    Shouldn't be required anymore since discard is back in the fstab 😯
    1
    Post #114

    I made a script file for it. 😉
    fstrim - [github] - Link

    Cheers. :cowboy:
    I have used that script every time I've run Restock, but unfortunately it obviously hasn't worked. Thanks
  • 36
    RESTOCK is a new Nexus 7 2013 repair and factory reset tool for Windows. The NRT app (Nexus Root Toolkit) is similar but is old, closed-source, unsupported, abandoned, does no eMMC diagnostics and most importantly - it offers no repartitioning. Unlike NRT, Restock is specialized and optimized for Nexus 7'13 only, with streamlined operation and minimal user input.

    If fastboot mode is available, then no matter what software problems like bootloops or softbricks are observed, or what custom ROM you had used before - Restock will restore your tablet to original, latest stock image, factory setup in 10 minutes (more time for one-off components download if necessary). Unforeseen issues should be reported in this thread and hopefully will be resolved within 24 hours.

    If fastboot mode is not available, try the unbricking guide first.

    For hardware issues, check this thread.

    FEATURES

    • supports both flo and deb variants
    • small app download size (2.5MB)
    • automatic latest stock image (mob30x) and USB driver download from official google.com locations
    • robust, reliable USB device detection and driver installation - tested on Windows: XP-32, W7-32/64, W10-64(1809)
    • eMMC memory test and diagnostics
    • automatic device unlocking
    • option of repartition to original factory layout
      - precise and reliable for any eMMC size, including 64GB and 128GB mods
      - required for repartition scripts which check for original layout and flashing specific custom ROMs like e.g. Ubuntu Touch
      - advised for selling in original factory condition and resolving difficult ROM flashing issues and starting from scratch
    • minimal user interaction and fully scripted auto-processing
    • the Restock script is open for inspection, corrections and improvements; post your comments and suggestions here
    USAGE

    1. download the attached zip file
    2. unzip it
    3. double-click on "restock.bat"
    4. follow the prompts
    SAMPLE OUTPUT
    Code:
    Nexus 7'13 Restock v1 @2019 k23m
    SUPPORT - http://bit.ly/2C35sLZ
    WARNING - installing factory image will ERASE ALL DATA from the device
    Enter device name [flo OR deb]: flo
    
    Downloading USB drivers and the latest factory image.
    If not deleted, will not be downloaded again.
    
    --  https://dl-ssl.google.com/android/repository/latest_usb_driver_windows.zip
    Resolving dl-ssl.google.com... 74.125.24.190, 74.125.24.91, 74.125.24.93, ...
    Connecting to dl-ssl.google.com|74.125.24.190|:443... connected.
    WARNING: cannot verify dl-ssl.google.com's certificate, issued by 'CN=GTS CA 1O1,O=Google Trust Services,C=US':
      Unable to locally verify the issuer's authority.
    HTTP request sent, awaiting response... 200 OK
    Length: 8682859 (8.3M) [application/zip]
    Saving to: 'latest_usb_driver_windows.zip'
    latest_usb_driver_windows.zip  14%[======>                              ]   1.21M   383KB/s    eta 19s
    ...
    
    --  https://dl.google.com/dl/android/aosp/razor-mob30x-factory-52684dff.zip
    Resolving dl.google.com... 172.217.25.46
    Connecting to dl.google.com|172.217.25.46|:443... connected.
    WARNING: cannot verify dl.google.com's certificate, issued by 'CN=GTS CA 1O1,O=Google Trust Services,C=US':
      Unable to locally verify the issuer's authority.
    HTTP request sent, awaiting response... 200 OK
    Length: 505296115 (482M) [application/zip]
    Saving to: 'razor-mob30x-factory-52684dff.zip'
    
    razor-mob30x-factory-52684dff  86%[=============================>       ] 417.98M   410KB/s    eta 2m 57s
    ...
    
    1. boot the Nexus in fastboot mode: when OFF press POWER + VOLUME DOWN
    2. when in the bootloader menu, connect it to your PC
    3. wait a few seconds, then...
    Press any key to continue . . .
    ...
    ...
    INFO:   Successfull installation of 'd:\restock\data\usb_driver\android_winusb.inf'.
    INFO:   Returning with code 0x1
    
    Device not found...
    1. disconnect it from PC
    2. reboot to bootloader again
    3. reconnect it to PC
    Press any key to continue . . .
    
    Verify...
    eMMC test...
    If it freezes here, the chip is faulty and needs replacement.
    eMMC OK
    Lock status...
    GPT...
    
    Partitions had been changed.
    Restore original partitions? [y/n]: y
    Wait...
    sending 'bootloader' (3911 KB)...
    OKAY [  0.141s]
    writing 'bootloader'...
    OKAY [  1.518s]
    finished. total time: 1.658s
    rebooting into bootloader...
    OKAY [ -0.000s]
    finished. total time: 0.008s
    Wait...
    sending 'gpt' (35 KB)...
    OKAY [  0.016s]
    writing 'gpt'...
    OKAY [  0.109s]
    finished. total time: 0.141s
    rebooting into bootloader...
    OKAY [ -0.000s]
    finished. total time: 0.012s
    
    If error, copy and post it, include restock.log
    
    http://bit.ly/2C35sLZ
    
    Note: Android flash takes 2 minutes, initial boot takes 7 minutes.
    
    Press any key to continue . . .
    sending 'bootloader' (3915 KB)...
    OKAY [  0.125s]
    writing 'bootloader'...
    OKAY [  1.377s]
    finished. total time: 1.502s
    rebooting into bootloader...
    OKAY [  0.000s]
    finished. total time: 0.007s
    archive does not contain 'boot.sig'
    archive does not contain 'recovery.sig'
    archive does not contain 'system.sig'
    --------------------------------------------
    Bootloader Version...: FLO-04.08
    Baseband Version.....: none
    Serial Number........: xxxxxxxxx
    --------------------------------------------
    checking product...
    OKAY [  0.016s]
    checking version-bootloader...
    OKAY [  0.000s]
    sending 'boot' (7422 KB)...
    OKAY [  0.234s]
    writing 'boot'...
    OKAY [  1.000s]
    sending 'recovery' (8166 KB)...
    OKAY [  0.266s]
    writing 'recovery'...
    OKAY [  0.328s]
    erasing 'system'...
    OKAY [  1.143s]
    sending 'system' (843549 KB)...
    OKAY [ 26.516s]
    writing 'system'...
    OKAY [ 39.986s]
    erasing 'userdata'...
    OKAY [ 23.750s]
    formatting 'userdata' partition...
    Creating filesystem with parameters:
        Size: 28856791040
        Block size: 4096
        Blocks per group: 32768
        Inodes per group: 8192
        Inode size: 256
        Journal blocks: 32768
        Label:
        Blocks: 7045115
        Block groups: 215
        Reserved block group size: 1024
    Created filesystem with 11/1761280 inodes and 154578/7045115 blocks
    sending 'userdata' (139085 KB)...
    writing 'userdata'...
    OKAY [ 12.434s]
    erasing 'cache'...
    OKAY [  0.437s]
    formatting 'cache' partition...
    Creating filesystem with parameters:
        Size: 587202560
        Block size: 4096
        Blocks per group: 32768
        Inodes per group: 7168
        Inode size: 256
        Journal blocks: 2240
        Label:
        Blocks: 143360
        Block groups: 5
        Reserved block group size: 39
    Created filesystem with 11/35840 inodes and 4616/143360 blocks
    sending 'cache' (10984 KB)...
    writing 'cache'...
    OKAY [  0.891s]
    rebooting...
    finished. total time: 107.057s
    Press any key to exit...



    RESTOCK 2

    SCRIPTS
    • restock.bat - the main script: stock install, repair, repartition and factory reset
    • addons.bat - install TWRP custom recovery, mob30x-fix1, root/Magisk, ElementalX-N7-6.17 kernel
    • fstrim.bat - faster eMMC writes: dispatches TRIM command for all unused filesystem blocks
    • safe-unlock.bat - unlock without data loss
    • getlog.bat - diagnostics #1
    • relog.bat - diagnostics #2
    ADDONS
    These addons should be installed immediately after RESTOCK and before Android setup:
    1. TWRP deb/flo custom recovery (it must be flashed before the other addon options)
    2. MOB30X-FIX1 - improved Android 6.0.1 stock MOB30X installation, info: https://forum.xda-developers.com/showthread.php?t=4021757 In short, it adds WiFi 'Skip' setup option and removes old GApps to increase space on the system partition
    3. root/Magisk - https://github.com/topjohnwu/Magisk
    4. ElementalX-N7-6.17 custom kernel - I recommend to preset "doubletap2wake" and "battery life extender". For car use also preset "USB OTG + charge mode", info: https://forum.xda-developers.com/showthread.php?t=2389022
    ERRORS
    If you see errors, copy and report them. Run getlog.bat and include "getlog.log" in your post. If possible, also run relog.bat and attach "relog-xxxxxx.zip" to your post.

    FSTRIM
    For optimal eMMC performance run fstrim.bat from time to time.

    SAFE UNLOCK
    Unlock your device without data loss. MiFlash is described in the Unbricking Guide:
    https://forum.xda-developers.com/showpost.php?p=75360854&postcount=199
    Do not proceed unless you have read the unbricking guide and downloaded all components.



    OPTIONS

    Try mob30x-fix1 for improved Android 6.0.1 stock installation.

    Next consider CROSS : 1-click installation of secure, up-to-date Android 7-to-11 custom ROMs, including TWRP, repartition, root, etc. as easily as RESTOCK.



    NOTE

    If Android is stuck on boot logo, with TWRP flash k23m-persist-fix2.zip
    3
    Then from Windows install the ZIP file you provided? It's my first time using TWRP.

    • get Restock2
    • run addons.bat
    • "Flash TWRP?" --> YES and follow the instructions
    • when TWRP is up and running, MTP-transfer k23m-persist-fix2.zip to it
    • from TWRP install k23m-persist-fix2.zip
    • reboot

    🤞

    PM me if you have further questions.
    2
    Did not even realize this was new! Thanks for making such a wonderfull tool! Currently using it to flash flo, and it works great!
    Will install lineage after this tho :p

    Code:
    1. boot the Nexus in fastboot mode: when OFF press POWER + VOLUME DOWN
    2. when in the bootloader menu, connect it to your PC
    3. wait a few seconds, then...
    Press any key to continue . . .
    Verify...
    eMMC test...
    If it freezes here, the chip is faulty and needs replacement.
    eMMC OK
    Lock status...
    GPT...
    
    If error, copy and post it, include restock.log
    
    [url]http://bit.ly/2C35sLZ[/url]
    
    Note: Android flash takes 2 minutes, initial boot takes 7 minutes.
    Press any key to continue . . .
    sending 'bootloader' (3915 KB)...
    OKAY [  0.131s]
    writing 'bootloader'...
    OKAY [  1.581s]
    finished. total time: 1.719s
    rebooting into bootloader...
    OKAY [  0.009s]
    finished. total time: 0.014s
    archive does not contain 'boot.sig'
    archive does not contain 'recovery.sig'
    archive does not contain 'system.sig'
    --------------------------------------------
    Bootloader Version...: FLO-04.08
    Baseband Version.....: none
    Serial Number........: 07206d7c
    --------------------------------------------
    checking product...
    OKAY [  0.003s]
    checking version-bootloader...
    OKAY [  0.004s]
    sending 'boot' (7422 KB)...
    OKAY [  0.239s]
    writing 'boot'...
    OKAY [  0.397s]
    sending 'recovery' (8166 KB)...
    OKAY [  0.265s]
    writing 'recovery'...
    OKAY [  0.448s]
    erasing 'system'...
    OKAY [  0.743s]
    sending 'system' (843549 KB)...
    OKAY [ 26.422s]
    writing 'system'...
    OKAY [ 51.719s]
    erasing 'userdata'...
    OKAY [  9.570s]
    formatting 'userdata' partition...
    Creating filesystem with parameters:
        Size: 13342060544
        Block size: 4096
        Blocks per group: 32768
        Inodes per group: 8144
        Inode size: 256
        Journal blocks: 32768
        Label:
        Blocks: 3257339
        Block groups: 100
        Reserved block group size: 799
    Created filesystem with 11/814400 inodes and 91881/3257339 blocks
    sending 'userdata' (137198 KB)...
    writing 'userdata'...
    OKAY [ 12.298s]
    erasing 'cache'...
    OKAY [  0.051s]
    formatting 'cache' partition...
    Creating filesystem with parameters:
        Size: 587202560
        Block size: 4096
        Blocks per group: 32768
        Inodes per group: 7168
        Inode size: 256
        Journal blocks: 2240
        Label:
        Blocks: 143360
        Block groups: 5
        Reserved block group size: 39
    Created filesystem with 11/35840 inodes and 4616/143360 blocks
    sending 'cache' (10984 KB)...
    writing 'cache'...
    OKAY [  1.029s]
    rebooting...
    
    finished. total time: 103.239s
    Press any key to exit...
    2
    I had this mad idea to install Android 11 on my old and unused Nexus 7 but right after the first try with the repartitioning, my microusb stopped working (forever)... so my tab started sitting on the table totally empty with a messed partition.
    Hopefully a friend of mine had a Nexus 7 with broken screen so I just took its motherboard (avoiding the microusb soldering) and did all over again the procedure.
    Again I had problems with the connection but this time was the cable. Infact even if kept perfectly/unused I've found that not all my cables were good for this procedure so I just used a Samsung cable and everything worked.
    So, just giving an advice: before doing everything, just test your ports and cables :)
    Aaaand big thanks to all the devs who keep alive this great device, especially @k23m who guided me through all this procedure!
    2
    Well, it finally booted! But it took some attempts... Seems like there were problems in both mmcblk0p23 (cache) and mmcblk0p30 (data), so tried fastboot format cache and fastboot format userdata, but somehow it didnt work. What it finally make it boot was to format data and format cache from TWRP. What a nightmare!
    I'm afraid, it's not over. The eMMC flash memory IC is faulty and with no spare NAND blocks the issue will unpredictably show up at random partitions. If it works now, then do not flash any new ROM again, keep it read-only as much as possible and the Nexus will be still usable. Note that the lifespan of your 16GB eMMC is half of the more common 32GB model. It is possible to replace eMMC and even upgrade it to 64GB, more info is here.
    :good: