From 22fdfa96292a2cd2490920b031567a0fab5eb22a Mon Sep 17 00:00:00 2001
From: DerAndere <26200979+DerAndere1@users.noreply.github.com>
Date: Thu, 26 Aug 2021 01:05:06 +0200
Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Melzi=20with=20OptiBoot=20build?=
 =?UTF-8?q?=20(#22630)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Marlin/src/pins/pins.h                  |  2 +-
 Marlin/src/pins/sanguino/pins_ANET_10.h | 18 +++++++++++++++++-
 ini/avr.ini                             |  1 +
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h
index 1c3e1ac7cf..86283dae24 100644
--- a/Marlin/src/pins/pins.h
+++ b/Marlin/src/pins/pins.h
@@ -329,7 +329,7 @@
 #elif MB(OMCA)
   #include "sanguino/pins_OMCA.h"               // ATmega644P, ATmega644                  env:sanguino644p
 #elif MB(ANET_10)
-  #include "sanguino/pins_ANET_10.h"            // ATmega1284P                            env:sanguino1284p env:sanguino1284p_optimized
+  #include "sanguino/pins_ANET_10.h"            // ATmega1284P                            env:sanguino1284p env:sanguino1284p_optimized env:melzi_optiboot
 #elif MB(SETHI)
   #include "sanguino/pins_SETHI.h"              // ATmega644P, ATmega644, ATmega1284P     env:sanguino1284p_optimized env:sanguino1284p env:sanguino644p
 
diff --git a/Marlin/src/pins/sanguino/pins_ANET_10.h b/Marlin/src/pins/sanguino/pins_ANET_10.h
index ac8fa80eb8..e54209ed6a 100644
--- a/Marlin/src/pins/sanguino/pins_ANET_10.h
+++ b/Marlin/src/pins/sanguino/pins_ANET_10.h
@@ -86,8 +86,24 @@
  *   Many thanks to Hans Raaf (@oderwat) for developing the Anet-specific software and supporting the Anet community.
  */
 
+/**
+ * OptiBoot Bootloader:
+ *   Optiboot is an alternative bootloader that can be flashed on the board to free up space for a larger firmware build.
+ *   See https://github.com/Optiboot/optiboot for more information.
+ *
+ * Install Marlin with Arduino IDE:
+ *   For a board with the stock bootloader, select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.'
+ *   For a board with OptiBoot, select 'Sanguino (Optiboot)' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.'
+ *
+ * Install Marlin with PlatformIO IDE:
+ *   (NOTE: You can set a default build environment by editing the value of 'default_env' in 'platformio.ini'.
+ *          For the best user experience install the "Auto Build Marlin" extension.)
+ *   For a board with the stock bootloader use Build / Upload under the 'sanguino1284p' or 'sanguino1284p_optimized' target.
+ *   For a board with OptiBoot, use Build / Upload under the 'melzi_optiboot' target.
+ */
+
 #if NOT_TARGET(__AVR_ATmega1284P__)
-  #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'melzi' or 'melzi_optiboot.')"
+  #error "Oops! Select 'Sanguino' in 'Tools > Board' and 'ATmega1284P' in 'Tools > Processor.' (For PlatformIO, use 'sanguino1284p' or 'sanguino1284p_optimized'. With optiboot, use 'melzi_optiboot.')"
 #endif
 
 #define BOARD_INFO_NAME "Anet 1.0"
diff --git a/ini/avr.ini b/ini/avr.ini
index 88f54a723c..e4d64de712 100644
--- a/ini/avr.ini
+++ b/ini/avr.ini
@@ -141,6 +141,7 @@ platform     = atmelavr
 extends      = common_avr8
 board        = sanguino_atmega1284p
 upload_speed = 115200
+board_upload.maximum_size = 130048
 
 #
 # Melzi and clones (Zonestar Melzi2 with tuned flags)