Skip to content

Commit

Permalink
🚸 UUID fallback to STM32 device SN (MarlinFirmware#24759)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
stuartpittaway and thinkyhead committed Dec 16, 2022
1 parent a7a493d commit f1a05d1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
37 changes: 29 additions & 8 deletions Marlin/src/gcode/host/M115.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "../../feature/caselight.h"
#endif

#if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID)
#include "../../libs/hex_print.h"
#endif

//#define MINIMAL_CAP_LINES // Don't even mention the disabled capabilities

#if ENABLED(EXTENDED_CAPABILITIES_REPORT)
Expand Down Expand Up @@ -59,20 +63,37 @@
* the capability is not present.
*/
void GcodeSuite::M115() {
SERIAL_ECHOLNPGM(
"FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ") "
"SOURCE_CODE_URL:" SOURCE_CODE_URL " "
"PROTOCOL_VERSION:" PROTOCOL_VERSION " "
"MACHINE_TYPE:" MACHINE_NAME " "
"EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " "
SERIAL_ECHOPGM("FIRMWARE_NAME:Marlin"
" " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ")"
" SOURCE_CODE_URL:" SOURCE_CODE_URL
" PROTOCOL_VERSION:" PROTOCOL_VERSION
" MACHINE_TYPE:" MACHINE_NAME
" EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS)
#if NUM_AXES != XYZ
"AXIS_COUNT:" STRINGIFY(NUM_AXES) " "
" AXIS_COUNT:" STRINGIFY(NUM_AXES)
#endif
#ifdef MACHINE_UUID
"UUID:" MACHINE_UUID
" 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;
LOOP_L_N(i, 3) {
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);
}
#endif

SERIAL_EOL();

#if ENABLED(EXTENDED_CAPABILITIES_REPORT)

// The port that sent M115
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@

// I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC)
#define HAS_MCP3426_ADC
#ifdef STM32F4
#define HAS_STM32_UID
#endif

//
// Servos
Expand Down

0 comments on commit f1a05d1

Please sign in to comment.