One-Time Programmable Storage (machine.OTP) API Reference#
Overview#
CanMV K230 provides the OTP (One-Time Programmable, one-time programmable memory) class for reading chip OTP data and querying the read/write lock status of a specified address.
The OTP object is a singleton. Repeated calls to OTP() return the same instance.
API Reference#
The OTP class is located under the machine module.
Example#
from machine import OTP
import binascii
otp = OTP()
data = otp.read(0x000, 32)
print(binascii.hexlify(data))
lock = otp.get_lock(0x000)
if lock == OTP.NA:
print("No Access")
elif lock == OTP.RO:
print("Read Only")
elif lock == OTP.RW:
print("Read Write")
Constructor#
Syntax
otp = OTP()
Parameters
None.
Return Value
Returns the OTP singleton object.
read#
Description
Reads byte data from the specified OTP address.
Syntax
data = otp.read(addr, length)
Parameters
Parameter Name |
Description |
|---|---|
|
Starting address for reading, ranging from |
|
Read length, ranging from 1 to 1024 bytes |
Return Value
Returns the read OTP data as bytes.
Notes
addr + lengthmust not exceed the total OTP range.A single read cannot cross the
0x400boundary.
get_lock#
Description
Queries the read/write lock status of the specified OTP address.
Syntax
lock = otp.get_lock(addr)
Parameters
Parameter Name |
Description |
|---|---|
|
OTP address to query, ranging from |
Return Value
Returns the lock status as an integer, which can be compared with the following constants:
Constant |
Value |
Description |
|---|---|---|
|
0 |
No Access, inaccessible |
|
1 |
Read Only, read-only |
|
2 |
Read Write, readable and writable |
Constants#
Constant |
Description |
|---|---|
|
OTP address is inaccessible |
|
OTP address is read-only |
|
OTP address is readable and writable |
Notes#
The OTP may store device security configuration or identity-related information. Before printing or saving it, please confirm the use case.
The current
machine.OTPonly provides interfaces for reading and querying the lock status; it does not provide interfaces for writing or locking.
