[Nexus 7 (2013) General] k23m:
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

download the attached zip file

unzip it

double-click on "restock.bat"

follow the prompts

SAMPLE OUTPUT

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:

TWRP deb/flo custom recovery (it must be flashed before the other addon options)

MOB30X-FIX1 - improved Android 6.0.1 stock MOB30X installation, info: https://xdaforums.com/showthread.php?t=4021757 In short, it adds WiFi 'Skip' setup option and removes old GApps to increase space on the system partition

root/Magisk - https://github.com/topjohnwu/Magisk

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://xdaforums.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://xdaforums.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