mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -234,6 +234,10 @@ PCBVersion readPCBVersion() {
|
||||
return PCB_LATEST;
|
||||
}
|
||||
|
||||
PCBVersion readPCBVersionInMemory() {
|
||||
return PCB_LATEST;
|
||||
}
|
||||
|
||||
void writePCBVersion(PCBVersion) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ void setClockFrequency(Frequency f);
|
||||
typedef uint32_t PCBVersion;
|
||||
|
||||
PCBVersion readPCBVersion();
|
||||
PCBVersion readPCBVersionInMemory();
|
||||
void writePCBVersion(PCBVersion version);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user