blob: 241e852665d3253857eec08ffdea3b3ae8ab0dcf [file] [log] [blame]
David Lattimorebedd66a2021-09-10 13:36:05 +10001#!/usr/bin/env python3
2
3# Copyright 2021 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# Turns the HPS off then back on again. This is useful after flashing the HPS
8# MCU for the first time, or after running a factory test in order to get back
9# to the system bootloader (provided the MCU flash is empty).
10
11from pyftdi.gpio import GpioAsyncController
12import time
13
14gpio = GpioAsyncController()
15# Set GPIO pin 6 (hps power enable) as an output, then make sure it's pulled
16# low (power off)
17gpio.configure('ftdi://ftdi:ft4232/1', direction=0x40)
18gpio.write(0)
19time.sleep(0.1)
20# Set GPIO pin 6 back to being an input. It'll get pulled high by the pull-up
21# resistor (power on).
22gpio.set_direction(0x40, 0)