Просмотр исходного кода

🚸 UUID fallback to STM32 device SN (#24759)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Stuart Pittaway 2 лет назад
Родитель
Сommit
6f68942e83
Аккаунт пользователя с таким Email не найден
2 измененных файлов: 32 добавлений и 8 удалений
  1. 29
    8
      Marlin/src/gcode/host/M115.cpp
  2. 3
    0
      Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h

+ 29
- 8
Marlin/src/gcode/host/M115.cpp Просмотреть файл

@@ -32,6 +32,10 @@
32 32
   #include "../../feature/caselight.h"
33 33
 #endif
34 34
 
35
+#if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID)
36
+  #include "../../libs/hex_print.h"
37
+#endif
38
+
35 39
 //#define MINIMAL_CAP_LINES // Don't even mention the disabled capabilities
36 40
 
37 41
 #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
@@ -59,20 +63,37 @@
59 63
  *       the capability is not present.
60 64
  */
61 65
 void GcodeSuite::M115() {
62
-  SERIAL_ECHOLNPGM(
63
-    "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ") "
64
-    "SOURCE_CODE_URL:" SOURCE_CODE_URL " "
65
-    "PROTOCOL_VERSION:" PROTOCOL_VERSION " "
66
-    "MACHINE_TYPE:" MACHINE_NAME " "
67
-    "EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " "
66
+  SERIAL_ECHOPGM("FIRMWARE_NAME:Marlin"
67
+    " " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ")"
68
+    " SOURCE_CODE_URL:" SOURCE_CODE_URL
69
+    " PROTOCOL_VERSION:" PROTOCOL_VERSION
70
+    " MACHINE_TYPE:" MACHINE_NAME
71
+    " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS)
68 72
     #if NUM_AXES != XYZ
69
-      "AXIS_COUNT:" STRINGIFY(NUM_AXES) " "
73
+      " AXIS_COUNT:" STRINGIFY(NUM_AXES)
70 74
     #endif
71 75
     #ifdef MACHINE_UUID
72
-      "UUID:" MACHINE_UUID
76
+      " UUID:" MACHINE_UUID
73 77
     #endif
74 78
   );
75 79
 
80
+  // STM32UID:111122223333
81
+  #if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID)
82
+    // STM32 based devices output the CPU device serial number
83
+    // Used by LumenPnP / OpenPNP to keep track of unique hardware/configurations
84
+    // https://github.com/opulo-inc/lumenpnp
85
+    // Although this code should work on all STM32 based boards
86
+    SERIAL_ECHOPGM(" UUID:");
87
+    uint32_t *uid_address = (uint32_t*)UID_BASE;
88
+    LOOP_L_N(i, 3) {
89
+      const uint32_t UID = uint32_t(READ_REG(*(uid_address)));
90
+      uid_address += 4U;
91
+      for (int B = 24; B >= 0; B -= 8) print_hex_byte(UID >> B);
92
+    }
93
+  #endif
94
+
95
+  SERIAL_EOL();
96
+
76 97
   #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
77 98
 
78 99
     // The port that sent M115

+ 3
- 0
Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h Просмотреть файл

@@ -44,6 +44,9 @@
44 44
 
45 45
 // I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC)
46 46
 #define HAS_MCP3426_ADC
47
+#ifdef STM32F4
48
+  #define HAS_STM32_UID
49
+#endif
47 50
 
48 51
 //
49 52
 // Servos

Загрузка…
Отмена
Сохранить