[ion/device] Lock OTP after writing version

This commit is contained in:
Gabriel Ozouf
2021-03-16 10:20:13 +01:00
committed by Gabriel
parent cbb435d656
commit ed18f1e95f
4 changed files with 10 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ void PCBVersion(const char * input) {
reply(sKO);
return;
}
Board::lockVersionOTP();
#endif
reply(sOK);
}

View File

@@ -240,6 +240,8 @@ PCBVersion readPCBVersionInMemory() {
void writePCBVersion(PCBVersion) {}
void lockVersionOTP() {}
}
}
}

View File

@@ -394,12 +394,17 @@ PCBVersion readPCBVersionInMemory() {
}
void writePCBVersion(PCBVersion version) {
/* TODO: We also need to lock the OTP in which the version has been written. */
uint8_t * destination = reinterpret_cast<uint8_t *>(InternalFlash::Config::OTPAddresses[pcbVersionOTPIndex]);
PCBVersion formattedVersion = ~version;
InternalFlash::WriteMemory(destination, reinterpret_cast<uint8_t *>(&formattedVersion), sizeof(formattedVersion));
}
void lockVersionOTP() {
uint8_t * destination = reinterpret_cast<uint8_t *>(InternalFlash::Config::OTPLocksAddress + pcbVersionOTPIndex);
uint8_t zero = 0x00;
InternalFlash::WriteMemory(destination, &zero, sizeof(zero));
}
}
}
}

View File

@@ -30,6 +30,7 @@ typedef uint32_t PCBVersion;
PCBVersion readPCBVersion();
PCBVersion readPCBVersionInMemory();
void writePCBVersion(PCBVersion version);
void lockVersionOTP();
}
}