mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-04-23 01:09:13 -04:00
Module loading should work again
Modules won't load if already loaded (dirty footprint hack)
This commit is contained in:
parent
58367839a6
commit
496c77fe3e
@ -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
|
||||
|
Binary file not shown.
@ -485,7 +485,6 @@ void wait_for_switch(void) {
|
||||
ReadyForSwitchMessage message;
|
||||
shared_memory.application_queue.push(message);
|
||||
(*loop_ptr)();
|
||||
return;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
@ -496,6 +495,18 @@ int main(void) {
|
||||
|
||||
EventDispatcher event_dispatcher;
|
||||
auto& message_handlers = event_dispatcher.message_handlers();
|
||||
|
||||
message_handlers.register_handler(Message::ID::ModuleID,
|
||||
[&message_handlers](Message* p) {
|
||||
ModuleIDMessage reply;
|
||||
auto message = static_cast<ModuleIDMessage*>(p);
|
||||
if (message->query == true) { // Shouldn't be needed
|
||||
memcpy(reply.md5_signature, (const void *)(0x10087FF0), 16);
|
||||
reply.query = false;
|
||||
shared_memory.application_queue.push(reply);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
message_handlers.register_handler(Message::ID::BasebandConfiguration,
|
||||
[&message_handlers](const Message* const p) {
|
||||
@ -538,7 +549,7 @@ int main(void) {
|
||||
baseband_thread.baseband_processor = new XylosProcessor();
|
||||
break;
|
||||
|
||||
case 0xFF:
|
||||
case SWITCH:
|
||||
wait_for_switch();
|
||||
|
||||
default:
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* 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
|
||||
@ -45,11 +45,10 @@ void XylosProcessor::execute(buffer_c8_t buffer) {
|
||||
digit = shared_memory.xylosdata[byte_pos++];
|
||||
}
|
||||
|
||||
if (!digit) {
|
||||
if (digit == 0xFF) {
|
||||
message.n = 25; // End of message code
|
||||
shared_memory.xylos_transmit_done = true;
|
||||
shared_memory.application_queue.push(message);
|
||||
digit = 0;
|
||||
}
|
||||
|
||||
sample_count = 0;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
* 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
|
||||
|
Binary file not shown.
@ -348,7 +348,7 @@ private:
|
||||
|
||||
const auto baseband_buffer =
|
||||
new std::array<baseband::sample_t, 8192>();
|
||||
|
||||
|
||||
char ram_loop[32];
|
||||
typedef int (*fn_ptr)(void);
|
||||
fn_ptr loop_ptr;
|
||||
@ -363,7 +363,6 @@ void wait_for_switch(void) {
|
||||
ReadyForSwitchMessage message;
|
||||
shared_memory.application_queue.push(message);
|
||||
(*loop_ptr)();
|
||||
return;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
@ -374,6 +373,18 @@ int main(void) {
|
||||
|
||||
EventDispatcher event_dispatcher;
|
||||
auto& message_handlers = event_dispatcher.message_handlers();
|
||||
|
||||
message_handlers.register_handler(Message::ID::ModuleID,
|
||||
[&message_handlers](Message* p) {
|
||||
ModuleIDMessage reply;
|
||||
auto message = static_cast<ModuleIDMessage*>(p);
|
||||
if (message->query == true) { // Shouldn't be needed
|
||||
memcpy(reply.md5_signature, (const void *)(0x10087FF0), 16);
|
||||
reply.query = false;
|
||||
shared_memory.application_queue.push(reply);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
message_handlers.register_handler(Message::ID::BasebandConfiguration,
|
||||
[&message_handlers](const Message* const p) {
|
||||
|
@ -23,7 +23,7 @@ __process_stack_size__ = 0x1000; /* main() stack */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
flash : org = 0x00000000, len = 128k /* SPIFI flash @ 0x140????? */
|
||||
flash : org = 0x00000000, len = 256k /* SPIFI flash @ 0x140????? */
|
||||
ram : org = 0x20000000, len = 64k /* AHB SRAM @ 0x20000000 */
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ __process_stack_size__ = 0x1000; /* main() stack */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
flash : org = 0x00000000, len = 32k /* Local SRAM @ 0x10080000 */
|
||||
flash : org = 0x00000000, len = 32752 /* Local SRAM @ 0x10080000 */
|
||||
ram : org = 0x10000000, len = 96k /* Local SRAM @ 0x10000000 */
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
Retune = 11,
|
||||
ReadyForSwitch = 12,
|
||||
AFSKData = 13,
|
||||
ModuleID = 14,
|
||||
MAX
|
||||
};
|
||||
|
||||
@ -297,6 +298,17 @@ public:
|
||||
int n = 0;
|
||||
};
|
||||
|
||||
class ModuleIDMessage : public Message {
|
||||
public:
|
||||
ModuleIDMessage(
|
||||
) : Message { ID::ModuleID }
|
||||
{
|
||||
}
|
||||
|
||||
bool query;
|
||||
char md5_signature[16];
|
||||
};
|
||||
|
||||
class ReadyForSwitchMessage : public Message {
|
||||
public:
|
||||
ReadyForSwitchMessage(
|
||||
|
@ -1,2 +1,2 @@
|
||||
const char md5_baseband[16] = {0x20,0xb7,0x1a,0x68,0x28,0xda,0xc9,0xb8,0x01,0xb0,0xbd,0x68,0x0d,0xd5,0xd6,0xa7,};
|
||||
const char md5_baseband_tx[16] = {0xe5,0x29,0xb9,0xf0,0x81,0x50,0x45,0x69,0x24,0xaf,0xdd,0x4e,0xdb,0xaf,0xd8,0x97,};
|
||||
const char md5_baseband[16] = {0xef,0xc2,0x85,0x1d,0x83,0x0d,0x5c,0x18,0x55,0x7b,0x80,0x75,0xc9,0x6a,0x54,0xe1,};
|
||||
const char md5_baseband_tx[16] = {0xad,0xc6,0x44,0x4e,0xf4,0xe1,0xb8,0xb2,0x29,0x52,0x1d,0x33,0x1f,0xda,0x5d,0xd6,};
|
||||
|
Binary file not shown.
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Copyright (C) 2016 Furrtek
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@ -56,35 +55,59 @@ sys.argv = sys.argv[1:]
|
||||
|
||||
# Format for module file:
|
||||
# Magic (4), Version (2), Length (4), Name (16), MD5 (16), Description (214)
|
||||
# Unpadded module binary...
|
||||
# Module binary...
|
||||
# MD5 (16)
|
||||
|
||||
for args in sys.argv:
|
||||
data = read_image(args + '/build/' + args + '.bin')
|
||||
data_r = data
|
||||
|
||||
# Magic bytes
|
||||
info = 'PPM '
|
||||
|
||||
# Version
|
||||
info += struct.pack('H', 1)
|
||||
|
||||
# Length
|
||||
info += struct.pack('I', len(data))
|
||||
|
||||
# Module name
|
||||
name = read_image(args + '/name')
|
||||
if len(name) > 16:
|
||||
name = name[0:15]
|
||||
pad_size = 16 - len(name)
|
||||
name += (data_default_byte * pad_size)
|
||||
info += name
|
||||
|
||||
# Module MD5 footprint
|
||||
m.update(data)
|
||||
digest = m.digest()
|
||||
pad_size = 16 - len(digest)
|
||||
digest += (data_default_byte * pad_size)
|
||||
info += digest
|
||||
|
||||
# Module description
|
||||
description = read_image(args + '/description')
|
||||
if len(description) > 214:
|
||||
description = description[0:213]
|
||||
pad_size = 214 - len(description)
|
||||
description += (data_default_byte * pad_size)
|
||||
info += description
|
||||
|
||||
# Padding
|
||||
data = info + data
|
||||
pad_size = (32768 + 256 - 16) - len(data)
|
||||
data += (data_default_byte * pad_size)
|
||||
data += digest
|
||||
write_file(data, args + '.bin')
|
||||
|
||||
# Add to modules.h
|
||||
md5sum = ''
|
||||
for byte in digest:
|
||||
md5sum += '0x' + format(byte, '02x') + ','
|
||||
h_data += 'const char md5_' + args.replace('-','_') + '[16] = {' + md5sum + '};\n'
|
||||
|
||||
# Update original binary with MD5 footprint
|
||||
write_file(data[256:(32768+256)], args + '/build/' + args + '.bin')
|
||||
|
||||
write_file(h_data, 'common/modules.h')
|
||||
|
Loading…
x
Reference in New Issue
Block a user