From fa69a49bfb92fa56d44e29739b05340a8e2d2ee2 Mon Sep 17 00:00:00 2001 From: will-v-pi <108662275+will-v-pi@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:13:11 +0000 Subject: [PATCH] Add option to ignore already-set bits in otp set command (#175) Adds -s, --set-bits option to otp set command --- main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.cpp b/main.cpp index e769afb..1f75cd3 100644 --- a/main.cpp +++ b/main.cpp @@ -417,6 +417,7 @@ struct _settings { int redundancy = -1; bool raw = false; bool ecc = false; + bool ignore_set = false; bool fuzzy = false; uint32_t value = 0; uint8_t lock0 = 0; @@ -1067,6 +1068,7 @@ struct otp_set_command : public cmd { (option('c', "--copies") & integer("copies").min(1).set(settings.otp.redundancy)) % "Read multiple redundant values" + option('r', "--raw").set(settings.otp.raw) % "Set raw 24 bit values" + option('e', "--ecc").set(settings.otp.ecc) % "Use error correction" + + option('s', "--set-bits").set(settings.otp.ignore_set) % "Set bits only" + (option('i', "--include") & value("filename").add_to(settings.otp.extra_files)).min(0).max(1) % "Include extra otp definition" // todo more than 1 ).min(0).doc_non_optional(true) % "Redundancy/Error Correction Overrides" + ( @@ -7318,6 +7320,10 @@ bool otp_set_command::execute(device_map &devices) { settings.otp.value &= field->mask; settings.otp.value |= old_raw_value & ~field->mask; } + if (settings.otp.ignore_set) { + // OR with current value, to ignore any already-set bits + settings.otp.value |= old_raw_value; + } // todo check for clearing bits if (old_raw_value && settings.otp.ecc) { fail(ERROR_NOT_POSSIBLE, "Cannot modify OTP ECC row(s)\n");