Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into ender3v2_bu…
Browse files Browse the repository at this point in the history
…gfix

* upstream/bugfix-2.0.x: (23 commits)
  BTT SKR V2 probe and chamber pins (MarlinFirmware#21717)
  Rename, clean up boards/variants (MarlinFirmware#21655)
  BTT SKR V2.0 / Stepper Driver Anti-Reverse Protection (MarlinFirmware#21503)
  Fix E3V2 Advanced Settings with PLR off (MarlinFirmware#21700)
  FTDI EVE Touch UI fixes (MarlinFirmware#21706)
  Use temp_info_t for temp_redundant (MarlinFirmware#21715)
  [cron] Bump distribution date (2021-04-27)
  Remove compiler flag merge-constants (MarlinFirmware#21711)
  Make Cancel Objects reporting optional (MarlinFirmware#21698)
  typo (MarlinFirmware#21710)
  Help users confused by "bed size" (MarlinFirmware#21714)
  Fix "continuous" typo (MarlinFirmware#21701)
  Prettier output from opt scripts (MarlinFirmware#21707)
  Fix relocated LiquidCrystal library (MarlinFirmware#21699)
  [cron] Bump distribution date (2021-04-26)
  whitespace
  Fix HMI_HomeOffN axis
  Fix usage, commentary of MANUAL_PROBE_START_Z, Z_AFTER_PROBING (MarlinFirmware#21692)
  [cron] Bump distribution date (2021-04-25)
  E3V2 DWIN Advanced Settings (MarlinFirmware#21534)
  ...

# Conflicts:
#	Marlin/Configuration.h
  • Loading branch information
Michael authored and Michael committed Apr 27, 2021
2 parents 808c1c6 + 516fe13 commit 5b4b326
Show file tree
Hide file tree
Showing 210 changed files with 1,754 additions and 1,020 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ root = true
[{*.patch,syntax_test_*}]
trim_trailing_whitespace = false

[{*.c,*.cpp,*.h}]
[{*.c,*.cpp,*.h,*.ino}]
charset = utf-8

[{*.c,*.cpp,*.h,Makefile}]
[{*.c,*.cpp,*.h,*.ino,Makefile}]
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
- NUCLEO_F767ZI
- REMRAM_V1
- BTT_SKR_SE_BX
- chitu_f103

# Put lengthy tests last

Expand Down
14 changes: 13 additions & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2843,7 +2843,7 @@
/**
* Enable M122 debugging command for TMC stepper drivers.
* M122 S0/1 will enable continous reporting.
* M122 S0/1 will enable continuous reporting.
*/
//#define TMC_DEBUG
Expand Down Expand Up @@ -3388,6 +3388,15 @@
#define POWER_MONITOR_VOLTAGE_OFFSET 0 // Offset (in volts) applied to the calculated voltage
#endif

/**
* Stepper Driver Anti-SNAFU Protection
*
* If the SAFE_POWER_PIN is defined for your board, Marlin will check
* that stepper drivers are properly plugged in before applying power.
* Disable protection if your stepper drivers don't support the feature.
*/
//#define DISABLE_DRIVER_SAFE_POWER_PROTECT

/**
* CNC Coordinate Systems
*
Expand Down Expand Up @@ -3642,6 +3651,9 @@
* Implement M486 to allow Marlin to skip objects
*/
//#define CANCEL_OBJECTS
#if ENABLED(CANCEL_OBJECTS)
#define CANCEL_OBJECTS_REPORTING // Emit the current object as a status message
#endif

/**
* I2C position encoders for closed loop control.
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -993,5 +993,5 @@ clean:

.PHONY: all build elf hex eep lss sym program coff extcoff clean depend sizebefore sizeafter

# Automaticaly include the dependency files created by gcc
# Automatically include the dependency files created by gcc
-include ${patsubst %.o, %.d, ${OBJ}}
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/MarlinSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static inline __always_inline void my_usart_irq(ring_buffer *rb, ring_buffer *wb
}
else if (srflags & USART_SR_ORE) {
// overrun and empty data, just do a dummy read to clear ORE
// and prevent a raise condition where a continous interrupt stream (due to ORE set) occurs
// and prevent a raise condition where a continuous interrupt stream (due to ORE set) occurs
// (see chapter "Overrun error" ) in STM32 reference manual
regs->DR;
}
Expand Down
17 changes: 17 additions & 0 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@
#include "lcd/extui/lib/dgus/DGUSScreenHandler.h"
#endif

#if HAS_DRIVER_SAFE_POWER_PROTECT
#include "feature/stepper_driver_safety.h"
#endif

PGMSTR(M112_KILL_STR, "M112 Shutdown");

MarlinState marlin_state = MF_INITIALIZING;
Expand Down Expand Up @@ -1223,6 +1227,15 @@ void setup() {
SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.)
#endif

#if PIN_EXISTS(SAFE_POWER)
#if HAS_DRIVER_SAFE_POWER_PROTECT
SETUP_RUN(stepper_driver_backward_check());
#else
SETUP_LOG("SAFE_POWER");
OUT_WRITE(SAFE_POWER_PIN, HIGH);
#endif
#endif

#if ENABLED(PROBE_TARE)
SETUP_RUN(probe.tare_init());
#endif
Expand Down Expand Up @@ -1467,6 +1480,10 @@ void setup() {
SETUP_RUN(test_tmc_connection(true, true, true, true));
#endif

#if HAS_DRIVER_SAFE_POWER_PROTECT
SETUP_RUN(stepper_driver_backward_report());
#endif

#if HAS_PRUSA_MMU2
SETUP_RUN(mmu2.init());
#endif
Expand Down
37 changes: 19 additions & 18 deletions Marlin/src/core/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,25 +363,26 @@
#define BOARD_BLACK_STM32F407VE 4204 // BLACK_STM32F407VE
#define BOARD_BLACK_STM32F407ZE 4205 // BLACK_STM32F407ZE
#define BOARD_STEVAL_3DP001V1 4206 // STEVAL-3DP001V1 3D PRINTER BOARD
#define BOARD_BTT_SKR_PRO_V1_1 4207 // BigTreeTech SKR Pro v1.1 (STM32F407ZG)
#define BOARD_BTT_SKR_PRO_V1_2 4208 // BigTreeTech SKR Pro v1.2 (STM32F407ZG)
#define BOARD_BTT_BTT002_V1_0 4209 // BigTreeTech BTT002 v1.0 (STM32F407VG)
#define BOARD_BTT_SKR_PRO_V1_1 4207 // BigTreeTech SKR Pro v1.1 (STM32F407ZGT6)
#define BOARD_BTT_SKR_PRO_V1_2 4208 // BigTreeTech SKR Pro v1.2 (STM32F407ZGT6)
#define BOARD_BTT_BTT002_V1_0 4209 // BigTreeTech BTT002 v1.0 (STM32F407VGT6)
#define BOARD_BTT_E3_RRF 4210 // BigTreeTech E3 RRF (STM32F407VGT6)
#define BOARD_BTT_GTR_V1_0 4211 // BigTreeTech GTR v1.0 (STM32F407IGT)
#define BOARD_LERDGE_K 4212 // Lerdge K (STM32F407ZG)
#define BOARD_LERDGE_S 4213 // Lerdge S (STM32F407VE)
#define BOARD_LERDGE_X 4214 // Lerdge X (STM32F407VE)
#define BOARD_VAKE403D 4215 // VAkE 403D (STM32F446VET6)
#define BOARD_FYSETC_S6 4216 // FYSETC S6 (STM32F446VET6)
#define BOARD_FYSETC_S6_V2_0 4217 // FYSETC S6 v2.0 (STM32F446VET6)
#define BOARD_FYSETC_SPIDER 4218 // FYSETC Spider (STM32F446VET6)
#define BOARD_FLYF407ZG 4219 // FLYF407ZG (STM32F407ZG)
#define BOARD_MKS_ROBIN2 4220 // MKS_ROBIN2 (STM32F407ZE)
#define BOARD_MKS_ROBIN_PRO_V2 4221 // MKS Robin Pro V2 (STM32F407VE)
#define BOARD_MKS_ROBIN_NANO_V3 4222 // MKS Robin Nano V3 (STM32F407VG)
#define BOARD_ANET_ET4 4223 // ANET ET4 V1.x (STM32F407VGT6)
#define BOARD_ANET_ET4P 4224 // ANET ET4P V1.x (STM32F407VGT6)
#define BOARD_FYSETC_CHEETAH_V20 4225 // FYSETC Cheetah V2.0
#define BOARD_BTT_SKR_V2_0 4211 // BigTreeTech SKR v2.0 (STM32F407VGT6)
#define BOARD_BTT_GTR_V1_0 4212 // BigTreeTech GTR v1.0 (STM32F407IGT)
#define BOARD_LERDGE_K 4213 // Lerdge K (STM32F407ZG)
#define BOARD_LERDGE_S 4214 // Lerdge S (STM32F407VE)
#define BOARD_LERDGE_X 4215 // Lerdge X (STM32F407VE)
#define BOARD_VAKE403D 4216 // VAkE 403D (STM32F446VET6)
#define BOARD_FYSETC_S6 4217 // FYSETC S6 (STM32F446VET6)
#define BOARD_FYSETC_S6_V2_0 4218 // FYSETC S6 v2.0 (STM32F446VET6)
#define BOARD_FYSETC_SPIDER 4219 // FYSETC Spider (STM32F446VET6)
#define BOARD_FLYF407ZG 4220 // FLYF407ZG (STM32F407ZG)
#define BOARD_MKS_ROBIN2 4221 // MKS_ROBIN2 (STM32F407ZE)
#define BOARD_MKS_ROBIN_PRO_V2 4222 // MKS Robin Pro V2 (STM32F407VE)
#define BOARD_MKS_ROBIN_NANO_V3 4223 // MKS Robin Nano V3 (STM32F407VG)
#define BOARD_ANET_ET4 4224 // ANET ET4 V1.x (STM32F407VGT6)
#define BOARD_ANET_ET4P 4225 // ANET ET4P V1.x (STM32F407VGT6)
#define BOARD_FYSETC_CHEETAH_V20 4226 // FYSETC Cheetah V2.0

//
// ARM Cortex M7
Expand Down
30 changes: 15 additions & 15 deletions Marlin/src/feature/bedlevel/bedlevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,27 +213,27 @@ void reset_bed_level() {

void _manual_goto_xy(const xy_pos_t &pos) {

// Get the resting Z position for after the XY move
#ifdef MANUAL_PROBE_START_Z
constexpr float startz = _MAX(0, MANUAL_PROBE_START_Z);
#if MANUAL_PROBE_HEIGHT > 0
do_blocking_move_to_xy_z(pos, MANUAL_PROBE_HEIGHT);
do_blocking_move_to_z(startz);
#else
do_blocking_move_to_xy_z(pos, startz);
#endif
#elif MANUAL_PROBE_HEIGHT > 0
const float prev_z = current_position.z;
do_blocking_move_to_xy_z(pos, MANUAL_PROBE_HEIGHT);
do_blocking_move_to_z(prev_z);
constexpr float finalz = _MAX(0, MANUAL_PROBE_START_Z); // If a MANUAL_PROBE_START_Z value is set, always respect it
#else
do_blocking_move_to_xy(pos);
#warning "It's recommended to set some MANUAL_PROBE_START_Z value for manual leveling."
#endif
#if Z_CLEARANCE_BETWEEN_MANUAL_PROBES > 0 // A probe/obstacle clearance exists so there is a raise:
#ifndef MANUAL_PROBE_START_Z
const float finalz = current_position.z; // - Use the current Z for starting-Z if no MANUAL_PROBE_START_Z was provided
#endif
do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_MANUAL_PROBES); // - Raise Z, then move to the new XY
do_blocking_move_to_z(finalz); // - Lower down to the starting Z height, ready for adjustment!
#elif defined(MANUAL_PROBE_START_Z) // A starting-Z was provided, but there's no raise:
do_blocking_move_to_xy_z(pos, finalz); // - Move in XY then down to the starting Z height, ready for adjustment!
#else // Zero raise and no starting Z height either:
do_blocking_move_to_xy(pos); // - Move over with no raise, ready for adjustment!
#endif

current_position = pos;

TERN_(LCD_BED_LEVELING, ui.wait_for_move = false);
}

#endif
#endif // MESH_BED_LEVELING || PROBE_MANUALLY

#endif // HAS_LEVELING
2 changes: 1 addition & 1 deletion Marlin/src/feature/cancel_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void CancelObject::set_active_object(const int8_t obj) {
else
skipping = false;

#if HAS_STATUS_MESSAGE
#if BOTH(HAS_STATUS_MESSAGE, CANCEL_OBJECTS_REPORTING)
if (active_object >= 0)
ui.status_printf_P(0, PSTR(S_FMT " %i"), GET_TEXT(MSG_PRINTING_OBJECT), int(active_object));
else
Expand Down
171 changes: 171 additions & 0 deletions Marlin/src/feature/stepper_driver_safety.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* 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 <https://www.gnu.org/licenses/>.
*
*/
#include "../inc/MarlinConfig.h"
#include "../lcd/marlinui.h"

#if HAS_DRIVER_SAFE_POWER_PROTECT

#include "stepper_driver_safety.h"

static uint32_t axis_plug_backward = 0;

void stepper_driver_backward_error(PGM_P str) {
SERIAL_ERROR_START();
SERIAL_ECHOPGM_P(str);
SERIAL_ECHOLNPGM(" driver is backward!");
ui.status_printf_P(2, PSTR(S_FMT S_FMT), str, GET_TEXT(MSG_DRIVER_BACKWARD));
}

void stepper_driver_backward_check() {

OUT_WRITE(SAFE_POWER_PIN, LOW);

#define TEST_BACKWARD(AXIS, BIT) do { \
SET_INPUT(AXIS##_ENABLE_PIN); \
OUT_WRITE(AXIS##_STEP_PIN, false); \
delay(20); \
if (READ(AXIS##_ENABLE_PIN) == false) { \
SBI(axis_plug_backward, BIT); \
stepper_driver_backward_error(PSTR(STRINGIFY(AXIS))); \
} \
}while(0)

#if HAS_X_ENABLE
TEST_BACKWARD(X, 0);
#endif
#if HAS_X2_ENABLE
TEST_BACKWARD(X2, 1);
#endif

#if HAS_Y_ENABLE
TEST_BACKWARD(Y, 2);
#endif
#if HAS_Y2_ENABLE
TEST_BACKWARD(Y2, 3);
#endif

#if HAS_Z_ENABLE
TEST_BACKWARD(Z, 4);
#endif
#if HAS_Z2_ENABLE
TEST_BACKWARD(Z2, 5);
#endif
#if HAS_Z3_ENABLE
TEST_BACKWARD(Z3, 6);
#endif
#if HAS_Z4_ENABLE
TEST_BACKWARD(Z4, 7);
#endif

#if HAS_E0_ENABLE
TEST_BACKWARD(E0, 8);
#endif
#if HAS_E1_ENABLE
TEST_BACKWARD(E1, 9);
#endif
#if HAS_E2_ENABLE
TEST_BACKWARD(E2, 10);
#endif
#if HAS_E3_ENABLE
TEST_BACKWARD(E3, 11);
#endif
#if HAS_E4_ENABLE
TEST_BACKWARD(E4, 12);
#endif
#if HAS_E5_ENABLE
TEST_BACKWARD(E5, 13);
#endif
#if HAS_E6_ENABLE
TEST_BACKWARD(E6, 14);
#endif
#if HAS_E7_ENABLE
TEST_BACKWARD(E7, 15);
#endif

if (!axis_plug_backward)
WRITE(SAFE_POWER_PIN, HIGH);
}

void stepper_driver_backward_report() {
if (!axis_plug_backward) return;

auto _report_if_backward = [](PGM_P axis, uint8_t bit) {
if (TEST(axis_plug_backward, bit))
stepper_driver_backward_error(axis);
};

#define REPORT_BACKWARD(axis, bit) _report_if_backward(PSTR(STRINGIFY(axis)), bit)

#if HAS_X_ENABLE
REPORT_BACKWARD(X, 0);
#endif
#if HAS_X2_ENABLE
REPORT_BACKWARD(X2, 1);
#endif

#if HAS_Y_ENABLE
REPORT_BACKWARD(Y, 2);
#endif
#if HAS_Y2_ENABLE
REPORT_BACKWARD(Y2, 3);
#endif

#if HAS_Z_ENABLE
REPORT_BACKWARD(Z, 4);
#endif
#if HAS_Z2_ENABLE
REPORT_BACKWARD(Z2, 5);
#endif
#if HAS_Z3_ENABLE
REPORT_BACKWARD(Z3, 6);
#endif
#if HAS_Z4_ENABLE
REPORT_BACKWARD(Z4, 7);
#endif

#if HAS_E0_ENABLE
REPORT_BACKWARD(E0, 8);
#endif
#if HAS_E1_ENABLE
REPORT_BACKWARD(E1, 9);
#endif
#if HAS_E2_ENABLE
REPORT_BACKWARD(E2, 10);
#endif
#if HAS_E3_ENABLE
REPORT_BACKWARD(E3, 11);
#endif
#if HAS_E4_ENABLE
REPORT_BACKWARD(E4, 12);
#endif
#if HAS_E5_ENABLE
REPORT_BACKWARD(E5, 13);
#endif
#if HAS_E6_ENABLE
REPORT_BACKWARD(E6, 14);
#endif
#if HAS_E7_ENABLE
REPORT_BACKWARD(E7, 15);
#endif
}

#endif // HAS_DRIVER_SAFE_POWER_PROTECT
Loading

0 comments on commit 5b4b326

Please sign in to comment.