diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index dd0987d..ed5f0df 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -470,6 +470,30 @@ DevicePanel::DevicePanel(SettingsWindow *parent) : ListWidget(parent) { }); addItem(deleteDrivingDataBtn); + // Panda flashing button + auto flashPandaBtn = new ButtonControl(tr("Flash Panda"), tr("FLASH"), tr("Use this button to troubleshoot and update the Panda device's firmware.")); + connect(flashPandaBtn, &ButtonControl::clicked, [=]() { + if (ConfirmationDialog::confirm(tr("Are you sure you want to flash the Panda?"), tr("Flash"), this)) { + std::thread([=]() { + QProcess process; + flashPandaBtn->setValue(tr("Flashing...")); + + process.setWorkingDirectory("/data/openpilot/panda/board"); + process.start("/bin/sh", QStringList{"-c", "./recover.py"}); + process.waitForFinished(); + process.start("/bin/sh", QStringList{"-c", "./flash.py"}); + process.waitForFinished(); + + process.setWorkingDirectory("/data/openpilot/panda/tests"); + process.start("/bin/sh", QStringList{"-c", "python reflash_internal_panda.py"}); + process.waitForFinished(); + + Hardware::reboot(); + }).detach(); + } + }); + addItem(flashPandaBtn); + QObject::connect(uiState(), &UIState::offroadTransition, [=](bool offroad) { for (auto btn : findChildren()) { btn->setEnabled(offroad);