[ion/device] Adapt behaviour in factory

When flashing fo the first time, we need Epsilon to know the PCB version
before the OTP are flashed. We also need the to prevent Epsilon from
writing the OTP outside of the factory.
This commit is contained in:
Gabriel Ozouf
2021-03-15 17:50:07 +01:00
committed by Gabriel
parent 00b74430cd
commit cbb435d656
4 changed files with 24 additions and 3 deletions

View File

@@ -12,11 +12,18 @@ void PCBVersion(const char * input) {
return;
}
/* When running the bench for a diagnostic, we must absolutely not write the
* OTP, as N0110 built prior to the PCB revision would still have their OTP
* blank and unlocked. */
#if IN_FACTORY
Board::writePCBVersion(PCB_LATEST);
if (Board::readPCBVersion() != PCB_LATEST) {
/* Read directly from memory, as when IN_FACTORY is true, the method
* readPCBVersion always returns PCB_LATEST. */
if (Board::readPCBVersionInMemory() != PCB_LATEST) {
reply(sKO);
return;
}
#endif
reply(sOK);
}

View File

@@ -234,6 +234,10 @@ PCBVersion readPCBVersion() {
return PCB_LATEST;
}
PCBVersion readPCBVersionInMemory() {
return PCB_LATEST;
}
void writePCBVersion(PCBVersion) {}
}

View File

@@ -379,8 +379,17 @@ constexpr int pcbVersionOTPIndex = 0;
* version number. This way, devices with blank OTP are considered version 0. */
PCBVersion readPCBVersion() {
/* FIXME: When flashing for the first time after assembling the device, this
* should return PCB_LATEST. */
#if IN_FACTORY
/* When flashing for the first time, we want all systems that depend on the
* PCB version to function correctly before flashing the PCB version. This
* way, flashing the PCB version can be done last. */
return PCB_LATEST;
#else
return readPCBVersionInMemory();
#endif
}
PCBVersion readPCBVersionInMemory() {
return ~*reinterpret_cast<const PCBVersion *>(InternalFlash::Config::OTPAddresses[pcbVersionOTPIndex]);
}

View File

@@ -28,6 +28,7 @@ void setClockFrequency(Frequency f);
typedef uint32_t PCBVersion;
PCBVersion readPCBVersion();
PCBVersion readPCBVersionInMemory();
void writePCBVersion(PCBVersion version);
}