diff --git a/include/icsneo/device/bootloaderpipeline.h b/include/icsneo/device/bootloaderpipeline.h index 5ed53268..acb84fd7 100644 --- a/include/icsneo/device/bootloaderpipeline.h +++ b/include/icsneo/device/bootloaderpipeline.h @@ -91,9 +91,10 @@ struct FlashPhase : public BootloaderPhase { bool authenticate = true; bool encrypt = true; bool checkOutOfDate = true; + uint8_t slot = UINT8_MAX; - FlashPhase(ChipID chip, BootloaderCommunication comm, bool authenticate = true, bool encrypt = true, bool checkOutOfDate = true) - : chip(chip), comm(comm), authenticate(authenticate), encrypt(encrypt), checkOutOfDate(checkOutOfDate) {} + FlashPhase(ChipID chip, BootloaderCommunication comm, bool authenticate = true, bool encrypt = true, bool checkOutOfDate = true, uint8_t slot = UINT8_MAX) + : chip(chip), comm(comm), authenticate(authenticate), encrypt(encrypt), checkOutOfDate(checkOutOfDate), slot(slot) {} }; enum class BootloaderSetting { diff --git a/include/icsneo/device/tree/radgigastar/radgigastar.h b/include/icsneo/device/tree/radgigastar/radgigastar.h index e09cf719..97735bd6 100644 --- a/include/icsneo/device/tree/radgigastar/radgigastar.h +++ b/include/icsneo/device/tree/radgigastar/radgigastar.h @@ -87,9 +87,32 @@ public: } BootloaderPipeline pipeline; + auto compVersions = getComponentVersions(); for(size_t i = 0; i < chipVersions.size(); i++) { const auto& version = chipVersions[i]; - pipeline.add(version.id, BootloaderCommunication::RADMultiChip, i == 0); + auto it = compVersions.begin(); + std::vector sameIdComponents; + while(it != compVersions.end()) { + it = std::find_if(it, compVersions.end(), [&version](const auto& component) { + return (ChipID)component.identifier == version.id; + }); + if (it != compVersions.end()) { + sameIdComponents.push_back(*it); + it++; + } + } + if (sameIdComponents.size() > 1) { + std::vector tempCompVersions; + for (const auto& component : compVersions) { + if ((ChipID)component.identifier != version.id || component.expansionSlot != sameIdComponents[0].expansionSlot) { + tempCompVersions.push_back(component); + } + } + compVersions = std::move(tempCompVersions); + } + if (!sameIdComponents.empty()) { + pipeline.add(version.id, BootloaderCommunication::RADMultiChip, i == 0, true, true, sameIdComponents[0].expansionSlot); + } } pipeline.add(mainChipID); pipeline.add(std::chrono::milliseconds(3000)); diff --git a/include/icsneo/device/tree/radgigastar2/radgigastar2.h b/include/icsneo/device/tree/radgigastar2/radgigastar2.h index 2f9b02df..51afec1a 100644 --- a/include/icsneo/device/tree/radgigastar2/radgigastar2.h +++ b/include/icsneo/device/tree/radgigastar2/radgigastar2.h @@ -171,9 +171,32 @@ public: } BootloaderPipeline pipeline; + auto compVersions = getComponentVersions(); for(size_t i = 0; i < chipVersions.size(); i++) { const auto& version = chipVersions[i]; - pipeline.add(version.id, BootloaderCommunication::RADMultiChip, i == 0); + auto it = compVersions.begin(); + std::vector sameIdComponents; + while(it != compVersions.end()) { + it = std::find_if(it, compVersions.end(), [&version](const auto& component) { + return (ChipID)component.identifier == version.id; + }); + if (it != compVersions.end()) { + sameIdComponents.push_back(*it); + it++; + } + } + if (sameIdComponents.size() > 1) { + std::vector tempCompVersions; + for (const auto& component : compVersions) { + if ((ChipID)component.identifier != version.id || component.expansionSlot != sameIdComponents[0].expansionSlot) { + tempCompVersions.push_back(component); + } + } + compVersions = std::move(tempCompVersions); + } + if (!sameIdComponents.empty()) { + pipeline.add(version.id, BootloaderCommunication::RADMultiChip, i == 0, true, true, sameIdComponents[0].expansionSlot); + } } pipeline.add(mainChipID); pipeline.add(std::chrono::milliseconds(3000));