From c8e898e8ce3e277c1c861404c4b9d3f933cfe0e9 Mon Sep 17 00:00:00 2001 From: "Rick Farina (Zero_Chaos)" Date: Tue, 21 Feb 2017 12:19:30 -0500 Subject: [PATCH] this seems a bit nicer, and it handles people changing the firmware names a little bit --- host/bin/switch_to_hackrf | 36 ++++++++++++++++++++++++++++++++++-- host/bin/switch_to_portapack | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/host/bin/switch_to_hackrf b/host/bin/switch_to_hackrf index 78f996ab..37f3ca03 100755 --- a/host/bin/switch_to_hackrf +++ b/host/bin/switch_to_hackrf @@ -6,6 +6,38 @@ printf "After the HackRF is plugged in, you may release the DFU button.\n" printf "Press any key to continue or ^c to abort\n" read -dfu-util --device 1fc9:000c --download hackrf_one_usb_ram.dfu --reset +for i in /usr/share/hackrf/hackrf_one_usb.dfu /usr/share/hackrf/hackrf_one_usb_ram.dfu hackrf_one_usb.dfu; do + if [ -r "${i}" ]; then + ram_firmware="${i}" + break + fi +done + +if [ -n "${ram_firmware}" ]; then + printf "\nFound firmware: ${ram_firmware}\n" + printf "Flashing...\n" +else + printf "Unable to fine firmware to flash, please have hackrf_one_usb.dfu\n" + printf "in current directory or /usr/share/hackrf/\n" + exit 1 +fi + +for i in /usr/share/hackrf/hackrf_one_usb.bin /usr/share/hackrf/hckrf_one_usb_rom_to_ram.bin hackrf_one_usb.bin; do + if [ -r "${i}" ]; then + rom_firmware="${i}" + break + fi +done + +if [ -n "${rom_firmware}" ]; then + printf "\nFound firmware: ${rom_firmware}\n" + printf "Flashing...\n" +else + printf "Unable to fine firmware to flash, please have hackrf_one_usb.bin\n" + printf "in current directory or /usr/share/hackrf/\n" + exit 1 +fi + +dfu-util --device 1fc9:000c --download "${ram_firmware}" --reset sleep 2s -hackrf_spiflash -w hackrf_one_usb_rom_to_ram.bin +hackrf_spiflash -w "${rom_firmware}" diff --git a/host/bin/switch_to_portapack b/host/bin/switch_to_portapack index 41ac8c54..f7c4372d 100755 --- a/host/bin/switch_to_portapack +++ b/host/bin/switch_to_portapack @@ -6,6 +6,38 @@ printf "After the HackRF is plugged in, you may release the DFU button.\n" printf "Press any key to continue or ^c to abort\n" read -dfu-util --device 1fc9:000c --download hackrf_one_usb_ram.dfu --reset +for i in /usr/share/hackrf/hackrf_one_usb.dfu /usr/share/hackrf/hackrf_one_usb_ram.dfu hackrf_one_usb.dfu; do + if [ -r "${i}" ]; then + ram_firmware="${i}" + break + fi +done + +if [ -n "${ram_firmware}" ]; then + printf "\nFound firmware: ${ram_firmware}\n" + printf "Flashing...\n" +else + printf "Unable to fine firmware to flash, please have hackrf_one_usb.dfu\n" + printf "in current directory or /usr/share/hackrf/\n" + exit 1 +fi + +for i in /usr/share/hackrf/portapack-h1-firmware.bin portapack-h1-firmware.bin; do + if [ -r "${i}" ]; then + rom_firmware="${i}" + break + fi +done + +if [ -n "${rom_firmware}" ]; then + printf "\nFound firmware: ${rom_firmware}\n" + printf "Flashing...\n" +else + printf "Unable to fine firmware to flash, please have portapack-h1-firmware.bin\n" + printf "in current directory or /usr/share/hackrf/\n" + exit 1 +fi + +dfu-util --device 1fc9:000c --download "${ram_firmware}" --reset sleep 2s -hackrf_spiflash -w portapack-h1-firmware.bin +hackrf_spiflash -w "${rom_firmware}"