Skip to content

Commit

Permalink
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots authored Nov 10, 2023
2 parents d19b576 + bf0acc9 commit 184bde0
Show file tree
Hide file tree
Showing 37 changed files with 231 additions and 119 deletions.
9 changes: 7 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,13 @@ body:

- type: input
attributes:
label: Add-ons
description: Please list any hardware add-ons that could be involved.
label: LCD/Controller
description: Some Marlin behaviors are determined by the controller. Describe your LCD/Controller model and version.

- type: input
attributes:
label: Other add-ons
description: Please list any other hardware add-ons that could be involved.

- type: dropdown
attributes:
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/close-stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,21 @@ jobs:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has had no activity in the last 60 days. Please add a reply if you want to keep this issue active, otherwise it will be automatically closed within 10 days.'
days-before-stale: 60
days-before-close: 10
stale-issue-message: |
Greetings from the Marlin AutoBot!
This issue has had no activity for the last 90 days.
Do you still see this issue with the latest `bugfix-2.1.x` code?
Please add a reply within 14 days or this issue will be automatically closed.
To keep a confirmed issue open we can also add a "Bug: Confirmed" tag.
Disclaimer: This is an open community project with lots of activity and limited
resources. The main project contributors will do a bug sweep ahead of the next
release, but any skilled member of the community may jump in at any time to fix
this issue. That can take a while depending on our busy lives so please be patient,
and take advantage of other resources such as the MarlinFirmware Discord to help
solve the issue.
days-before-stale: 90
days-before-close: 14
stale-issue-label: 'stale-closing-soon'
exempt-all-assignees: true
exempt-issue-labels: 'Bug: Confirmed !,T: Feature Request,Needs: More Data,Needs: Discussion,Needs: Documentation,Needs: Patch,Needs: Work,Needs: Testing,help wanted,no-locking'
10 changes: 7 additions & 3 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1641,9 +1641,13 @@

#define Z_PROBE_LOW_POINT -2 // (mm) Farthest distance below the trigger-point to go before stopping

// For M851 give a range for adjusting the Z probe offset
#define Z_PROBE_OFFSET_RANGE_MIN -20 // (mm)
#define Z_PROBE_OFFSET_RANGE_MAX 20 // (mm)
// For M851 provide ranges for adjusting the X, Y, and Z probe offsets
//#define PROBE_OFFSET_XMIN -50 // (mm)
//#define PROBE_OFFSET_XMAX 50 // (mm)
//#define PROBE_OFFSET_YMIN -50 // (mm)
//#define PROBE_OFFSET_YMAX 50 // (mm)
//#define PROBE_OFFSET_ZMIN -20 // (mm)
//#define PROBE_OFFSET_ZMAX 20 // (mm)

// Enable the M48 repeatability test to test probe accuracy
//#define Z_MIN_PROBE_REPEATABILITY_TEST
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* here we define this default string as the date where the latest release
* version was tagged.
*/
//#define STRING_DISTRIBUTION_DATE "2023-10-29"
//#define STRING_DISTRIBUTION_DATE "2023-11-10"

/**
* Defines a generic printer name to be output to the LCD after booting Marlin.
Expand Down
7 changes: 6 additions & 1 deletion Marlin/src/HAL/shared/backtrace/unwarmbytab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ static const char *UnwTabGetFunctionName(const UnwindCallbacks *cb, uint32_t add
return nullptr;

if ((flag_word & 0xFF000000) == 0xFF000000) {
return (const char *)(address - 4 - (flag_word & 0x00FFFFFF));
const uint32_t fn_name_addr = address - 4 - (flag_word & 0x00FFFFFF);

// Ensure the address is readable to avoid returning a bogus pointer
uint8_t dummy = 0;
if (cb->readB(fn_name_addr, &dummy))
return (const char *)fn_name_addr;
}
return nullptr;
}
Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ void CommonHandler_C(ContextStateFrame * frame, unsigned long lr, unsigned long
if (!faulted_from_exception) { // Not sure about the non_usage_fault, we want to try anyway, don't we ? && !non_usage_fault_occurred)
// Try to resume to our handler here
CFSR |= CFSR; // The ARM programmer manual says you must write to 1 all fault bits to clear them so this instruction is correct
// The frame will not be valid when returning anymore, let's clean it
savedFrame.CFSR = 0;

frame->pc = (uint32_t)resume_from_fault; // Patch where to return to
frame->lr = 0xDEADBEEF; // If our handler returns (it shouldn't), let's make it trigger an exception immediately
Expand Down
54 changes: 37 additions & 17 deletions Marlin/src/feature/backlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,25 @@ Backlash backlash;
* spread over multiple segments, smoothing out artifacts even more.
*/

void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const AxisBits dm, block_t * const block) {
void Backlash::add_correction_steps(const xyze_long_t &dist, const AxisBits dm, block_t * const block) {
AxisBits changed_dir = last_direction_bits ^ dm;
// Ignore direction change unless steps are taken in that direction
#if DISABLED(CORE_BACKLASH) || ANY(MARKFORGED_XY, MARKFORGED_YX)
if (!da) changed_dir.x = false;
if (!db) changed_dir.y = false;
if (!dc) changed_dir.z = false;
if (!dist.a) changed_dir.x = false;
if (!dist.b) changed_dir.y = false;
if (!dist.c) changed_dir.z = false;
#elif CORE_IS_XY
if (!(da + db)) changed_dir.x = false;
if (!(da - db)) changed_dir.y = false;
if (!dc) changed_dir.z = false;
if (!(dist.a + dist.b)) changed_dir.x = false;
if (!(dist.a - dist.b)) changed_dir.y = false;
if (!dist.c) changed_dir.z = false;
#elif CORE_IS_XZ
if (!(da + dc)) changed_dir.x = false;
if (!(da - dc)) changed_dir.z = false;
if (!db) changed_dir.y = false;
if (!(dist.a + dist.c)) changed_dir.x = false;
if (!(dist.a - dist.c)) changed_dir.z = false;
if (!dist.b) changed_dir.y = false;
#elif CORE_IS_YZ
if (!(db + dc)) changed_dir.y = false;
if (!(db - dc)) changed_dir.z = false;
if (!da) changed_dir.x = false;
if (!(dist.b + dist.c)) changed_dir.y = false;
if (!(dist.b - dist.c)) changed_dir.z = false;
if (!dist.a) changed_dir.x = false;
#endif
last_direction_bits ^= changed_dir;

Expand All @@ -97,7 +97,15 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const

const float f_corr = float(correction) / all_on;

bool changed = false;
float millimeters_delta = 0.0f;
#if IS_KINEMATIC
float sqr_stepper_space_mm = 0.0f;
#endif

LOOP_NUM_AXES(axis) {
TERN_(IS_KINEMATIC, sqr_stepper_space_mm += sq(dist[axis] * planner.mm_per_step[axis]));

if (distance_mm[axis]) {
const bool forward = dm[axis];

Expand All @@ -107,8 +115,6 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const

// Decide how much of the residual error to correct in this segment
int32_t error_correction = residual_error[axis];
if (forward == (error_correction < 0))
error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps

#ifdef BACKLASH_SMOOTHING_MM
if (error_correction && smoothing_mm != 0) {
Expand All @@ -118,9 +124,18 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
}
#endif

// Don't correct backlash in the opposite direction to movement on this axis and for accuracy in
// updating block->millimeters, don't add too many steps to the movement on this axis
if (forward)
LIMIT(error_correction, 0, dist[axis]);
else
LIMIT(error_correction, dist[axis], 0);

// This correction reduces the residual error and adds block steps
if (error_correction) {
changed = true;
block->steps[axis] += ABS(error_correction);
millimeters_delta += dist[axis] * error_correction * sq(planner.mm_per_step[axis]);
#if ENABLED(CORE_BACKLASH)
switch (axis) {
case CORE_AXIS_1:
Expand All @@ -142,6 +157,11 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
}
}
}

// If backlash correction steps were added modify block->millimeters with a linear approximation
// See https://github.com/MarlinFirmware/Marlin/pull/26392
if (changed)
block->millimeters += TERN(IS_KINEMATIC, millimeters_delta * block->millimeters / sqr_stepper_space_mm, millimeters_delta / block->millimeters);
}

int32_t Backlash::get_applied_steps(const AxisEnum axis) {
Expand All @@ -151,8 +171,8 @@ int32_t Backlash::get_applied_steps(const AxisEnum axis) {

const int32_t residual_error_axis = residual_error[axis];

// At startup it is assumed the last move was forwards. So the applied
// steps will always be a non-positive number.
// At startup it is assumed the last move was forward.
// So the applied steps will always be negative.

if (forward) return -residual_error_axis;

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/backlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Backlash {
return has_measurement(X_AXIS) || has_measurement(Y_AXIS) || has_measurement(Z_AXIS);
}

static void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const AxisBits dm, block_t * const block);
static void add_correction_steps(const xyze_long_t &dist, const AxisBits dm, block_t * const block);
static int32_t get_applied_steps(const AxisEnum axis);

#if ENABLED(BACKLASH_GCODE)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ void unified_bed_leveling::shift_mesh_height() {
#endif

#ifndef HUGE_VALF
#define HUGE_VALF (10e100F)
#define HUGE_VALF __FLT_MAX__
#endif

best = do_furthest // Points with valid data or HUGE_VALF are skipped
Expand Down
9 changes: 8 additions & 1 deletion Marlin/src/gcode/feature/pause/G27.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@
#include "../../../module/motion.h"

/**
* G27: Park the nozzle
* G27: Park the nozzle according with the given style
*
* P<style> - Parking style:
* 0 = (Default) Relative raise by NOZZLE_PARK_Z_RAISE_MIN (>= NOZZLE_PARK_POINT.z) before XY parking.
* 1 = Absolute move to NOZZLE_PARK_POINT.z before XY parking. (USE WITH CAUTION!)
* 2 = Relative raise by NOZZLE_PARK_POINT.z before XY parking.
* 3 = Relative raise by NOZZLE_PARK_Z_RAISE_MIN, skip XY parking.
* 4 = No Z raise. Just XY parking.
*/
void GcodeSuite::G27() {
// Don't allow nozzle parking without homing first
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/gcode/probe/M851.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ void GcodeSuite::M851() {
if (parser.seenval('X')) {
const float x = parser.value_float();
#if HAS_PROBE_XY_OFFSET
if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
if (WITHIN(x, PROBE_OFFSET_XMIN, PROBE_OFFSET_XMAX))
offs.x = x;
else {
SERIAL_ECHOLNPGM("?X out of range (-", X_BED_SIZE, " to ", X_BED_SIZE, ")");
SERIAL_ECHOLNPGM("?X out of range (", PROBE_OFFSET_XMIN, " to ", PROBE_OFFSET_XMAX, ")");
ok = false;
}
#else
Expand All @@ -58,10 +58,10 @@ void GcodeSuite::M851() {
if (parser.seenval('Y')) {
const float y = parser.value_float();
#if HAS_PROBE_XY_OFFSET
if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
if (WITHIN(y, PROBE_OFFSET_YMIN, PROBE_OFFSET_YMAX))
offs.y = y;
else {
SERIAL_ECHOLNPGM("?Y out of range (-", Y_BED_SIZE, " to ", Y_BED_SIZE, ")");
SERIAL_ECHOLNPGM("?Y out of range (", PROBE_OFFSET_YMIN, " to ", PROBE_OFFSET_YMAX, ")");
ok = false;
}
#else
Expand All @@ -71,10 +71,10 @@ void GcodeSuite::M851() {

if (parser.seenval('Z')) {
const float z = parser.value_float();
if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
if (WITHIN(z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX))
offs.z = z;
else {
SERIAL_ECHOLNPGM("?Z out of range (", Z_PROBE_OFFSET_RANGE_MIN, " to ", Z_PROBE_OFFSET_RANGE_MAX, ")");
SERIAL_ECHOLNPGM("?Z out of range (", PROBE_OFFSET_ZMIN, " to ", PROBE_OFFSET_ZMAX, ")");
ok = false;
}
}
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/inc/Changes.h
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,8 @@
#error "FOLDER_SORTING is now SDSORT_FOLDERS."
#elif defined(BTT_MINI_12864_V1)
#error "BTT_MINI_12864_V1 is now BTT_MINI_12864."
#elif defined(Z_PROBE_OFFSET_RANGE_MIN) || defined(Z_PROBE_OFFSET_RANGE_MAX)
#error "Z_PROBE_OFFSET_RANGE_(MIN|MAX) is now PROBE_OFFSET_Z(MIN|MAX)."
#endif

// L64xx stepper drivers have been removed
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -1465,8 +1465,8 @@
#undef Z_PROBE_ERROR_TOLERANCE
#undef MULTIPLE_PROBING
#undef EXTRA_PROBING
#undef Z_PROBE_OFFSET_RANGE_MIN
#undef Z_PROBE_OFFSET_RANGE_MAX
#undef PROBE_OFFSET_ZMIN
#undef PROBE_OFFSET_ZMAX
#undef PAUSE_BEFORE_DEPLOY_STOW
#undef PAUSE_PROBE_DEPLOY_WHEN_TRIGGERED
#undef PROBING_HEATERS_OFF
Expand Down
20 changes: 16 additions & 4 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2943,14 +2943,26 @@
* Bed Probe dependencies
*/
#if ANY(MESH_BED_LEVELING, HAS_BED_PROBE)
#ifndef Z_PROBE_OFFSET_RANGE_MIN
#define Z_PROBE_OFFSET_RANGE_MIN -20
#ifndef PROBE_OFFSET_ZMIN
#define PROBE_OFFSET_ZMIN -20
#endif
#ifndef Z_PROBE_OFFSET_RANGE_MAX
#define Z_PROBE_OFFSET_RANGE_MAX 20
#ifndef PROBE_OFFSET_ZMAX
#define PROBE_OFFSET_ZMAX 20
#endif
#endif
#if HAS_BED_PROBE
#ifndef PROBE_OFFSET_XMIN
#define PROBE_OFFSET_XMIN -50
#endif
#ifndef PROBE_OFFSET_XMAX
#define PROBE_OFFSET_XMAX 50
#endif
#ifndef PROBE_OFFSET_YMIN
#define PROBE_OFFSET_YMIN -50
#endif
#ifndef PROBE_OFFSET_YMAX
#define PROBE_OFFSET_YMAX 50
#endif
#if ALL(ENDSTOPPULLUPS, USE_Z_MIN_PROBE)
#define ENDSTOPPULLUP_ZMIN_PROBE
#endif
Expand Down
37 changes: 30 additions & 7 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1418,20 +1418,15 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#endif

/**
* Check for improper NOZZLE_TO_PROBE_OFFSET
* Check for improper PROBING_MARGIN
*/
constexpr xyz_pos_t sanity_nozzle_to_probe_offset = NOZZLE_TO_PROBE_OFFSET;
#if ENABLED(NOZZLE_AS_PROBE)
static_assert(sanity_nozzle_to_probe_offset.x == 0 && sanity_nozzle_to_probe_offset.y == 0,
"NOZZLE_AS_PROBE requires the XY offsets in NOZZLE_TO_PROBE_OFFSET to both be 0.");
#elif !IS_KINEMATIC
#if NONE(NOZZLE_AS_PROBE, IS_KINEMATIC)
static_assert(PROBING_MARGIN >= 0, "PROBING_MARGIN must be >= 0.");
static_assert(PROBING_MARGIN_BACK >= 0, "PROBING_MARGIN_BACK must be >= 0.");
static_assert(PROBING_MARGIN_FRONT >= 0, "PROBING_MARGIN_FRONT must be >= 0.");
static_assert(PROBING_MARGIN_LEFT >= 0, "PROBING_MARGIN_LEFT must be >= 0.");
static_assert(PROBING_MARGIN_RIGHT >= 0, "PROBING_MARGIN_RIGHT must be >= 0.");
#endif

#define _MARGIN(A) TERN(IS_KINEMATIC, PRINTABLE_RADIUS, ((A##_BED_SIZE) / 2))
static_assert(PROBING_MARGIN < _MARGIN(X), "PROBING_MARGIN is too large.");
static_assert(PROBING_MARGIN_BACK < _MARGIN(Y), "PROBING_MARGIN_BACK is too large.");
Expand All @@ -1440,6 +1435,34 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
static_assert(PROBING_MARGIN_RIGHT < _MARGIN(X), "PROBING_MARGIN_RIGHT is too large.");
#undef _MARGIN

/**
* Check for improper PROBE_OFFSET_[XYZ](MIN|MAX)
*/
#define PROBE_OFFSET_ASSERT(varname, x, min, max) static_assert(WITHIN(x, min, max), varname " must be within " STRINGIFY(min) " and " STRINGIFY(max))
#if HAS_PROBE_XY_OFFSET
PROBE_OFFSET_ASSERT("PROBE_OFFSET_XMIN", PROBE_OFFSET_XMIN, -(X_BED_SIZE), X_BED_SIZE);
PROBE_OFFSET_ASSERT("PROBE_OFFSET_XMAX", PROBE_OFFSET_XMAX, -(X_BED_SIZE), X_BED_SIZE);
PROBE_OFFSET_ASSERT("PROBE_OFFSET_YMIN", PROBE_OFFSET_YMIN, -(Y_BED_SIZE), Y_BED_SIZE);
PROBE_OFFSET_ASSERT("PROBE_OFFSET_YMAX", PROBE_OFFSET_YMAX, -(Y_BED_SIZE), Y_BED_SIZE);
#endif
PROBE_OFFSET_ASSERT("PROBE_OFFSET_ZMIN", PROBE_OFFSET_ZMIN, -20, 20);
PROBE_OFFSET_ASSERT("PROBE_OFFSET_ZMAX", PROBE_OFFSET_ZMAX, -20, 20);

/**
* Check for improper NOZZLE_AS_PROBE or NOZZLE_TO_PROBE_OFFSET
*/
constexpr xyz_pos_t sanity_nozzle_to_probe_offset = NOZZLE_TO_PROBE_OFFSET;
#if ENABLED(NOZZLE_AS_PROBE)
static_assert(sanity_nozzle_to_probe_offset.x == 0 && sanity_nozzle_to_probe_offset.y == 0,
"NOZZLE_AS_PROBE requires the XY offsets in NOZZLE_TO_PROBE_OFFSET to both be 0.");
#endif
#if HAS_PROBE_XY_OFFSET
PROBE_OFFSET_ASSERT("NOZZLE_TO_PROBE_OFFSET.x", sanity_nozzle_to_probe_offset.x, PROBE_OFFSET_XMIN, PROBE_OFFSET_XMAX);
PROBE_OFFSET_ASSERT("NOZZLE_TO_PROBE_OFFSET.y", sanity_nozzle_to_probe_offset.y, PROBE_OFFSET_YMIN, PROBE_OFFSET_YMAX);
#endif
PROBE_OFFSET_ASSERT("NOZZLE_TO_PROBE_OFFSET.z", sanity_nozzle_to_probe_offset.z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX);
#undef PROBE_OFFSET_ASSERT

/**
* Make sure Z raise values are set
*/
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2023-10-29"
#define STRING_DISTRIBUTION_DATE "2023-11-10"
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/e3v2/creality/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ void hmiMoveDone(const AxisEnum axis) {
dwinUpdateLCD();
return;
}
LIMIT(hmiValues.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100, (Z_PROBE_OFFSET_RANGE_MAX) * 100);
LIMIT(hmiValues.offset_value, (PROBE_OFFSET_ZMIN) * 100, (PROBE_OFFSET_ZMAX) * 100);
last_zoffset = dwin_zoffset;
dwin_zoffset = hmiValues.offset_value / 100.0f;
#if ANY(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP)
Expand Down
Loading

0 comments on commit 184bde0

Please sign in to comment.