meier/plocSupervisor #89
@ -926,7 +926,7 @@ candump can0
|
|||||||
|
|
||||||
## Dump content of file in hex
|
## Dump content of file in hex
|
||||||
````
|
````
|
||||||
cat file.bin | hexdump
|
cat file.bin | hexdump -C
|
||||||
````
|
````
|
||||||
|
|
||||||
## Preparation of a fresh rootfs and SD card
|
## Preparation of a fresh rootfs and SD card
|
||||||
|
@ -292,7 +292,7 @@ void PlocUpdater::commandUpdateAvailable() {
|
|||||||
remainingPackets = numOfUpdatePackets;
|
remainingPackets = numOfUpdatePackets;
|
||||||
packetsSent = 0;
|
packetsSent = 0;
|
||||||
|
|
||||||
uint32_t imageCrc = makeCrc();
|
calcImageCrc();
|
||||||
|
|
||||||
PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast<uint8_t>(updateMemory),
|
PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast<uint8_t>(updateMemory),
|
||||||
static_cast<uint8_t>(updatePartition), imageSize, imageCrc, numOfUpdatePackets);
|
static_cast<uint8_t>(updatePartition), imageSize, imageCrc, numOfUpdatePackets);
|
||||||
@ -338,7 +338,7 @@ void PlocUpdater::commandUpdatePacket() {
|
|||||||
file.close();
|
file.close();
|
||||||
// sequence count of first packet is 1
|
// sequence count of first packet is 1
|
||||||
packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK);
|
packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK);
|
||||||
if (numOfUpdatePackets > 0) {
|
if (numOfUpdatePackets > 1) {
|
||||||
adjustSequenceFlags(packet);
|
adjustSequenceFlags(packet);
|
||||||
}
|
}
|
||||||
packet.makeCrc();
|
packet.makeCrc();
|
||||||
@ -383,9 +383,27 @@ void PlocUpdater::commandUpdateVerify() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PlocUpdater::makeCrc() {
|
void PlocUpdater::calcImageCrc() {
|
||||||
//TODO: Waiting on input from TAS about the CRC to use
|
std::ifstream file(updateFile, std::ifstream::binary);
|
||||||
return 0;
|
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) {
|
void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) {
|
||||||
|
@ -92,6 +92,11 @@ private:
|
|||||||
// Maximum size of update payload data per space packet (max size of space packet is 1024 bytes)
|
// Maximum size of update payload data per space packet (max size of space packet is 1024 bytes)
|
||||||
static const size_t MAX_SP_DATA = 1016;
|
static const size_t MAX_SP_DATA = 1016;
|
||||||
|
|
||||||
|
static const uint32_t TOPBIT_32 = (1 << 31);
|
||||||
|
static const uint32_t POLYNOMIAL_32 = 0x04C11DB7;
|
||||||
|
static const uint32_t INITIAL_REMAINDER_32 = 0xFFFFFFFF;
|
||||||
|
static const uint32_t FINAL_XOR_VALUE_32 = 0xFFFFFFFF;
|
||||||
|
|
||||||
MessageQueueIF* commandQueue = nullptr;
|
MessageQueueIF* commandQueue = nullptr;
|
||||||
|
|
||||||
#if BOARD_TE0720 == 0
|
#if BOARD_TE0720 == 0
|
||||||
@ -168,7 +173,7 @@ private:
|
|||||||
bool isSdCardMounted(sd::SdCard sdCard);
|
bool isSdCardMounted(sd::SdCard sdCard);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ReturnValue_t makeCrc();
|
void calcImageCrc();
|
||||||
|
|
||||||
void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet);
|
void adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet);
|
||||||
};
|
};
|
||||||
|
@ -1453,7 +1453,7 @@ public:
|
|||||||
UpdateInfo(uint16_t apid, uint8_t memory, uint8_t partition, uint32_t imageSize,
|
UpdateInfo(uint16_t apid, uint8_t memory, uint8_t partition, uint32_t imageSize,
|
||||||
uint32_t imageCrc, uint32_t numPackets) :
|
uint32_t imageCrc, uint32_t numPackets) :
|
||||||
SupvTcSpacePacket(PAYLOAD_LENGTH, apid), memory(memory), partition(partition), imageSize(
|
SupvTcSpacePacket(PAYLOAD_LENGTH, apid), memory(memory), partition(partition), imageSize(
|
||||||
imageSize), numPackets(numPackets) {
|
imageSize), imageCrc(imageCrc), numPackets(numPackets) {
|
||||||
initPacket();
|
initPacket();
|
||||||
makeCrc();
|
makeCrc();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user