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

OTP_DATA_PAGE1_LOCK1 set BL lock error #2

Open
maximus64 opened this issue Sep 6, 2024 · 3 comments
Open

OTP_DATA_PAGE1_LOCK1 set BL lock error #2

maximus64 opened this issue Sep 6, 2024 · 3 comments

Comments

@maximus64
Copy link

maximus64 commented Sep 6, 2024

Followed the instruction to lock chip but encounter error when burn lock for OTP_DATA_PAGE1_LOCK1 and OTP_DATA_PAGE2_LOCK1

ERROR: Cannot clear bits in OTP row(s): current value 040404, new value 101010

With fresh Pico 2 board, this value already programmed to 0x040404 and when run ./lock_chip.sh it refuse to burn since bit 3 is already set.

I think the script need to update to follow:

# Lock writes to PAGE1
picotool otp set --raw OTP_DATA_PAGE1_LOCK1 0x141414
picotool otp set --raw OTP_DATA_PAGE2_LOCK1 0x141414

So what is the actual OTP lock configuration of the Golden unit? is it will be 0x141414 or 0x101010?

Log:

$ ./lock_chip.sh 
Are you sure you want to fully lock down the chip?
Please type PLEASE LOCK to continue
PLEASE LOCK
ROW 0x0040  OLD_VALUE=0x000001: OTP_DATA_CRIT1
        "Page 1 critical boot flags (RBIT-8)"
    field DEBUG_DISABLE (bit 2)
ROW 0x004b  OLD_VALUE=0x000001: OTP_DATA_BOOT_FLAGS1
        "Disable/Enable boot paths/features in the RP2350 mask ROM. Disables always supersede enables. Enables are provided where there are other
        configurations in OTP that must be valid. (RBIT-3)"
    field KEY_INVALID (bits 8-11)
ROW 0x0040  OLD_VALUE=0x000005: OTP_DATA_CRIT1
        "Page 1 critical boot flags (RBIT-8)"
    field GLITCH_DETECTOR_ENABLE (bit 4)
ROW 0x0040  OLD_VALUE=0x000015: OTP_DATA_CRIT1
        "Page 1 critical boot flags (RBIT-8)"
    field GLITCH_DETECTOR_SENS (bits 5-6)
ROW 0x0f83  OLD_VALUE=0x040404: OTP_DATA_PAGE1_LOCK1
        "Lock configuration MSBs for page 1 (rows 0x40 through 0x7f). Locks are stored with 3-way majority vote encoding, so that bits can be set
        independently. This OTP location is always readable, and is write-protected by its own permissions."
ERROR: Cannot clear bits in OTP row(s): current value 040404, new value 101010

ROW 0x0f85  OLD_VALUE=0x040404: OTP_DATA_PAGE2_LOCK1
        "Lock configuration MSBs for page 2 (rows 0x80 through 0xbf). Locks are stored with 3-way majority vote encoding, so that bits can be set
        independently. This OTP location is always readable, and is write-protected by its own permissions."
ERROR: Cannot clear bits in OTP row(s): current value 040404, new value 101010
@maximus64 maximus64 changed the title OTP_DATA_PAGE1_LOCK1 set BL look error OTP_DATA_PAGE1_LOCK1 set BL lock error Sep 6, 2024
@polhenarejos
Copy link

polhenarejos commented Sep 7, 2024

I confirm that picotool otp get OTP_DATA_PAGE1_LOCK1 and picotool otp get OTP_DATA_PAGE2_LOCK1 both return 0x040404 on a fresh new RP2350.

This is expected from the datasheet:

The main controls for the bootrom are stored in BOOT_FLAGS0 and BOOT_FLAGS1. These are both in page 1 of OTP,
which has the following default permissions on a blank device:
• Read-write for Secure (S)
• Read-write for bootloader (BL)
• Read-only for Non-secure (NS)

which is equivalent to 0x4.

Boot key hashes are stored in page 2 of OTP, starting from BOOTKEY0_0. There is space for up to four boot key hashes
in this page

Here, the datasheet does not say anything related with PAGE2_LOCK1 default permission, but it seems it uses the same: RW for S, RW for BL and RO for NS. So, NS cannot write BOOTKEYs.

@abdalrahimnaser
Copy link

Hey guys, would you be interested in teaming up to tackle this challenge?

@polhenarejos
Copy link

Sure, what would you need?

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

No branches or pull requests

3 participants