diff --git a/firmware/application/apps/gps_sim_app.cpp b/firmware/application/apps/gps_sim_app.cpp index f51011c95..545d08266 100644 --- a/firmware/application/apps/gps_sim_app.cpp +++ b/firmware/application/apps/gps_sim_app.cpp @@ -29,6 +29,7 @@ #include "baseband_api.hpp" #include "portapack.hpp" +#include "cpld_update.hpp" #include "portapack_persistent_memory.hpp" using namespace portapack; @@ -242,7 +243,8 @@ GpsSimAppView::GpsSimAppView( GpsSimAppView::~GpsSimAppView() { radio::disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } void GpsSimAppView::on_hide() { diff --git a/firmware/application/apps/lge_app.cpp b/firmware/application/apps/lge_app.cpp index ad3b6d0a7..f5f81e65f 100644 --- a/firmware/application/apps/lge_app.cpp +++ b/firmware/application/apps/lge_app.cpp @@ -27,6 +27,7 @@ #include "lge_app.hpp" #include "baseband_api.hpp" +#include "cpld_update.hpp" #include "ui_textentry.hpp" #include "string_format.hpp" @@ -48,7 +49,8 @@ LGEView::~LGEView() { settings.save("tx_lge", &app_settings); transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . + baseband::shutdown();// better this function at the end, not load_sram() that sometimes produces hang up. } void LGEView::generate_lge_frame(const uint8_t command, const uint16_t address_a, const uint16_t address_b, std::vector& data) { diff --git a/firmware/application/apps/soundboard_app.cpp b/firmware/application/apps/soundboard_app.cpp index 97e6ad706..02039ae39 100644 --- a/firmware/application/apps/soundboard_app.cpp +++ b/firmware/application/apps/soundboard_app.cpp @@ -25,6 +25,7 @@ #include "soundboard_app.hpp" #include "string_format.hpp" #include "tonesets.hpp" +#include "cpld_update.hpp" using namespace tonekey; using namespace portapack; @@ -295,7 +296,8 @@ SoundBoardView::~SoundBoardView() { stop(); transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } } diff --git a/firmware/application/apps/ui_adsb_tx.cpp b/firmware/application/apps/ui_adsb_tx.cpp index 918e744cb..997bd65d6 100644 --- a/firmware/application/apps/ui_adsb_tx.cpp +++ b/firmware/application/apps/ui_adsb_tx.cpp @@ -26,6 +26,7 @@ #include "manchester.hpp" #include "string_format.hpp" #include "portapack.hpp" +#include "cpld_update.hpp" #include "baseband_api.hpp" #include @@ -290,8 +291,9 @@ ADSBTxView::~ADSBTxView() { settings.save("tx_adsb", &app_settings); transmitter_model.disable(); - baseband::shutdown(); -} + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, withouth ghost signal problem at the exit . + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. + } void ADSBTxView::generate_frames() { const uint32_t ICAO_address = sym_icao.value_hex_u64(); diff --git a/firmware/application/apps/ui_aprs_tx.cpp b/firmware/application/apps/ui_aprs_tx.cpp index 5d2759314..281fb0d97 100644 --- a/firmware/application/apps/ui_aprs_tx.cpp +++ b/firmware/application/apps/ui_aprs_tx.cpp @@ -26,6 +26,7 @@ #include "aprs.hpp" #include "string_format.hpp" #include "portapack.hpp" +#include "cpld_update.hpp" #include "baseband_api.hpp" #include "portapack_shared_memory.hpp" #include "portapack_persistent_memory.hpp" @@ -48,7 +49,8 @@ APRSTXView::~APRSTXView() { settings.save("tx_aprs", &app_settings); transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } void APRSTXView::start_tx() { diff --git a/firmware/application/apps/ui_bht_tx.cpp b/firmware/application/apps/ui_bht_tx.cpp index b70f4d17d..dd8e9e868 100644 --- a/firmware/application/apps/ui_bht_tx.cpp +++ b/firmware/application/apps/ui_bht_tx.cpp @@ -24,6 +24,7 @@ #include "string_format.hpp" #include "baseband_api.hpp" +#include "cpld_update.hpp" #include "portapack_persistent_memory.hpp" using namespace portapack; @@ -145,6 +146,8 @@ BHTView::~BHTView() { settings.save("tx_bht", &app_settings); transmitter_model.disable(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } BHTView::BHTView(NavigationView& nav) { diff --git a/firmware/application/apps/ui_coasterp.cpp b/firmware/application/apps/ui_coasterp.cpp index 446ad8416..bbe1871b8 100644 --- a/firmware/application/apps/ui_coasterp.cpp +++ b/firmware/application/apps/ui_coasterp.cpp @@ -23,6 +23,7 @@ #include "ui_coasterp.hpp" #include "baseband_api.hpp" +#include "cpld_update.hpp" #include "portapack_persistent_memory.hpp" #include @@ -42,7 +43,8 @@ CoasterPagerView::~CoasterPagerView() { settings.save("tx_coaster", &app_settings); transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } void CoasterPagerView::generate_frame() { diff --git a/firmware/application/apps/ui_encoders.cpp b/firmware/application/apps/ui_encoders.cpp index 05c90a3f5..4749ab6d6 100644 --- a/firmware/application/apps/ui_encoders.cpp +++ b/firmware/application/apps/ui_encoders.cpp @@ -24,6 +24,7 @@ #include "baseband_api.hpp" #include "string_format.hpp" +#include "cpld_update.hpp" using namespace portapack; @@ -208,7 +209,8 @@ EncodersView::~EncodersView() { settings.save("tx_ook", &app_settings); transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // ghost signal c/m to the problem at the exit . + baseband::shutdown(); // better this function after load_sram() } void EncodersView::update_progress() { diff --git a/firmware/application/apps/ui_jammer.cpp b/firmware/application/apps/ui_jammer.cpp index b1cbe9a3e..76dd48f8d 100644 --- a/firmware/application/apps/ui_jammer.cpp +++ b/firmware/application/apps/ui_jammer.cpp @@ -25,6 +25,7 @@ #include "ui_freqman.hpp" #include "baseband_api.hpp" +#include "cpld_update.hpp" #include "string_format.hpp" using namespace portapack; @@ -183,7 +184,8 @@ void JammerView::focus() { JammerView::~JammerView() { transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } void JammerView::on_retune(const rf::Frequency freq, const uint32_t range) { diff --git a/firmware/application/apps/ui_keyfob.cpp b/firmware/application/apps/ui_keyfob.cpp index b5bfb145e..b85e2d682 100644 --- a/firmware/application/apps/ui_keyfob.cpp +++ b/firmware/application/apps/ui_keyfob.cpp @@ -23,6 +23,7 @@ #include "ui_keyfob.hpp" #include "baseband_api.hpp" +#include "cpld_update.hpp" #include "string_format.hpp" using namespace portapack; @@ -140,7 +141,8 @@ KeyfobView::~KeyfobView() { settings.save("tx_keyfob", &app_settings); transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } void KeyfobView::update_progress(const uint32_t progress) { diff --git a/firmware/application/apps/ui_lcr.cpp b/firmware/application/apps/ui_lcr.cpp index 6f5b14892..400903732 100644 --- a/firmware/application/apps/ui_lcr.cpp +++ b/firmware/application/apps/ui_lcr.cpp @@ -27,6 +27,7 @@ #include "modems.hpp" #include "baseband_api.hpp" #include "string_format.hpp" +#include "cpld_update.hpp" #include "serializer.hpp" @@ -44,7 +45,8 @@ LCRView::~LCRView() { settings.save("tx_lcr", &app_settings); transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } /* diff --git a/firmware/application/apps/ui_mictx.cpp b/firmware/application/apps/ui_mictx.cpp index 68d98212d..397b595b0 100644 --- a/firmware/application/apps/ui_mictx.cpp +++ b/firmware/application/apps/ui_mictx.cpp @@ -30,6 +30,7 @@ using wolfson::wm8731::WM8731; #include "tonesets.hpp" #include "portapack_hal.hpp" +#include "cpld_update.hpp" #include "string_format.hpp" #include "irq_controls.hpp" @@ -178,6 +179,7 @@ void MicTXView::rxaudio(bool is_on) { receiver_model.set_vga(rx_vga); receiver_model.set_rf_amp(rx_amp); receiver_model.enable(); + hackrf::cpld::load_sram_no_verify(); // to have a good RX without any ghost inside Mic App audio::output::start(); } else { //These incredibly convoluted steps are required for the vumeter to reappear when stopping RX. receiver_model.set_modulation(ReceiverModel::Mode::NarrowbandFMAudio); //This fixes something with AM RX... @@ -548,7 +550,8 @@ MicTXView::~MicTXView() { transmitter_model.disable(); if (rx_enabled) //Also turn off audio rx if enabled rxaudio(false); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } } diff --git a/firmware/application/apps/ui_morse.cpp b/firmware/application/apps/ui_morse.cpp index 1c9468d90..6378b0257 100644 --- a/firmware/application/apps/ui_morse.cpp +++ b/firmware/application/apps/ui_morse.cpp @@ -26,6 +26,7 @@ #include "baseband_api.hpp" #include "hackrf_gpio.hpp" #include "portapack_shared_memory.hpp" +#include "cpld_update.hpp" #include "ui_textentry.hpp" #include "string_format.hpp" @@ -102,7 +103,8 @@ MorseView::~MorseView() { settings.save("tx_morse", &app_settings); transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit . + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } void MorseView::paint(Painter&) { diff --git a/firmware/application/apps/ui_pocsag_tx.cpp b/firmware/application/apps/ui_pocsag_tx.cpp index 58de068e2..0a329676c 100644 --- a/firmware/application/apps/ui_pocsag_tx.cpp +++ b/firmware/application/apps/ui_pocsag_tx.cpp @@ -23,6 +23,7 @@ #include "ui_pocsag_tx.hpp" #include "baseband_api.hpp" +#include "cpld_update.hpp" #include "string_format.hpp" #include "ui_textentry.hpp" @@ -43,7 +44,8 @@ POCSAGTXView::~POCSAGTXView() { settings.save("tx_pocsag", &app_settings); transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } void POCSAGTXView::on_tx_progress(const uint32_t progress, const bool done) { diff --git a/firmware/application/apps/ui_rds.cpp b/firmware/application/apps/ui_rds.cpp index 7e8f1da87..35ac84361 100644 --- a/firmware/application/apps/ui_rds.cpp +++ b/firmware/application/apps/ui_rds.cpp @@ -24,6 +24,7 @@ #include "portapack.hpp" #include "baseband_api.hpp" +#include "cpld_update.hpp" #include "portapack_shared_memory.hpp" #include @@ -180,7 +181,8 @@ RDSView::~RDSView() { settings.save("tx_rds", &app_settings); transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } void RDSView::start_tx() { diff --git a/firmware/application/apps/ui_sstvtx.cpp b/firmware/application/apps/ui_sstvtx.cpp index 55e882d22..2bf603f3a 100644 --- a/firmware/application/apps/ui_sstvtx.cpp +++ b/firmware/application/apps/ui_sstvtx.cpp @@ -25,6 +25,7 @@ #include "portapack.hpp" #include "hackrf_hal.hpp" +#include "cpld_update.hpp" #include #include @@ -93,7 +94,8 @@ SSTVTXView::~SSTVTXView() { settings.save("tx_sstv", &app_settings); transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } void SSTVTXView::on_tuning_frequency_changed(rf::Frequency f) { diff --git a/firmware/application/apps/ui_touchtunes.cpp b/firmware/application/apps/ui_touchtunes.cpp index 8d2cc0571..7420b993d 100644 --- a/firmware/application/apps/ui_touchtunes.cpp +++ b/firmware/application/apps/ui_touchtunes.cpp @@ -26,6 +26,7 @@ #include "baseband_api.hpp" #include "string_format.hpp" +#include "cpld_update.hpp" using namespace portapack; @@ -39,7 +40,8 @@ void TouchTunesView::focus() { TouchTunesView::~TouchTunesView() { transmitter_model.disable(); - baseband::shutdown(); + hackrf::cpld::load_sram_no_verify(); // to leave all RX ok, without ghost signal problem at the exit. + baseband::shutdown(); // better this function at the end, not load_sram() that sometimes produces hang up. } void TouchTunesView::stop_tx() { diff --git a/firmware/common/cpld_update.cpp b/firmware/common/cpld_update.cpp index 039646918..3055eb3dc 100644 --- a/firmware/common/cpld_update.cpp +++ b/firmware/common/cpld_update.cpp @@ -114,6 +114,20 @@ bool load_sram() { return ok; } +void load_sram_no_verify() { + // CoolRunner II family has Hybrid memory CPLD arquitecture (SRAM+NVM) + // It seems that after using TX App somehow , I do not why , the CPLD_SRAM part needs to be re_loaded to solve #637 ghost beat + // load_sram() it is already called at each boot in portapack.cpp ,including verify CPLD part. + // Here we skipped CPLD verify part,just to be quicker (in case any CPLD problem it will be detected in the boot process). + + auto jtag_target_hackrf_cpld = jtag_target_hackrf(); + hackrf::one::cpld::CPLD hackrf_cpld { jtag_target_hackrf_cpld }; + + hackrf_cpld.write_sram(hackrf::one::cpld::verify_blocks); + + return; +} + bool verify_eeprom() { auto jtag_target_hackrf_cpld = jtag_target_hackrf(); hackrf::one::cpld::CPLD hackrf_cpld { jtag_target_hackrf_cpld }; diff --git a/firmware/common/cpld_update.hpp b/firmware/common/cpld_update.hpp index 6799c7089..36c87a1b0 100644 --- a/firmware/common/cpld_update.hpp +++ b/firmware/common/cpld_update.hpp @@ -38,6 +38,7 @@ namespace hackrf { namespace cpld { bool load_sram(); +void load_sram_no_verify(); // added to solve issue #637 , "ghost" signal at RX , after using any TX App bool verify_eeprom(); void init_from_eeprom();