make sd over usb external (#2918)

This commit is contained in:
Totoo
2026-01-10 15:10:23 +01:00
committed by GitHub
parent 266d90a600
commit dc976c7f38
8 changed files with 151 additions and 55 deletions
+6
View File
@@ -281,6 +281,11 @@ set(EXTCPPSRC
external/siggen/main.cpp
external/siggen/ui_siggen.cpp
#sdusb
external/sdusb/main.cpp
external/sdusb/ui_sd_over_usb.cpp
)
set(EXTAPPLIST
@@ -351,4 +356,5 @@ set(EXTAPPLIST
flex_rx
subcarrx
siggen
sdusb
)
+7 -1
View File
@@ -90,6 +90,7 @@ MEMORY
ram_external_app_sstvrx (rwx) : org = 0xADF10000, len = 32k
ram_external_app_subcarrx (rwx) : org = 0xADF20000, len = 32k
ram_external_app_siggen (rwx) : org = 0xADF30000, len = 32k
ram_external_app_sdusb (rwx) : org = 0xADF40000, len = 32k
}
@@ -499,6 +500,11 @@ SECTIONS
*(*ui*external_app*siggen*);
} > ram_external_app_siggen
.external_app_sdusb : ALIGN(4) SUBALIGN(4)
{
KEEP(*(.external_app.app_sdusb.application_information));
*(*ui*external_app*sdusb*);
} > ram_external_app_sdusb
}
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 2024 Bernd Herzog
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include "ui.hpp"
#include "ui_sd_over_usb.hpp"
#include "ui_navigation.hpp"
#include "external_app.hpp"
namespace ui::external_app::sdusb {
void initialize_app(ui::NavigationView& nav) {
nav.push<SdOverUsbView>();
}
} // namespace ui::external_app::sdusb
extern "C" {
__attribute__((section(".external_app.app_sdusb.application_information"), used)) application_information_t _application_information_sdusb = {
/*.memory_location = */ (uint8_t*)0x00000000,
/*.externalAppEntry = */ ui::external_app::sdusb::initialize_app,
/*.header_version = */ CURRENT_HEADER_VERSION,
/*.app_version = */ VERSION_MD5,
/*.app_name = */ "SD Over USB",
/*.bitmap_data = */ {
0xF0,
0x0F,
0x10,
0x08,
0x50,
0x0A,
0x10,
0x08,
0x10,
0x08,
0x10,
0x08,
0xF8,
0x1F,
0xF8,
0x1F,
0xF8,
0x1F,
0xF8,
0x1F,
0xF8,
0x1F,
0xF8,
0x1F,
0xF8,
0x1F,
0xF0,
0x0F,
0x80,
0x01,
0x80,
0x01,
},
/*.icon_color = */ ui::Color::yellow().v,
/*.menu_location = */ app_location_t::UTILITIES,
/*.desired_menu_position = */ -1,
/*.m4_app_tag = portapack::spi_flash::image_tag_usb_sd */ {'P', 'U', 'S', 'B'},
/*.m4_app_offset = */ 0x00000000, // will be filled at compile time
};
}
+59
View File
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Bernd Herzog
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include "ui_sd_over_usb.hpp"
#include "portapack_shared_memory.hpp"
namespace ui::external_app::sdusb {
SdOverUsbView::SdOverUsbView(NavigationView& nav)
: nav_(nav) {
add_children({&labels,
&button_run});
button_run.on_select = [this](Button&) {
ui::Painter painter;
painter.fill_rectangle(
{0, 0, portapack::display.width(), portapack::display.height()},
Theme::getInstance()->bg_darkest->background);
painter.draw_bitmap(
{portapack::display.width() / 2 - 8, portapack::display.height() / 2 - 8},
bitmap_icon_hackrf,
Theme::getInstance()->bg_darkest->foreground,
Theme::getInstance()->bg_darkest->background);
sdcDisconnect(&SDCD1);
sdcStop(&SDCD1);
portapack::shutdown(true);
baseband::run_prepared_image(portapack::memory::map::m4_code.base());
m0_halt();
/* will not return*/
};
}
void SdOverUsbView::focus() {
button_run.focus();
}
} // namespace ui::external_app::sdusb
+63
View File
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
* Copyright (C) 2023 Bernd Herzog
*
* This file is part of PortaPack.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef __UI_SD_OVER_USB_H__
#define __UI_SD_OVER_USB_H__
#include "ui_widget.hpp"
#include "ui_navigation.hpp"
#include "string_format.hpp"
#include "ff.h"
#include "baseband_api.hpp"
#include "core_control.hpp"
#include <cstdint>
namespace ui::external_app::sdusb {
class SdOverUsbView : public View {
public:
SdOverUsbView(NavigationView& nav);
void focus() override;
std::string title() const override { return "SD over USB"; };
private:
NavigationView& nav_;
Labels labels{
{{UI_POS_X_CENTER(22), 2 * 16}, "Click Run to start the", Theme::getInstance()->bg_darkest->foreground},
{{UI_POS_X_CENTER(22), 3 * 16}, "USB Mass Storage Mode.", Theme::getInstance()->bg_darkest->foreground},
{{UI_POS_X_CENTER(21), 5 * 16}, "It can take up to 20s", Theme::getInstance()->bg_darkest->foreground},
{{UI_POS_X_CENTER(19), 6 * 16}, "for the drive to be", Theme::getInstance()->bg_darkest->foreground},
{{UI_POS_X_CENTER(10), 7 * 16}, "available.", Theme::getInstance()->bg_darkest->foreground},
};
Button button_run{
{UI_POS_X_CENTER(12), 15 * 16, 12 * 8, 3 * 16},
"Run"};
};
} // namespace ui::external_app::sdusb
#endif /*__UI_SD_OVER_USB_H__*/