raspberrypi / pico-examples

BSD 3-Clause "New" or "Revised" License
2.94k stars 844 forks source link

otp/hello_otp example problem #554

Closed Octopus1633 closed 1 month ago

Octopus1633 commented 1 month ago

Hi, I am running the otp/hello_otp example, why does the output show that the first write fails for both ECC and RAW, is this normal, is there any problem?

企业微信截图_17273176772738
will-v-pi commented 1 month ago

Is this your second time running the example? This example will only work correctly when run for the first time on a board as it modifies the OTP (One-Time-Programable Memory), so if you run it a second time on the same board it will throw these errors - this bootrom error is documented in the SDK

#define BOOTROM_ERROR_UNSUPPORTED_MODIFICATION (-18) // Write is impossible based on previous writes; e.g. attempted to clear an OTP bit

If you want to run this example again on the same board, you can modify the OTP rows used by the example - again, this will only work the first time for each set of OTP rows used

    // Row to write ECC data
    uint16_t ecc_row = 0x400;
    // Row to write raw data
    uint16_t raw_row = 0x410;
Octopus1633 commented 1 month ago

Thank you for your patience. After changing the address, I successfully ran the program again.

企业微信截图_17273477136502
lurch commented 1 month ago

@will-v-pi I wonder if it'd be useful if that example was modified to print out the existing OTP row contents before atempting to write to them, and/or check that the rows are indeed empty before trying to modify them? :thinking: (he blindly suggests, knowing very little about OTP!)

will-v-pi commented 1 month ago

Yeah, that sounds sensible - if the rows are non-zero then it can just throw an error and stop