diff --git a/firmware/application/m4_startup.cpp b/firmware/application/m4_startup.cpp index 42ceeb437..0354b1a48 100644 --- a/firmware/application/m4_startup.cpp +++ b/firmware/application/m4_startup.cpp @@ -105,14 +105,14 @@ void m4_switch(const char * hash) { modhash = const_cast(hash); // Ask M4 to enter wait loop in RAM - BasebandConfiguration baseband_switch { - .mode = 255, // DEBUG + /*BasebandConfiguration baseband_switch { + .mode = 255, .sampling_rate = 0, .decimation_factor = 1, }; BasebandConfigurationMessage message { baseband_switch }; - shared_memory.baseband_queue.push(message); + shared_memory.baseband_queue.push(message);*/ } void m4_request_shutdown() { diff --git a/firmware/application/ui_lcr.cpp b/firmware/application/ui_lcr.cpp index 76fd97492..4f70eb078 100644 --- a/firmware/application/ui_lcr.cpp +++ b/firmware/application/ui_lcr.cpp @@ -192,7 +192,7 @@ LCRView::LCRView( transmitter_model.set_baseband_configuration({ .mode = 1, - .sampling_rate = 1536000, // Is this right ? + .sampling_rate = 2280000, // Is this right ? .decimation_factor = 1, }); @@ -323,7 +323,7 @@ LCRView::LCRView( transmitter_model.enable(); }; - button_txsetup.on_select = [&nav, &transmitter_model](Button&){ + button_txsetup.on_select = [&nav](Button&){ nav.push(new AFSKSetupView { nav }); }; diff --git a/firmware/application/ui_lcr.hpp b/firmware/application/ui_lcr.hpp index 9a83b3363..0d282ed49 100644 --- a/firmware/application/ui_lcr.hpp +++ b/firmware/application/ui_lcr.hpp @@ -85,7 +85,7 @@ private: Checkbox checkbox_am_a { { 16, 68 }, - 20, + 0, "" }; Button button_setam_a { @@ -94,7 +94,7 @@ private: }; Checkbox checkbox_am_b { { 16, 68+40 }, - 20, + 0, "" }; Button button_setam_b { @@ -103,7 +103,7 @@ private: }; Checkbox checkbox_am_c { { 16, 68+40+40 }, - 20, + 0, " " }; Button button_setam_c { @@ -112,7 +112,7 @@ private: }; Checkbox checkbox_am_d { { 16, 68+40+40+40 }, - 20, + 0, "" }; Button button_setam_d { @@ -121,7 +121,7 @@ private: }; Checkbox checkbox_am_e { { 16, 68+40+40+40+40 }, - 20, + 0, "" }; Button button_setam_e { diff --git a/firmware/application/ui_loadmodule.cpp b/firmware/application/ui_loadmodule.cpp index 865864c6a..92f63c0ce 100644 --- a/firmware/application/ui_loadmodule.cpp +++ b/firmware/application/ui_loadmodule.cpp @@ -35,7 +35,7 @@ #include #include -using namespace hackrf::one; +using namespace portapack; namespace ui { @@ -53,31 +53,20 @@ void LoadModuleView::on_hide() { } void LoadModuleView::on_show() { - // Ask for MD5 signature and compare - ModuleIDMessage message; - - //message_map.unregister_handler(Message::ID::ModuleID); + char md5_signature[16]; + uint8_t c; - EventDispatcher::message_map().register_handler(Message::ID::ModuleID, - [this](Message* const p) { - uint8_t c; - const auto message = static_cast(p); - if (message->query == false) { // Shouldn't be needed - for (c=0;c<16;c++) { - if (message->md5_signature[c] != _hash[c]) break; - } - if (c == 16) { - text_info.set("Module already loaded :)"); - _mod_loaded = true; - } else { - loadmodule(); - } - } - } - ); - - message.query = true; - shared_memory.baseband_queue.push(message); + memcpy(md5_signature, (const void *)(0x10087FF0), 16); + for (c=0; c<16; c++) { + if (md5_signature[c] != _hash[c]) break; + } + if (c == 16) { + text_info.set("Module already loaded :)"); + _mod_loaded = true; + } else { + text_info.set("Loading module"); + loadmodule(); + } } int LoadModuleView::load_image() { @@ -133,9 +122,11 @@ int LoadModuleView::load_image() { void LoadModuleView::loadmodule() { //message_map.unregister_handler(Message::ID::ReadyForSwitch); - EventDispatcher::message_map().register_handler(Message::ID::ReadyForSwitch, + m4_switch(_hash); + + /*EventDispatcher::message_map().register_handler(Message::ID::ReadyForSwitch, [this](Message* const p) { - (void)p; + (void)p;*/ if (load_image()) { text_info.set(to_string_hex(*((unsigned int*)0x10080000),8)); //text_infob.set(to_string_hex(*((unsigned int*)0x10080004),8)); @@ -145,10 +136,9 @@ void LoadModuleView::loadmodule() { text_info.set("Module not found :("); _mod_loaded = false; } - } - ); + // } + //); - m4_switch(_hash); } LoadModuleView::LoadModuleView( @@ -166,7 +156,7 @@ LoadModuleView::LoadModuleView( _hash = hash; button_ok.on_select = [this,&nav,new_view](Button&){ - nav.pop(); + //nav.pop(); if (_mod_loaded == true) nav.push(new_view); }; } diff --git a/firmware/baseband-tx.bin b/firmware/baseband-tx.bin index 0166000cd..575f9871b 100644 Binary files a/firmware/baseband-tx.bin and b/firmware/baseband-tx.bin differ diff --git a/firmware/baseband.bin b/firmware/baseband.bin index e8951686e..3be4fca05 100644 Binary files a/firmware/baseband.bin and b/firmware/baseband.bin differ diff --git a/firmware/baseband/baseband_thread.cpp b/firmware/baseband/baseband_thread.cpp index 92b968f5e..b67734893 100644 --- a/firmware/baseband/baseband_thread.cpp +++ b/firmware/baseband/baseband_thread.cpp @@ -123,6 +123,22 @@ void BasebandThread::run() { delete baseband_buffer; } +char ram_loop[32]; +typedef int (*fn_ptr)(void); +fn_ptr loop_ptr; + +void ram_loop_fn(void) { + while(1) {} +} + +void BasebandThread::wait_for_switch(void) { + memcpy(&ram_loop[0], reinterpret_cast(&ram_loop_fn), 32); + loop_ptr = reinterpret_cast(&ram_loop[0]); + ReadyForSwitchMessage message; + shared_memory.application_queue.push(message); + (*loop_ptr)(); +} + BasebandProcessor* BasebandThread::create_processor(const int32_t mode) { switch(mode) { case 0: return new NarrowbandAMAudio(); @@ -132,6 +148,7 @@ BasebandProcessor* BasebandThread::create_processor(const int32_t mode) { case 4: return new WidebandSpectrum(); case 5: return new TPMSProcessor(); case 6: return new ERTProcessor(); + case 255: wait_for_switch(); default: return nullptr; } } diff --git a/firmware/baseband/baseband_thread.hpp b/firmware/baseband/baseband_thread.hpp index 81d35433a..b6da76369 100644 --- a/firmware/baseband/baseband_thread.hpp +++ b/firmware/baseband/baseband_thread.hpp @@ -45,6 +45,8 @@ public: return baseband::Direction::Receive; } + void wait_for_switch(void); + Thread* thread_main { nullptr }; Thread* thread_rssi { nullptr }; BasebandProcessor* baseband_processor { nullptr }; diff --git a/firmware/common/modules.h b/firmware/common/modules.h index cfa0bc26d..cdb0cc9c5 100644 --- a/firmware/common/modules.h +++ b/firmware/common/modules.h @@ -1,2 +1,2 @@ -const char md5_baseband[16] = {0xba,0x35,0x2a,0xd7,0x2c,0x17,0x40,0x68,0x54,0x8a,0x5f,0x9a,0x98,0x8b,0x9d,0x73,}; -const char md5_baseband_tx[16] = {0x65,0x3a,0x50,0x6c,0xf4,0x93,0x69,0xce,0x8c,0x8d,0x3c,0xb6,0x9e,0x21,0xba,0xd8,}; +const char md5_baseband[16] = {0x03,0x77,0xc0,0x0b,0x13,0x5b,0x84,0x72,0x8f,0x4b,0xbb,0x51,0x48,0x54,0x82,0xd3,}; +const char md5_baseband_tx[16] = {0xa3,0xb9,0xd4,0x35,0xb5,0xe0,0x66,0x82,0xac,0x61,0x59,0xa1,0x27,0x36,0x0b,0xfe,}; diff --git a/firmware/portapack-h1-firmware.bin b/firmware/portapack-h1-firmware.bin index 70b3945e7..853c9cce1 100644 Binary files a/firmware/portapack-h1-firmware.bin and b/firmware/portapack-h1-firmware.bin differ diff --git a/sdcard/baseband-tx.bin b/sdcard/baseband-tx.bin index 0166000cd..575f9871b 100644 Binary files a/sdcard/baseband-tx.bin and b/sdcard/baseband-tx.bin differ diff --git a/sdcard/baseband.bin b/sdcard/baseband.bin index e8951686e..3be4fca05 100644 Binary files a/sdcard/baseband.bin and b/sdcard/baseband.bin differ