# Marlin 2

A chaque fois je prends le master.zip de Marlin + le master.zip de "Marlin configuration" (ils ont fait 2 dépôts séparés). Je copie les exemples de la  SKR (car pas d'ender 3 sans la SKR mini ) pour partir d'une version fresh.

# Version originale

Fourni avec l'imprimante : Marlin 1.1.6.1

M503 : 

```
Send: M503
Recv: echo:  G21    ; (mm)
Recv: echo:  M149 C ; Units in Celsius
Recv: 
Recv: echo:Filament settings: Disabled
Recv: echo:  M200 D1.75
Recv: echo:  M200 D0
Recv: echo:Steps per unit:
Recv: echo:  M92 X80.00 Y80.00 Z400.00 E93.00
Recv: echo:Maximum feedrates (units/s):
Recv: echo:  M203 X500.00 Y500.00 Z5.00 E25.00
Recv: echo:Maximum Acceleration (units/s2):
Recv: echo:  M201 X500 Y500 Z100 E5000
Recv: echo:Acceleration (units/s2): P<print_accel> R<retract_accel> T<travel_accel>
Recv: echo:  M204 P500.00 R500.00 T500.00
Recv: echo:Advanced: Q<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate> X<max_x_jerk> Y<max_y_jerk> Z<max_z_jerk> E<max_e_jerk>
Recv: echo:  M205 Q20000 S0.00 T0.00 X10.00 Y10.00 Z0.30 E5.00
Recv: echo:Home offset:
Recv: echo:  M206 X0.00 Y0.00 Z0.00
Recv: echo:Material heatup parameters:
Recv: echo:  M145 S0 H185 B45 F255
Recv: echo:  M145 S1 H240 B0 F255
Recv: echo:PID settings:
Recv: echo:  M301 P21.73 I1.54 D76.55
Recv: ok
```

# Modifs


# Compilation

# Post reddit pour modif Marlin pour SKR

Qui a vraiment plein d'infos

https://www.reddit.com/r/ender3/comments/e894j7/marlin_20x_guide_for_ender_3_using_skr_mini_e3_v12/

Changes to the original [Marlin](https://github.com/MarlinFirmware/Marlin/) [2.0.5.3](https://github.com/MarlinFirmware/Marlin/releases) files for Ender 3 with SKR mini E3 v1.2.

^(Use this guide with other marlin versions at your own risk.)

# Content:

1. Getting started
2. Essential changes
3. PID autotune
4. BLTOUCH
5. Measure NOZZLE_TO_PROBE_OFFSET
6. BLTouch wiring
7. Unified Bed Leveling (UBL)
8. Manual Mesh Bed Leveling
9. Filament Runout Detection and Filament Change
10. Linear Advance
11. Junction Deviation
12. All in one Retraction testing
13. 512k flash memory
14. Compiling firmware
15. Flashing firmware
16. Updating/Reflashing firmware
17. Printable Direct Drive mod
18. Changelog

# Getting started

1. Install [VSCode](https://code.visualstudio.com/) and [Git](https://git-scm.com/downloads) according to this [Installation guide](https://youtu.be/W6zYvRgGr3Q)
2. Open Marlin in VSCode as it is in this [Comment](https://www.reddit.com/r/ender3/comments/e894j7/marlin_20x_guide_for_ender_3_using_skr_mini_e3_v12/fney69s/)
   1. (You can choose the marlin version at the bottom left corner of the window, the default is the latest 2.0.x)
3. Modify your Marlin based on this guide
   1. (**Not necessary step**) Optionally you can use the [marlin example file](https://github.com/MarlinFirmware/Marlin/tree/2.0.x/config) for this board for easier/faster editing. The example file for this board is in the zip file, under config\examples\BigTreeTech\SKR Mini E3 1.2\.

E - Enable | C - Change | E&amp;C - Enable and Change | D - Disable

Enable/Disable by deleting/placing **//** at the start of a line.

# Essential changes

Essential / useful changes to platformio.ini, Configuration.h and Configuration_adv.h files in Marlin/ folder.

# platformio.ini:

* **C**    `default_envs =` STM32F103RC_btt_512K

# Configuration.h:

* **E**    `SHOW_CUSTOM_BOOTSCREEN`
* **E**    `CUSTOM_STATUS_SCREEN_IMAGE`
   * (Copy `_Bootscreen.h` / `_Statusscreen.h` file from Marlin\config\examples\Creality\Ender-3\ to Marlin\Marlin folder)
   * Download it from the [Marlin GitHub](https://github.com/MarlinFirmware/Marlin/tree/2.0.x/config).
* **C**    `SERIAL_PORT` 2
* **E**    `SERIAL_PORT_2` -1
* **C**    `BAUDRATE` 115200
   * (BTT default baudrate)
* **C**    `MOTHERBOARD` BOARD_BTT_SKR_MINI_E3_V1_2
* **E&amp;C**     `CUSTOM_MACHINE_NAME` \"Ender-3\"
* **C**    `DEFAULT_NOMINAL_FILAMENT_DIA` 1.75
* **C**    `TEMP_SENSOR_BED` 1
* **C**    `BED_MAXTEMP` 125
   * (By setting it to 70 for a magnetic bed that works up to 70 °C, marlin will only let it heat up to 60, for safety reason)
* **E**    `PIDTEMPBED`
   * (You don't need to enable `PIDTEMPBED`, if you are satisfied with your heated bed, but by calibrating the heated bed, it could heat up faster and maintain temperature more accurately)
   * (Be sure to do a PID autotune for your heated bed after you enabled it in your firmware, otherwise it will trigger Thermal Runaway Protection when heating up the bed. You can find the guide under the **PID autotune** section, later in this post)
* **C**    `EXTRUDE_MAXLENGTH` 200
   * (Or measure the length from the extruder gear to the nozzle through the PTFE tube)
* **C**    `Z_MIN_PROBE_ENDSTOP_INVERTING` true
   * (BLTouch v3/3.1 can work with either true/false, but v2 needs it to be true)
* **E&amp;C**    `X_DRIVER_TYPE` TMC2209
* **E&amp;C**    `Y_DRIVER_TYPE` TMC2209
* **E&amp;C**    `Z_DRIVER_TYPE` TMC2209
* **E&amp;C**    `E0_DRIVER_TYPE` TMC2209
* **C**    `DEFAULT_AXIS_STEPS_PER_UNIT` { 80, 80, 400, 93 }
* **C**    `DEFAULT_MAX_FEEDRATE` { 500, 500, 20, 60 }
* **C**    `DEFAULT_ACCELERATION` 500
* **C**    `DEFAULT_RETRACT_ACCELERATION` 500
* **C**    `DEFAULT_TRAVEL_ACCELERATION` 500
* **E**    `CLASSIC_JERK`
   * (Use Classic Jerk instead of Junction Deviation, as JD is still not working properly, and sometimes can cause bad results when printing curves) ([https://github.com/MarlinFirmware/Marlin/issues/17146](https://github.com/MarlinFirmware/Marlin/issues/17146))
* **E&amp;C**    `TRAVEL_EXTRA_XYJERK` 5.0
* **C**    `DEFAULT_EJERK` 15.0
* **E**    `S_CURVE_ACCELERATION`
   * ([LIN_ADVANCE and S_CURVE_ACCELERATION may not play well together](https://github.com/MarlinFirmware/Marlin/commit/c3946dd0174b63136f9c8437ca159a17ddc68512). Disable f you want to use Linear Advance)
* **C**    `INVERT_X_DIR` true
* **C**    `INVERT_E0_DIR` true
* **C**    `X_BED_SIZE` 235
* **C**    `Y_BED_SIZE` 235
* **C**    `Z_MAX_POS` 250
* **E**    `LEVEL_BED_CORNERS`
* **C**    `LEVEL_CORNERS_HEIGHT` 0.1
   * (Set it to the thickness of the paper/credit card/feeler gauge you want to use)
* **C**    `HOMING_FEEDRATE_XY` (50*60)
* **E**    `EEPROM_SETTINGS`
* **E**    `NOZZLE_PARK_FEATURE`
* **C**    `NOZZLE_PARK_POINT` { (X_MIN_POS + 10), (Y_MAX_POS - 10), 20 }
* **D**    `DISPLAY_CHARSET_HD44780`
* **E**    `SDSUPPORT`
* **E**    `CR10_STOCKDISPLAY`
* **E**    `FAN_SOFT_PWM`

# Configuration_adv.h:

* **E**    `QUICK_HOME`
* **C**    `SLOWDOWN_DIVISOR` 8
* **E**    `ADAPTIVE_STEP_SMOOTHING`
* **E**    `STATUS_MESSAGE_SCROLLING`
* **E**    `PRINT_PROGRESS_SHOW_DECIMALS`
* **E**    `SHOW_REMAINING_TIME`
* **E**    `USE_M73_REMAINING_TIME`
* **E**    `ROTATE_PROGRESS_DISPLAY`
* **E**    `SCROLL_LONG_FILENAMES`
* **E&amp;C**     `SDCARD_CONNECTION` ONBOARD
* **E**    `STATUS_HEAT_PERCENT`
* **E**    `LIN_ADVANCE`
   * ([LIN_ADVANCE and S_CURVE_ACCELERATION may not play well together](https://github.com/MarlinFirmware/Marlin/commit/c3946dd0174b63136f9c8437ca159a17ddc68512). Disable S-Curve Acc. if you want to use LA)
* **C**    `LIN_ADVANCE_K` 0.00
   * (You can find guide links to calibrate your K value under the **Linear Advance** section, later in this post)
* **C**    `BLOCK_BUFFER_SIZE` 32
* **C**    `BLOCK_BUFFER_SIZE` 32
* **C**    `BUFSIZE`  32
* **C**    `TX_BUFFER_SIZE` 32
* **C**    `X_CURRENT` 580
* **C**    `Y_CURRENT` 580
* **C**    `Z_CURRENT` 580
* **C**    `E0_CURRENT` 650
* **C**    `CHOPPER_TIMING` CHOPPER_DEFAULT_24V
* **E**    `MONITOR_DRIVER_STATUS`
* **D**    `HYBRID_THRESHOLD`
* **E**    `CANCEL_OBJECTS`

# PID autotune

(You don't need to enable `PIDTEMPBED` if you are satisfied with your heated bed, but by calibrating the heated bed, it can heat up faster and can maintain temperature more accurately)

1. Connect the printer to the PC (USB, Octoprint, etc.)
2. Use  any software that can send gcode commands to a printer ([Octoprint](https://octoprint.org/), [Pronterface](https://www.pronterface.com/), [Repetier](https://www.repetier.com/), [Simplify3D](https://www.simplify3d.com/), etc.)
3. Connect to the printer in the software if not done automatically (COM4, 115200)
4. By sending an `M301`/`M304` to the printer you will the PID values for the **HOTEND / HEATED BED,** take a note of those values
5. To start an autotune, you will need to send an  `M303`  `C` &lt; count &gt; `E` &lt; index &gt; `S` &lt; temp &gt; `U` to the printer.
   1. For the **hotend** I used `M303 C25 E0 S205 U`    (Hotend: `E0`)
      1. (Turn on the part cooling fan for the hotend PID autotuning)
      2. ( C5 should be enough, but C25 doesn't take too long either, S &lt; temp &gt; should be the 5-10 more than the printing temperature you usually use)
   2. For the **heated bed** I used `M303 C25 E-1 S60 U`    (Heated bed: `E-1`)
      1. ( C5 should be enough, but if I did 25 for the hotend might as well do it to the bed too, S &lt; temp &gt; should be the bed temperature you usually use) (If after the `M303` ... you get \"PID Autotune failed! Temperature too high\", send an `M304 P0.00 I0.00 D0.00` to the printer, then redo the PID autotune)
6. Wait for the operation to complete (when it's done the heating cycle will stop and the temperature will drop)
7. Take a not of the new P, I, D values that the software displays
8. Send an `M500` to the printer to save the the new PID values to the EEPROM
9. To make sure that all the values are saved, send an `M301` / `M304` to the printer to display the current PID values
10. If the current PID values doesn't match the new values, then you need to set the PID values manually:
11. **Hotend**: Send an `M301` `P`&lt; value &gt; `I` &lt; value &gt; `D`&lt; value &gt; to the printer
12. **Heated bed**: Send an `M304` `P`&lt; value &gt; `I` &lt; value &gt; `D`&lt; value &gt; to the printer
13. Send an `M500` to the printer to save the the new PID values to the EEPROM
14. In Configuration.h update the PID values for future firmware updates (`DEFAULT_Kp`, ...`Ki`, ...`Kd`, `DEFAULT_bedKp`, ...`bedKi`, ...`bedKd`)

&amp;#x200B;

* The 3D Print General    [PID Autotuning](https://youtu.be/luAPE44J2QM)

# BLTOUCH

**Configuration.h:**

* **E**    `BLTOUCH`
* **C**    `NOZZLE_TO_PROBE_OFFSET` { -44.5, -10, -1.00 }
   * (Edit these values according to your setup, help is in the **Measure NOZZLE_TO_PROBE_OFFSET** section)
* **C**    `MIN_PROBE_EDGE` 10
   * (If you have clips holding the bed, increase it to your clip size +5)
* **C**    `XY_PROBE_SPEED` 6000
   * (With 6000 the BLTouch works more reliably)
* **E**    `Z_MIN_PROBE_REPEATABILITY_TEST`
* **E**    `AUTO_BED_LEVELING_BILINEAR`
   * (or use `AUTO_BED_LEVELING_UBL` / `MESH_BED_LEVELING`, guide links later in this post)
* **E**    `RESTORE_LEVELING_AFTER_G28`
* **E**    `Z_SAFE_HOMING`

**Configuration_adv.h:**

* **E**    `BLTOUCH_DELAY` 500
   * (If you are experiencing failed probing, then increasing it could help)
* **D**    `BLTOUCH_SET_5V_MODE`
* **E**    `BABYSTEPPING`
* **C**    `BABYSTEP_MULTIPLICATOR_Z` 4
   * (1 will raise the Z-axis by 1 microstep (0.0025), 4 will raise the Z-axis by 0.01)
* E    `DOUBLECLICK_FOR_Z_BABYSTEPPING`
   * (Double-click on the Status Screen to edit Z Babystepping during prints)
* **E**    `BABYSTEP_ZPROBE_OFFSET`
* **E**    `BABYSTEP_ZPROBE_GFX_OVERLAY`

# Measure NOZZLE_TO_PROBE_OFFSET

1. Take rough measurements from the probe pin to the nozzle in X and Y directions
   1. (The tip of the probe pin should be [2.3-4.3mm](https://5020dafe-17d8-4c4c-bf3b-914a8fdd5140.filesusr.com/ugd/f5a1c8_d40d077cf5c24918bd25b6524f649f11.pdf) higher than the nozzle)
2. Change the `NOZZLE_TO_PROBE_OFFSET` values according to your measurements
3. Compile - flash - boot ...
4. Home the printer
5. Take a note of the X and Y coordinates (you can do that in the printer move axis menu)
6. Move the Z axis down until the nozzle touches or almost touches the print bed
7. Mark that point where the nozzle touches the bed (make sure that your mark won't move on the bed)
8. Move the X and Y axis in the printer menu until the probe pin is spot on to your mark
9. Take a note of the X and Y coordinates
10. Subtract the X/Y coordinates from the original X/Y coordinates to get the `NOZZLE_TO_PROBE_OFFSET`

# BLTouch wiring

* Teaching Tech    [Guide](https://youtu.be/ikHhzOIlHPg) for SKR mini E3 v1.2 + BLTouch
* Chris Riley        [BLtouch](https://youtu.be/p504oU-D6iE) Bed Leveling Sensor
* [Wiring diagram](https://raw.githubusercontent.com/morningreis/Marlin-SKR-E3-Mini-1.2/bugfix-2.0.x/SKR_E3_Mini_1.2_wiring.png) from GitHub
   * SERVOS
      * Brown or Blue - GND
      * Red - +5V
      * Yellow - PA1
   * Z-STOP
      * Black - GND
      * White - PC2

# Unified Bed Leveling (UBL)

* Marlin    [UBL guide](https://marlinfw.org/docs/features/unified_bed_leveling.html)
* Chris Riley    [UBL video guide](https://youtu.be/ONpKxkil16Q)

# Manual Mesh Bed Leveling

Configuration.h

* **E**    `PROBE_MANUALLY`
* **C**    `NOZZLE_TO_PROBE_OFFSET` { 0, 0, 0 }
* **E**    `MESH_BED_LEVELING`
* **E**    `RESTORE_LEVELING_AFTER_G28`
* **C**    `GRID_MAX_POINTS_X` 5 (Or change it accordingly to your needs)
* **E**    `LCD_BED_LEVELING`

Leveling:

Heat up your bed to the temperature you usually print on (e.g. 60°C) (Make sure that there are no plastic on the nozzle, that would alter the nozzles distance to the bed)

1. Select: Prepare - Bed Leveling - Level Bed
2. Wait for Homing XYZ to complete
3. When Click to Begin appears, press the controller button to move to the first point
4. Use the controller wheel to adjust Z so that a piece of paper can just pass under the nozzle
5. Press the controller button to save the Z value and move to the next point
6. Repeat steps 4-5 until completed
7. Select: Configuration - Store settings to save the mesh to the EEPROM
8. Select: Motion - Fade height: Set it to 10
9. Select: Motion - Store settings
10. Make a [test print](https://www.thingiverse.com/thing:3695971), and as it prints you can change the nozzle distance to the bed in Motion - Bed Z with the controller wheel
11. Select: Configuration - Store settings

&amp;#x200B;

* Marlin    [Bed Leveling (Manual)](https://marlinfw.org/docs/gcode/G029-mbl.html)
* Teaching Tech    [Manual Mesh Bed Levelling](https://youtu.be/vcxM7-VK44k)
* Crosslink    [Ender 3 Mesh Bed Leveling](https://youtu.be/Rij29oy6t70)

# Filament Runout Detection and Filament Change

**pins_BTT_SKR_MINI_E3.h**        (Found it in Marlin\Marlin\src\pins\stm32f1\)

* **D**    `Z_MIN_PROBE_PIN`

Switch with 2 pin connector:

* **C**    `FIL_RUNOUT_PIN` PC14 // \"PROBE\"

**Configuration.h**

* **E**    `FILAMENT_RUNOUT_SENSOR`
* **E&amp;C**    `FILAMENT_RUNOUT_DISTANCE_MM` 5

(Filament Runout detection and [M600 - Filament Change](https://marlinfw.org/docs/gcode/M600.html) part)

* **C**    `EXTRUDE_MAXLENGTH` 100
   * (Length from the extruder gear to the nozzle + 10)
* **E**    `NOZZLE_PARK_FEATURE`
* **C**    `NOZZLE_PARK_Z_FEEDRATE` 3

**Configuration_adv.h**

* **E**    `ADVANCED_PAUSE_FEATURE`
* **C**    `PAUSE_PARK_RETRACT_FEEDRATE` 30
   * (Change it to your retraction speed)
* **C**    `PAUSE_PARK_RETRACT_LENGTH` 6
   * (Change it to your retraction length)
* **C**    `FILAMENT_CHANGE_UNLOAD_LENGTH` 100
   * (Length from the extruder gear to the nozzle OR set it to 0 for manual filament extraction)
   * (This needs to be less than or equal to `EXTRUDE_MAXLENGTH`)
* **C**    `FILAMENT_CHANGE_FAST_LOAD_LENGTH` 0
   * (Length from the extruder gear to the nozzle OR set it to 0 for manual filament insertion)
   * (This needs to be less than or equal to `EXTRUDE_MAXLENGTH`)
* **C**    `FILAMENT_CHANGE_ALERT_BEEPS` 10
   * (10 might be too much/annoying, if so, lower it to your liking)
* **E**    `PARK_HEAD_ON_PAUSE`
* **E**    `HOME_BEFORE_FILAMENT_CHANGE`
* **E**    `FILAMENT_LOAD_UNLOAD_GCODES`
   * (Adds `M701`/`M702` Load/Unload G-code, and Load/Unload in the LCD Prepare menu.)

Connect your Runout switch with 2 pin connector to the \"PROBE\" (PC14) and with 3 pin connector to the \"PT-DET\" connector on either side of the \"SERVOS\" (BLTouch) connector. (I use the Z-endstop switch with 2 pin connector for runout sensor)

Teaching Tech

* [DIY filament runout sensor + M600 colour changing](https://youtu.be/gwHpXaj_6xE)
* [SKR mini E3 V1.2 guide](https://youtu.be/ikHhzOIlHPg)

Chris Riley

* [Marlin Filament Change M600](https://youtu.be/CDz2IxxINBE)
* [Filament Runout Sensor](https://youtu.be/tl4VZ4zlxFQ)

# Linear Advance

* Linear Advance    [K-factor Calibration](http://marlinfw.org/tools/lin_advance/k-factor.html)
* Teaching Tech    [Linear advance video guide](https://youtu.be/n3yK0lJ8TWM)
* Chris Riley    [Linear advance video guide](https://youtu.be/V-bKfYF3I-o)

# Junction Deviation

* [Computing Junction Deviation for Marlin Firmware](http://blog.kyneticcnc.com/2018/10/computing-junction-deviation-for-marlin.html)

# All in one Retraction testing

* KARL JOHNSON    [How to Easily Calibrate Retraction in 3D Printers](https://www.cnx-software.com/2019/09/05/how-to-easily-calibrate-retraction-in-3d-printers/)

# 512k flash memory

* Alex Kenis
   * [LIES! the SKR e3 mini v1.2 ACTUALLY still has 512k of memory?](https://youtu.be/EBIahC1P2e0)
   * [Follow-up : SKR e3 mini v1_2, testing the extra memory](https://youtu.be/q0JEx3uzgSo)

# Compiling firmware

Use [VSCode](https://code.visualstudio.com/) with the PlatformIO extension and [Git GUI](https://git-scm.com/).

* Chris Riley
   * [VSCode installation guide](https://youtu.be/W6zYvRgGr3Q) for Marlin 2.0.

You can find the firmware file in Marlin/.pio/build/STM32F103RC_btt_512K/firmware.bin

# Flashing firmware

Place the firmware.bin file onto your SD card, them insert it into your printer and turn it on. After a short 20-30 sec blank screen your printer should be ready.

If after ~50-60 sec there is still a blank screen, don't worry, just turn off your printer. A long blank screen could mean that the firmware you just tried is bad in some way. You should recheck your configurations, then try reflashing it. [Comment](https://www.reddit.com/r/ender3/comments/e894j7/marlin_20x_guide_for_ender_3_using_skr_mini_e3_v12/fqfcwli/).

# Updating/Reflashing firmware

([Comment](https://www.reddit.com/r/ender3/comments/e894j7/marlin_20x_guide_for_ender_3_using_skr_mini_e3_v12/fney69s/)) You don't need to redo all the changes every time you want to update to a newer version of marlin,  just copy your edited files to the new marlin and compare them in VSC Source Control (Ctrl+Shift+G), and copy anything that is new or changed.

Not all changes will be applied on a firmware update. For that you will need to reset your printer settings by Restore Defaults ([M502](https://marlinfw.org/docs/gcode/M502.html)) in menu - Configuration, then Save Settings ([M500](https://marlinfw.org/docs/gcode/M500.html)). It will reset your settings back to your edited firmware values.

# Printable Direct Drive mod

Printable [Direct Drive](https://www.thingiverse.com/thing:4140659) extruder mount for Ender 3, Ender 5, CR-10 etc.

# Changelog:

^(Changes older than 1 month are deleted.)

* 04.22.
   * Added Linear Advance and S-Curve Acceleration conflict [cautionary](https://github.com/MarlinFirmware/Marlin/commit/c3946dd0174b63136f9c8437ca159a17ddc68512).
* 04.26.
   * pins_BTT_SKR_MINI_E3.h location changed form ...\stm32 to ...\stm32f1
   * If you get EEPROM error on startup, go in the printer to the Configuration, press Restore Defaults then Store Settings
* 05.13.
   * Removed `#define`
* 05.14.
   * Disabled Hybrid Threshold and settings related to it, to the way it will be in [2.0.6](https://github.com/MarlinFirmware/Configurations/pull/103)
   * Added `DEFAULT_EJERK`, `HOME_BEFORE_FILAMENT_CHANGE`
* 05.19.
   * Removed the `PT-DET` option for filament runout sensor, as it cannot be used for filament runout sensor.

# Feedbacks are always welcome."