Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to ignore already-set bits in otp set command #175

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,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 @@ -1070,6 +1071,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 @@ -7082,6 +7084,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
Loading