Skip to content

Commit

Permalink
dcm220 fw download
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jan 24, 2020
1 parent 9322787 commit 0751c97
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 58 deletions.
1 change: 1 addition & 0 deletions src/eez/gui/action_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,7 @@ void action_debug_trace_log_toggle() {
void onFirmwareSelected(const char *filePath) {
int err;
if (!bp3c::flash_slave::start(g_channel->slotIndex, filePath, &err)) {
errorMessage("Failed to start update!");
}
}

Expand Down
19 changes: 9 additions & 10 deletions src/eez/gui/app_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ AppContext::AppContext() {


void AppContext::stateManagment() {
// remove alert message after period of time
uint32_t inactivityPeriod = psu::idle::getGuiAndEncoderInactivityPeriod();
if (getActivePageId() == INTERNAL_PAGE_ID_TOAST_MESSAGE) {
ToastMessagePage *page = (ToastMessagePage *)getActivePage();
if (!page->hasAction() && inactivityPeriod >= CONF_GUI_TOAST_DURATION_MS) {
popPage();
}
}

if (m_nextIterOperation == NEXT_ITER_OPERATION_SET) {
setPage(m_pageIdToSetOnNextIter);
if (m_pageIdToSetOnNextIter == PAGE_ID_WELCOME) {
Expand All @@ -78,16 +87,6 @@ void AppContext::stateManagment() {
}
}

// remove alert message after period of time
uint32_t inactivityPeriod = psu::idle::getGuiAndEncoderInactivityPeriod();
if (getActivePageId() == INTERNAL_PAGE_ID_TOAST_MESSAGE) {
ToastMessagePage *page = (ToastMessagePage *)getActivePage();
if (!page->hasAction() && inactivityPeriod >= CONF_GUI_TOAST_DURATION_MS) {
popPage();
return;
}
}

if (m_showInfoMessageOnNextIter) {
gui::infoMessage(m_showInfoMessageOnNextIter);
m_showInfoMessageOnNextIter = nullptr;
Expand Down
1 change: 0 additions & 1 deletion src/eez/gui/dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ void infoMessage(data::Value value) {
pushToastMessage(ToastMessagePage::create(INFO_TOAST, value));
}


void infoMessage(const char *message1, const char *message2) {
pushToastMessage(ToastMessagePage::create(INFO_TOAST, message1, message2));
}
Expand Down
5 changes: 4 additions & 1 deletion src/eez/gui/page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include <eez/gui/app_context.h>
#include <eez/modules/mcu/display.h>

#include <eez/modules/psu/psu.h>
#include <eez/modules/psu/gui/psu.h>

using namespace eez::mcu;

namespace eez {
Expand Down Expand Up @@ -108,7 +111,7 @@ ToastMessagePage *ToastMessagePage::create(ToastType type, const char *message1)
page->message3 = nullptr;

page->actionWidget.action = 0;
page->appContext = g_appContext;
page->appContext = &eez::psu::gui::g_psuAppContext;

return page;
}
Expand Down
73 changes: 40 additions & 33 deletions src/eez/modules/bp3c/flash_slave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,36 +463,44 @@ bool start(int slotIndex, const char *hexFilePath, int *err) {
}

void uploadHexFile() {
// uint8_t buffer[256];
// if (readMemory(0x08000000, buffer, sizeof(buffer))) {
// for (size_t i = 0; i < sizeof(buffer) / 16; i++) {
// for (size_t j = 0; j < 16; j++) {
// DebugTrace("%02x", (int)buffer[i * 16 + j]);
// }
// DebugTrace("\n");
// }
// }

uint8_t hour, minute, second;
psu::datetime::getTime(hour, minute, second);
DebugTrace("[%02d:%02d:%02d] Flash started\n", hour, minute, second);
// uint8_t buffer[256];
// if (readMemory(0x08000000, buffer, sizeof(buffer))) {
// for (size_t i = 0; i < sizeof(buffer) / 16; i++) {
// for (size_t j = 0; j < 16; j++) {
// DebugTrace("%02x", (int)buffer[i * 16 + j]);
// }
// DebugTrace("\n");
// }
// }

// uint8_t hour, minute, second;
// psu::datetime::getTime(hour, minute, second);
// DebugTrace("[%02d:%02d:%02d] Flash started\n", hour, minute, second);

bool eofReached = false;
File file;
size_t totalSize = 0;
HexRecord hexRecord;
uint32_t addressUpperBits = 0;

#if OPTION_DISPLAY
eez::psu::gui::PsuAppContext::showProgressPageWithoutAbort("Downloading firmware...");
#endif

if (!eraseAll()) {
DebugTrace("Failed to erase all!\n");
goto Exit;
}

if (!file.open(g_hexFilePath, FILE_OPEN_EXISTING | FILE_READ)) {
DebugTrace("Can't open firmware hex file!\n");
return;
goto Exit;
}

#if OPTION_DISPLAY
eez::psu::gui::PsuAppContext::showProgressPageWithoutAbort("Downloading firmware...");
size_t totalSize = file.size();
totalSize = file.size();
#endif

eraseAll();

HexRecord hexRecord;
uint32_t addressUpperBits = 0;
bool eofReached = false;
while (!eofReached && readHexRecord(file, hexRecord)) {

#if OPTION_DISPLAY
Expand All @@ -512,23 +520,22 @@ void uploadHexFile() {
}
}

if (eofReached) {
uint8_t hour, minute, second;
psu::datetime::getTime(hour, minute, second);
DebugTrace("[%02d:%02d:%02d] Flash finished\n", hour, minute, second);
} else {
uint8_t hour, minute, second;
psu::datetime::getTime(hour, minute, second);
DebugTrace("[%02d:%02d:%02d] Flash failed\n", hour, minute, second);
}
// uint8_t hour, minute, second;
// psu::datetime::getTime(hour, minute, second);
// DebugTrace("[%02d:%02d:%02d] Flash finished\n", hour, minute, second);

file.close();

Exit:
leaveBootloaderMode();

#if OPTION_DISPLAY
eez::psu::gui::g_psuAppContext.hideProgressPage();
#endif

file.close();

leaveBootloaderMode();
if (!eofReached) {
errorMessage("Downloading failed!");
}
}

} // namespace flash_slave
Expand Down
28 changes: 15 additions & 13 deletions src/eez/modules/psu/gui/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ PsuAppContext::PsuAppContext() {
}

void PsuAppContext::stateManagment() {
if (m_popProgressPage) {
if (getActivePageId() == (m_progressWithoutAbort ? PAGE_ID_PROGRESS_WITHOUT_ABORT : PAGE_ID_PROGRESS)) {
popPage();
}
m_popProgressPage = false;
}

if (m_clearTextMessage) {
m_clearTextMessage = false;
if (getActivePageId() == PAGE_ID_TEXT_MESSAGE) {
popPage();
m_textMessage[0] = 0;
}
}

AppContext::stateManagment();

uint32_t tickCount = micros();
Expand Down Expand Up @@ -274,26 +289,13 @@ void PsuAppContext::stateManagment() {
m_pushProgressPage = false;
}

if (m_popProgressPage) {
if (getActivePageId() == (m_progressWithoutAbort ? PAGE_ID_PROGRESS_WITHOUT_ABORT : PAGE_ID_PROGRESS)) {
popPage();
}
m_popProgressPage = false;
}

if (m_showTextMessage) {
m_showTextMessage = false;
if (getActivePageId() != PAGE_ID_TEXT_MESSAGE) {
pushPage(PAGE_ID_TEXT_MESSAGE);
} else {
++m_textMessageVersion;
}
} else if (m_clearTextMessage) {
m_clearTextMessage = false;
if (getActivePageId() == PAGE_ID_TEXT_MESSAGE) {
popPage();
m_textMessage[0] = 0;
}
} else {
// clear text message if active page is not PAGE_ID_TEXT_MESSAGE
if (getActivePageId() != PAGE_ID_TEXT_MESSAGE && m_textMessage[0]) {
Expand Down

0 comments on commit 0751c97

Please sign in to comment.