From 391e3431fcc6f271f60584603697edf664bbb59c Mon Sep 17 00:00:00 2001 From: alex-luxonis Date: Wed, 28 Jul 2021 19:47:58 +0300 Subject: [PATCH 01/17] Make sure the bootloader starts at a flash sector-aligned offset, it had an extra offset of 512 bytes --- include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp | 2 +- include/depthai-bootloader-shared/UsbBootloaderConfig.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp b/include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp index eccc99c..6f1fa44 100644 --- a/include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp +++ b/include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp @@ -29,7 +29,7 @@ struct NetworkBootloaderStructure : Structure { constexpr static long HEADER_SIZE = 512; constexpr static long CONFIG_SIZE = 16 * 1024; constexpr static long BOOTLOADER_OFFSET = HEADER_OFFSET + HEADER_SIZE; - constexpr static long BOOTLOADER_SIZE = 8 * 1024 * 1024 - CONFIG_SIZE; + constexpr static long BOOTLOADER_SIZE = 8 * 1024 * 1024 - CONFIG_SIZE - HEADER_SIZE; constexpr static long CONFIG_OFFSET = BOOTLOADER_OFFSET + BOOTLOADER_SIZE; constexpr static long APPLICATION_OFFSET = CONFIG_OFFSET + CONFIG_SIZE; diff --git a/include/depthai-bootloader-shared/UsbBootloaderConfig.hpp b/include/depthai-bootloader-shared/UsbBootloaderConfig.hpp index 193f68a..8b62d9a 100644 --- a/include/depthai-bootloader-shared/UsbBootloaderConfig.hpp +++ b/include/depthai-bootloader-shared/UsbBootloaderConfig.hpp @@ -31,7 +31,7 @@ struct UsbBootloaderStructure : Structure { constexpr static long HEADER_SIZE = 512; constexpr static long CONFIG_SIZE = 16 * 1024; constexpr static long BOOTLOADER_OFFSET = HEADER_OFFSET + HEADER_SIZE; - constexpr static long BOOTLOADER_SIZE = 1 * 1024 * 1024 - CONFIG_SIZE; + constexpr static long BOOTLOADER_SIZE = 1 * 1024 * 1024 - CONFIG_SIZE - HEADER_SIZE; constexpr static long CONFIG_OFFSET = BOOTLOADER_OFFSET + BOOTLOADER_SIZE; constexpr static long APPLICATION_OFFSET = CONFIG_OFFSET + CONFIG_SIZE; From 16094d86721636a4f461cd281e977c585d4ad873 Mon Sep 17 00:00:00 2001 From: Martin Peterlin Date: Sat, 7 Aug 2021 00:25:56 +0200 Subject: [PATCH 02/17] WIP: Network bootloader config --- .../NetworkBootloaderConfig.hpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp b/include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp index 6f1fa44..3ca3799 100644 --- a/include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp +++ b/include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp @@ -13,13 +13,23 @@ namespace bootloader { // Config -/* TODO(themarpe) struct NetworkBootloaderConfig { - char ip[16]; - char subnetMask[16]; - char gateway[16]; + /** + * If timeout < 0 - waits forever + * if timeout == 0 - no timeout + * if timeout > 0 - waits timeout milliseconds + */ + std::int32_t timeoutMs = -1; + // Network configuration options + // IPv4 + std::uint32_t ipv4; + std::uint32_t ipv4Mask; + std::uint32_t ipv4Gateway; + // TODO(themarpe) - IPv6 + std::uint32_t ipv6[4]; + std::uint32_t ipv6Prefix; + std::uint32_t ipv6Gateway[4]; }; -*/ // Structure From 1fd198b4a3b912a9fe5b2a917e98505269a8e93c Mon Sep 17 00:00:00 2001 From: Martin Peterlin Date: Thu, 12 Aug 2021 17:08:55 +0200 Subject: [PATCH 03/17] Added bootloader config and slight refactor --- .../depthai-bootloader-shared/Bootloader.hpp | 46 ++++-- include/depthai-bootloader-shared/Config.hpp | 140 ++++++++++++++++++ .../NetworkBootloaderConfig.hpp | 65 -------- .../depthai-bootloader-shared/Structure.hpp | 60 ++++++++ .../UsbBootloaderConfig.hpp | 56 ------- 5 files changed, 234 insertions(+), 133 deletions(-) create mode 100644 include/depthai-bootloader-shared/Config.hpp delete mode 100644 include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp delete mode 100644 include/depthai-bootloader-shared/UsbBootloaderConfig.hpp diff --git a/include/depthai-bootloader-shared/Bootloader.hpp b/include/depthai-bootloader-shared/Bootloader.hpp index 9e99782..65a9f4c 100644 --- a/include/depthai-bootloader-shared/Bootloader.hpp +++ b/include/depthai-bootloader-shared/Bootloader.hpp @@ -8,23 +8,12 @@ #include "Type.hpp" #include "Section.hpp" #include "Memory.hpp" -#include "UsbBootloaderConfig.hpp" -#include "NetworkBootloaderConfig.hpp" namespace dai { namespace bootloader { -inline const Structure getStructure(Type type){ - switch(type){ - case Type::USB: return UsbBootloaderStructure(); - case Type::NETWORK: return NetworkBootloaderStructure(); - } - // Default - return UsbBootloaderStructure(); -} - namespace request { enum Command : uint32_t { @@ -37,6 +26,8 @@ namespace request { UPDATE_FLASH_EX_2, NO_OP, GET_BOOTLOADER_TYPE, + SET_BOOTLOADER_CONFIG, + GET_BOOTLOADER_CONFIG, }; struct BaseRequest { @@ -75,6 +66,7 @@ namespace request { // Data }; + // 0.0.12 or higher struct BootMemory : BaseRequest { // Common BootMemory() : BaseRequest(BOOT_MEMORY) {} @@ -114,10 +106,26 @@ namespace request { GetBootloaderType() : BaseRequest(GET_BOOTLOADER_TYPE) {} // Data + }; + + + // 0.0.14 or higher + struct SetBootloaderConfig : BaseRequest { + // Common + SetBootloaderConfig() : BaseRequest(SET_BOOTLOADER_CONFIG) {} + + // Data + Memory memory; uint32_t totalSize; uint32_t numPackets; }; + struct GetBootloaderConfig : BaseRequest { + // Common + GetBootloaderConfig() : BaseRequest(GET_BOOTLOADER_CONFIG) {} + + // Data + }; } @@ -128,7 +136,8 @@ namespace response { FLASH_COMPLETE = 0, FLASH_STATUS_UPDATE, BOOTLOADER_VERSION, - BOOTLOADER_TYPE + BOOTLOADER_TYPE, + GET_BOOTLOADER_CONFIG, }; struct BaseResponse { @@ -168,6 +177,19 @@ namespace response { Type type; }; + + // 0.0.14 + struct GetBootloaderConfig : BaseResponse { + // Common + GetBootloaderConfig() : BaseResponse(GET_BOOTLOADER_CONFIG) {} + + // Data + uint32_t success; + char errorMsg[64]; + uint32_t totalSize; + uint32_t numPackets; + }; + } } // namespace bootloader diff --git a/include/depthai-bootloader-shared/Config.hpp b/include/depthai-bootloader-shared/Config.hpp new file mode 100644 index 0000000..0c4e2ab --- /dev/null +++ b/include/depthai-bootloader-shared/Config.hpp @@ -0,0 +1,140 @@ +#pragma once + +#include "Memory.hpp" + +// std +#include +#include +#include + +// libraries +#include "nlohmann/json.hpp" + +namespace dai +{ +namespace bootloader +{ + + +// Config +struct NetworkConfig { + /** + * If timeout < 0 - waits forever + * if timeout == 0 - no timeout + * if timeout > 0 - waits timeout milliseconds + */ + std::chrono::milliseconds timeout{15000}; + // Network configuration options + // IPv4 + std::uint32_t ipv4 = 0; + std::uint32_t ipv4Mask = 0; + std::uint32_t ipv4Gateway = 0; + std::uint32_t ipv4Dns = 0; + std::uint32_t ipv4DnsAlt = 0; + bool staticIpv4 = false; + // TODO(themarpe) - IPv6 + std::array ipv6 = {}; + std::uint32_t ipv6Prefix = 0; + std::array ipv6Gateway = {}; + std::array ipv6Dns = {}; + std::array ipv6DnsAlt = {}; + bool staticIpv6 = false; + // MAC address - if not flashed, overwrites autogenerated one + std::array mac = {}; +}; +// Serialization/Deserialization - NetworkBootloaderConfig +// Doesn't error if some fields are missing +inline void to_json(nlohmann::json& j, const NetworkConfig& c) { + // Manually serialize the fields + nlohmann::to_json(j["timeout"], c.timeout.count()); + nlohmann::to_json(j["ipv4"], c.ipv4); + nlohmann::to_json(j["ipv4Mask"], c.ipv4Mask); + nlohmann::to_json(j["ipv4Gateway"], c.ipv4Gateway); + nlohmann::to_json(j["ipv4Dns"], c.ipv4Dns); + nlohmann::to_json(j["ipv6"], c.ipv6); + nlohmann::to_json(j["ipv6Prefix"], c.ipv6Prefix); + nlohmann::to_json(j["ipv6Gateway"], c.ipv6Gateway); + nlohmann::to_json(j["ipv6Dns"], c.ipv6Dns); + nlohmann::to_json(j["ipv6DnsAlt"], c.ipv6DnsAlt); + nlohmann::to_json(j["staticIpv4"], c.staticIpv4); + nlohmann::to_json(j["staticIpv6"], c.staticIpv6); + nlohmann::to_json(j["mac"], c.mac); +} +inline void from_json(const nlohmann::json& j, NetworkConfig& c) { + // Manually serialize the fields + if(j.contains("timeout")) c.timeout = std::chrono::milliseconds(j["timeout"].get()); + if(j.contains("ipv4")) j["ipv4"].get_to(c.ipv4); + if(j.contains("ipv4Mask")) j["ipv4Mask"].get_to(c.ipv4Mask); + if(j.contains("ipv4Gateway")) j["ipv4Gateway"].get_to(c.ipv4Gateway); + if(j.contains("ipv4Dns")) j["ipv4Dns"].get_to(c.ipv4Dns); + if(j.contains("ipv6")) j["ipv6"].get_to(c.ipv6); + if(j.contains("ipv6Prefix")) j["ipv6Prefix"].get_to(c.ipv6Prefix); + if(j.contains("ipv6Gateway")) j["ipv6Gateway"].get_to(c.ipv6Gateway); + if(j.contains("ipv6Dns")) j["ipv6Dns"].get_to(c.ipv6Dns); + if(j.contains("ipv6DnsAlt")) j["ipv6DnsAlt"].get_to(c.ipv6DnsAlt); + if(j.contains("staticIpv4")) j["staticIpv4"].get_to(c.staticIpv4); + if(j.contains("staticIpv6")) j["staticIpv6"].get_to(c.staticIpv6); + if(j.contains("mac")) j["mac"].get_to(c.mac); +} + + +// Config +struct UsbConfig { + /** + * If timeout < 0 - waits forever + * if timeout == 0 - no timeout + * if timeout > 0 - waits timeout milliseconds + */ + std::chrono::milliseconds timeout{3000}; + + /** + * UNKNOWN = 0, LOW, FULL, HIGH, SUPER, SUPER_PLUS + */ + int maxUsbSpeed = 3; + + /// VID/PID pair used by bootloader + uint16_t vid = 0x03E7, pid = 0xF63C; +}; +// Serialization/Deserialization - UsbBootloaderConfig +// Doesn't error if some fields are missing +inline void to_json(nlohmann::json& j, const UsbConfig& c) { + // Manually serialize the fields + nlohmann::to_json(j["timeout"], c.timeout.count()); + nlohmann::to_json(j["maxUsbSpeed"], c.maxUsbSpeed); + nlohmann::to_json(j["vid"], c.vid); + nlohmann::to_json(j["pid"], c.pid); +} +inline void from_json(const nlohmann::json& j, UsbConfig& c) { + // Manually serialize the fields + if(j.contains("timeout")) c.timeout = std::chrono::milliseconds(j["timeout"].get()); + if(j.contains("maxUsbSpeed")) j["maxUsbSpeed"].get_to(c.maxUsbSpeed); + if(j.contains("vid")) j["vid"].get_to(c.vid); + if(j.contains("pid")) j["pid"].get_to(c.pid); +} + +struct Config { + Memory applicationMemory; + UsbConfig usb; + NetworkConfig network; +}; + + +// Serialization/Deserialization - Config +// Doesn't error if some fields are missing +inline void to_json(nlohmann::json& j, const Config& c) { + // Manually serialize the fields - without modifying any existing fields + nlohmann::to_json(j["appMem"], c.applicationMemory); + nlohmann::to_json(j["network"], c.network); + nlohmann::to_json(j["usb"], c.usb); +} +inline void from_json(const nlohmann::json& j, Config& c) { + // Manually serialize the fields + if(j.contains("appMem")) j["appMem"].get_to(c.applicationMemory); + if(j.contains("network")) j["network"].get_to(c.network); + if(j.contains("usb")) j["usb"].get_to(c.usb); +} + + +} // namespace bootloader +} // namespace dai + diff --git a/include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp b/include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp deleted file mode 100644 index 3ca3799..0000000 --- a/include/depthai-bootloader-shared/NetworkBootloaderConfig.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#pragma once - -// std -#include -#include - -// project -#include "Structure.hpp" - -namespace dai -{ -namespace bootloader -{ - -// Config -struct NetworkBootloaderConfig { - /** - * If timeout < 0 - waits forever - * if timeout == 0 - no timeout - * if timeout > 0 - waits timeout milliseconds - */ - std::int32_t timeoutMs = -1; - // Network configuration options - // IPv4 - std::uint32_t ipv4; - std::uint32_t ipv4Mask; - std::uint32_t ipv4Gateway; - // TODO(themarpe) - IPv6 - std::uint32_t ipv6[4]; - std::uint32_t ipv6Prefix; - std::uint32_t ipv6Gateway[4]; -}; - - -// Structure -struct NetworkBootloaderStructure : Structure { - - constexpr static long HEADER_OFFSET = 0; - constexpr static long HEADER_SIZE = 512; - constexpr static long CONFIG_SIZE = 16 * 1024; - constexpr static long BOOTLOADER_OFFSET = HEADER_OFFSET + HEADER_SIZE; - constexpr static long BOOTLOADER_SIZE = 8 * 1024 * 1024 - CONFIG_SIZE - HEADER_SIZE; - constexpr static long CONFIG_OFFSET = BOOTLOADER_OFFSET + BOOTLOADER_SIZE; - constexpr static long APPLICATION_OFFSET = CONFIG_OFFSET + CONFIG_SIZE; - - NetworkBootloaderStructure() : Structure({ - {Section::HEADER, HEADER_OFFSET}, - {Section::BOOTLOADER_CONFIG, CONFIG_OFFSET}, - {Section::BOOTLOADER, BOOTLOADER_OFFSET}, - {Section::APPLICATION, APPLICATION_OFFSET}, - }, { - {Section::HEADER, HEADER_SIZE}, - {Section::BOOTLOADER_CONFIG, CONFIG_SIZE}, - {Section::BOOTLOADER, BOOTLOADER_SIZE}, - {Section::APPLICATION, 0}, - }) {} - -}; - -static const NetworkBootloaderStructure networkBootloaderStructure; - -} // namespace bootloader -} // namespace dai - - diff --git a/include/depthai-bootloader-shared/Structure.hpp b/include/depthai-bootloader-shared/Structure.hpp index d558b01..2e56239 100644 --- a/include/depthai-bootloader-shared/Structure.hpp +++ b/include/depthai-bootloader-shared/Structure.hpp @@ -5,6 +5,7 @@ // project #include "Section.hpp" +#include "Type.hpp" namespace dai { @@ -19,6 +20,65 @@ struct Structure { Structure(decltype(offset) a, decltype(size) b) : offset(a), size(b) {} }; +// Structure +struct NetworkBootloaderStructure : Structure { + + constexpr static long HEADER_OFFSET = 0; + constexpr static long HEADER_SIZE = 512; + constexpr static long CONFIG_SIZE = 16 * 1024; + constexpr static long BOOTLOADER_OFFSET = HEADER_OFFSET + HEADER_SIZE; + constexpr static long BOOTLOADER_SIZE = 8 * 1024 * 1024 - CONFIG_SIZE - HEADER_SIZE; + constexpr static long CONFIG_OFFSET = BOOTLOADER_OFFSET + BOOTLOADER_SIZE; + constexpr static long APPLICATION_OFFSET = CONFIG_OFFSET + CONFIG_SIZE; + + NetworkBootloaderStructure() : Structure({ + {Section::HEADER, HEADER_OFFSET}, + {Section::BOOTLOADER_CONFIG, CONFIG_OFFSET}, + {Section::BOOTLOADER, BOOTLOADER_OFFSET}, + {Section::APPLICATION, APPLICATION_OFFSET}, + }, { + {Section::HEADER, HEADER_SIZE}, + {Section::BOOTLOADER_CONFIG, CONFIG_SIZE}, + {Section::BOOTLOADER, BOOTLOADER_SIZE}, + {Section::APPLICATION, 0}, + }) {} + +}; + +// Structure +struct UsbBootloaderStructure : Structure { + + constexpr static long HEADER_OFFSET = 0; + constexpr static long HEADER_SIZE = 512; + constexpr static long CONFIG_SIZE = 16 * 1024; + constexpr static long BOOTLOADER_OFFSET = HEADER_OFFSET + HEADER_SIZE; + constexpr static long BOOTLOADER_SIZE = 1 * 1024 * 1024 - CONFIG_SIZE - HEADER_SIZE; + constexpr static long CONFIG_OFFSET = BOOTLOADER_OFFSET + BOOTLOADER_SIZE; + constexpr static long APPLICATION_OFFSET = CONFIG_OFFSET + CONFIG_SIZE; + + UsbBootloaderStructure() : Structure({ + {Section::HEADER, HEADER_OFFSET}, + {Section::BOOTLOADER_CONFIG, CONFIG_OFFSET}, + {Section::BOOTLOADER, BOOTLOADER_OFFSET}, + {Section::APPLICATION, APPLICATION_OFFSET}, + }, { + {Section::HEADER, HEADER_SIZE}, + {Section::BOOTLOADER_CONFIG, CONFIG_SIZE}, + {Section::BOOTLOADER, BOOTLOADER_SIZE}, + {Section::APPLICATION, 0}, + }) {} + +}; + +inline const Structure getStructure(Type type){ + switch(type){ + case Type::USB: return UsbBootloaderStructure(); + case Type::NETWORK: return NetworkBootloaderStructure(); + } + // Default + return UsbBootloaderStructure(); +} + } // namespace bootloader } // namespace dai diff --git a/include/depthai-bootloader-shared/UsbBootloaderConfig.hpp b/include/depthai-bootloader-shared/UsbBootloaderConfig.hpp deleted file mode 100644 index 8b62d9a..0000000 --- a/include/depthai-bootloader-shared/UsbBootloaderConfig.hpp +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -// std -#include -#include -#include - -// project -#include "Structure.hpp" - -namespace dai -{ -namespace bootloader -{ - -// Config -struct UsbBootloaderConfig { - /** - * If timeout < 0 - waits forever - * if timeout == 0 - no timeout - * if timeout > 0 - waits timeout milliseconds - */ - std::int32_t timeoutMs = -1; -}; - - -// Structure -struct UsbBootloaderStructure : Structure { - - constexpr static long HEADER_OFFSET = 0; - constexpr static long HEADER_SIZE = 512; - constexpr static long CONFIG_SIZE = 16 * 1024; - constexpr static long BOOTLOADER_OFFSET = HEADER_OFFSET + HEADER_SIZE; - constexpr static long BOOTLOADER_SIZE = 1 * 1024 * 1024 - CONFIG_SIZE - HEADER_SIZE; - constexpr static long CONFIG_OFFSET = BOOTLOADER_OFFSET + BOOTLOADER_SIZE; - constexpr static long APPLICATION_OFFSET = CONFIG_OFFSET + CONFIG_SIZE; - - UsbBootloaderStructure() : Structure({ - {Section::HEADER, HEADER_OFFSET}, - {Section::BOOTLOADER_CONFIG, CONFIG_OFFSET}, - {Section::BOOTLOADER, BOOTLOADER_OFFSET}, - {Section::APPLICATION, APPLICATION_OFFSET}, - }, { - {Section::HEADER, HEADER_SIZE}, - {Section::BOOTLOADER_CONFIG, CONFIG_SIZE}, - {Section::BOOTLOADER, BOOTLOADER_SIZE}, - {Section::APPLICATION, 0}, - }) {} - -}; - -} // namespace bootloader -} // namespace dai - - - From 55e2bae88d3254ebd355832cbf190c53687a66a1 Mon Sep 17 00:00:00 2001 From: Martin Peterlin Date: Fri, 13 Aug 2021 13:22:12 +0200 Subject: [PATCH 04/17] Added memory and auto memory options to config --- include/depthai-bootloader-shared/Bootloader.hpp | 16 ++++++++++++++++ include/depthai-bootloader-shared/Memory.hpp | 2 +- include/depthai-bootloader-shared/Section.hpp | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/depthai-bootloader-shared/Bootloader.hpp b/include/depthai-bootloader-shared/Bootloader.hpp index 65a9f4c..bcc3113 100644 --- a/include/depthai-bootloader-shared/Bootloader.hpp +++ b/include/depthai-bootloader-shared/Bootloader.hpp @@ -28,6 +28,7 @@ namespace request { GET_BOOTLOADER_TYPE, SET_BOOTLOADER_CONFIG, GET_BOOTLOADER_CONFIG, + BOOTLOADER_MEMORY, }; struct BaseRequest { @@ -124,6 +125,13 @@ namespace request { // Common GetBootloaderConfig() : BaseRequest(GET_BOOTLOADER_CONFIG) {} + // Data + Memory memory; + }; + struct BootloaderMemory : BaseRequest { + // Common + BootloaderMemory() : BaseRequest(BOOTLOADER_MEMORY) {} + // Data }; @@ -138,6 +146,7 @@ namespace response { BOOTLOADER_VERSION, BOOTLOADER_TYPE, GET_BOOTLOADER_CONFIG, + BOOTLOADER_MEMORY, }; struct BaseResponse { @@ -190,6 +199,13 @@ namespace response { uint32_t numPackets; }; + struct BootloaderMemory : BaseResponse { + // Common + GetBootloaderMemory() : BaseResponse(BOOTLOADER_MEMORY) {} + + // Data + Memory memory; + }; } } // namespace bootloader diff --git a/include/depthai-bootloader-shared/Memory.hpp b/include/depthai-bootloader-shared/Memory.hpp index 57e8990..bbe435a 100644 --- a/include/depthai-bootloader-shared/Memory.hpp +++ b/include/depthai-bootloader-shared/Memory.hpp @@ -9,7 +9,7 @@ namespace bootloader { enum class Memory : std::int32_t { - FLASH, EMMC + AUTO = -1, FLASH = 0, EMMC = 1, }; } // namespace bootloader diff --git a/include/depthai-bootloader-shared/Section.hpp b/include/depthai-bootloader-shared/Section.hpp index 0292313..32fc7dd 100644 --- a/include/depthai-bootloader-shared/Section.hpp +++ b/include/depthai-bootloader-shared/Section.hpp @@ -9,7 +9,7 @@ namespace bootloader { enum class Section : std::int32_t { - HEADER, BOOTLOADER, BOOTLOADER_CONFIG, APPLICATION + AUTO = -1, HEADER = 0, BOOTLOADER = 1, BOOTLOADER_CONFIG = 2, APPLICATION = 3 }; } // namespace bootloader From 0b0e50123c6d80891a55d8ab0e7999d519d1ed73 Mon Sep 17 00:00:00 2001 From: Martin Peterlin Date: Fri, 13 Aug 2021 13:43:26 +0200 Subject: [PATCH 05/17] Fixed a bootloader memory response error --- include/depthai-bootloader-shared/Bootloader.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/depthai-bootloader-shared/Bootloader.hpp b/include/depthai-bootloader-shared/Bootloader.hpp index bcc3113..3deef53 100644 --- a/include/depthai-bootloader-shared/Bootloader.hpp +++ b/include/depthai-bootloader-shared/Bootloader.hpp @@ -201,7 +201,7 @@ namespace response { struct BootloaderMemory : BaseResponse { // Common - GetBootloaderMemory() : BaseResponse(BOOTLOADER_MEMORY) {} + BootloaderMemory() : BaseResponse(BOOTLOADER_MEMORY) {} // Data Memory memory; From ff0388376d272cabdb79bf68f21fd7130d8212a6 Mon Sep 17 00:00:00 2001 From: Martin Peterlin Date: Fri, 13 Aug 2021 14:28:45 +0200 Subject: [PATCH 06/17] Added capability to clear configuration --- include/depthai-bootloader-shared/Bootloader.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/depthai-bootloader-shared/Bootloader.hpp b/include/depthai-bootloader-shared/Bootloader.hpp index 3deef53..c082ad7 100644 --- a/include/depthai-bootloader-shared/Bootloader.hpp +++ b/include/depthai-bootloader-shared/Bootloader.hpp @@ -117,6 +117,7 @@ namespace request { // Data Memory memory; + uint32_t clearConfig; uint32_t totalSize; uint32_t numPackets; }; From 2771f02436c80c211b17295754966be48123ebbf Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Mon, 16 Aug 2021 20:41:24 +0200 Subject: [PATCH 07/17] Used macro for optional serialization/deserialization instead --- include/depthai-bootloader-shared/Config.hpp | 84 +++----------------- 1 file changed, 13 insertions(+), 71 deletions(-) diff --git a/include/depthai-bootloader-shared/Config.hpp b/include/depthai-bootloader-shared/Config.hpp index 0c4e2ab..fe349cc 100644 --- a/include/depthai-bootloader-shared/Config.hpp +++ b/include/depthai-bootloader-shared/Config.hpp @@ -10,6 +10,13 @@ // libraries #include "nlohmann/json.hpp" +#define DEPTHAI_BOOTLOADER_NLOHMANN_JSON_OPTIONAL_TO(v1) nlohmann::to_json(nlohmann_json_j[#v1], nlohmann_json_t.v1); +#define DEPTHAI_BOOTLOADER_NLOHMANN_JSON_OPTIONAL_FROM(v1) if(nlohmann_json_j.contains(#v1)) nlohmann_json_j[#v1].get_to(nlohmann_json_t.v1); + +#define DEPTHAI_BOOTLOADER_NLOHMANN_DEFINE_TYPE_OPTIONAL_NON_INTRUSIVE(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(DEPTHAI_BOOTLOADER_NLOHMANN_JSON_OPTIONAL_TO, __VA_ARGS__)) } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(DEPTHAI_BOOTLOADER_NLOHMANN_JSON_OPTIONAL_FROM, __VA_ARGS__)) } + namespace dai { namespace bootloader @@ -23,7 +30,7 @@ struct NetworkConfig { * if timeout == 0 - no timeout * if timeout > 0 - waits timeout milliseconds */ - std::chrono::milliseconds timeout{15000}; + int timeoutMs = 15000; // Network configuration options // IPv4 std::uint32_t ipv4 = 0; @@ -42,41 +49,7 @@ struct NetworkConfig { // MAC address - if not flashed, overwrites autogenerated one std::array mac = {}; }; -// Serialization/Deserialization - NetworkBootloaderConfig -// Doesn't error if some fields are missing -inline void to_json(nlohmann::json& j, const NetworkConfig& c) { - // Manually serialize the fields - nlohmann::to_json(j["timeout"], c.timeout.count()); - nlohmann::to_json(j["ipv4"], c.ipv4); - nlohmann::to_json(j["ipv4Mask"], c.ipv4Mask); - nlohmann::to_json(j["ipv4Gateway"], c.ipv4Gateway); - nlohmann::to_json(j["ipv4Dns"], c.ipv4Dns); - nlohmann::to_json(j["ipv6"], c.ipv6); - nlohmann::to_json(j["ipv6Prefix"], c.ipv6Prefix); - nlohmann::to_json(j["ipv6Gateway"], c.ipv6Gateway); - nlohmann::to_json(j["ipv6Dns"], c.ipv6Dns); - nlohmann::to_json(j["ipv6DnsAlt"], c.ipv6DnsAlt); - nlohmann::to_json(j["staticIpv4"], c.staticIpv4); - nlohmann::to_json(j["staticIpv6"], c.staticIpv6); - nlohmann::to_json(j["mac"], c.mac); -} -inline void from_json(const nlohmann::json& j, NetworkConfig& c) { - // Manually serialize the fields - if(j.contains("timeout")) c.timeout = std::chrono::milliseconds(j["timeout"].get()); - if(j.contains("ipv4")) j["ipv4"].get_to(c.ipv4); - if(j.contains("ipv4Mask")) j["ipv4Mask"].get_to(c.ipv4Mask); - if(j.contains("ipv4Gateway")) j["ipv4Gateway"].get_to(c.ipv4Gateway); - if(j.contains("ipv4Dns")) j["ipv4Dns"].get_to(c.ipv4Dns); - if(j.contains("ipv6")) j["ipv6"].get_to(c.ipv6); - if(j.contains("ipv6Prefix")) j["ipv6Prefix"].get_to(c.ipv6Prefix); - if(j.contains("ipv6Gateway")) j["ipv6Gateway"].get_to(c.ipv6Gateway); - if(j.contains("ipv6Dns")) j["ipv6Dns"].get_to(c.ipv6Dns); - if(j.contains("ipv6DnsAlt")) j["ipv6DnsAlt"].get_to(c.ipv6DnsAlt); - if(j.contains("staticIpv4")) j["staticIpv4"].get_to(c.staticIpv4); - if(j.contains("staticIpv6")) j["staticIpv6"].get_to(c.staticIpv6); - if(j.contains("mac")) j["mac"].get_to(c.mac); -} - +DEPTHAI_BOOTLOADER_NLOHMANN_DEFINE_TYPE_OPTIONAL_NON_INTRUSIVE(NetworkConfig, timeoutMs, ipv4, ipv4Mask, ipv4Gateway, ipv4Dns, ipv4DnsAlt, staticIpv4, ipv6, ipv6Prefix, ipv6Gateway, ipv6Dns, ipv6DnsAlt, staticIpv6, mac); // Config struct UsbConfig { @@ -85,7 +58,7 @@ struct UsbConfig { * if timeout == 0 - no timeout * if timeout > 0 - waits timeout milliseconds */ - std::chrono::milliseconds timeout{3000}; + int timeoutMs = 3000; /** * UNKNOWN = 0, LOW, FULL, HIGH, SUPER, SUPER_PLUS @@ -95,45 +68,14 @@ struct UsbConfig { /// VID/PID pair used by bootloader uint16_t vid = 0x03E7, pid = 0xF63C; }; -// Serialization/Deserialization - UsbBootloaderConfig -// Doesn't error if some fields are missing -inline void to_json(nlohmann::json& j, const UsbConfig& c) { - // Manually serialize the fields - nlohmann::to_json(j["timeout"], c.timeout.count()); - nlohmann::to_json(j["maxUsbSpeed"], c.maxUsbSpeed); - nlohmann::to_json(j["vid"], c.vid); - nlohmann::to_json(j["pid"], c.pid); -} -inline void from_json(const nlohmann::json& j, UsbConfig& c) { - // Manually serialize the fields - if(j.contains("timeout")) c.timeout = std::chrono::milliseconds(j["timeout"].get()); - if(j.contains("maxUsbSpeed")) j["maxUsbSpeed"].get_to(c.maxUsbSpeed); - if(j.contains("vid")) j["vid"].get_to(c.vid); - if(j.contains("pid")) j["pid"].get_to(c.pid); -} +DEPTHAI_BOOTLOADER_NLOHMANN_DEFINE_TYPE_OPTIONAL_NON_INTRUSIVE(UsbConfig, timeoutMs, maxUsbSpeed, vid, pid); struct Config { - Memory applicationMemory; + Memory appMem = Memory::AUTO; UsbConfig usb; NetworkConfig network; }; - - -// Serialization/Deserialization - Config -// Doesn't error if some fields are missing -inline void to_json(nlohmann::json& j, const Config& c) { - // Manually serialize the fields - without modifying any existing fields - nlohmann::to_json(j["appMem"], c.applicationMemory); - nlohmann::to_json(j["network"], c.network); - nlohmann::to_json(j["usb"], c.usb); -} -inline void from_json(const nlohmann::json& j, Config& c) { - // Manually serialize the fields - if(j.contains("appMem")) j["appMem"].get_to(c.applicationMemory); - if(j.contains("network")) j["network"].get_to(c.network); - if(j.contains("usb")) j["usb"].get_to(c.usb); -} - +DEPTHAI_BOOTLOADER_NLOHMANN_DEFINE_TYPE_OPTIONAL_NON_INTRUSIVE(Config, appMem, usb, network); } // namespace bootloader } // namespace dai From 678ff68015661137137c454383cc2ff7bf82f016 Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Wed, 18 Aug 2021 00:36:24 +0200 Subject: [PATCH 08/17] Updated default timeout for network bootloader --- include/depthai-bootloader-shared/Config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/depthai-bootloader-shared/Config.hpp b/include/depthai-bootloader-shared/Config.hpp index fe349cc..00a1571 100644 --- a/include/depthai-bootloader-shared/Config.hpp +++ b/include/depthai-bootloader-shared/Config.hpp @@ -30,7 +30,7 @@ struct NetworkConfig { * if timeout == 0 - no timeout * if timeout > 0 - waits timeout milliseconds */ - int timeoutMs = 15000; + int timeoutMs = 30000; // Network configuration options // IPv4 std::uint32_t ipv4 = 0; From 596fab896b1a543a1e022553bc6782cfb5cea024 Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Thu, 19 Aug 2021 21:11:14 +0200 Subject: [PATCH 09/17] Updated SBR and added a response to BootApplication call --- include/depthai-bootloader-shared/Bootloader.hpp | 10 ++++++++++ include/depthai-bootloader-shared/SBR.h | 14 +++++++++++--- src/SBR.c | 16 ++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/include/depthai-bootloader-shared/Bootloader.hpp b/include/depthai-bootloader-shared/Bootloader.hpp index c082ad7..10350cb 100644 --- a/include/depthai-bootloader-shared/Bootloader.hpp +++ b/include/depthai-bootloader-shared/Bootloader.hpp @@ -148,6 +148,7 @@ namespace response { BOOTLOADER_TYPE, GET_BOOTLOADER_CONFIG, BOOTLOADER_MEMORY, + BOOT_APPLICATION, }; struct BaseResponse { @@ -207,6 +208,15 @@ namespace response { // Data Memory memory; }; + + struct BootApplication : BaseResponse { + // Common + BootApplication() : BaseResponse(BOOT_APPLICATION) {} + + // Data + uint32_t success; + char errorMsg[64]; + }; } } // namespace bootloader diff --git a/include/depthai-bootloader-shared/SBR.h b/include/depthai-bootloader-shared/SBR.h index ad51b10..7e90f17 100644 --- a/include/depthai-bootloader-shared/SBR.h +++ b/include/depthai-bootloader-shared/SBR.h @@ -12,9 +12,15 @@ extern "C" { #define SBR_SECTION_NAME_MAX_SIZE (16) #define SBR_IDENTIFIER_SIZE (2) -#define SBR_SECTION_FLAG_BOOTABLE (0x1) -#define SBR_SECTION_FLAG_IGNORE_CHECKSUM (0x2) - +#define SBR_SECTION_FLAG_BOOTABLE (1 << 0) +#define SBR_SECTION_FLAG_IGNORE_CHECKSUM (1 << 1) +#define SBR_SECTION_FLAG_COMPRESSION_MASK (0x7 << 2) +typedef enum { + SBR_NO_COMPRESSION = 0U << 2, + SBR_COMPRESSION_ZLIB = 1U << 2, + SBR_COMPRESSION_GZ = 2U << 2, + SBR_COMPRESSION_XZ = 3U << 2, +} SBR_COMPRESSION; static const uint8_t SBR_IDENTIFIER[SBR_IDENTIFIER_SIZE] = {'B', 'R'}; @@ -62,10 +68,12 @@ void sbr_section_set_checksum(SBR_SECTION* sbr_section, uint32_t checksum); void sbr_section_set_type(SBR_SECTION* sbr_section, uint8_t type); void sbr_section_set_bootable(SBR_SECTION* sbr_section, bool bootable); void sbr_section_set_ignore_checksum(SBR_SECTION* sbr_section, bool ignore_checksum); +void sbr_section_set_compression(SBR_SECTION* sbr_section, SBR_COMPRESSION compression); bool sbr_section_get_bootable(const SBR_SECTION* sbr_section); bool sbr_section_get_ignore_checksum(const SBR_SECTION* sbr_section); bool sbr_section_is_valid(const SBR_SECTION* sbr_section); +SBR_COMPRESSION sbr_section_get_compression(const SBR_SECTION* sbr_section); #ifdef __cplusplus } diff --git a/src/SBR.c b/src/SBR.c index c55e0ba..4af87d8 100644 --- a/src/SBR.c +++ b/src/SBR.c @@ -137,6 +137,12 @@ bool sbr_section_get_ignore_checksum(const SBR_SECTION* sbr_section) { return false; } +SBR_COMPRESSION sbr_section_get_compression(const SBR_SECTION* sbr_section){ + if(sbr_section == NULL) return SBR_NO_COMPRESSION; + return sbr_section->flags & SBR_SECTION_FLAG_COMPRESSION_MASK; +} + + bool sbr_section_is_valid(const SBR_SECTION* sbr_section) { // Valid SBR section must have a name set, as well as a non zero size if(sbr_section->name[0] == 0 || ((uint8_t)sbr_section->name[0]) == 0xFF) { @@ -206,3 +212,13 @@ void sbr_section_set_ignore_checksum(SBR_SECTION* sbr_section, bool ignore_check sbr_section->flags &= ~SBR_SECTION_FLAG_IGNORE_CHECKSUM; } } + +void sbr_section_set_compression(SBR_SECTION* sbr_section, SBR_COMPRESSION compression){ + assert(sbr_section != NULL); + + // Clear previous compression + sbr_section->flags &= ~SBR_SECTION_FLAG_COMPRESSION_MASK; + + // Set new compression + sbr_section->flags |= compression; +} From 819c84e30cb54c873645c133bf0e1c1f3ca4b469 Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Thu, 19 Aug 2021 23:35:29 +0200 Subject: [PATCH 10/17] Updated SBR.c --- src/SBR.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/SBR.c b/src/SBR.c index 4af87d8..2602db6 100644 --- a/src/SBR.c +++ b/src/SBR.c @@ -137,12 +137,11 @@ bool sbr_section_get_ignore_checksum(const SBR_SECTION* sbr_section) { return false; } -SBR_COMPRESSION sbr_section_get_compression(const SBR_SECTION* sbr_section){ +SBR_COMPRESSION sbr_section_get_compression(const SBR_SECTION* sbr_section) { if(sbr_section == NULL) return SBR_NO_COMPRESSION; return sbr_section->flags & SBR_SECTION_FLAG_COMPRESSION_MASK; } - bool sbr_section_is_valid(const SBR_SECTION* sbr_section) { // Valid SBR section must have a name set, as well as a non zero size if(sbr_section->name[0] == 0 || ((uint8_t)sbr_section->name[0]) == 0xFF) { @@ -213,7 +212,7 @@ void sbr_section_set_ignore_checksum(SBR_SECTION* sbr_section, bool ignore_check } } -void sbr_section_set_compression(SBR_SECTION* sbr_section, SBR_COMPRESSION compression){ +void sbr_section_set_compression(SBR_SECTION* sbr_section, SBR_COMPRESSION compression) { assert(sbr_section != NULL); // Clear previous compression From bb7079b46109756624d80fe91d1097f2c156d34d Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Fri, 20 Aug 2021 01:54:47 +0200 Subject: [PATCH 11/17] Updated BL config commands --- include/depthai-bootloader-shared/Bootloader.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/depthai-bootloader-shared/Bootloader.hpp b/include/depthai-bootloader-shared/Bootloader.hpp index 10350cb..a6bb88a 100644 --- a/include/depthai-bootloader-shared/Bootloader.hpp +++ b/include/depthai-bootloader-shared/Bootloader.hpp @@ -116,10 +116,11 @@ namespace request { SetBootloaderConfig() : BaseRequest(SET_BOOTLOADER_CONFIG) {} // Data - Memory memory; - uint32_t clearConfig; - uint32_t totalSize; - uint32_t numPackets; + Memory memory = Memory::AUTO; + int64_t offset = -1; + uint32_t clearConfig = 0; + uint32_t totalSize = 0; + uint32_t numPackets = 0; }; struct GetBootloaderConfig : BaseRequest { @@ -127,7 +128,8 @@ namespace request { GetBootloaderConfig() : BaseRequest(GET_BOOTLOADER_CONFIG) {} // Data - Memory memory; + Memory memory = Memory::AUTO; + int64_t offset = -1; }; struct BootloaderMemory : BaseRequest { // Common From d82e38dacd5bca22469c89489e8aacd67bd49f20 Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Fri, 20 Aug 2021 02:06:58 +0200 Subject: [PATCH 12/17] Updated GetBootloaderConfig command --- include/depthai-bootloader-shared/Bootloader.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/depthai-bootloader-shared/Bootloader.hpp b/include/depthai-bootloader-shared/Bootloader.hpp index a6bb88a..3a48b66 100644 --- a/include/depthai-bootloader-shared/Bootloader.hpp +++ b/include/depthai-bootloader-shared/Bootloader.hpp @@ -130,6 +130,7 @@ namespace request { // Data Memory memory = Memory::AUTO; int64_t offset = -1; + uint32_t maxSize = 0; }; struct BootloaderMemory : BaseRequest { // Common From 2eab2771cfa55034f7012c5ae110cab7c294b817 Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Fri, 20 Aug 2021 02:07:23 +0200 Subject: [PATCH 13/17] Added AUTO option to BL Type --- include/depthai-bootloader-shared/Structure.hpp | 1 + include/depthai-bootloader-shared/Type.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/depthai-bootloader-shared/Structure.hpp b/include/depthai-bootloader-shared/Structure.hpp index 2e56239..801eae3 100644 --- a/include/depthai-bootloader-shared/Structure.hpp +++ b/include/depthai-bootloader-shared/Structure.hpp @@ -72,6 +72,7 @@ struct UsbBootloaderStructure : Structure { inline const Structure getStructure(Type type){ switch(type){ + case Type::AUTO: throw std::invalid_argument("Invalid argument to getStructure function"); case Type::USB: return UsbBootloaderStructure(); case Type::NETWORK: return NetworkBootloaderStructure(); } diff --git a/include/depthai-bootloader-shared/Type.hpp b/include/depthai-bootloader-shared/Type.hpp index a4d462c..adeead7 100644 --- a/include/depthai-bootloader-shared/Type.hpp +++ b/include/depthai-bootloader-shared/Type.hpp @@ -9,7 +9,7 @@ namespace bootloader { enum class Type : std::int32_t { - USB, NETWORK + AUTO = -1, USB = 0, NETWORK = 1 }; } // namespace bootloader From 7b2c4ab141df199b3d08e06bda20a9326576c345 Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Fri, 20 Aug 2021 02:31:07 +0200 Subject: [PATCH 14/17] Added missing header to Structure --- include/depthai-bootloader-shared/Structure.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/depthai-bootloader-shared/Structure.hpp b/include/depthai-bootloader-shared/Structure.hpp index 801eae3..0b729bb 100644 --- a/include/depthai-bootloader-shared/Structure.hpp +++ b/include/depthai-bootloader-shared/Structure.hpp @@ -2,6 +2,7 @@ // std #include +#include // project #include "Section.hpp" From d411e490e94417746ad6da597d9d284bdab10d2c Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Sun, 22 Aug 2021 23:51:21 +0200 Subject: [PATCH 15/17] Added naming and version information to responses and requests --- .../depthai-bootloader-shared/Bootloader.hpp | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/include/depthai-bootloader-shared/Bootloader.hpp b/include/depthai-bootloader-shared/Bootloader.hpp index 3a48b66..dd56737 100644 --- a/include/depthai-bootloader-shared/Bootloader.hpp +++ b/include/depthai-bootloader-shared/Bootloader.hpp @@ -40,12 +40,18 @@ namespace request { struct UsbRomBoot : BaseRequest { // Common UsbRomBoot() : BaseRequest(USB_ROM_BOOT) {} + + static constexpr auto VERSION = "0.0.2"; + static constexpr const char* NAME = "UsbRomBoot"; }; struct BootApplication : BaseRequest { // Common BootApplication() : BaseRequest(BOOT_APPLICATION) {} // Data + + static constexpr const char* VERSION = "0.0.2"; + static constexpr const char* NAME = "BootApplication"; }; struct UpdateFlash : BaseRequest { @@ -57,6 +63,9 @@ namespace request { Storage storage; uint32_t totalSize; uint32_t numPackets; + + static constexpr const char* VERSION = "0.0.2"; + static constexpr const char* NAME = "UpdateFlash"; }; @@ -65,6 +74,9 @@ namespace request { GetBootloaderVersion() : BaseRequest(GET_BOOTLOADER_VERSION) {} // Data + + static constexpr const char* VERSION = "0.0.2"; + static constexpr const char* NAME = "GetBootloaderVersion"; }; // 0.0.12 or higher @@ -75,6 +87,9 @@ namespace request { // Data uint32_t totalSize; uint32_t numPackets; + + static constexpr const char* VERSION = "0.0.12"; + static constexpr const char* NAME = "BootMemory"; }; // UpdateFlashEx - Additional options @@ -87,6 +102,9 @@ namespace request { Section section; uint32_t totalSize; uint32_t numPackets; + + static constexpr const char* VERSION = "0.0.12"; + static constexpr const char* NAME = "UpdateFlashEx"; }; // UpdateFlashEx2 - Additional options @@ -99,6 +117,9 @@ namespace request { uint32_t offset; uint32_t totalSize; uint32_t numPackets; + + static constexpr const char* VERSION = "0.0.12"; + static constexpr const char* NAME = "UpdateFlashEx2"; }; @@ -107,6 +128,9 @@ namespace request { GetBootloaderType() : BaseRequest(GET_BOOTLOADER_TYPE) {} // Data + + static constexpr const char* VERSION = "0.0.12"; + static constexpr const char* NAME = "GetBootloaderType"; }; @@ -121,6 +145,9 @@ namespace request { uint32_t clearConfig = 0; uint32_t totalSize = 0; uint32_t numPackets = 0; + + static constexpr const char* VERSION = "0.0.14"; + static constexpr const char* NAME = "SetBootloaderConfig"; }; struct GetBootloaderConfig : BaseRequest { @@ -131,12 +158,18 @@ namespace request { Memory memory = Memory::AUTO; int64_t offset = -1; uint32_t maxSize = 0; + + static constexpr const char* VERSION = "0.0.14"; + static constexpr const char* NAME = "GetBootloaderConfig"; }; struct BootloaderMemory : BaseRequest { // Common BootloaderMemory() : BaseRequest(BOOTLOADER_MEMORY) {} // Data + + static constexpr const char* VERSION = "0.0.14"; + static constexpr const char* NAME = "BootloaderMemory"; }; } @@ -167,6 +200,9 @@ namespace response { // Data uint32_t success; char errorMsg[64]; + + static constexpr const char* VERSION = "0.0.2"; + static constexpr const char* NAME = "FlashComplete"; }; struct FlashStatusUpdate : BaseResponse { // Common @@ -174,6 +210,9 @@ namespace response { // Data float progress; + + static constexpr const char* VERSION = "0.0.2"; + static constexpr const char* NAME = "FlashStatusUpdate"; }; struct BootloaderVersion : BaseResponse { // Common @@ -181,6 +220,9 @@ namespace response { // Data uint32_t major, minor, patch; + + static constexpr const char* VERSION = "0.0.2"; + static constexpr const char* NAME = "BootloaderVersion"; }; struct BootloaderType : BaseResponse { @@ -189,6 +231,9 @@ namespace response { // Data Type type; + + static constexpr const char* VERSION = "0.0.12"; + static constexpr const char* NAME = "BootloaderType"; }; @@ -202,6 +247,9 @@ namespace response { char errorMsg[64]; uint32_t totalSize; uint32_t numPackets; + + static constexpr const char* VERSION = "0.0.14"; + static constexpr const char* NAME = "GetBootloaderConfig"; }; struct BootloaderMemory : BaseResponse { @@ -210,6 +258,9 @@ namespace response { // Data Memory memory; + + static constexpr const char* VERSION = "0.0.14"; + static constexpr const char* NAME = "BootloaderMemory"; }; struct BootApplication : BaseResponse { @@ -219,6 +270,9 @@ namespace response { // Data uint32_t success; char errorMsg[64]; + + static constexpr const char* VERSION = "0.0.14"; + static constexpr const char* NAME = "BootApplication"; }; } From 1d97cf4630268c1292dfe9104abc19c7fe486da5 Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Mon, 23 Aug 2021 01:02:16 +0200 Subject: [PATCH 16/17] Added definitions for Bootloader.hpp --- src/Bootloader.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/Bootloader.cpp diff --git a/src/Bootloader.cpp b/src/Bootloader.cpp new file mode 100644 index 0000000..016d504 --- /dev/null +++ b/src/Bootloader.cpp @@ -0,0 +1,49 @@ +#include "depthai-bootloader-shared/Bootloader.hpp" + +namespace dai { +namespace bootloader { + +// Bootloader.hpp definitions + +// Requests +decltype(request::UsbRomBoot::VERSION) constexpr request::UsbRomBoot::VERSION; +decltype(request::UsbRomBoot::NAME) constexpr request::UsbRomBoot::NAME; +decltype(request::BootApplication::VERSION) constexpr request::BootApplication::VERSION; +decltype(request::BootApplication::NAME) constexpr request::BootApplication::NAME; +decltype(request::UpdateFlash::VERSION) constexpr request::UpdateFlash::VERSION; +decltype(request::UpdateFlash::NAME) constexpr request::UpdateFlash::NAME; +decltype(request::GetBootloaderVersion::VERSION) constexpr request::GetBootloaderVersion::VERSION; +decltype(request::GetBootloaderVersion::NAME) constexpr request::GetBootloaderVersion::NAME; +decltype(request::BootMemory::VERSION) constexpr request::BootMemory::VERSION; +decltype(request::BootMemory::NAME) constexpr request::BootMemory::NAME; +decltype(request::UpdateFlashEx::VERSION) constexpr request::UpdateFlashEx::VERSION; +decltype(request::UpdateFlashEx::NAME) constexpr request::UpdateFlashEx::NAME; +decltype(request::UpdateFlashEx2::VERSION) constexpr request::UpdateFlashEx2::VERSION; +decltype(request::UpdateFlashEx2::NAME) constexpr request::UpdateFlashEx2::NAME; +decltype(request::GetBootloaderType::VERSION) constexpr request::GetBootloaderType::VERSION; +decltype(request::GetBootloaderType::NAME) constexpr request::GetBootloaderType::NAME; +decltype(request::SetBootloaderConfig::VERSION) constexpr request::SetBootloaderConfig::VERSION; +decltype(request::SetBootloaderConfig::NAME) constexpr request::SetBootloaderConfig::NAME; +decltype(request::GetBootloaderConfig::VERSION) constexpr request::GetBootloaderConfig::VERSION; +decltype(request::GetBootloaderConfig::NAME) constexpr request::GetBootloaderConfig::NAME; +decltype(request::BootloaderMemory::VERSION) constexpr request::BootloaderMemory::VERSION; +decltype(request::BootloaderMemory::NAME) constexpr request::BootloaderMemory::NAME; + +// Responses +decltype(response::FlashComplete::VERSION) constexpr response::FlashComplete::VERSION; +decltype(response::FlashComplete::NAME) constexpr response::FlashComplete::NAME; +decltype(response::FlashStatusUpdate::VERSION) constexpr response::FlashStatusUpdate::VERSION; +decltype(response::FlashStatusUpdate::NAME) constexpr response::FlashStatusUpdate::NAME; +decltype(response::BootloaderVersion::VERSION) constexpr response::BootloaderVersion::VERSION; +decltype(response::BootloaderVersion::NAME) constexpr response::BootloaderVersion::NAME; +decltype(response::BootloaderType::VERSION) constexpr response::BootloaderType::VERSION; +decltype(response::BootloaderType::NAME) constexpr response::BootloaderType::NAME; +decltype(response::GetBootloaderConfig::VERSION) constexpr response::GetBootloaderConfig::VERSION; +decltype(response::GetBootloaderConfig::NAME) constexpr response::GetBootloaderConfig::NAME; +decltype(response::BootloaderMemory::VERSION) constexpr response::BootloaderMemory::VERSION; +decltype(response::BootloaderMemory::NAME) constexpr response::BootloaderMemory::NAME; +decltype(response::BootApplication::VERSION) constexpr response::BootApplication::VERSION; +decltype(response::BootApplication::NAME) constexpr response::BootApplication::NAME; + +} +} \ No newline at end of file From 1a4da6776a1c019ee2698ab7587a5c7e81f89d60 Mon Sep 17 00:00:00 2001 From: TheMarpe Date: Tue, 24 Aug 2021 20:58:35 +0200 Subject: [PATCH 17/17] Updated formatting --- src/Bootloader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bootloader.cpp b/src/Bootloader.cpp index 016d504..16a399f 100644 --- a/src/Bootloader.cpp +++ b/src/Bootloader.cpp @@ -45,5 +45,5 @@ decltype(response::BootloaderMemory::NAME) constexpr response::BootloaderMemory: decltype(response::BootApplication::VERSION) constexpr response::BootApplication::VERSION; decltype(response::BootApplication::NAME) constexpr response::BootApplication::NAME; -} -} \ No newline at end of file +} // namespace bootloader +} // namespace dai \ No newline at end of file