
ADVi3++ Firmware 5.x.x
Sorry all it's got to be done, The WARNING & Legal bit at the bottom.
-------------------------------------------------------------------------------
I am not affiliated, associated, authorized or endorsed directly / indirectly with the following company's [Wanhao], [DWIN Technology], [Marlin], [ADVi3++], [avrdudes], [Balco Brands LTD], [7-ZIP], [Antclabs inc] or [Microsoft].
This is my own work for my own purpose (I am developing Hardware modifications for the WDi3P v5.4 3D printer). I AM NOT responsible for any damage done to your printer or hardware when attempting using this modification, USE CAREFULY AT YOU OWN RISK.
Please read this guide at least twice before attempting any software or hardware modifications.
-------------------------------------------------------------------------------
​
This guide has been written for any persons who owns the popular but old Wanhao duplicator i3 Plus MK II v5.4 3D printer or derivatives. This guide will help download & compile a copy of opensource firmware advi3++ by Sebastien Andrivet & will integrate the popular auto bed levelling sensor bltouch by antclabs inc.
​
This guide will require the user to compile or download custom firmware for your printer, if you are interested in further information about this firmware I recommend signing up to advi3++ by Sebastien Andrivet. It is recommended the user purchase or manufacture a custom Expansion board sold in my store to allow for easy installation of the BLTouch Smart. The user will be required to download Visual Studio Code by Microsoft & ADVi3++ source code by Sebastien Andrivet.
​
NOTE – Precompiled binaries are for supporting patreons of advi3++ by Sebastien Andrivet only.
I WILL NOT be posting or supplying any links to precompiled binary's.
Link to ADVi3++ - Community Forum | Source Code | Patreon Support
​
​
This guide assumes the user already owns a BLTouch or BLTouch Smart.
This guide assumes the user uses Microsoft windows x32 / x64 bit.
This guide assumes the user has already subscribed to ADVi3++ & have access to the LCD components of the firmware
-------------------------------------------------------------------------------
Downloading / Extracting
​
Microsoft Visual Studio Code
​
So first off using your favourite web browser go to the following link for Visual Studio Code by Microsoft.
​
Weblink - https://code.visualstudio.com/
Direct Download - Microsoft Visual Studio Code Download
​
Save the file to your desktop or preferred download location, I have used the desktop in this guide for ease of access later.


Microsoft Visual Studio Code - Download pages
ADVi3++ Firmware source code
​
Using your favourite web browser go to the following link to download the source code for ADVi3++ firmware by Sebastien Andravet. This guide will be using v5.6.0 which is the latest version of source code as of writing this guide.
​
Weblink - https://github.com/andrivet/ADVi3pp/releases
Direct Download - ADVi3++ v5.6.0 source code Download
​
Save the file to your desktop or preferred download location, I have used the desktop in this guide for ease of access later.


ADVi3++ GitHub Source Code - Download pages
AVRDude - Microchip downloader / updater
​
This software is optional / for thoes who are having issues with the Microsoft Visual Studio Code uploading process. Using your favourite web browser go to the following link to download avrdude.
​
Weblink - https://github.com/avrdudes/avrdude/releases
Direct Download - avrdude x86 - avrdude x64
​
Save the file to your desktop or preferred download location, I have used the desktop in this guide for ease of access later.


avrdude - Download pages
Build Environment / software Setup
​
Now that you have successfully downloaded all the required software, we are going to setup the build environment that will allow us to successfully compile & upload the ADVi3++ Custom Firmware to our 3D Printer.



Microsoft Visual Studio Code
​
Locate & double click the Microsoft Visual Studio Code .EXE installer you downloaded earlier, you should be asked by windows security / user account control to confirm you are happy to run this software by clicking 'YES'.
It is important to know this will modify your computer by installing Microsoft Visual Studio Code to your C: Drive.


Microsoft Visual Studio Code will begin the install by asking you to accept the Licence agreement. Continue by clicking the dot next to 'I accept the agreement' & then click 'Next' to continue the installation.

Microsoft Visual Studio Code will now ask for an install location, unless you have a specific location or reason to change the install location, leave this as default & click 'NEXT' to continue installation.

Microsoft Visual Studio Code will now ask if you want to install shortcuts to start menu allowing for easy location / start of the application, I recommend you leave this as default & click 'NEXT' to continue installation.

Microsoft Visual Studio Code will now ask if you want the installer to perform any additional tasks during the install process, I recommend you leave this as default with the addition of clicking 'Create a desktop icon' & click 'NEXT' to continue installation.

Microsoft Visual Studio Code will now ask you to review all settings entered into the installer, if you are happy so far click 'Install' to continue installation.

Microsoft Visual Studio Code will now Install to the C: Drive on your computer, depending on the speed of your system this could take between 30 second to 2 minutes to complete the install.

Microsoft Visual Studio Code has now completed it's install & is now ready for setup. Untick 'Launch Visual studio code' & click 'FINISH'.

ADVi3++ Source Code
​
Locate the ADVi3++ .ZIP file you downloaded earlier & using your favourite compression software [ I'm using 7-zip ] extract to the desktop.
It is important to note this will require a minimum of 1GB of available HDD space on your computer to allow for extraction & compiling.




Avrdude
​
Locate the avrdude .ZIP file you downloaded earlier & using your favourite compression software [ I'm using 7-zip ] extract to the desktop.
It is important to note this will require a minimum of 10MB of available HDD space on your computer. This is also an optional step if you are experiencing issues with uploading from Microsoft Visual Studio Code.




Build Environment & extensions setup
​
Now you have successfully installed & Extracted all the required software, we are going to install & setup the required build environment extensions that will allow us to successfully compile & upload the ADVi3++ Custom Firmware to our 3D Printer.
​
Locate & double click the Microsoft Visual Studio Code shortcut on your desktop or start menu & you will be presented with a welcome page asking you what you would like to do.


Before we can start to modify the ADVi3++ source code you'll need to use the Microsoft Visual Studio Code inbuilt extension browser & install the required extensions to be able to translate / modify the code.
​
Open the extension browser by clicking on the Extensions icon or by using the keyboard shortcut CTL+SHIFT+X

You will now be required to search & install the following extensions into Microsoft Visual Studio Code, these extensions will allow for the compiling, diagnosing, & uploading of the ADVi3++ firmware.
​
It is important to note that after the install of the extensions, you will need to close Microsoft Visual Studio Code a reopen it for auto setup to begin.
​
Not all extensions are strictly necessary, but it will help prevent Microsoft Visual Studio Code from complaining about them from being missing.
C/C++
C/C++ Runner
PlatformIO IDE
C/C++ Extension Pack
Auto build Marlin





Once you have reopened Microsoft Visual Studio Code it will look different. You will notice some new icons on the left, these are the newly installed extensions: PlatformIO IDE & Auto build Marlin.
​
We now need to open ADVi3++ source code folder as a project in Microsoft Visual Studio Code. Clicking 'OPEN FOLDER' you will be presented with a pop up file explorer, locate the extracted ADVi3++ folder from earlier & click 'SELECT FOLDER'.
​
It's important to note the moment you click 'SELECT FOLDER' it could take up to 5 minutes to complete the next step depending on the speed of your system.

Microsoft Visual Studio Code will now ask you to confirm you trust the author of these files before allowing them to be loaded. It is required that you do trust them before you can continue with this guide. You now have a project tree on the left hand side of the screen, also referred to as the explorer.
​
You notice Microsoft Visual Studio Code has also started several automated processes in the bottom right corner of the screen; It is important that you let them finish before continuing. In particular the Platform IDE must complete otherwise compiling will fail.
​
The tabs at the top of the screen can be closed as they will not be required during the modification process.

Time to modify the first lines of code allowing for the MK II v5.4 BLTouch to be compiled, this is a build environment modification & will require Microsoft Visual Studio Code to be restarted after modification before any chances can take effect.
​
On the left pane select the explorer icon & select your build folder if they are not already open, click the ini sub folder to open it, & select the file 'advi3pp.ini'. This will open the file on the right pane ready for modification.
​
Scroll down the page on the right until you get to line 47 & then select the empty space next to the line number & press the return / enter key. Copy & paste or type the following lines of code written below in red from line 48-50, then press return / enter & save the file by either pressing CTL+S or file save. Now restart Microsoft Visual Studio Code.
​
[env:advi3pp_54_bltouch]
extends = advi3pp
build_flags = ${advi3pp.build_flags} -DADVi3PP_54 -DBLTOUCH -DNDEBUG

After Microsoft Visual Studio Code has restarted we want to check if the build environment modification has been entered correctly & has updated PlatformIO IDE.
​
On the left pane select the PlatformIO icon. The project file section will now change to a compiling menu, here you should now see the advi3pp_54_bltouch sub menu containing the build environment we are going to use. This menu is how we are going to finally compile the ADVi3++ firmware into our binary .HEX & upload to the 3D Printer.

Now that we have the build environment capable of compiling the v5.4 BLTouch firmware, we now need to inform it what programme it needs to use to communicate with the 3D printer. As we are only programming the printer & not doing any fancy diagnostic, I will be using the printer's onboard USB serial programmer / communications port.
​
On the left pane select the explorer icon & select your build folder if they are not already open, click to open the ini sub folder & select the file 'advi3pp.ini'. This will open the file on the right pane ready for modification.
​
Scroll down the page on the right until you get to line 15. Copy & paste or type the following lines of code written below in red replacing the existing code, this should stop at line 21. Save the file by either pressing CTL+S or file save, then close the tab.
​
upload_port = COM?
upload_flags =
-D
-v
-V
-C${platformio.packages_dir}/tool-avrdude/avrdude.conf
-p$BOARD_MCU
-P$UPLOAD_PORT
-b$UPLOAD_SPEED
-cwiring
-D - Disables auto erase feature causing upload issues
-v - Enables verbose logging output
-V - Disable verification after upload
-C - Select configuration file for 3D Printer uploading
-p - Sets Board CPU / MCU Type
-P - Sets printer upload port
-b - Sets printer upload baud rate
-c - Sets programmer type

The keen-eyed among you all have noticed there is a ? next to the COM upload port in the code above, this is where you have to put your 3D Printers COM number... The easiest way I have found to find this is through windows device manager.
​
Please note it's easier to search for your printer's COM number with the printer firstly disconnected.
​
Click on the start menu, type 'Device Manager' into the search bar & click 'OPEN', this will open the Windows device manager showing all items connected to your computer. We are only interested in the Ports [COM & LPT] tab, clicking this tab will present all the serial communication devices attached to your computer.
​
With this tab open take note of any existing COM numbers [if there are any] then plug your 3D Printer in, the device manager should update the tab with the name of your
3D printer [USB-SERIAL CH340 & port number], in this case [COM5]. Go back to Microsoft Visual Studio Code & replace the ? with the newly acquired COM number. Save the file by either pressing CTL+S or file save, then close the tab.


We are now at the final steps of the build environment setup, you will now need to adjust the speed at which Microsoft Visual Studio Code communicates with the 3D printer. This is called a BAUD Rate, having the correct BAUD will allow us to interact with the printer, sending G-Code commands & monitor any information the printer may send to the serial COM.
​
On the left pane select the explorer icon & select your build folder if they are not already open, click to open platformio.ini. This will open the file on the right pane ready for modification.
​
Scroll down the page on the right until you get to line 257, select the number 250000 & replace it with 115200. Save the file by either pressing CTL+S or file save, then close the tab.
​
This is the last modification required for the build environment. We will now work on the code modification for the ADVi3++ source code.

Modifying the ADVi3++ Source code
​
Sticking with Microsoft Visual Studio Code we are now going to modify a few lines of code so the ADVi3++ firmware can use the BLTouch Smart. This modification will define the correct pinout for the ADVi3++ pins.h file, informing the advi3pp_54 / advi3pp_54_bltouch build environments & allowing for correct pin setup on the firmware.
​
On the left pane select the explorer icon & select your build folder if they are not already open. Click the marlin sub folder, click the src sub folder, click the pins sub folder & select the file 'pins.h'. This will open the file on the right pane ready for modification.
​
Scroll down the page on the right until you get to line 302, Copy & paste or type the following line of code written below in red, replacing the existing code. Save the file by either pressing CTL+S or file save, then close the tab.

#include "advi3pp/pins_ADVI3PP.h" // ATmega2560 env:advi3pp_54 env:advi3pp_54_bltouch

The environment now knows the pin layout file to use but still does not know what pins the BLTouch smart will be connected to. This modification will define the exact pins on the 3D Printer mainboard ADVi3++ that the firmware will use to detect the BLTouch smart sensor.
​
On the left pane select the explorer icon & select your build folder if they are not already open. Click the marlin sub folder, click the src sub folder, click the pins sub folder, click the advi3pp sub folder & select the file 'pins_ADVI3PP.h'. This will open the file on the right pane ready for modification.
​
Scroll down the page on the right until you get to line 53, highlight line 53-55 & press delete. Copy & paste or type the following line of code written below in red, this should end at line 58. Save the file by either pressing CTL+S or file save, then close the tab.
​
#elif MB(ADVI3PP_I3_PLUS_54)
#define Z_STOP_PIN 6 // PH3 / PCINT8
#define Z_MIN_PROBE_PIN 6 // PH3 / PCINT8
#if ENABLED(BLTOUCH)
#define SERVO0_PIN 7 // PG1 / !RD
#endif

Finally we are going to tell ADVi3++ that the BLTouch smart is to be used instead of a fixed mounted probe.
​
On the left pane select the explorer icon & select your build folder if they are not already open. Click the marlin sub folder & select the file 'configuration.h'. This will open the file on the right pane ready for modification.
​
Scroll down the page on the right until you get to line 1347, highlight line 1347-1348 & press delete. Copy & paste or type the following line of code written below in red this should end at line 1349. Save the file by either pressing CTL+S or file save, then close the tab.
​
//#define FIX_MOUNTED_PROBE
#define BLTOUCH
#endif
​
It is important to note that after this modification you will not be able to compile firmware for MKII v5.4 fixed mounted probe firmware. You will need to comment out #define BLTOUCH & uncomment #define FIXED_MOUNTED_PROBE if you wish to switch back.
​
This is the last modification required for the ADVi3++ Firmware. We are now ready to compile the firmware into the final .HEX & upload to your 3D Printer.

Compiling Source Code & Uploading
​
Well its taken its time but we have now reached the part where the source code can now be compiled into a usable firmware & uploaded to the 3D Printer.
​
On the left pane select the PlatformIO icon & select the project tasks menu if its not already open. Click the advi3pp_54_bltouch sub menu, click the general sub menu & click upload. This will now instruct Microsoft Visual Studio Code & your build environment to start compiling the firmware & upload directly to your 3D Printer when complete.
​
It's important to note that depending on the speed of your system this could take 30 seconds to 5 minutes to complete. Your 3D Printer will automatically reboot & clear its EEPROM once complete.
​
You should see a console screen open up at the bottom of the screen, this will display quite a few messages & warnings, these can safely be ignored as they relate to the compiling process. At the end of the whole process you should get a green SUCCESS line. The ADVi3++ Firmware has now been compiled & uploaded to your 3D Printer.


For those of you having issues uploading through Microsoft Visual Studio Code there is an alternative solution. We will compile the firmware & save it to a .HEX file for upload with an external program from AVR Dudes.
​
On the left pane select the PlatformIO icon & select the project tasks menu if its not already open, click the advi3pp_54_bltouch sub menu, click the general sub menu & click 'build'. This will now instruct Microsoft Visual Studio Code & your build environment to start compiling the firmware & create a .HEX file in the source code folder.
C:\-----\-----------\Desktop\ADVi3pp-advi3-5.6.0\.pio\build\advi3pp_54_bltouch\
It's important to note that depending on the speed of your system this could take 30 second to 5 minutes to complete.
​
You should see a console screen open up at the bottom of the screen, this will display quite a few messages & warnings, these can safely be ignored as they relate to the compiling process. At the end of the whole process you should get a green SUCCESS line. The ADVi3++ Firmware has now been compiled.

With the firmware successfully compiled you can now close Microsoft Visual Studio Code.
Avrdude is an AVR Downloader Uploader, a program for downloading & uploading the on-chip memories of Microchip’s AVR microcontrollers. It can program the Flash & EEPROM, & where supported by the programming protocol, EFuses.
Unfortunately avrdude does not have a clickable application with a lovely looking GUI; we need to use it through Windows command prompt. Click on the start menu, type 'Command Prompt' into the search bar & click 'OPEN'. You should be asked by windows security / user account control to confirm you are happy to run this software, click 'YES'. This will open Windows Command Prompt ready for us to use later in this guide.


We are currently setting up Windows command prompt ready for uploading to your 3D Printer, once the black screen of Windows command prompt opens we are going to change to the avrdude program directory on the desktop. Copy & paste or type the following command written below in red modifying your user directory / location, press return / enter. This should point Windows command prompt to the avrdude root directory.
​
cd C:\----\-----------\Desktop\avrdude-v7.1-windows-x64
​
It's important to know that I am using the x64 version of avrdude, this will not function on x86 systems. If you are in need of the x86 version please click here

With Windows command prompt now ready to go, minimalize it to the start menu. We are now going to locate the .HEX file created by Microsoft Visual Studio Code earlier in this guide & move it to the avrdude root directory in preparation for the final upload.
​
Open file explorer & navigate to the following directory written below in red modifying your user directory, this should be located on your desktop.
C:\-----\-----------\Desktop\ADVi3pp-advi3-5.6.0\.pio\build\advi3pp_54_bltouch\
In this directory is a file called 'firmware.hex', this is the ADVi3++ custom firmware we need to move to avrdude root directory & upload to our 3D printer. Right click on 'firmware.hex' & click copy. In the same explorer screen navigate to the following directory written below in red modifying your user directory, this should be located on your desktop. Right click & paste the 'firmware.hex' file.
​
C:\-----\-----------\Desktop\avrdude-v7.1-windows-x64

You can now close file explorer as its no longer needed. With the avrdude root directory prepared we turn back to Windows command prompt. To upload the custom firmware to your 3D Printer Copy & paste or type the following line of code written below in red replacing the 'com?' with your 3D Printers COM number we discovered earlier in this guide. Press return / enter to begin the upload process.
avrdude -D -V -v -c wiring -p m2560 -P com? -b 115200 -U flash:w:firmware.hex:i
Windows command prompt will now display information about your 3D Printers MCU/CPU, EEPROM size & then begin the progress of uploading the firmware.
Its important to note that depending on the speed of your system this could take 30 second to 5 minutes to complete. Your 3D Printer will automatically reboot & clear its EEPROM once complete.


Final Thoughts
​
So my final thoughts for this project. This project had me frustrated & due to my own impatience I originally decided to quit. However, picking the project back up a year later with help from several online forums & the ADVi3++ community, I found that learning to understand C++ & code with Microsoft Visual Studio Code has been an easy & fun experience, making the firmware modifications a breeze.
Creating custom changes to the ADVi3++ source code & ultimately compiling the complete firmware ready for use was a relatively simple task once a basic understanding was achieved. I went into this experience with little knowledge of the C++ coding language & thanks to Sebastien, ADVi3++ Community & various online forums I have come out the other end with a whole heap of knowledge. I will continue to make changes / customisations as & when I need them. Any changes I make to the source code I will have hosted on my GitHub page readly available for all to use. There will be no precompiled binarys available on any of my platforms.
--------------------------------------------------------------------------------All of the plans / schematics & code are available freely available for use or modification under the GNU Licence & available on the following platforms...
Link to Mr.S.J.D.Developments - EasyEDA OSHWLabls | GitHub
​
If you are interested in custom expansion board that compliments this firmware, I have made an assembly & install guide below...
Link to Mr.S.J.D.Developments - Custom Multifunctional Expansion Board
--------------------------------------------------------------------------------
Copyright
ADVi3++
-
Copyright © 2017-2023 Sebastien Andrivet Link To GitHub Page
-
Copyright © 2016-2023 Link to Marlin GitHub
-
Based on Sprinter & grbl. Copyright © 2011 Camiel Gubbels / Erik van der Zalm
--------------------------------------------------------------------------------
Licences
- WANHAO DUPLICATOR I3 MKII v5.4 - EXPANSION BOARD
This design is free, you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This design is distributed in the hope that it will be useful to people with the Wanhao Duplicator i3 Plus v5.4 3D Printer, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see Link to GNU Licence.
- ADVi3++ Firmware
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see Link to GNU Licence.
- Marlin 3D Printer Firmware
Marlin is published under the Link to Marlin GPL license because we believe in open development. The GPL comes with both rights and obligations. Whether you use Marlin firmware as the driver for your open or closed-source product, you must keep Marlin open, and you must provide your compatible Marlin source code to end users upon request. The most straightforward way to comply with the Marlin license is to make a fork of Marlin on Github, perform your modifications, and direct users to your modified fork.
​
While we can't prevent the use of this code in products (3D printers, CNC, etc.) that are closed source or crippled by a patent, we would prefer that you choose another firmware or, better yet, make your own.
--------------------------------------------------------------------------------
As mentioned above I DO NOT offer any warrantee or guarantee with this modification, every care has been taken to make the modification is safe & compatible as possible with the Wanhao Duplicator i3 Plus v5.4 3d Printer using ADVi3++ firmware.
--------------------------------------------------------------------------------