forked from raspberrypi/pico-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unique_board_id.c
32 lines (26 loc) · 926 Bytes
/
unique_board_id.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include "pico/stdlib.h"
#include "pico/unique_id.h"
// RP2040 does not have a unique on-board ID, but this is a standard feature
// on the NOR flash it boots from. There is a 1:1 association between RP2040
// and the flash, so this can be used to get a 64 bit globally unique board ID
// for an RP2040-based board, including Pico.
//
// The pico_unique_id library retrieves this unique identifier during boot and
// stores it in memory, where it can be accessed at any time without
// disturbing the flash XIP hardware.
int main() {
stdio_init_all();
pico_unique_board_id_t board_id;
pico_get_unique_board_id(&board_id);
printf("Unique identifier:");
for (int i = 0; i < PICO_UNIQUE_BOARD_ID_SIZE_BYTES; ++i) {
printf(" %02x", board_id.id[i]);
}
printf("\n");
}