PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches

One-time programmable slots holding factory data. More...

Enumerations

enum  { OTP_HWVER = 0 , OTP_SERIAL = 1 , OTP_PCBA_SERIAL = 2 , NUM_OTP_SLOTS = 3 }
 OTP slot indexes. More...
 

Functions

bool otp_is_locked (const uint8_t index)
 Check whether the OTP storage is locked.
 
char * otp_get_slot (const uint8_t index)
 Read a slot.
 
int otp_write_slot (const uint8_t index, const char *value)
 Write a string to an unwritten slot.
 

Detailed Description

One-time programmable slots holding factory data.

Each slot holds a NUL-terminated string of up to 31 characters, stored in a flash security register. A slot can be written once.

char *serial = otp_get_slot(OTP_SERIAL);
char * otp_get_slot(const uint8_t index)
Read a slot.
@ OTP_SERIAL
Watch serial number.
Definition otp.h:27

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

OTP slot indexes.

Enumerator
OTP_HWVER 

Hardware version.

OTP_SERIAL 

Watch serial number.

OTP_PCBA_SERIAL 

PCBA serial number.

NUM_OTP_SLOTS 

Number of slots.

Function Documentation

◆ otp_get_slot()

char * otp_get_slot ( const uint8_t  index)

Read a slot.

Parameters
indexSlot index.
Returns
Slot contents, in a static buffer overwritten by the next read, or NULL on error. An unwritten slot reads as 0xFF bytes.

◆ otp_is_locked()

bool otp_is_locked ( const uint8_t  index)

Check whether the OTP storage is locked.

Locking applies to the whole security register holding the slots.

Parameters
indexSlot index.
Returns
true if locked.

◆ otp_write_slot()

int otp_write_slot ( const uint8_t  index,
const char *  value 
)

Write a string to an unwritten slot.

Parameters
indexSlot index.
valueNUL-terminated string, at most 31 characters.
Return values
0Written and verified.
-EEXISTThe slot already holds data.
-EINVALInvalid slot or value.
-EIOThe write failed or could not be verified.