Skip to content

Commit

Permalink
Add option to ignore already-set bits in otp set command (#175)
Browse files Browse the repository at this point in the history
Adds -s, --set-bits option to otp set command
  • Loading branch information
will-v-pi authored Nov 21, 2024
1 parent 4a403bb commit fa69a49
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 @@ -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" +
(
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit fa69a49

Please sign in to comment.