Skip to main content

Automated GrapheneOS flashing with security verification

Project description

GrapheneOS Flasher

A Python tool that automates the download, cryptographic verification, and flashing of GrapheneOS factory images.

It follows the official CLI installation guide step-by-step and surfaces clear, actionable prompts at each stage so you always know what is happening and why.


Requirements

Tool Version Purpose
Python 3.14+ Runtime
OpenSSH (ssh-keygen) any Signature verification
Android platform-tools (fastboot, adb) 35.0.1+ Device communication

Install platform-tools: Download from developer.android.com and add the extracted directory to your PATH.


Installation

From PyPI (recommended)

uv tool install grapheneos-flasher
# or
pip install grapheneos-flasher

Then run:

grapheneos-flasher <device_codename> [options]

From source

git clone https://github.com/264nm/grapheneos-flasher
cd grapheneos-flasher
uv sync
uv run grapheneos-flasher <device_codename> [options]

Usage

Download and verify only (safe — no device changes)

uv run grapheneos-flasher shiba

Downloads the latest factory image and signature, verifies the cryptographic signature against GrapheneOS's public key, and extracts the archive. Prints manual step-by-step instructions at the end. Nothing is written to your device.

Flash GrapheneOS (installs the OS, wipes all data)

uv run grapheneos-flasher shiba --flash

Runs through download → verify → extract, then presents a pre-flight checklist and walks you through the flash interactively. The tool handles unlocking and re-locking the bootloader automatically.

Flash without bootloader management

uv run grapheneos-flasher shiba --flash --no-bootloader-mgmt

Skips automatic unlock/lock. You must run fastboot flashing unlock before flashing and fastboot flashing lock afterwards. The tool still validates that the bootloader is unlocked before proceeding.

Flash a specific version

uv run grapheneos-flasher shiba --version 2026050900 --flash

Sideload an OTA update (updates an existing GrapheneOS install, preserves data)

uv run grapheneos-flasher shiba --sideload

Downloads only the OTA update package (not the full factory image), then guides you through booting into recovery and sideloading via adb sideload. Use this to update a device already running GrapheneOS — it is not a substitute for a fresh flash.

Re-running without re-downloading

By default, files are saved in your current working directory. Running the same command again will skip files that are already present:

  ✓  shiba-install-2026050900.zip  (1573 MB)  (already exists, skipping)

Use --work-dir to specify a different location:

uv run grapheneos-flasher shiba --work-dir ~/grapheneos-files

If the directory does not exist the tool falls back to a system temp directory.


Supported devices

Codename Device
tokay Pixel 9a
akita Pixel 9
comet Pixel 9 Pro
caiman Pixel 9 Pro XL
tegu Pixel 9 Pro Fold
shiba Pixel 8
husky Pixel 8 Pro
axolotl Pixel 8a
felix Pixel Fold
tangorpro Pixel Tablet
panther Pixel 7
cheetah Pixel 7 Pro
lynx Pixel 7a
oriole Pixel 6
raven Pixel 6 Pro
bluejay Pixel 6a

Devices are modelled by the Device enum in cli.py — member name is the codename, value is the display name. Device.from_codename(s) returns the member or None for unknown inputs.

For the authoritative list see grapheneos.org/faq#device-support.


What the tool does

Fresh install (--flash)

  1. Download allowed_signers, the factory image zip, and its .sig signature file from releases.grapheneos.org. Skips files already present in the working directory.
  2. Verify the signature with ssh-keygen -Y verify, exactly as the official guide prescribes.
  3. Extract the archive with tar xf.
  4. Pre-flight checklist — pauses and shows what to prepare on your device before you type yes.
  5. Unlock — checks fastboot getvar unlocked. If locked, sends fastboot flashing unlock, waits for the device to wipe and reboot back into fastboot, and verifies the new state. Skipped with --no-bootloader-mgmt.
  6. Flash — runs bash flash-all.sh from inside the extracted directory.
  7. Lock — sends fastboot flashing lock and verifies the bootloader is locked before the device reboots into GrapheneOS setup. Skipped with --no-bootloader-mgmt (reminder shown instead).

OTA sideload (--sideload)

  1. Downloads only the OTA update package (no factory image).
  2. Guides you through booting into recovery mode and selecting Apply update from ADB.
  3. Runs adb sideload <ota.zip>.

Note: Sideloading is for updating a device already running GrapheneOS. For a fresh install, use --flash instead.


Security

  • Signature verification uses the same ssh-keygen -Y verify command as the official GrapheneOS CLI guide — no third-party crypto libraries.
  • The tool refuses to flash if verification fails.
  • All files are downloaded to the working directory (default: CWD).
  • The factory image namespace is "factory images" and the identity is contact@grapheneos.org, matching GrapheneOS's published signing policy.

Architecture

Module Class Responsibility
ui.py Instructions Terminal output helpers (ok, fail, info, warn, block, step) and all user-facing instruction text
core.py GrapheneOSFlasher Top-level orchestrator
core.py DownloadConfig URL and filename construction
core.py DefaultFileHandler HTTP downloads and archive extraction
core.py SecurityVerifier ssh-keygen signature verification
core.py DeviceManager fastboot and adb device interaction, bootloader management
cli.py Argument parsing and entry point

FileHandler is an abstract base class — supply a custom implementation to GrapheneOSFlasher(config, file_handler=...) for testing or alternative download strategies.


Development

# Install dev dependencies
uv sync

# Run tests
uv run python -m pytest

# Run a specific test file
uv run python -m pytest tests/test_ui.py
uv run python -m pytest tests/test_core.py
uv run python -m pytest tests/test_cli.py

# With coverage
uv run python -m pytest --cov=grapheneos_flasher --cov-report=html

# Type checking
uv run mypy grapheneos_flasher

# Formatting and linting
uv run black grapheneos_flasher tests
uv run isort grapheneos_flasher tests
uv run flake8 grapheneos_flasher tests

License

MIT. Provided for educational and personal use. Always verify the security of any flashing process against the official GrapheneOS documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grapheneos_flasher-0.1.1.tar.gz (42.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grapheneos_flasher-0.1.1-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file grapheneos_flasher-0.1.1.tar.gz.

File metadata

  • Download URL: grapheneos_flasher-0.1.1.tar.gz
  • Upload date:
  • Size: 42.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for grapheneos_flasher-0.1.1.tar.gz
Algorithm Hash digest
SHA256 dcea9449339fee3078d46e892089575c9861c190b0e2678984388d0da6c3d183
MD5 9b0c7b94fbf1dbd1ec33c4fe56bf62e8
BLAKE2b-256 77e970cedf753a4f1b8b2f6cf0c5ebce6ad2b7c778d1d802f9006b7bc8b00227

See more details on using hashes here.

Provenance

The following attestation bundles were made for grapheneos_flasher-0.1.1.tar.gz:

Publisher: release.yml on 264nm/grapheneos-flasher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file grapheneos_flasher-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for grapheneos_flasher-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce24a438c9e8211e554051cf41fc59aa9a389d63928595b76648570a06f9b341
MD5 9d64e680470558bd6e37a41e1f4cb3a9
BLAKE2b-256 f3762a7edfb9baa7bcfa485e4347fe0b19e5f04cd229adbfe5b489c566b59103

See more details on using hashes here.

Provenance

The following attestation bundles were made for grapheneos_flasher-0.1.1-py3-none-any.whl:

Publisher: release.yml on 264nm/grapheneos-flasher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page