From d6bb7bf71810db1b02dec985e8383594c193f55f Mon Sep 17 00:00:00 2001
From: Jason Self <j@jxself.org>
Date: Thu, 4 Jul 2019 16:57:58 -0700
Subject: [PATCH 4/8] atusb: Build updates

Update the root level Makefile to both invoke "make atusb.dfu" when
building.

Update the INSTALL document to mention the dependency on dfu-util.

Update the root level Makefile to install atusb.dfu if it's compiled.
Even though the kernel itself doesn't load the firmware into the
device this will ensure that pre-compiled firmware is included in the
release tarballs.
---
 INSTALL  | 5 +++--
 Makefile | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/INSTALL b/INSTALL
index 9ea6dad..70c4381 100644
--- a/INSTALL
+++ b/INSTALL
@@ -17,6 +17,7 @@ system:
 
     * A C/C++ compiler, like GCC
     * Cmake
+    * dfu-util - Device Firmware Upgrade Utilities
     * GNU Bison/YACC
     * GNU Flex
     * GNU Gperf
@@ -35,7 +36,7 @@ system:
 On GNU/Linux distros that use apt you can install these with:
 
     apt install gcc-avr avr-libc binutils-arm-linux-gnueabi \
-    binutils-arm-none-eabi bison cmake flex g++ gcc \
+    binutils-arm-none-eabi bison cmake dfu-util flex g++ gcc \
     gcc-arm-linux-gnueabi gcc-arm-none-eabi gperf make wget
 
 CARL9170 Firmware Configuration
@@ -48,7 +49,7 @@ atusb: Firmware for the ATUSB IEEE 802.15.4 USB Adapter
 
 To flash the firmware you need dfu-util on the host. Issue
 
-    make dfu
+    dfu-util -d 20b7:1540 -D atusb.dfu
 
 right after plugging the device into the USB port while the red led is
 still on.
diff --git a/Makefile b/Makefile
index 8474b30..51f708d 100644
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,7 @@ ath9k_htc: ath9k_htc_toolchain
 	cd ath9k_htc && $(MAKE) -C target_firmware
 
 atusb:
-	cd atusb && $(MAKE)
+	cd atusb && $(MAKE) atusb.dfu
 
 av7110:
 	cd av7110 && $(MAKE)
@@ -103,6 +103,7 @@ install:
 		ln -s ath9k_htc/htc_9271-1.4.0.fw $(prefix)/htc_9271.fw; fi;
 	if [ -a ath9k_htc/target_firmware/htc_7010.fw ]; then $(install_program) -D ath9k_htc/target_firmware/htc_7010.fw $(prefix)/ath9k_htc/htc_7010-1.4.0.fw && \
 		ln -s ath9k_htc/htc_7010-1.4.0.fw $(prefix)/htc_7010.fw; fi;
+        if [ -a atusb/atusb.dfu ]; then $(install_program) -D atusb/atusb.dfu $(prefix)/atusb/atusb.dfu; fi;
 	if [ -a av7110/bootcode.bin ]; then $(install_program) -D av7110/bootcode.bin $(prefix)/av7110/bootcode.bin; fi;
 	if [ -a cis/3CCFEM556.cis ]; then $(install_program) -D cis/3CCFEM556.cis $(prefix)/cis/3CCFEM556.cis; fi;
 	if [ -a cis/3CXEM556.cis ]; then $(install_program) -D cis/3CXEM556.cis $(prefix)/cis/3CXEM556.cis; fi;
-- 
2.26.0

