-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Luke Wren <wren6991@gmail.com>
- Loading branch information
1 parent
13f89f6
commit 744bd9f
Showing
4 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
add_executable(unique_board_id | ||
unique_board_id.c | ||
) | ||
|
||
target_link_libraries(unique_board_id | ||
pico_stdlib | ||
pico_unique_id | ||
) | ||
|
||
# create map/bin/hex file etc. | ||
pico_add_extra_outputs(unique_board_id) | ||
|
||
# add url via pico_set_program_url | ||
example_auto_set_url(unique_board_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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"); | ||
} |