blob: b6aee188f5736d4991d0b6368320164a0c49e67d [file] [log] [blame]
Dan Callaghan039a7e92022-08-25 16:46:27 +10001#!/bin/bash
2
David Lattimore3b6faa22022-10-18 14:10:43 +11003# Copyright 2022 The ChromiumOS Authors
Dan Callaghan039a7e92022-08-25 16:46:27 +10004# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7set -e
8
9if ! command -v dfu-programmer >/dev/null ; then
10 echo "Missing dfu-programmer" >&2
11 echo "Hint: sudo apt install dfu-programmer" >&2
12 exit 1
13fi
14
15PROJECT_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)
16
17cd "${PROJECT_ROOT}/avr"
18if [ -f intlisten.hex ] && ! command -v avr-gcc >/dev/null ; then
19 echo "Missing avr-gcc, using precompiled AVR firmware" >&2
20else
21 make intlisten.hex
22fi
23"${PROJECT_ROOT}/scripts/avr-reset"
24# It takes some time for the kernel to probe the USB device after reset.
25sleep 0.7
26dfu-programmer atmega16u4 erase
27dfu-programmer atmega16u4 flash intlisten.hex
28dfu-programmer atmega16u4 start