diff --git a/ion/src/device/bench/command/pcb_version.cpp b/ion/src/device/bench/command/pcb_version.cpp index 190ea7274..99f1e29f0 100644 --- a/ion/src/device/bench/command/pcb_version.cpp +++ b/ion/src/device/bench/command/pcb_version.cpp @@ -23,6 +23,7 @@ void PCBVersion(const char * input) { reply(sKO); return; } + Board::lockVersionOTP(); #endif reply(sOK); } diff --git a/ion/src/device/n0100/drivers/board.cpp b/ion/src/device/n0100/drivers/board.cpp index cd9ebad17..bd1345a4d 100644 --- a/ion/src/device/n0100/drivers/board.cpp +++ b/ion/src/device/n0100/drivers/board.cpp @@ -240,6 +240,8 @@ PCBVersion readPCBVersionInMemory() { void writePCBVersion(PCBVersion) {} +void lockVersionOTP() {} + } } } diff --git a/ion/src/device/n0110/drivers/board.cpp b/ion/src/device/n0110/drivers/board.cpp index c7d8391eb..bcb354d02 100644 --- a/ion/src/device/n0110/drivers/board.cpp +++ b/ion/src/device/n0110/drivers/board.cpp @@ -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(InternalFlash::Config::OTPAddresses[pcbVersionOTPIndex]); PCBVersion formattedVersion = ~version; InternalFlash::WriteMemory(destination, reinterpret_cast(&formattedVersion), sizeof(formattedVersion)); } +void lockVersionOTP() { + uint8_t * destination = reinterpret_cast(InternalFlash::Config::OTPLocksAddress + pcbVersionOTPIndex); + uint8_t zero = 0x00; + InternalFlash::WriteMemory(destination, &zero, sizeof(zero)); +} + } } } diff --git a/ion/src/device/shared/drivers/board.h b/ion/src/device/shared/drivers/board.h index 9bbe9b62a..68dcaa2be 100644 --- a/ion/src/device/shared/drivers/board.h +++ b/ion/src/device/shared/drivers/board.h @@ -30,6 +30,7 @@ typedef uint32_t PCBVersion; PCBVersion readPCBVersion(); PCBVersion readPCBVersionInMemory(); void writePCBVersion(PCBVersion version); +void lockVersionOTP(); } }