MCPcopy Create free account
hub / github.com/SmingHub/Sming / verifyRoms

Method verifyRoms

Sming/Libraries/OtaUpgrade/OtaUpgrade/BasicStream.cpp:95–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void BasicStream::verifyRoms()
96{
97 state = State::RomsComplete;
98
99 debug_d("Signature/Checksum: %s", makeHexString(verificationData.data(), verificationData.size(), ' ').c_str());
100
101 if(!verifier.verify(verificationData)) {
102 if(slot.updated) {
103 // Destroy start sector of updated ROM to avoid accidentally booting an unsanctioned firmware
104 Storage::spiFlash->erase_range(slot.partition.address(), Storage::spiFlash->getBlockSize());
105 }
106 setError(Error::VerificationFailed);
107 return;
108 }
109
110 // In a future extension, there might be OTA files without ROM images (SPIFFS-only update, etc.)
111 if(fileHeader.romCount == 0) {
112 return;
113 }
114
115 debug_i("ROM update complete");
116 if(!slot.updated) {
117 setError(Error::NoRomFound);
118 return;
119 }
120
121 if(ota.setBootPartition(slot.partition)) {
122 debug_i("ROM %u activated", toLongString(slot.partition.type(), slot.partition.subType()).c_str());
123 } else {
124 setError(Error::RomActivationFailed);
125 }
126}
127
128size_t BasicStream::write(const uint8_t* data, size_t size)
129{

Callers

nothing calls this directly

Calls 12

makeHexStringFunction · 0.85
dataMethod · 0.80
addressMethod · 0.80
subTypeMethod · 0.80
toLongStringFunction · 0.50
c_strMethod · 0.45
sizeMethod · 0.45
verifyMethod · 0.45
erase_rangeMethod · 0.45
getBlockSizeMethod · 0.45
setBootPartitionMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected