Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full factory reset #82

Open
adeebshihadeh opened this issue Jan 24, 2025 · 0 comments
Open

Full factory reset #82

adeebshihadeh opened this issue Jan 24, 2025 · 0 comments

Comments

@adeebshihadeh
Copy link
Collaborator

Part of #59.

flash.comma.ai should be able to bring a device into a complete factory state (except giving your device a new private key):

  • I pushed all the images to agnos-builder. We need to generate a manifest of all the images, just like we do with ota.json for AGNOS OTA updates.
  • Here's the code for our internal QDL flasher we run in production:
      print("Connecting...")
      try:
        f, info = connect(device, False)
      except Exception:
        f, info = connect(device, True)
      soc_serial = info['serial']
      device_info['hardware_id'] = info['msm_hw_id']

      device_info['serial'] = f.get_android_serial()

      print("Serial: %s" % device_info['serial'])
      print("SOC Serial: %s" % soc_serial)
      logger.log_start(device_info)

      # Erase device
      for lun in range(6):
        print(f"Erasing lun {lun}")
        f.erase_lun(lun)

      # Flash partition tables
      print("Flashing partition tables")
      for lun, name, start_sector, num_sectors, hashsum in PARTITION_TABLES:
        print(f"Programming '{name}'")
        safe_program_raw(f, lun, start_sector, num_sectors, f"{BASE_FIRMWARE_PATH}/{name}.bin", hashsum)

      # Fix lun partition table (resizes userdata), since different UFS chips have a slight variance in total size
      print("Fixing lun 0 and 5 partition table")
      f.fix_gpt(lun=0)
      f.fix_gpt(lun=5)

      # Flash all partitions
      for lun, name, filename, hashsum in QDL_FLASH_ARRAY:
        safe_program_partition(f, lun, name, f"{BASE_FIRMWARE_PATH}/{filename}", hashsum)

      # Set bootable LUN
      f.set_bootable_storagedrive(lun=1)

      # Reboot
      f.reset()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant