Browse Source

Add debug logging for setup()

Scott Lahteine 4 years ago
parent
commit
b5530775c9
1 changed files with 66 additions and 43 deletions
  1. 66
    43
      Marlin/src/MarlinCore.cpp

+ 66
- 43
Marlin/src/MarlinCore.cpp View File

959
   // UI must be initialized before EEPROM
959
   // UI must be initialized before EEPROM
960
   // (because EEPROM code calls the UI).
960
   // (because EEPROM code calls the UI).
961
 
961
 
962
+  #if ENABLED(MARLIN_DEV_MODE)
963
+    auto log_current_ms = [&](PGM_P const msg) {
964
+      SERIAL_ECHO_START();
965
+      SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHO("] ");
966
+      serialprintPGM(msg);
967
+      SERIAL_EOL();
968
+    };
969
+    #define SETUP_LOG(M) log_current_ms(PSTR(M))
970
+  #else
971
+    #define SETUP_LOG(...) NOOP
972
+  #endif
973
+  #define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0)
974
+
962
   // Set up LEDs early
975
   // Set up LEDs early
963
   #if HAS_COLOR_LEDS
976
   #if HAS_COLOR_LEDS
964
-    leds.setup();
977
+    SETUP_RUN(leds.setup());
965
   #endif
978
   #endif
966
 
979
 
967
-  ui.init();
980
+  SETUP_RUN(ui.init());
981
+
968
   #if HAS_SPI_LCD && ENABLED(SHOW_BOOTSCREEN)
982
   #if HAS_SPI_LCD && ENABLED(SHOW_BOOTSCREEN)
969
-    ui.show_bootscreen();
983
+    SETUP_RUN(ui.show_bootscreen());
970
   #endif
984
   #endif
971
 
985
 
972
-  ui.reset_status();        // Load welcome message early. (Retained if no errors exist.)
986
+  #if !HAS_SERVICE_INTERVALS
987
+    SETUP_RUN(ui.reset_status());     // Load welcome message early. (Retained if no errors exist.)
988
+  #endif
973
 
989
 
974
   #if ENABLED(SDSUPPORT)
990
   #if ENABLED(SDSUPPORT)
975
-    card.mount();           // Mount the SD card before settings.first_load
991
+    SETUP_RUN(card.mount());          // Mount the SD card before settings.first_load
992
+  #endif
993
+
994
+  SETUP_RUN(settings.first_load());   // Load data from EEPROM if available (or use defaults)
995
+                                      // This also updates variables in the planner, elsewhere
996
+
997
+  #if HAS_SERVICE_INTERVALS
998
+    SETUP_RUN(ui.reset_status(true)); // Show service messages or keep current status
976
   #endif
999
   #endif
977
-                            // Load data from EEPROM if available (or use defaults)
978
-  settings.first_load();    // This also updates variables in the planner, elsewhere
979
 
1000
 
980
   #if ENABLED(TOUCH_BUTTONS)
1001
   #if ENABLED(TOUCH_BUTTONS)
981
-    touch.init();
1002
+    SETUP_RUN(touch.init());
982
   #endif
1003
   #endif
983
 
1004
 
984
-  #if HAS_M206_COMMAND      // Initialize current position based on home_offset
985
-    current_position += home_offset;
1005
+  #if HAS_M206_COMMAND
1006
+    current_position += home_offset;  // Init current position based on home_offset
986
   #endif
1007
   #endif
987
 
1008
 
988
-  sync_plan_position();     // Vital to init stepper/planner equivalent for current_position
1009
+  sync_plan_position();               // Vital to init stepper/planner equivalent for current_position
989
 
1010
 
990
-  thermalManager.init();    // Initialize temperature loop
1011
+  SETUP_RUN(thermalManager.init());   // Initialize temperature loop
991
 
1012
 
992
-  print_job_timer.init();   // Initial setup of print job timer
1013
+  SETUP_RUN(print_job_timer.init());  // Initial setup of print job timer
993
 
1014
 
994
-  endstops.init();          // Init endstops and pullups
1015
+  SETUP_RUN(endstops.init());         // Init endstops and pullups
995
 
1016
 
996
-  stepper.init();           // Init stepper. This enables interrupts!
1017
+  SETUP_RUN(stepper.init());          // Init stepper. This enables interrupts!
997
 
1018
 
998
   #if HAS_SERVOS
1019
   #if HAS_SERVOS
999
-    servo_init();
1020
+    SETUP_RUN(servo_init());
1000
   #endif
1021
   #endif
1001
 
1022
 
1002
   #if HAS_Z_SERVO_PROBE
1023
   #if HAS_Z_SERVO_PROBE
1003
-    probe.servo_probe_init();
1024
+    SETUP_RUN(probe.servo_probe_init());
1004
   #endif
1025
   #endif
1005
 
1026
 
1006
   #if HAS_PHOTOGRAPH
1027
   #if HAS_PHOTOGRAPH
1008
   #endif
1029
   #endif
1009
 
1030
 
1010
   #if HAS_CUTTER
1031
   #if HAS_CUTTER
1011
-    cutter.init();
1032
+    SETUP_RUN(cutter.init());
1012
   #endif
1033
   #endif
1013
 
1034
 
1014
   #if ENABLED(COOLANT_MIST)
1035
   #if ENABLED(COOLANT_MIST)
1019
   #endif
1040
   #endif
1020
 
1041
 
1021
   #if HAS_BED_PROBE
1042
   #if HAS_BED_PROBE
1022
-    endstops.enable_z_probe(false);
1043
+    SETUP_RUN(endstops.enable_z_probe(false));
1023
   #endif
1044
   #endif
1024
 
1045
 
1025
   #if ENABLED(USE_CONTROLLER_FAN)
1046
   #if ENABLED(USE_CONTROLLER_FAN)
1027
   #endif
1048
   #endif
1028
 
1049
 
1029
   #if HAS_STEPPER_RESET
1050
   #if HAS_STEPPER_RESET
1030
-    enableStepperDrivers();
1051
+    SETUP_RUN(enableStepperDrivers());
1031
   #endif
1052
   #endif
1032
 
1053
 
1033
   #if ENABLED(DIGIPOT_I2C)
1054
   #if ENABLED(DIGIPOT_I2C)
1034
-    digipot_i2c_init();
1055
+    SETUP_RUN(digipot_i2c_init());
1035
   #endif
1056
   #endif
1036
 
1057
 
1037
   #if ENABLED(DAC_STEPPER_CURRENT)
1058
   #if ENABLED(DAC_STEPPER_CURRENT)
1038
-    dac_init();
1059
+    SETUP_RUN(dac_init());
1039
   #endif
1060
   #endif
1040
 
1061
 
1041
   #if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1
1062
   #if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1
1058
     #if DISABLED(CASE_LIGHT_USE_NEOPIXEL)
1079
     #if DISABLED(CASE_LIGHT_USE_NEOPIXEL)
1059
       if (PWM_PIN(CASE_LIGHT_PIN)) SET_PWM(CASE_LIGHT_PIN); else SET_OUTPUT(CASE_LIGHT_PIN);
1080
       if (PWM_PIN(CASE_LIGHT_PIN)) SET_PWM(CASE_LIGHT_PIN); else SET_OUTPUT(CASE_LIGHT_PIN);
1060
     #endif
1081
     #endif
1061
-    update_case_light();
1082
+    SETUP_RUN(update_case_light());
1062
   #endif
1083
   #endif
1063
 
1084
 
1064
   #if ENABLED(MK2_MULTIPLEXER)
1085
   #if ENABLED(MK2_MULTIPLEXER)
1086
+    SETUP_LOG("MK2_MULTIPLEXER");
1065
     SET_OUTPUT(E_MUX0_PIN);
1087
     SET_OUTPUT(E_MUX0_PIN);
1066
     SET_OUTPUT(E_MUX1_PIN);
1088
     SET_OUTPUT(E_MUX1_PIN);
1067
     SET_OUTPUT(E_MUX2_PIN);
1089
     SET_OUTPUT(E_MUX2_PIN);
1068
   #endif
1090
   #endif
1069
 
1091
 
1070
   #if HAS_FANMUX
1092
   #if HAS_FANMUX
1071
-    fanmux_init();
1093
+    SETUP_RUN(fanmux_init());
1072
   #endif
1094
   #endif
1073
 
1095
 
1074
   #if ENABLED(MIXING_EXTRUDER)
1096
   #if ENABLED(MIXING_EXTRUDER)
1075
-    mixer.init();
1097
+    SETUP_RUN(mixer.init());
1076
   #endif
1098
   #endif
1077
 
1099
 
1078
   #if ENABLED(BLTOUCH)
1100
   #if ENABLED(BLTOUCH)
1079
-    bltouch.init(/*set_voltage=*/true);
1101
+    SETUP_RUN(bltouch.init(/*set_voltage=*/true));
1080
   #endif
1102
   #endif
1081
 
1103
 
1082
   #if ENABLED(I2C_POSITION_ENCODERS)
1104
   #if ENABLED(I2C_POSITION_ENCODERS)
1083
-    I2CPEM.init();
1105
+    SETUP_RUN(I2CPEM.init());
1084
   #endif
1106
   #endif
1085
 
1107
 
1086
   #if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
1108
   #if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
1109
+    SETUP_LOG("i2c...");
1087
     i2c.onReceive(i2c_on_receive);
1110
     i2c.onReceive(i2c_on_receive);
1088
     i2c.onRequest(i2c_on_request);
1111
     i2c.onRequest(i2c_on_request);
1089
   #endif
1112
   #endif
1090
 
1113
 
1091
   #if DO_SWITCH_EXTRUDER
1114
   #if DO_SWITCH_EXTRUDER
1092
-    move_extruder_servo(0);   // Initialize extruder servo
1115
+    SETUP_RUN(move_extruder_servo(0));  // Initialize extruder servo
1093
   #endif
1116
   #endif
1094
 
1117
 
1095
   #if ENABLED(SWITCHING_NOZZLE)
1118
   #if ENABLED(SWITCHING_NOZZLE)
1119
+    SETUP_LOG("SWITCHING_NOZZLE");
1096
     // Initialize nozzle servo(s)
1120
     // Initialize nozzle servo(s)
1097
     #if SWITCHING_NOZZLE_TWO_SERVOS
1121
     #if SWITCHING_NOZZLE_TWO_SERVOS
1098
       lower_nozzle(0);
1122
       lower_nozzle(0);
1103
   #endif
1127
   #endif
1104
 
1128
 
1105
   #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
1129
   #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
1106
-    mpe_settings_init();
1130
+    SETUP_RUN(mpe_settings_init());
1107
   #endif
1131
   #endif
1108
 
1132
 
1109
   #if ENABLED(PARKING_EXTRUDER)
1133
   #if ENABLED(PARKING_EXTRUDER)
1110
-    pe_solenoid_init();
1134
+    SETUP_RUN(pe_solenoid_init());
1111
   #endif
1135
   #endif
1112
 
1136
 
1113
   #if ENABLED(SWITCHING_TOOLHEAD)
1137
   #if ENABLED(SWITCHING_TOOLHEAD)
1115
   #endif
1139
   #endif
1116
 
1140
 
1117
   #if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
1141
   #if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
1118
-    est_init();
1142
+    SETUP_RUN(est_init());
1119
   #endif
1143
   #endif
1120
 
1144
 
1121
   #if ENABLED(POWER_LOSS_RECOVERY)
1145
   #if ENABLED(POWER_LOSS_RECOVERY)
1122
-    recovery.check();
1146
+    SETUP_RUN(recovery.check());
1123
   #endif
1147
   #endif
1124
 
1148
 
1125
   #if ENABLED(USE_WATCHDOG)
1149
   #if ENABLED(USE_WATCHDOG)
1126
-    watchdog_init();          // Reinit watchdog after HAL_get_reset_source call
1150
+    SETUP_RUN(watchdog_init());       // Reinit watchdog after HAL_get_reset_source call
1127
   #endif
1151
   #endif
1128
 
1152
 
1129
   #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
1153
   #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
1130
-    init_closedloop();
1154
+    SETUP_RUN(init_closedloop());
1131
   #endif
1155
   #endif
1132
 
1156
 
1133
   #ifdef STARTUP_COMMANDS
1157
   #ifdef STARTUP_COMMANDS
1158
+    SETUP_LOG("STARTUP_COMMANDS");
1134
     queue.inject_P(PSTR(STARTUP_COMMANDS));
1159
     queue.inject_P(PSTR(STARTUP_COMMANDS));
1135
   #endif
1160
   #endif
1136
 
1161
 
1137
   #if ENABLED(INIT_SDCARD_ON_BOOT) && !HAS_SPI_LCD
1162
   #if ENABLED(INIT_SDCARD_ON_BOOT) && !HAS_SPI_LCD
1138
-    card.beginautostart();
1163
+    SETUP_RUN(card.beginautostart());
1139
   #endif
1164
   #endif
1140
 
1165
 
1141
   #if ENABLED(HOST_PROMPT_SUPPORT)
1166
   #if ENABLED(HOST_PROMPT_SUPPORT)
1142
-    host_action_prompt_end();
1167
+    SETUP_RUN(host_action_prompt_end());
1143
   #endif
1168
   #endif
1144
 
1169
 
1145
   #if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
1170
   #if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
1146
-    test_tmc_connection(true, true, true, true);
1171
+    SETUP_RUN(test_tmc_connection(true, true, true, true));
1147
   #endif
1172
   #endif
1148
 
1173
 
1149
   #if ENABLED(PRUSA_MMU2)
1174
   #if ENABLED(PRUSA_MMU2)
1150
-    mmu2.init();
1151
-  #endif
1152
-
1153
-  #if HAS_SERVICE_INTERVALS
1154
-    ui.reset_status(true);  // Show service messages or keep current status
1175
+    SETUP_RUN(mmu2.init());
1155
   #endif
1176
   #endif
1156
 
1177
 
1157
   #if ENABLED(MAX7219_DEBUG)
1178
   #if ENABLED(MAX7219_DEBUG)
1158
-    max7219.init();
1179
+    SETUP_RUN(max7219.init());
1159
   #endif
1180
   #endif
1181
+
1182
+  SETUP_LOG("setup() completed.");
1160
 }
1183
 }
1161
 
1184
 
1162
 /**
1185
 /**

Loading…
Cancel
Save