diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 8acb193..6e4d438 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -20,17 +20,12 @@ jobs: # libraries to install for all boards UNIVERSAL_LIBRARIES: | - source-path: ./ - - name: Arduino_DebugUtils - - name: Arduino_SecureElement - - name: ArduinoECCX08 - - name: WiFiNINA # sketch paths to compile (recursive) for all boards UNIVERSAL_SKETCH_PATHS: | - examples/lzssDecoder - examples/crc32 - examples/crc16 - examples/sha256 - - examples/boardID SKETCHES_REPORTS_PATH: sketches-reports strategy: diff --git a/examples/boardID/boardID.ino b/examples/boardID/boardID.ino deleted file mode 100644 index 77d690b..0000000 --- a/examples/boardID/boardID.ino +++ /dev/null @@ -1,26 +0,0 @@ -/* - This file is part of the Arduino_CloudUtils library. - - Copyright (c) 2024 Arduino SA - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include - -void setup() { - Serial.begin(9600); - while (!Serial); - -#ifdef ARDUINO_OPTA - Ethernet.begin(NULL,0,0); -#endif - -} - -void loop() { - Serial.println(arduino::bpid::get()); - delay(2000); -} diff --git a/src/Arduino_BPId.h b/src/Arduino_BPId.h deleted file mode 100644 index 802f2fa..0000000 --- a/src/Arduino_BPId.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - This file is part of the Arduino_CloudUtils library. - - Copyright (c) 2024 Arduino SA - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ -#pragma once - -#include "./bpid/bpid.h" diff --git a/src/bpid/bpid.cpp b/src/bpid/bpid.cpp deleted file mode 100644 index 2876e63..0000000 --- a/src/bpid/bpid.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - This file is part of the Arduino_CloudUtils library. - - Copyright (c) 2024 Arduino SA - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include "bpid.h" -#include "../sha256/SHA256.h" -#include "../hex/hex.h" - -namespace arduino { namespace bpid { - - bool get(uint8_t* in, uint32_t size) { - if (size < BOARD_PROVISIONING_ID_SIZE) { - return false; - } - uint8_t offset = 0; - if (!arduino::ucid::get(&in[offset], size)) { - return false; - } - offset += UC_UID_SIZE; - if (!arduino::mac::get(&in[offset], size - offset)) { - return false; - } - offset += IFACE_MAC_ADDR_LENGTH; - if (!arduino::csn::get(&in[offset], size - offset)) { - return false; - } - return true; - } - - String get() { - uint8_t data[BOARD_PROVISIONING_ID_SIZE]; - if (!get(data, sizeof(data))) { - return String(""); - } - uint8_t out[SHA256_DIGEST_SIZE]; - arduino::sha256::sha256(data, sizeof(data), out); - return arduino::hex::encode(out, sizeof(out)); - } - -}} // arduino::bpid diff --git a/src/bpid/bpid.h b/src/bpid/bpid.h deleted file mode 100644 index 780bf8a..0000000 --- a/src/bpid/bpid.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - This file is part of the Arduino_CloudUtils library. - - Copyright (c) 2024 Arduino SA - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#pragma once - -#include -#include "ucid.h" -#include "mac.h" -#include "csn.h" - -namespace arduino { namespace bpid { - /* - * This library contains the methods to get board provisioning id - */ - - constexpr int BOARD_PROVISIONING_ID_SIZE = UC_UID_SIZE + - IFACE_MAC_ADDR_LENGTH + - CRYPTO_SN_SIZE; - - bool get(uint8_t* in, uint32_t size); - String get(); - -}} // arduino::bpid diff --git a/src/bpid/csn.cpp b/src/bpid/csn.cpp deleted file mode 100644 index 2e547f9..0000000 --- a/src/bpid/csn.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - This file is part of the Arduino_CloudUtils library. - - Copyright (c) 2024 Arduino SA - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include "csn.h" -#include "hex/hex.h" - -namespace arduino { namespace csn { - - bool get(uint8_t *in, uint32_t size) { -#if CRYPTO_SN_SIZE == 0 - (void)in; - (void)size; - return false; -#else - if (size < CRYPTO_SN_SIZE) { - return false; - } - SecureElement se; - if (!se.begin() || !arduino::hex::decode(se.serialNumber(), in, size)) { - return false; - } - return true; -#endif - } - -}} // arduino::csn diff --git a/src/bpid/csn.h b/src/bpid/csn.h deleted file mode 100644 index 795c07e..0000000 --- a/src/bpid/csn.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - This file is part of the Arduino_CloudUtils library. - - Copyright (c) 2024 Arduino SA - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#pragma once - -#include - -#if defined(ARDUINO_NANO_RP2040_CONNECT) || \ - defined(ARDUINO_SAMD_NANO_33_IOT) || \ - defined(ARDUINO_SAMD_MKRWIFI1010) || \ - defined(ARDUINO_SAMD_MKRGSM1400) || \ - defined(ARDUINO_SAMD_MKRWAN1300) || \ - defined(ARDUINO_SAMD_MKRWAN1310) || \ - defined(ARDUINO_SAMD_MKRNB1500) || \ - defined(ARDUINO_SAMD_MKR1000) || \ - defined(ARDUINO_PORTENTA_H7_M7) || \ - defined(ARDUINO_OPTA) || \ - defined(ARDUINO_GIGA) - #include - #define CRYPTO_SN_SIZE 9 -#elif defined(ARDUINO_PORTENTA_C33) || \ - defined(ARDUINO_NICLA_VISION) - #include - #define CRYPTO_SN_SIZE 18 -#elif defined(ARDUINO_UNOR4_WIFI) - #include - #define CRYPTO_SN_SIZE 6 -#else - #define CRYPTO_SN_SIZE 0 -#endif - -namespace arduino { namespace csn { - /* - * This library contains the methods to get crypto serial number - */ - - bool get(uint8_t *in, uint32_t size); - -}} // arduino::csn diff --git a/src/bpid/mac.cpp b/src/bpid/mac.cpp deleted file mode 100644 index 8938534..0000000 --- a/src/bpid/mac.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - This file is part of the Arduino_CloudUtils library. - - Copyright (c) 2024 Arduino SA - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include "mac.h" - -namespace arduino { namespace mac { - - bool get(uint8_t *in, uint32_t size) { -#if IFACE_MAC_ADDR_LENGTH == 0 - (void)in; - (void)size; - return false; -#else - if (size < IFACE_MAC_ADDR_LENGTH) { - return false; - } - #if defined(ARDUINO_SAMD_MKRWIFI1010) || \ - defined(ARDUINO_SAMD_NANO_33_IOT) - WiFi.macAddress(in); - #elif defined(ARDUINO_PORTENTA_H7_M7) || \ - defined(ARDUINO_NICLA_VISION) || \ - defined(ARDUINO_GIGA) - WiFi.macAddress(in); - #elif defined(ARDUINO_PORTENTA_C33) || \ - defined(ARDUINO_UNOR4_WIFI) - WiFi.macAddress(in); - #elif defined(ARDUINO_NANO_RP2040_CONNECT) - WiFi.macAddress(in); - #elif defined(ARDUINO_OPTA) - Ethernet.MACAddress(in); - #endif - return true; -#endif - } - -}} // arduino::mac diff --git a/src/bpid/mac.h b/src/bpid/mac.h deleted file mode 100644 index be83415..0000000 --- a/src/bpid/mac.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - This file is part of the Arduino_CloudUtils library. - - Copyright (c) 2024 Arduino SA - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#pragma once - -#include - -#if defined(ARDUINO_NANO_RP2040_CONNECT) || \ - defined(ARDUINO_SAMD_MKRWIFI1010) || \ - defined(ARDUINO_SAMD_NANO_33_IOT) || \ - defined(ARDUINO_PORTENTA_H7_M7) || \ - defined(ARDUINO_NICLA_VISION) || \ - defined(ARDUINO_GIGA) - #include - #define IFACE_MAC_ADDR_LENGTH WL_MAC_ADDR_LENGTH -#elif defined(ARDUINO_PORTENTA_C33) - #include - #define IFACE_MAC_ADDR_LENGTH WL_MAC_ADDR_LENGTH -#elif defined(ARDUINO_UNOR4_WIFI) - #include - #define IFACE_MAC_ADDR_LENGTH 6 -#elif defined(ARDUINO_OPTA) - #include - #define IFACE_MAC_ADDR_LENGTH 6 -#else - #define IFACE_MAC_ADDR_LENGTH 0 -#endif - -namespace arduino { namespace mac { - /* - * This library contains the methods to get board mac address - * ARDUINO_NANO_RP2040_CONNECT: reversed - * ARDUINO_SAMD_MKRWIFI1010: reversed - * ARDUINO_SAMD_NANO_33_IOT: reversed - * ARDUINO_PORTENTA_H7_M7: WiFi.setTimeout(0);WiFi.begin("In33dm4c4ddr35", "In33dm4c4ddr35", ENC_TYPE_TKIP) reversed - * ARDUINO_NICLA_VISION: - * ARDUINO_GIGA: - * ARDUINO_PORTENTA_C33: Interface.begin() not reversed - * ARDUINO_UNOR4_WIFI: not reversed - * ARDUINO_OPTA: Ethernet.begin(NULL,0,0); reversed - */ - - bool get(uint8_t *in, uint32_t size); - -}} // arduino::mac diff --git a/src/bpid/ucid.cpp b/src/bpid/ucid.cpp deleted file mode 100644 index 38a2b0a..0000000 --- a/src/bpid/ucid.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - This file is part of the Arduino_CloudUtils library. - - Copyright (c) 2024 Arduino SA - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#include "ucid.h" - -namespace arduino { namespace ucid { - - bool get(uint8_t *in, uint32_t size) { -#if UC_UID_SIZE == 0 - (void)in; - (void)size; - return false; -#else - if (size < UC_UID_SIZE) { - return false; - } - #if defined(ARDUINO_SAMD_MKRWIFI1010) || \ - defined(ARDUINO_SAMD_NANO_33_IOT) - (*(uint32_t*)(&in[0x0])) = __builtin_bswap32(*(volatile uint32_t*)(0x0080A00C)); - (*(uint32_t*)(&in[0x4])) = __builtin_bswap32(*(volatile uint32_t*)(0x0080A040)); - (*(uint32_t*)(&in[0x8])) = __builtin_bswap32(*(volatile uint32_t*)(0x0080A044)); - (*(uint32_t*)(&in[0xC])) = __builtin_bswap32(*(volatile uint32_t*)(0x0080A048)); - #elif defined(ARDUINO_PORTENTA_H7_M7) || \ - defined(ARDUINO_NICLA_VISION) || \ - defined(ARDUINO_OPTA) || \ - defined(ARDUINO_GIGA) - (*(uint32_t*)(&in[0x0])) = __builtin_bswap32(HAL_GetUIDw0()); - (*(uint32_t*)(&in[0x4])) = __builtin_bswap32(HAL_GetUIDw1()); - (*(uint32_t*)(&in[0x8])) = __builtin_bswap32(HAL_GetUIDw2()); - #elif defined(ARDUINO_PORTENTA_C33) || \ - defined(ARDUINO_UNOR4_WIFI) - const bsp_unique_id_t* t = R_BSP_UniqueIdGet(); - (*(uint32_t*)(&in[0x0])) = __builtin_bswap32(t->unique_id_words[0x0]); - (*(uint32_t*)(&in[0x4])) = __builtin_bswap32(t->unique_id_words[0x1]); - (*(uint32_t*)(&in[0x8])) = __builtin_bswap32(t->unique_id_words[0x2]); - (*(uint32_t*)(&in[0xC])) = __builtin_bswap32(t->unique_id_words[0x3]); - #elif defined(ARDUINO_NANO_RP2040_CONNECT) - uint8_t id[UC_UID_SIZE]; - flash_get_unique_id(id); - (*(uint32_t*)(&in[0x0])) = __builtin_bswap32(*(uint32_t*)&id[0x0]); - (*(uint32_t*)(&in[0x4])) = __builtin_bswap32(*(uint32_t*)&id[0x4]); - #endif - return true; -#endif - } - -}} // arduino::ucid diff --git a/src/bpid/ucid.h b/src/bpid/ucid.h deleted file mode 100644 index 560f3b3..0000000 --- a/src/bpid/ucid.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - This file is part of the Arduino_CloudUtils library. - - Copyright (c) 2024 Arduino SA - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. -*/ - -#pragma once - -#include - -#if defined(ARDUINO_SAMD_NANO_33_IOT) || \ - defined(ARDUINO_SAMD_MKRWIFI1010) || \ - defined(ARDUINO_SAMD_MKRGSM1400) || \ - defined(ARDUINO_SAMD_MKRWAN1300) || \ - defined(ARDUINO_SAMD_MKRWAN1310) || \ - defined(ARDUINO_SAMD_MKRNB1500) || \ - defined(ARDUINO_SAMD_MKR1000) - #define UC_UID_SIZE 16 -#elif defined(ARDUINO_PORTENTA_H7_M7) || \ - defined(ARDUINO_NICLA_VISION) || \ - defined(ARDUINO_OPTA) || \ - defined(ARDUINO_GIGA) - #define UC_UID_SIZE 12 -#elif defined(ARDUINO_PORTENTA_C33) || \ - defined(ARDUINO_UNOR4_WIFI) - #define UC_UID_SIZE 16 -#elif defined(ARDUINO_NANO_RP2040_CONNECT) - extern "C" { - #include "hardware/flash.h" - } - #define UC_UID_SIZE FLASH_UNIQUE_ID_SIZE_BYTES -#else - #define UC_UID_SIZE 0 -#endif - -namespace arduino { namespace ucid { - /* - * This library contains the methods to get board microcontroller id - */ - - bool get(uint8_t *in, uint32_t size); - -}} // arduino::ucid