From e2586ceb226d378ce1fdc21c28aeba4de9910683 Mon Sep 17 00:00:00 2001 From: Totoo Date: Fri, 12 Jun 2026 16:25:43 +0200 Subject: [PATCH] proper fix for flasher (#3223) --- firmware/application/apps/ui_flash_utility.cpp | 8 ++------ firmware/application/apps/ui_flash_utility.hpp | 9 --------- firmware/application/usb_serial_shell.cpp | 3 +-- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/firmware/application/apps/ui_flash_utility.cpp b/firmware/application/apps/ui_flash_utility.cpp index 2c8486c15..74108c684 100644 --- a/firmware/application/apps/ui_flash_utility.cpp +++ b/firmware/application/apps/ui_flash_utility.cpp @@ -134,12 +134,6 @@ bool FlashUtilityView::endsWith(const std::u16string& str, const std::u16string& } } -void FlashUtilityView::wait_till_loaded() { - while (!isLoaded) { - chThdSleepMilliseconds(50); - } -} - std::filesystem::path FlashUtilityView::extract_tar(std::filesystem::path::string_type path, ui::Painter& painter) { // painter.fill_rectangle( @@ -157,6 +151,7 @@ std::filesystem::path FlashUtilityView::extract_tar(std::filesystem::path::strin bool FlashUtilityView::flash_firmware(std::filesystem::path::string_type path) { ui::Painter painter; + menu_view.hidden(true); if (endsWith(path, u".tar")) { // extract, then update path = extract_tar(u'/' + path, painter).native(); @@ -166,6 +161,7 @@ bool FlashUtilityView::flash_firmware(std::filesystem::path::string_type path) { painter.fill_rectangle({0, 50, portapack::display.width(), 90}, Theme::getInstance()->bg_darkest->background); painter.draw_string({0, 60}, *Theme::getInstance()->fg_red, "BAD FIRMWARE FILE OR W/R ERR"); chThdSleepMilliseconds(5000); + menu_view.hidden(false); return false; } painter.fill_rectangle( diff --git a/firmware/application/apps/ui_flash_utility.hpp b/firmware/application/apps/ui_flash_utility.hpp index e1a0d82d3..af1b4eb15 100644 --- a/firmware/application/apps/ui_flash_utility.hpp +++ b/firmware/application/apps/ui_flash_utility.hpp @@ -49,7 +49,6 @@ class FlashUtilityView : public View { std::string title() const override { return "Flash Utility"; }; bool flash_firmware(std::filesystem::path::string_type path); - void wait_till_loaded(); private: NavigationView& nav_; @@ -68,14 +67,6 @@ class FlashUtilityView : public View { void firmware_selected(std::filesystem::path::string_type path); bool endsWith(const std::u16string& str, const std::u16string& suffix); - bool isLoaded = false; - uint8_t refreshcnt = 0; - MessageHandlerRegistration message_handler_frame_sync{ - Message::ID::DisplayFrameSync, - [this](const Message* const) { - refreshcnt++; - if (refreshcnt > 5) isLoaded = true; - }}; }; } /* namespace ui */ diff --git a/firmware/application/usb_serial_shell.cpp b/firmware/application/usb_serial_shell.cpp index 886771af2..9e226d973 100644 --- a/firmware/application/usb_serial_shell.cpp +++ b/firmware/application/usb_serial_shell.cpp @@ -157,8 +157,7 @@ static void cmd_flash(BaseSequentialStream* chp, int argc, char* argv[]) { // call nav with flash auto open_view = nav->push(); chprintf(chp, "Flashing started\r\n"); - chThdSleepMilliseconds(150); // to give display some time to paint the screen - open_view->wait_till_loaded(); // also wait for first frame sync + chThdSleepMilliseconds(150); // to give display some time to paint the screen if (!open_view->flash_firmware(path.native())) { chprintf(chp, "error\r\n"); }