Dan Callaghan | 039a7e9 | 2022-08-25 16:46:27 +1000 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright 2022 The ChromiumOS Authors. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | set -e |
| 8 | |
| 9 | if ! 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 |
| 13 | fi |
| 14 | |
| 15 | PROJECT_ROOT=$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..) |
| 16 | |
| 17 | cd "${PROJECT_ROOT}/avr" |
| 18 | if [ -f intlisten.hex ] && ! command -v avr-gcc >/dev/null ; then |
| 19 | echo "Missing avr-gcc, using precompiled AVR firmware" >&2 |
| 20 | else |
| 21 | make intlisten.hex |
| 22 | fi |
| 23 | "${PROJECT_ROOT}/scripts/avr-reset" |
| 24 | # It takes some time for the kernel to probe the USB device after reset. |
| 25 | sleep 0.7 |
| 26 | dfu-programmer atmega16u4 erase |
| 27 | dfu-programmer atmega16u4 flash intlisten.hex |
| 28 | dfu-programmer atmega16u4 start |