diff --git a/README.md b/README.md
index ad0f8eb..9c675b3 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ It has been written to complement grblHAL and has features such as proper keyboa
---
-Latest build date is 20240416, see the [changelog](changelog.md) for details.
+Latest build date is 20240506, see the [changelog](changelog.md) for details.
__NOTE:__ Build 20240222 has moved the probe input to the ioPorts pool of inputs and will be allocated from it when configured.
The change is major and _potentially dangerous_, it may damage your probe, so please _verify correct operation_ after installing this, or later, builds.
diff --git a/changelog.md b/changelog.md
index 658d45f..e5a3090 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,24 @@
## grblHAL changelog
+Build 20240506
+
+Core:
+
+* Fix for incorrect handling of some flow control statements when nested. Ref. issue [#504](https://github.com/grblHAL/core/issues/504).
+
+* Fixed defaults and added sanity checks for spindle linearization parameters settings.
+
+Drivers:
+
+* ESP32: increased max application size to 2 MB. __NOTE:__ settings and any WebUI files stored in littlefs will be overwritten on an update, backup and restore when updating!
+
+* STM32F1xx: removed stray debug message.
+
+* STM32F4xx: added printf/scanf support to STM32CubeIDE builds with spindle linearization enabled, due to run time issues.
+Fixed incorrect EEPROM emulator flash section id, ref. core [discussion #503](https://github.com/grblHAL/core/discussions/503) and core [issue #457](https://github.com/grblHAL/core/issues/457).
+
+---
+
Build 20240427
Core:
diff --git a/config.h b/config.h
index 74596fa..f645645 100644
--- a/config.h
+++ b/config.h
@@ -1134,7 +1134,7 @@ Defines the parameters for the first entry in the spindle RPM linearization tabl
*/
///@{
#if !defined DEFAULT_RPM_POINT01 || defined __DOXYGEN__
-#define DEFAULT_RPM_POINT01 DEFAULT_SPINDLE_RPM_MIN // Don not change! Set DEFAULT_SPINDLE_RPM_MIN instead.
+#define DEFAULT_RPM_POINT01 NAN // DEFAULT_SPINDLE_RPM_MIN // Replace NAN with DEFAULT_SPINDLE_RPM_MIN to enable.
#endif
#if !defined DEFAULT_RPM_LINE_A1 || defined __DOXYGEN__
#define DEFAULT_RPM_LINE_A1 3.197101e-03f
@@ -1149,7 +1149,7 @@ Defines the parameters for the second entry in the spindle RPM linearization tab
*/
///@{
#if !defined DEFAULT_RPM_POINT12 || defined __DOXYGEN__
-#define DEFAULT_RPM_POINT12 9627.8 // Set to a float constant to enable.
+#define DEFAULT_RPM_POINT12 NAN // Change NAN to a float constant to enable.
#endif
#if !defined DEFAULT_RPM_LINE_A2 || defined __DOXYGEN__
#define DEFAULT_RPM_LINE_A2 1.722950e-2f
@@ -1164,7 +1164,7 @@ Defines the parameters for the third entry in the spindle RPM linearization tabl
*/
///@{
#if !defined DEFAULT_RPM_POINT23 || defined __DOXYGEN__
-#define DEFAULT_RPM_POINT23 10813.9 // Set to a float constant to enable.
+#define DEFAULT_RPM_POINT23 NAN // Change NAN to a float constant to enable.
#endif
#if !defined DEFAULT_RPM_LINE_A3 || defined __DOXYGEN__
#define DEFAULT_RPM_LINE_A3 5.901518e-02f
@@ -1179,7 +1179,7 @@ Defines the parameters for the fourth entry in the spindle RPM linearization tab
*/
///@{
#if !defined DEFAULT_RPM_POINT34 || defined __DOXYGEN__
-#define DEFAULT_RPM_POINT34 NAN // Set to a float constant to enable.
+#define DEFAULT_RPM_POINT34 NAN // Change NAN to a float constant to enable.
#endif
#if !defined DEFAULT_RPM_LINE_A4 || defined __DOXYGEN__
#define DEFAULT_RPM_LINE_A4 1.203413e-01f
diff --git a/grbl.h b/grbl.h
index f46117c..cd5fed0 100644
--- a/grbl.h
+++ b/grbl.h
@@ -42,7 +42,7 @@
#else
#define GRBL_VERSION "1.1f"
#endif
-#define GRBL_BUILD 20240427
+#define GRBL_BUILD 20240506
#define GRBL_URL "https://github.com/grblHAL"
diff --git a/ngc_flowctrl.c b/ngc_flowctrl.c
index 7ae9b74..a7c2125 100644
--- a/ngc_flowctrl.c
+++ b/ngc_flowctrl.c
@@ -305,7 +305,7 @@ status_code_t ngc_flowctrl (uint32_t o_label, char *line, uint_fast8_t *pos, boo
case NGCFlowCtrl_EndWhile:
if(hal.stream.file) {
if(last_op == NGCFlowCtrl_While) {
- if(o_label == stack[stack_idx].o_label) {
+ if(!skipping && o_label == stack[stack_idx].o_label) {
uint_fast8_t pos = 0;
if(!stack[stack_idx].skip && (status = ngc_eval_expression(stack[stack_idx].expr, &pos, &value)) == Status_OK) {
if(!(stack[stack_idx].skip = value == 0))
@@ -314,7 +314,7 @@ status_code_t ngc_flowctrl (uint32_t o_label, char *line, uint_fast8_t *pos, boo
if(stack[stack_idx].skip)
stack_pull();
}
- } else
+ } else if(!skipping)
status = Status_FlowControlSyntaxError;
} else
status = Status_FlowControlNotExecutingMacro;
@@ -338,13 +338,13 @@ status_code_t ngc_flowctrl (uint32_t o_label, char *line, uint_fast8_t *pos, boo
case NGCFlowCtrl_EndRepeat:
if(hal.stream.file) {
if(last_op == NGCFlowCtrl_Repeat) {
- if(o_label == stack[stack_idx].o_label) {
+ if(!skipping && o_label == stack[stack_idx].o_label) {
if(stack[stack_idx].repeats && --stack[stack_idx].repeats)
vfs_seek(stack[stack_idx].file, stack[stack_idx].file_pos);
else
stack_pull();
}
- } else
+ } else if(!skipping)
status = Status_FlowControlSyntaxError;
} else
status = Status_FlowControlNotExecutingMacro;
@@ -443,6 +443,8 @@ status_code_t ngc_flowctrl (uint32_t o_label, char *line, uint_fast8_t *pos, boo
if(status != Status_OK) {
ngc_flowctrl_init();
*skip = false;
+ if(settings.flags.ngc_debug_out)
+ report_message(line, Message_Plain);
} else
*skip = stack_idx >= 0 && stack[stack_idx].skip;