Update the firmware. Prerequisites should be checked before calling this.
| 2723 | |
| 2724 | // Update the firmware. Prerequisites should be checked before calling this. |
| 2725 | void RepRap::UpdateFirmware(c_string iapFilename, c_string iapParam) noexcept |
| 2726 | { |
| 2727 | FileStore *_ecv_null iapFile = platform->OpenFile(FIRMWARE_DIRECTORY, iapFilename, OpenMode::read); |
| 2728 | if (iapFile == nullptr) |
| 2729 | { |
| 2730 | iapFile = platform->OpenFile(DEFAULT_SYS_DIR, iapFilename, OpenMode::read); |
| 2731 | if (iapFile == nullptr) |
| 2732 | { |
| 2733 | // This should not happen because we already checked that the file exists, so use a simplified error message |
| 2734 | platform->Message(FirmwareUpdateMessage, "Missing IAP"); |
| 2735 | return; |
| 2736 | } |
| 2737 | } |
| 2738 | |
| 2739 | PrepareToLoadIap(); |
| 2740 | |
| 2741 | // Use RAM-based IAP |
| 2742 | iapFile->Read(reinterpret_cast<char *_ecv_array>(IAP_IMAGE_START), iapFile->Length()); |
| 2743 | iapFile->Close(); |
| 2744 | StartIap(iapParam); |
| 2745 | } |
| 2746 | |
| 2747 | #endif |
| 2748 |