From c8b1a8fbf6a1e715824b9cedf896eb5baf5a00cb Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sun, 17 Jul 2016 15:52:58 -0700 Subject: [PATCH] JTAG: Add functions to check EEPROM, load SRAM of HackRF CPLD. --- firmware/application/cpld_update.cpp | 31 ++++++++++++++++++++++++++++ firmware/application/cpld_update.hpp | 3 +++ 2 files changed, 34 insertions(+) diff --git a/firmware/application/cpld_update.cpp b/firmware/application/cpld_update.cpp index 6207c69e..64134e83 100644 --- a/firmware/application/cpld_update.cpp +++ b/firmware/application/cpld_update.cpp @@ -21,11 +21,14 @@ #include "cpld_update.hpp" +#include "hackrf_gpio.hpp" #include "portapack_hal.hpp" #include "jtag_target_gpio.hpp" #include "cpld_max5.hpp" +#include "cpld_xilinx.hpp" #include "portapack_cpld_data.hpp" +#include "hackrf_cpld_data.hpp" bool cpld_update_if_necessary() { jtag::GPIOTarget target { @@ -82,3 +85,31 @@ bool cpld_update_if_necessary() { return ok; } + +static jtag::GPIOTarget jtag_target_hackrf() { + return { + hackrf::one::gpio_cpld_tck, + hackrf::one::gpio_cpld_tms, + hackrf::one::gpio_cpld_tdi, + hackrf::one::gpio_cpld_tdo, + }; +} + +bool cpld_hackrf_load_sram() { + auto jtag_target_hackrf_cpld = jtag_target_hackrf(); + cpld::xilinx::XC2C64A hackrf_cpld { jtag_target_hackrf_cpld }; + + hackrf_cpld.write_sram(hackrf::one::cpld::verify_blocks); + const auto ok = hackrf_cpld.verify_sram(hackrf::one::cpld::verify_blocks); + + return ok; +} + +bool cpld_hackrf_verify_eeprom() { + auto jtag_target_hackrf_cpld = jtag_target_hackrf(); + cpld::xilinx::XC2C64A hackrf_cpld { jtag_target_hackrf_cpld }; + + const auto ok = hackrf_cpld.verify_eeprom(hackrf::one::cpld::verify_blocks); + + return ok; +} diff --git a/firmware/application/cpld_update.hpp b/firmware/application/cpld_update.hpp index 236b2fe0..bd317e10 100644 --- a/firmware/application/cpld_update.hpp +++ b/firmware/application/cpld_update.hpp @@ -24,4 +24,7 @@ bool cpld_update_if_necessary(); +bool cpld_hackrf_load_sram(); +bool cpld_hackrf_verify_eeprom(); + #endif/*__CPLD_UPDATE_H__*/