diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp
index 4bbd804984bcc19a23d91d56d658d1b514b0c591..f66d1c6d4f3008d67e07d3ebbd66f6c5d9b7fc9a 100644
--- a/Marlin/Marlin_main.cpp
+++ b/Marlin/Marlin_main.cpp
@@ -8866,25 +8866,43 @@ void quickstop_stepper() {
inline void gcode_M420() {
#if ENABLED(AUTO_BED_LEVELING_UBL)
+
// L to load a mesh from the EEPROM
if (parser.seen('L')) {
- const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.state.storage_slot;
- const int16_t a = settings.calc_num_meshes();
- if (!a) {
+ #if ENABLED(EEPROM_SETTINGS)
+ const int8_t storage_slot = parser.has_value() ? parser.value_int() : ubl.state.storage_slot;
+ const int16_t a = settings.calc_num_meshes();
+
+ if (!a) {
+ SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
+ return;
+ }
+
+ if (!WITHIN(storage_slot, 0, a - 1)) {
+ SERIAL_PROTOCOLLNPGM("?Invalid storage slot.");
+ SERIAL_PROTOCOLLNPAIR("?Use 0 to ", a - 1);
+ return;
+ }
+
+ settings.load_mesh(storage_slot);
+ ubl.state.storage_slot = storage_slot;
+
+ #else
+
SERIAL_PROTOCOLLNPGM("?EEPROM storage not available.");
return;
- }
- if (!WITHIN(storage_slot, 0, a - 1)) {
- SERIAL_PROTOCOLLNPGM("?Invalid storage slot.");
- SERIAL_PROTOCOLLNPAIR("?Use 0 to ", a - 1);
- return;
- }
+ #endif
+ }
- settings.load_mesh(storage_slot);
- ubl.state.storage_slot = storage_slot;
+ // L to load a mesh from the EEPROM
+ if (parser.seen('L') || parser.seen('V')) {
+ ubl.display_map(0); // Currently only supports one map type
+ SERIAL_ECHOLNPAIR("UBL_MESH_VALID = ", UBL_MESH_VALID);
+ SERIAL_ECHOLNPAIR("ubl.state.storage_slot = ", ubl.state.storage_slot);
}
+
#endif // AUTO_BED_LEVELING_UBL
// V to print the matrix or mesh
@@ -8906,15 +8924,6 @@ void quickstop_stepper() {
#endif
}
- #if ENABLED(AUTO_BED_LEVELING_UBL)
- // L to load a mesh from the EEPROM
- if (parser.seen('L') || parser.seen('V')) {
- ubl.display_map(0); // Currently only supports one map type
- SERIAL_ECHOLNPAIR("UBL_MESH_VALID = ", UBL_MESH_VALID);
- SERIAL_ECHOLNPAIR("ubl.state.storage_slot = ", ubl.state.storage_slot);
- }
- #endif
-
bool to_enable = false;
if (parser.seen('S')) {
to_enable = parser.value_bool();