Skip to content

Commit

Permalink
Add option to ignore already-set bits in otp set (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
will-v-pi committed Nov 20, 2024
1 parent fb85aca commit 1f82cb3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1071,6 +1072,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', "--ignore-set").set(settings.otp.ignore_set) % "Ignore any already-set bits" +
(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" +
(
Expand Down Expand Up @@ -7103,6 +7105,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");
Expand Down

0 comments on commit 1f82cb3

Please sign in to comment.