diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 443d73bfcf..ccebb87df9 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -88,10 +88,6 @@ #define MACHINE_NAME DEFAULT_MACHINE_NAME #endif -#ifndef MACHINE_UUID - #define MACHINE_UUID DEFAULT_MACHINE_UUID -#endif - #define MARLIN_WEBSITE_URL "marlinfw.org" //#if !defined(STRING_SPLASH_LINE3) && defined(WEBSITE_URL) diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 6d79430e9e..b6306885a5 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -32,7 +32,7 @@ #include "../../feature/caselight.h" #endif -#if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID) +#if !defined(MACHINE_UUID) && HAS_STM32_UID #include "../../libs/hex_print.h" #endif @@ -69,24 +69,31 @@ void GcodeSuite::M115() { #if NUM_AXES != XYZ " AXIS_COUNT:" STRINGIFY(NUM_AXES) #endif + #if defined(MACHINE_UUID) || HAS_STM32_UID + " UUID:" + #endif #ifdef MACHINE_UUID - " UUID:" MACHINE_UUID + MACHINE_UUID #endif ); - // STM32UID:111122223333 - #if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID) - // STM32 based devices output the CPU device serial number - // Used by LumenPnP / OpenPNP to keep track of unique hardware/configurations - // https://github.com/opulo-inc/lumenpnp - // Although this code should work on all STM32 based boards - SERIAL_ECHOPGM(" UUID:"); - uint32_t *uid_address = (uint32_t*)UID_BASE; - for (uint8_t i = 0; i < 3; ++i) { - const uint32_t UID = uint32_t(READ_REG(*(uid_address))); - uid_address += 4U; - for (int B = 24; B >= 0; B -= 8) print_hex_byte(UID >> B); - } + #if !defined(MACHINE_UUID) && HAS_STM32_UID + /** + * STM32-based devices have a 96-bit CPU device serial number. + * Used by LumenPnP / OpenPNP to keep track of unique hardware/configurations. + * https://github.com/opulo-inc/lumenpnp + * This code should work on all STM32-based boards. + */ + #if ENABLED(STM32_UID_SHORT_FORM) + uint32_t * const UID = (uint32_t*)UID_BASE; + SERIAL_ECHO(hex_long(UID[0]), hex_long(UID[1]), hex_long(UID[2])); + #else + uint16_t * const UID = (uint16_t*)UID_BASE; + SERIAL_ECHO( + F("CEDE2A2F-"), hex_word(UID[0]), '-', hex_word(UID[1]), '-', hex_word(UID[2]), '-', + hex_word(UID[3]), hex_word(UID[4]), hex_word(UID[5]) + ); + #endif #endif SERIAL_EOL(); diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index ef404d271e..a7f4c2a1c2 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1216,11 +1216,6 @@ #define NO_EEPROM_SELECTED 1 #endif -// Flag whether hex_print.cpp is used -#if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE, DEBUG_CARDREADER, M20_TIMESTAMP_SUPPORT) - #define NEED_HEX_PRINT 1 -#endif - // Flags for Case Light having a color property or a single pin #if ENABLED(CASE_LIGHT_ENABLE) #if ANY(CASE_LIGHT_USE_NEOPIXEL, CASE_LIGHT_USE_RGB_LED) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 4e18fd3938..919416d4f3 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3298,3 +3298,15 @@ FIL_RUNOUT5_PULLDOWN, FIL_RUNOUT6_PULLDOWN, FIL_RUNOUT7_PULLDOWN, FIL_RUNOUT8_PULLDOWN) #define USING_PULLDOWNS 1 #endif + +// Machine UUID can come from STM32 CPU Serial Number +#ifdef MACHINE_UUID + #undef HAS_STM32_UID +#elif !HAS_STM32_UID && defined(DEFAULT_MACHINE_UUID) + #define MACHINE_UUID DEFAULT_MACHINE_UUID +#endif + +// Flag whether hex_print.cpp is needed +#if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE, DEBUG_CARDREADER, M20_TIMESTAMP_SUPPORT, HAS_STM32_UID) + #define NEED_HEX_PRINT 1 +#endif diff --git a/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h index 447c6227d6..f940cd7179 100644 --- a/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h +++ b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h @@ -44,8 +44,10 @@ // I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC) #define HAS_MCP3426_ADC + +// Opulo Lumen uses the CPU serial number #ifdef STM32F4 - #define HAS_STM32_UID + #define HAS_STM32_UID 1 #endif // diff --git a/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h index 2f55fce4c3..332e70a33c 100644 --- a/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h +++ b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h @@ -45,6 +45,11 @@ // I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC) #define HAS_MCP3426_ADC +// Opulo Lumen uses the CPU serial number +#ifdef STM32F4 + #define HAS_STM32_UID 1 +#endif + // // Servos //