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

Conversation

will-v-pi
Copy link

This adds a way to set bits in an OTP row, without having to specify a field - for example for the page lock rows

Allows you to workaround this (for example)

$ picotool otp set crit1 0x1
ROW 0x0040  OLD_VALUE=0x000000: OTP_DATA_CRIT1
        "Page 1 critical boot flags (RBIT-8)"
$ picotool otp set crit1 0x2
ROW 0x0040  OLD_VALUE=0x000001: OTP_DATA_CRIT1
        "Page 1 critical boot flags (RBIT-8)"
ERROR: Cannot clear bits in OTP row(s): current value 000001, new value 000002

using the -s argument

$ picotool otp set crit1 0x2 -s
ROW 0x0040  OLD_VALUE=0x000001: OTP_DATA_CRIT1
        "Page 1 critical boot flags (RBIT-8)"
$ picotool otp get crit1
ROW 0x0040: OTP_DATA_CRIT1
        "Page 1 critical boot flags (RBIT-8)"

    VALUE 0x000003

    field GLITCH_DETECTOR_SENS (bits 5-6) = 0
        "Increase the sensitivity of the glitch detectors from their default."
    field GLITCH_DETECTOR_ENABLE (bit 4) = 0
        "Arm the glitch detectors to reset the system if an abnormal clock/power event is observed."
    field BOOT_ARCH (bit 3) = 0
        "Set the default boot architecture, 0=ARM 1=RISC-V. Ignored if ARM_DISABLE, RISCV_DISABLE or SECURE_BOOT_ENABLE is set."
    field DEBUG_DISABLE (bit 2) = 0
        "Disable all debug access"
    field SECURE_DEBUG_DISABLE (bit 1) = 1
        "Disable Secure debug access"
    field SECURE_BOOT_ENABLE (bit 0) = 1
        "Enable boot signature enforcement, and permanently disable the RISC-V cores."

Fixes #137

@will-v-pi will-v-pi added this to the 2.1.0 milestone Nov 12, 2024
@will-v-pi will-v-pi linked an issue Nov 12, 2024 that may be closed by this pull request
@lurch
Copy link
Contributor

lurch commented Nov 18, 2024

ERROR: Cannot clear bits in OTP row(s): current value 000001, new value 000002

I wonder if this error message should point people at the -s option?

Also, this PR should probably update https://github.com/raspberrypi/picotool/tree/develop?tab=readme-ov-file#otp too?

Copy link
Contributor

@kilograham kilograham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

's' is OK, but I think ignore-set is confusing... I think set-bits-only (or probably just set-bits)-is better, and we should probably disallow it with ECC

@lurch
Copy link
Contributor

lurch commented Nov 19, 2024

's' is OK, but I think ignore-set is confusing... I think set-bits-only (or probably just set-bits)-is better, and we should probably disallow it with ECC

Or I guess you could use:

option('o', "--or-existing").set(settings.otp.or_with_existing) % "Logically OR with any already-set bits"

?
But I'm not familiar enough with OTP and its usage, to know if that's actually a sensible suggestion or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to OR values into non ECC rows
3 participants