Skip to content

Instantly share code, notes, and snippets.

@soupslurpr
Created November 18, 2025 03:50
Show Gist options
  • Select an option

  • Save soupslurpr/95b49686252b943e6d573086d1313c9b to your computer and use it in GitHub Desktop.

Select an option

Save soupslurpr/95b49686252b943e6d573086d1313c9b to your computer and use it in GitHub Desktop.
flash current build at out without wiping for development
# Copyright 2012 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if ! command -v fastboot > /dev/null; then
echo "fastboot not found"
echo "Download the latest version at https://developer.android.com/studio/releases/platform-tools.html and add it to the shell PATH"
exit 1
fi
set -e
FASTBOOT_VERSION_STR=$(fastboot --version | grep "fastboot version " | cut -c18-23)
FASTBOOT_VERSION_NUM=$(echo $FASTBOOT_VERSION_STR | tr -d .)
if ! [ $FASTBOOT_VERSION_NUM -ge 3501 ]; then
echo "fastboot version ($FASTBOOT_VERSION_STR) is older than the minimum supported version (35.0.1)."
echo "Download the latest version at https://developer.android.com/studio/releases/platform-tools.html and add it to the shell PATH"
exit 1
fi
echo Available devices:
fastboot devices -l
slotcount=$(fastboot getvar slot-count 2>&1 | grep "slot-count:" | cut -d ' ' -f 2)
if ! [ $slotcount = "2" ]; then
echo Error: unexpected value of slot-count variable: expected 2, got $slotcount
exit 1
fi
fastboot flash --slot=other bootloader
fastboot --set-active=other
fastboot reboot-bootloader
sleep 5
fastboot flash --slot=other bootloader
fastboot --set-active=other
fastboot reboot-bootloader
sleep 5
# size of partition splits depends on this value
maxdownloadsize=$(fastboot getvar max-download-size 2>&1 | grep "max-download-size:" | cut -d ' ' -f 2)
if ! [ $maxdownloadsize = "0xf900000" ]; then
echo Error: unexpected value of max-download-size variable: expected 0xf900000, got $maxdownloadsize
exit 1
fi
# layout of the super partition depends on the current slot, which is hardcoded to slot A
fastboot --set-active=a
currentslot=$(fastboot getvar current-slot 2>&1 | grep "current-slot:" | cut -d ' ' -f 2)
if ! [ $currentslot = "a" ]; then
echo Error: unexpected value of current-slot variable: expected a, got $currentslot
exit 1
fi
fastboot flash radio
fastboot reboot-bootloader
sleep 5
fastboot flash boot
fastboot flash init_boot
fastboot flash dtbo
fastboot flash vendor_kernel_boot
fastboot flash pvmfw
fastboot flash vendor_boot
fastboot flash vbmeta
echo running fastboot flashall
fastboot flashall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment