🚸 UUID fallback to STM32 device SN (#24759)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Stuart Pittaway 2022-09-26 22:18:15 +01:00 committed by Scott Lahteine
parent a7a493d795
commit f1a05d19b0
2 changed files with 32 additions and 8 deletions

View File

@ -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)
@ -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

View File

@ -44,6 +44,9 @@
// I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC)
#define HAS_MCP3426_ADC
#ifdef STM32F4
#define HAS_STM32_UID
#endif
//
// Servos