From 671b574c9056be8850530cc790251d7aea3a9b7e Mon Sep 17 00:00:00 2001
From: GHGiampy <tisgiampy@tiscali.it>
Date: Mon, 17 Jan 2022 23:18:59 +0100
Subject: [PATCH 1/4] Fix SFN generation

---
 Marlin/src/sd/SdBaseFile.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp
index cfbc8fe313541..64d0ad68bd809 100644
--- a/Marlin/src/sd/SdBaseFile.cpp
+++ b/Marlin/src/sd/SdBaseFile.cpp
@@ -1113,8 +1113,8 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) {
       // Check minimal length
       if (iFree < 3) {
         // Append 4 extra characters
-        name[iFree++] = random(0,24) + 'A'; name[iFree++] = random(1,9) + 'A';
-        name[iFree++] = random(0,24) + 'A'; name[iFree++] = random(1,9) + 'A';
+        name[iFree++] = random(0,24) + 'A'; name[iFree++] = random(0,24) + 'A';
+        name[iFree++] = random(0,24) + 'A'; name[iFree++] = random(0,24) + 'A';
       }
       // Append '~cnt' characters
       if (iFree > 5) iFree = 5; // Force the append in the last 3 characters of name part

From 079735e9d59bb489452b3d070f931f5c1d48c410 Mon Sep 17 00:00:00 2001
From: GHGiampy <tisgiampy@tiscali.it>
Date: Mon, 17 Jan 2022 23:20:26 +0100
Subject: [PATCH 2/4] Added LONG_FILENAME_WRITE and CUSTOM_FIRMWARE_UPLOAD to
 M115

---
 Marlin/src/gcode/host/M115.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp
index 08943ed5f299d..145179a32ccef 100644
--- a/Marlin/src/gcode/host/M115.cpp
+++ b/Marlin/src/gcode/host/M115.cpp
@@ -154,6 +154,12 @@ void GcodeSuite::M115() {
     // LONG_FILENAME_HOST_SUPPORT (M33)
     cap_line(F("LONG_FILENAME"), ENABLED(LONG_FILENAME_HOST_SUPPORT));
 
+    // LONG_FILENAME_WRITE_SUPPORT (M20, M23, M28, M29, M30, M33, ...)
+    cap_line(F("LONG_FILENAME_WRITE"), ENABLED(LONG_FILENAME_WRITE_SUPPORT));
+
+    // CUSTOM_FIRMWARE_UPLOAD (M20)
+    cap_line(F("CUSTOM_FIRMWARE_UPLOAD"), ENABLED(CUSTOM_FIRMWARE_UPLOAD));
+
     // EXTENDED_M20 (M20 L)
     cap_line(F("EXTENDED_M20"), ENABLED(LONG_FILENAME_HOST_SUPPORT));
 

From 58ed6370c426303c9006ee0789014e41f2bfc534 Mon Sep 17 00:00:00 2001
From: GHGiampy <tisgiampy@tiscali.it>
Date: Mon, 17 Jan 2022 23:21:15 +0100
Subject: [PATCH 3/4] More info on comment

---
 Marlin/Configuration_adv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index 7e7e02d9afe8c..9598755f53113 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -1526,7 +1526,7 @@
   // LCD's font must contain the characters. Check your selected LCD language.
   //#define UTF_FILENAME_SUPPORT
 
-  // This allows Marlin to create files with long filenames
+  // This allows Marlin to create/delete files with long filenames with M28, M30 and Binary Transfer Protocol
   //#define LONG_FILENAME_WRITE_SUPPORT
 
   // This allows hosts to request long names for files and folders with M33

From 5d9a9db3f6954c64d287904fcc561b33c1b92d08 Mon Sep 17 00:00:00 2001
From: GHGiampy <tisgiampy@tiscali.it>
Date: Mon, 17 Jan 2022 23:29:18 +0100
Subject: [PATCH 4/4] Other comment

---
 Marlin/Configuration_adv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index 9598755f53113..b2ecd14d0c787 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -1529,7 +1529,7 @@
   // This allows Marlin to create/delete files with long filenames with M28, M30 and Binary Transfer Protocol
   //#define LONG_FILENAME_WRITE_SUPPORT
 
-  // This allows hosts to request long names for files and folders with M33
+  // This allows hosts to request long names for files and folders with M33 and M20
   //#define LONG_FILENAME_HOST_SUPPORT
 
   // Enable this option to scroll long filenames in the SD card menu