Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Bootloop, if HAS_PRINT_PROGRESS, but no options enabled #25249

Closed
ellensp opened this issue Jan 17, 2023 · 4 comments
Closed

[BUG] Bootloop, if HAS_PRINT_PROGRESS, but no options enabled #25249

ellensp opened this issue Jan 17, 2023 · 4 comments

Comments

@ellensp
Copy link
Contributor

ellensp commented Jan 17, 2023

Did you test the latest bugfix-2.1.x code?

Yes, and the problem still exists.

Bug Description

In Configuration_adv.h is the following

#if HAS_DISPLAY && EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY)
  #define SHOW_PROGRESS_PERCENT           // Show print progress percentage (doesn't affect progress bar)
  #define SHOW_ELAPSED_TIME               // Display elapsed printing time (prefix 'E')
  //#define SHOW_REMAINING_TIME           // Display estimated time to completion (prefix 'R')
  #if ENABLED(SET_INTERACTION_TIME)
    #define SHOW_INTERACTION_TIME         // Display time until next user interaction ('C' = filament change)
  #endif

If you have a display and enable SDSUPPORT but disable all the following options
SHOW_PROGRESS_PERCENT
SHOW_ELAPSED_TIME
SHOW_REMAINING_TIME
SHOW_INTERACTION_TIME

Marlin will compile without errors, but will bootloop
A warning is given

Marlin/src/lcd/dogm/status_screen_DOGM.cpp:451:15: warning: 'void prepare_time_string(const duration_t&, char)' defined but not used [-Wunused-function]
   static void prepare_time_string(const duration_t &time, char prefix) {

Bug Timeline

3 months, Since #24767

Expected behavior

No bootloop

Actual behavior

Bootloop

Steps to Reproduce

1 use provided config
2. watch marlin bootloop

Version of Marlin Firmware

Bugfix-2.1.x

Electronics

RAMPS 1.4 and REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER

Additional information & file uploads

Configuration.zip

The cause

progFunc

IN this code

  #if LCD_WITH_BLINK && DISABLED(HAS_GRAPHICAL_TFT)
    typedef void (*PrintProgress_t)();
    void MarlinUI::rotate_progress() { // Renew and redraw all enabled progress strings
      const PrintProgress_t progFunc[] = {
        OPTITEM(SHOW_PROGRESS_PERCENT, drawPercent)
        OPTITEM(SHOW_ELAPSED_TIME, drawElapsed)
        OPTITEM(SHOW_REMAINING_TIME, drawRemain)
        OPTITEM(SHOW_INTERACTION_TIME, drawInter)
      };
      static bool prev_blink;
      static uint8_t i;
      if (prev_blink != get_blink()) {
        prev_blink = get_blink();
        if (++i >= COUNT(progFunc)) i = 0;
        (*progFunc[i])();
      }
    }
  #endif

progFunc is populated with optional functions.
Later (*progFunc[i])(); calls these functions.
But when they are all disabled it crashes marlin

@ellensp
Copy link
Contributor Author

ellensp commented Jan 17, 2023

@EvilGremlin you might want to look into this

@ellensp
Copy link
Contributor Author

ellensp commented Jan 17, 2023

A quick fix is

--- a/Marlin/src/lcd/marlinui.cpp
+++ b/Marlin/src/lcd/marlinui.cpp
@@ -1746,20 +1746,22 @@ void MarlinUI::init() {
   #if LCD_WITH_BLINK && DISABLED(HAS_GRAPHICAL_TFT)
     typedef void (*PrintProgress_t)();
     void MarlinUI::rotate_progress() { // Renew and redraw all enabled progress strings
-      const PrintProgress_t progFunc[] = {
-        OPTITEM(SHOW_PROGRESS_PERCENT, drawPercent)
-        OPTITEM(SHOW_ELAPSED_TIME, drawElapsed)
-        OPTITEM(SHOW_REMAINING_TIME, drawRemain)
-        OPTITEM(SHOW_INTERACTION_TIME, drawInter)
-      };
-      static bool prev_blink;
-      static uint8_t i;
-      if (prev_blink != get_blink()) {
-        prev_blink = get_blink();
-        if (++i >= COUNT(progFunc)) i = 0;
-        (*progFunc[i])();
+      #if ANY(SHOW_PROGRESS_PERCENT,SHOW_ELAPSED_TIME,SHOW_REMAINING_TIME,SHOW_INTERACTION_TIME)
+        const PrintProgress_t progFunc[] = {
+          OPTITEM(SHOW_PROGRESS_PERCENT, drawPercent)
+          OPTITEM(SHOW_ELAPSED_TIME, drawElapsed)
+          OPTITEM(SHOW_REMAINING_TIME, drawRemain)
+          OPTITEM(SHOW_INTERACTION_TIME, drawInter)
+        };
+        static bool prev_blink;
+        static uint8_t i;
+        if (prev_blink != get_blink()) {
+          prev_blink = get_blink();
+          if (++i >= COUNT(progFunc)) i = 0;
+          (*progFunc[i])();
+        }
+      #endif
       }
-    }
   #endif
 
 #endif // HAS_PRINT_PROGRESS

but the following warning remains

Marlin/src/lcd/dogm/status_screen_DOGM.cpp:451:15: warning: 'void prepare_time_string(const duration_t&, char)' defined but not used [-Wunused-function]
   static void prepare_time_string(const duration_t &time, char prefix) {

@HTMLdu
Copy link

HTMLdu commented Jan 31, 2023

same here

@github-actions
Copy link

github-actions bot commented Apr 2, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants