Current state of affairs is now reflected by following PR (which is both to/from my own fork, and should never be merged … it’s only for those curious…)
main
← otp_upstream_dev
opened 01:53AM - 09 Mar 25 UTC
Recommended review is done by reviewing each individual commit, not the sum tota… l of changes.
No guarantees that the code at any given commit works correctly.
Testing is still needed.
Generally, this branch includes:
* Whitelabeling of buspirate boards that are based on RP2350 cpus (BP5XL, BP6, ...)
* Read-only OTP Directory APIs to quickly and easily find information stored in the OTP
* `void bp_otpdir_reset_iterator(void)` -- resets the iterator. state is kept per-CPU for now.
* `bool bp_otpdir_find_next_entry(void)` -- moves the iterator to the next entry. return `false` when no more entries exist.
* `BP_OTPDIR_ENTRY_TYPE bp_otpdir_get_current_entry_type(void)` -- what's the type of the current entry? there is a defined type for the end-of-directory, which is returned when iterator is at the end.
* `size_t bp_otpdir_get_current_entry_buffer_size(void)` -- returns the required size of buffer for the data referenced by the current entry
* `bool bp_otpdir_get_current_entry_data(void* buffer, size_t buffer_size)` -- reads the data from OTP on behalf of the caller, and if successful, fills the caller-supplied buffer. Automatically handles the data encoding used by the entry.
* Helper APIs for adding an entry to the OTP directory.
* `bool bp_otpdir_add_ecc_entry(BP_OTPDIR_ENTRY_TYPE entryType, uint16_t start_row, uint16_t row_count, size_t valid_byte_count)` -- Verifies the encoding type is a known ECC encoding type. Verifies `valid_byte_count` is reasonable and corresponds to the row count. Attempts to read all rows as ECC data. For ECC_STRING encoding, verifies the first NULL byte corresponds to the `valid_byte_count` parameter.
* Additional helper APIs can be added later, if any encoding type other than ECC or ECC_STRING is used. This single API is sufficient to add any data stored using ECC.
Found a nasty bug that’d corrupt the OTP. Still lots more testing to do.
The OTPDIR functionality has a framework which will likely work well, but it’s entirely untested code. On the plus side, it has a ton of RTT debug output. Externally-facing API is next up (and summarized in the above PR).
1 Like