Loading...
Searching...
No Matches
pico_unique_id

Unique device ID access API. More...

Data Structures

struct  pico_unique_board_id_t
 Unique board identifier. More...
 

Macros

#define PICO_UNIQUE_BOARD_ID_INIT_PRIORITY   1000
 Static initialization order.
 

Functions

void pico_get_unique_board_id (pico_unique_board_id_t *id_out)
 Get unique ID.
 
void pico_get_unique_board_id_string (char *id_out, uint len)
 Get unique ID in string format.
 

Detailed Description

Unique device ID access API.

On boards using RP2350, the unique identifier is read from OTP memory on boot.

Macro Definition Documentation

◆ PICO_UNIQUE_BOARD_ID_INIT_PRIORITY

#define PICO_UNIQUE_BOARD_ID_INIT_PRIORITY   1000

Static initialization order.

This defines the init_priority of the pico_unique_id. By default, it is 1000. The valid range is from 101-65535. Set it to -1 to set the priority to none, thus putting it after 65535. Changing this value will initialize the unique_id earlier or later in the static initialization order. This is most useful for C++ consumers of the pico-sdk.

See https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-constructor-function-attribute and https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html#index-init_005fpriority-variable-attribute

Here is an example of C++ static initializers that will run before, and then after, pico_unique_id is loaded:

    [[gnu::init_priority(500)]] my_class before_instance;
    [[gnu::init_priority(2000)]] my_class after_instance;

Function Documentation

◆ pico_get_unique_board_id()

void pico_get_unique_board_id ( pico_unique_board_id_t *  id_out)

Get unique ID.

Get the unique 64-bit device identifier.

On an RP2350-based board, the unique identifier is retrieved from OTP memory at boot.

Parameters
id_outa pointer to a pico_unique_board_id_t struct, to which the identifier will be written

◆ pico_get_unique_board_id_string()

void pico_get_unique_board_id_string ( char *  id_out,
uint  len 
)

Get unique ID in string format.

Get the unique 64-bit device identifier formatted as a 0-terminated ASCII hex string.

On an RP2350-based board, the unique identifier is retrieved from OTP memory at boot.

Parameters
id_outa pointer to a char buffer of size len, to which the identifier will be written
lenthe size of id_out. For full serial, len >= 2 * PICO_UNIQUE_BOARD_ID_SIZE_BYTES + 1