mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-21 23:19:02 +00:00
Module loading should work again
Modules won't load if already loaded (dirty footprint hack)
This commit is contained in:
@@ -55,6 +55,7 @@ int m4_load_image(void) {
|
||||
uint32_t mod_size;
|
||||
UINT bw;
|
||||
uint8_t i;
|
||||
uint16_t cnt;
|
||||
char md5sum[16];
|
||||
FILINFO modinfo;
|
||||
FIL modfile;
|
||||
@@ -77,9 +78,11 @@ int m4_load_image(void) {
|
||||
f_lseek(&modfile, 6);
|
||||
f_read(&modfile, &mod_size, 4, &bw);
|
||||
f_lseek(&modfile, 256);
|
||||
f_read(&modfile, reinterpret_cast<void*>(portapack::memory::map::m4_code.base()), mod_size, &bw);
|
||||
LPC_RGU->RESET_CTRL[0] = (1 << 13);
|
||||
// For some reason, f_read > 512 bytes at once crashes everything... :/
|
||||
for (cnt=0;cnt<256;cnt++)
|
||||
f_read(&modfile, reinterpret_cast<void*>(portapack::memory::map::m4_code.base()+(cnt*256)), 256, &bw);
|
||||
f_close(&modfile);
|
||||
LPC_RGU->RESET_CTRL[0] = (1 << 13);
|
||||
return 1;
|
||||
}
|
||||
f_close(&modfile);
|
||||
|
||||
@@ -290,16 +290,17 @@ LCRView::LCRView(
|
||||
memcpy(shared_memory.lcrdata, lcrframe_f, 256);
|
||||
|
||||
shared_memory.afsk_transmit_done = false;
|
||||
shared_memory.afsk_repeat = ((portapack::persistent_memory::afsk_config() >> 8) & 0xFF);
|
||||
shared_memory.afsk_repeat = (portapack::persistent_memory::afsk_config() >> 8) & 0xFF;
|
||||
|
||||
message_map.register_handler(Message::ID::TXDone,
|
||||
[this,&transmitter_model](Message* const p) {
|
||||
char str[8];
|
||||
const auto message = static_cast<const TXDoneMessage*>(p);
|
||||
if (message->n > 0) {
|
||||
char str[8];
|
||||
text_status.set(" ");
|
||||
strcpy(str, to_string_dec_int(message->n).c_str());
|
||||
strcat(str, "/");
|
||||
strcat(str, to_string_dec_int(shared_memory.afsk_repeat).c_str());
|
||||
strcat(str, to_string_dec_int((portapack::persistent_memory::afsk_config() >> 8) & 0xFF).c_str());
|
||||
text_status.set(str);
|
||||
} else {
|
||||
text_status.set("Done ! ");
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "ff.h"
|
||||
#include "hackrf_gpio.hpp"
|
||||
#include "portapack.hpp"
|
||||
|
||||
#include "portapack_shared_memory.hpp"
|
||||
#include "hackrf_hal.hpp"
|
||||
|
||||
#include <cstring>
|
||||
@@ -50,11 +50,39 @@ void LoadModuleView::on_hide() {
|
||||
}
|
||||
|
||||
void LoadModuleView::on_show() {
|
||||
// Ask for MD5 signature and compare
|
||||
ModuleIDMessage message;
|
||||
auto& message_map = context().message_map();
|
||||
|
||||
message_map.unregister_handler(Message::ID::ModuleID);
|
||||
|
||||
message_map.register_handler(Message::ID::ModuleID,
|
||||
[this](Message* const p) {
|
||||
uint8_t c;
|
||||
const auto message = static_cast<const ModuleIDMessage*>(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);
|
||||
}
|
||||
|
||||
void LoadModuleView::loadmodule() {
|
||||
auto& message_map = context().message_map();
|
||||
message_map.register_handler(Message::ID::ReadyForSwitch,
|
||||
[this](Message* const p) {
|
||||
(void)p;
|
||||
// const auto message = static_cast<const ReadyForSwitchMessage*>(p);
|
||||
if (m4_load_image()) {
|
||||
text_info.set("Module loaded :)");
|
||||
_mod_loaded = true;
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace ui {
|
||||
class LoadModuleView : public View {
|
||||
public:
|
||||
LoadModuleView(NavigationView& nav, const char * hash, View* new_view);
|
||||
void loadmodule();
|
||||
|
||||
void on_show() override;
|
||||
void on_hide() override;
|
||||
|
||||
@@ -111,19 +111,19 @@ void NavigationView::focus() {
|
||||
/* SystemMenuView ********************************************************/
|
||||
|
||||
SystemMenuView::SystemMenuView(NavigationView& nav) {
|
||||
add_items<10>({ {
|
||||
add_items<11>({ {
|
||||
{ "Play dead", ui::Color::red(), [&nav](){ nav.push(new PlayDeadView { nav, false }); } },
|
||||
{ "Receiver", ui::Color::cyan(), [&nav](){ nav.push(new ReceiverView { nav, receiver_model }); } },
|
||||
{ "Receiver", ui::Color::cyan(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband, new ReceiverView { nav, receiver_model }}); } },
|
||||
//{ "Nordic/BTLE RX", ui::Color::cyan(), [&nav](){ nav.push(new NotImplementedView { nav }); } },
|
||||
{ "Jammer", ui::Color::white(), [&nav](){ nav.push(new JammerView { nav, transmitter_model }); } },
|
||||
{ "Jammer", ui::Color::white(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband, new JammerView { nav, transmitter_model }}); } },
|
||||
//{ "Audio file TX", ui::Color::white(), [&nav](){ nav.push(new NotImplementedView { nav }); } },
|
||||
//{ "Encoder TX", ui::Color::green(), [&nav](){ nav.push(new NotImplementedView { nav }); } },
|
||||
{ "Whistle", ui::Color::purple(), [&nav](){ nav.push(new WhistleView { nav, transmitter_model }); } },
|
||||
//{ "SIGFOX RX", ui::Color::orange(), [&nav](){ nav.push(new SIGFRXView { nav, receiver_model }); } },
|
||||
//{ "RDS TX", ui::Color::yellow(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband_tx, new RDSView { nav, transmitter_model }}; } },
|
||||
{ "Xylos TX", ui::Color::orange(), [&nav](){ nav.push(new XylosView { nav, transmitter_model }); } },
|
||||
//{ "AFSK RX", ui::Color::cyan(), [&nav](){ nav.push(new AFSKRXView { nav, receiver_model }); } },
|
||||
{ "TEDI/LCR TX", ui::Color::yellow(), [&nav](){ nav.push(new LCRView { nav, transmitter_model }); } },
|
||||
{ "Whistle", ui::Color::purple(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband, new WhistleView { nav, transmitter_model }}); } },
|
||||
//{ "SIGFOX RX", ui::Color::orange(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband, new SIGFRXView { nav, receiver_model }}); } },
|
||||
{ "RDS TX", ui::Color::yellow(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband_tx, new RDSView { nav, transmitter_model }}); } },
|
||||
{ "Xylos TX", ui::Color::orange(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband_tx, new XylosView { nav, transmitter_model }}); } },
|
||||
//{ "AFSK RX", ui::Color::cyan(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband, new AFSKRXView { nav, receiver_model }}); } },
|
||||
{ "TEDI/LCR TX", ui::Color::yellow(), [&nav](){ nav.push(new LoadModuleView { nav, md5_baseband_tx, new LCRView { nav, transmitter_model }}); } },
|
||||
{ "Setup", ui::Color::white(), [&nav](){ nav.push(new SetupMenuView { nav }); } },
|
||||
{ "About", ui::Color::white(), [&nav](){ nav.push(new AboutView { nav }); } },
|
||||
{ "Debug", ui::Color::white(), [&nav](){ nav.push(new DebugMenuView { nav }); } },
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
*
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -106,6 +107,8 @@ void XylosView::upd_message() {
|
||||
else
|
||||
ccirmessage[c] -= 0x30;
|
||||
}
|
||||
|
||||
ccirmessage[20] = 0xFF;
|
||||
}
|
||||
|
||||
void XylosView::journuit() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
*
|
||||
* Copyright (C) 2016 Furrtek
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
||||
Reference in New Issue
Block a user