crc for ploc update
This commit is contained in:
@ -292,7 +292,7 @@ void PlocUpdater::commandUpdateAvailable() {
|
||||
remainingPackets = numOfUpdatePackets;
|
||||
packetsSent = 0;
|
||||
|
||||
uint32_t imageCrc = makeCrc();
|
||||
calcImageCrc();
|
||||
|
||||
PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast<uint8_t>(updateMemory),
|
||||
static_cast<uint8_t>(updatePartition), imageSize, imageCrc, numOfUpdatePackets);
|
||||
@ -338,7 +338,7 @@ void PlocUpdater::commandUpdatePacket() {
|
||||
file.close();
|
||||
// sequence count of first packet is 1
|
||||
packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK);
|
||||
if (numOfUpdatePackets > 0) {
|
||||
if (numOfUpdatePackets > 1) {
|
||||
adjustSequenceFlags(packet);
|
||||
}
|
||||
packet.makeCrc();
|
||||
@ -383,9 +383,27 @@ void PlocUpdater::commandUpdateVerify() {
|
||||
return;
|
||||
}
|
||||
|
||||
ReturnValue_t PlocUpdater::makeCrc() {
|
||||
//TODO: Waiting on input from TAS about the CRC to use
|
||||
return 0;
|
||||
void PlocUpdater::calcImageCrc() {
|
||||
std::ifstream file(updateFile, std::ifstream::binary);
|
||||
file.seekg(0, file.end);
|
||||
uint32_t count;
|
||||
uint32_t bit;
|
||||
uint32_t remainder = INITIAL_REMAINDER_32;
|
||||
char input;
|
||||
for (count = 0; count < imageSize; count++) {
|
||||
file.seekg(count, file.beg);
|
||||
file.read(&input, 1);
|
||||
remainder ^= (input << 16);
|
||||
for (bit = 8; bit > 0; --bit) {
|
||||
if (remainder & TOPBIT_32) {
|
||||
remainder = (remainder << 1) ^ POLYNOMIAL_32;
|
||||
} else {
|
||||
remainder = (remainder << 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
imageCrc = (remainder ^ FINAL_XOR_VALUE_32);
|
||||
}
|
||||
|
||||
void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) {
|
||||
|
Reference in New Issue
Block a user