diff --git a/firmware/application/CMakeLists.txt b/firmware/application/CMakeLists.txt index 8f1ea9281..0b355d05a 100644 --- a/firmware/application/CMakeLists.txt +++ b/firmware/application/CMakeLists.txt @@ -296,7 +296,6 @@ set(CPPSRC apps/ui_rds.cpp apps/ui_recon_settings.cpp apps/ui_recon.cpp - apps/ui_sd_over_usb.cpp apps/ui_search.cpp apps/ui_settings.cpp apps/ui_sonde.cpp diff --git a/firmware/application/external/external.cmake b/firmware/application/external/external.cmake index fc80b3a98..8aa407b25 100644 --- a/firmware/application/external/external.cmake +++ b/firmware/application/external/external.cmake @@ -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 ) diff --git a/firmware/application/external/external.ld b/firmware/application/external/external.ld index 090027d8b..cc8711285 100644 --- a/firmware/application/external/external.ld +++ b/firmware/application/external/external.ld @@ -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 + } diff --git a/firmware/application/external/sdusb/main.cpp b/firmware/application/external/sdusb/main.cpp new file mode 100644 index 000000000..c1eb2fe55 --- /dev/null +++ b/firmware/application/external/sdusb/main.cpp @@ -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(); +} +} // 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 +}; +} diff --git a/firmware/application/apps/ui_sd_over_usb.cpp b/firmware/application/external/sdusb/ui_sd_over_usb.cpp similarity index 92% rename from firmware/application/apps/ui_sd_over_usb.cpp rename to firmware/application/external/sdusb/ui_sd_over_usb.cpp index 937809151..57a20466d 100644 --- a/firmware/application/apps/ui_sd_over_usb.cpp +++ b/firmware/application/external/sdusb/ui_sd_over_usb.cpp @@ -23,7 +23,7 @@ #include "ui_sd_over_usb.hpp" #include "portapack_shared_memory.hpp" -namespace ui { +namespace ui::external_app::sdusb { SdOverUsbView::SdOverUsbView(NavigationView& nav) : nav_(nav) { @@ -46,7 +46,7 @@ SdOverUsbView::SdOverUsbView(NavigationView& nav) sdcStop(&SDCD1); portapack::shutdown(true); - m4_init(portapack::spi_flash::image_tag_usb_sd, portapack::memory::map::m4_code, false); + baseband::run_prepared_image(portapack::memory::map::m4_code.base()); m0_halt(); /* will not return*/ }; @@ -56,4 +56,4 @@ void SdOverUsbView::focus() { button_run.focus(); } -} /* namespace ui */ +} // namespace ui::external_app::sdusb diff --git a/firmware/application/apps/ui_sd_over_usb.hpp b/firmware/application/external/sdusb/ui_sd_over_usb.hpp similarity index 96% rename from firmware/application/apps/ui_sd_over_usb.hpp rename to firmware/application/external/sdusb/ui_sd_over_usb.hpp index 1c39c7e89..0784136ed 100644 --- a/firmware/application/apps/ui_sd_over_usb.hpp +++ b/firmware/application/external/sdusb/ui_sd_over_usb.hpp @@ -32,7 +32,7 @@ #include -namespace ui { +namespace ui::external_app::sdusb { class SdOverUsbView : public View { public: @@ -58,6 +58,6 @@ class SdOverUsbView : public View { "Run"}; }; -} /* namespace ui */ +} // namespace ui::external_app::sdusb #endif /*__UI_SD_OVER_USB_H__*/ diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 0a93e8010..b5603dba3 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -49,7 +49,7 @@ #include "ui_rds.hpp" #include "ui_recon.hpp" // #include "ui_scanner.hpp" -#include "ui_sd_over_usb.hpp" +// #include "ui_sd_over_usb.hpp" #include "ui_search.hpp" #include "ui_settings.hpp" #include "ui_sonde.hpp" @@ -146,7 +146,7 @@ const NavigationView::AppList NavigationView::appList = { {"freqman", "Freq. Manager", UTILITIES, Color::green(), &bitmap_icon_freqman, new ViewFactory()}, {"iqtrim", "IQ Trim", UTILITIES, Color::orange(), &bitmap_icon_trim, new ViewFactory()}, {"notepad", "Notepad", UTILITIES, Color::dark_cyan(), &bitmap_icon_notepad, new ViewFactory()}, - {nullptr, "SD Over USB", UTILITIES, Color::yellow(), &bitmap_icon_hackrf, new ViewFactory()}, + //{nullptr, "SD Over USB", UTILITIES, Color::yellow(), &bitmap_icon_hackrf, new ViewFactory()}, {nullptr, "Debug", UTILITIES, Color::light_grey(), &bitmap_icon_debug, new ViewFactory()}, //{"testapp", "Test App", UTILITIES, Color::dark_grey(), nullptr, new ViewFactory()}, // Dangerous apps. diff --git a/firmware/baseband/CMakeLists.txt b/firmware/baseband/CMakeLists.txt index 86a07a1cc..2a6454130 100644 --- a/firmware/baseband/CMakeLists.txt +++ b/firmware/baseband/CMakeLists.txt @@ -497,52 +497,6 @@ set(MODE_CPPSRC ) DeclareTargets(PFUT flash_utility) -### SD over USB - -set(MODE_INCDIR - ${HACKRF_PATH}/firmware - ${HACKRF_PATH}/firmware/common - ${HACKRF_PATH}/firmware/libopencm3/include -) -set(MODE_CPPSRC - sd_over_usb/proc_sd_over_usb.cpp - - sd_over_usb/scsi.c - sd_over_usb/diskio.c - sd_over_usb/sd_over_usb.c - sd_over_usb/usb_descriptor.c - sd_over_usb/hackrf_core.c - - ${HACKRF_PATH}/firmware/common/usb.c - ${HACKRF_PATH}/firmware/common/usb_queue.c - ${HACKRF_PATH}/firmware/hackrf_usb/usb_device.c - ${HACKRF_PATH}/firmware/hackrf_usb/usb_endpoint.c - ${HACKRF_PATH}/firmware/common/usb_request.c - ${HACKRF_PATH}/firmware/common/usb_standard_request.c - ${HACKRF_PATH}/firmware/common/platform_detect.c - ${HACKRF_PATH}/firmware/common/gpio_lpc.c - ${HACKRF_PATH}/firmware/common/firmware_info.c - ${HACKRF_PATH}/firmware/common/si5351c.c - ${HACKRF_PATH}/firmware/common/i2c_bus.c - ${HACKRF_PATH}/firmware/common/mixer.c - ${HACKRF_PATH}/firmware/common/clkin.c - ${HACKRF_PATH}/firmware/common/spi_bus.c - ${HACKRF_PATH}/firmware/common/sgpio.c - ${HACKRF_PATH}/firmware/common/rf_path.c - ${HACKRF_PATH}/firmware/common/i2c_lpc.c - ${HACKRF_PATH}/firmware/common/spi_ssp.c - ${HACKRF_PATH}/firmware/common/rffc5071_spi.c - ${HACKRF_PATH}/firmware/common/rffc5071.c - ${HACKRF_PATH}/firmware/common/clkin.c - ${HACKRF_PATH}/firmware/common/gpdma.c - - ${HACKRF_PATH}/firmware/libopencm3/lib/cm3/nvic.c - ${HACKRF_PATH}/firmware/libopencm3/lib/cm3/sync.c - ${HACKRF_PATH}/firmware/libopencm3/lib/lpc43xx/scu.c - ${HACKRF_PATH}/firmware/libopencm3/lib/lpc43xx/timer.c - ${HACKRF_PATH}/firmware/libopencm3/lib/lpc43xx/i2c.c -) -DeclareTargets(PUSB sd_over_usb) ### Place external app and disabled images below so they don't get added to the firmware set(add_to_firmware FALSE) @@ -711,6 +665,54 @@ set(MODE_CPPSRC DeclareTargets(PSCD subcar) +### SD over USB + +set(MODE_INCDIR + ${HACKRF_PATH}/firmware + ${HACKRF_PATH}/firmware/common + ${HACKRF_PATH}/firmware/libopencm3/include +) +set(MODE_CPPSRC + sd_over_usb/proc_sd_over_usb.cpp + + sd_over_usb/scsi.c + sd_over_usb/diskio.c + sd_over_usb/sd_over_usb.c + sd_over_usb/usb_descriptor.c + sd_over_usb/hackrf_core.c + + ${HACKRF_PATH}/firmware/common/usb.c + ${HACKRF_PATH}/firmware/common/usb_queue.c + ${HACKRF_PATH}/firmware/hackrf_usb/usb_device.c + ${HACKRF_PATH}/firmware/hackrf_usb/usb_endpoint.c + ${HACKRF_PATH}/firmware/common/usb_request.c + ${HACKRF_PATH}/firmware/common/usb_standard_request.c + ${HACKRF_PATH}/firmware/common/platform_detect.c + ${HACKRF_PATH}/firmware/common/gpio_lpc.c + ${HACKRF_PATH}/firmware/common/firmware_info.c + ${HACKRF_PATH}/firmware/common/si5351c.c + ${HACKRF_PATH}/firmware/common/i2c_bus.c + ${HACKRF_PATH}/firmware/common/mixer.c + ${HACKRF_PATH}/firmware/common/clkin.c + ${HACKRF_PATH}/firmware/common/spi_bus.c + ${HACKRF_PATH}/firmware/common/sgpio.c + ${HACKRF_PATH}/firmware/common/rf_path.c + ${HACKRF_PATH}/firmware/common/i2c_lpc.c + ${HACKRF_PATH}/firmware/common/spi_ssp.c + ${HACKRF_PATH}/firmware/common/rffc5071_spi.c + ${HACKRF_PATH}/firmware/common/rffc5071.c + ${HACKRF_PATH}/firmware/common/clkin.c + ${HACKRF_PATH}/firmware/common/gpdma.c + + ${HACKRF_PATH}/firmware/libopencm3/lib/cm3/nvic.c + ${HACKRF_PATH}/firmware/libopencm3/lib/cm3/sync.c + ${HACKRF_PATH}/firmware/libopencm3/lib/lpc43xx/scu.c + ${HACKRF_PATH}/firmware/libopencm3/lib/lpc43xx/timer.c + ${HACKRF_PATH}/firmware/libopencm3/lib/lpc43xx/i2c.c +) +DeclareTargets(PUSB sd_over_usb) + + ### HackRF "factory" firmware add_custom_command(