Implement reboot to new image

This commit is contained in:
Michael Ehrenreich
2022-06-27 01:28:59 +02:00
parent fc6fbd083d
commit f3603870fa

View File

@ -178,6 +178,8 @@ protocol::serial::Feedback feedback;
#ifdef FEATURE_CAN #ifdef FEATURE_CAN
std::atomic<int16_t> timeoutCntLeft = 0; std::atomic<int16_t> timeoutCntLeft = 0;
std::atomic<int16_t> timeoutCntRight = 0; std::atomic<int16_t> timeoutCntRight = 0;
uint32_t *reboot_request_address = 0;
#endif #endif
uint32_t main_loop_counter; uint32_t main_loop_counter;
@ -252,6 +254,7 @@ void parseCanCommand();
void applyIncomingCanMessage(); void applyIncomingCanMessage();
void sendCanFeedback(); void sendCanFeedback();
void sendFlasherFeedback(); void sendFlasherFeedback();
void handleFlasher();
#endif #endif
#ifdef FEATURE_BUTTON #ifdef FEATURE_BUTTON
@ -410,7 +413,7 @@ int main()
parseCanCommand(); parseCanCommand();
sendCanFeedback(); sendCanFeedback();
sendFlasherFeedback(); handleFlasher();
#endif #endif
#ifdef FEATURE_BUTTON #ifdef FEATURE_BUTTON
@ -1670,11 +1673,21 @@ void applyIncomingCanMessage()
break; break;
case MotorController<isBackBoard, false>::Command::Poweroff: case MotorController<isBackBoard, false>::Command::Poweroff:
case MotorController<isBackBoard, true>::Command::Poweroff: case MotorController<isBackBoard, true>::Command::Poweroff:
{
if (header.DLC >= 2)
{
// Reboot selected image
reboot_request_address = (uint32_t *)((*(uint8_t *)buf == 0) ? APP_A_START : APP_B_START);
}
else
{
#ifdef FEATURE_BUTTON #ifdef FEATURE_BUTTON
if (*((bool*)buf)) if (*((bool*)buf))
poweroff(); poweroff();
#endif #endif
break; }
break;
}
default: default:
#ifndef CAN_LOG_UNKNOWN_ADDR #ifndef CAN_LOG_UNKNOWN_ADDR
if constexpr (false) if constexpr (false)
@ -1798,6 +1811,16 @@ void sendFlasherFeedback() {
//while (true); //while (true);
} }
} }
void handleFlasher()
{
sendFlasherFeedback();
if (reboot_request_address)
{
reboot_new_image(reboot_request_address);
}
}
#endif #endif
#ifdef FEATURE_BUTTON #ifdef FEATURE_BUTTON