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,48 +959,69 @@ void setup() {
959 959
   // UI must be initialized before EEPROM
960 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 975
   // Set up LEDs early
963 976
   #if HAS_COLOR_LEDS
964
-    leds.setup();
977
+    SETUP_RUN(leds.setup());
965 978
   #endif
966 979
 
967
-  ui.init();
980
+  SETUP_RUN(ui.init());
981
+
968 982
   #if HAS_SPI_LCD && ENABLED(SHOW_BOOTSCREEN)
969
-    ui.show_bootscreen();
983
+    SETUP_RUN(ui.show_bootscreen());
970 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 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 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 1001
   #if ENABLED(TOUCH_BUTTONS)
981
-    touch.init();
1002
+    SETUP_RUN(touch.init());
982 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 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 1019
   #if HAS_SERVOS
999
-    servo_init();
1020
+    SETUP_RUN(servo_init());
1000 1021
   #endif
1001 1022
 
1002 1023
   #if HAS_Z_SERVO_PROBE
1003
-    probe.servo_probe_init();
1024
+    SETUP_RUN(probe.servo_probe_init());
1004 1025
   #endif
1005 1026
 
1006 1027
   #if HAS_PHOTOGRAPH
@@ -1008,7 +1029,7 @@ void setup() {
1008 1029
   #endif
1009 1030
 
1010 1031
   #if HAS_CUTTER
1011
-    cutter.init();
1032
+    SETUP_RUN(cutter.init());
1012 1033
   #endif
1013 1034
 
1014 1035
   #if ENABLED(COOLANT_MIST)
@@ -1019,7 +1040,7 @@ void setup() {
1019 1040
   #endif
1020 1041
 
1021 1042
   #if HAS_BED_PROBE
1022
-    endstops.enable_z_probe(false);
1043
+    SETUP_RUN(endstops.enable_z_probe(false));
1023 1044
   #endif
1024 1045
 
1025 1046
   #if ENABLED(USE_CONTROLLER_FAN)
@@ -1027,15 +1048,15 @@ void setup() {
1027 1048
   #endif
1028 1049
 
1029 1050
   #if HAS_STEPPER_RESET
1030
-    enableStepperDrivers();
1051
+    SETUP_RUN(enableStepperDrivers());
1031 1052
   #endif
1032 1053
 
1033 1054
   #if ENABLED(DIGIPOT_I2C)
1034
-    digipot_i2c_init();
1055
+    SETUP_RUN(digipot_i2c_init());
1035 1056
   #endif
1036 1057
 
1037 1058
   #if ENABLED(DAC_STEPPER_CURRENT)
1038
-    dac_init();
1059
+    SETUP_RUN(dac_init());
1039 1060
   #endif
1040 1061
 
1041 1062
   #if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1
@@ -1058,41 +1079,44 @@ void setup() {
1058 1079
     #if DISABLED(CASE_LIGHT_USE_NEOPIXEL)
1059 1080
       if (PWM_PIN(CASE_LIGHT_PIN)) SET_PWM(CASE_LIGHT_PIN); else SET_OUTPUT(CASE_LIGHT_PIN);
1060 1081
     #endif
1061
-    update_case_light();
1082
+    SETUP_RUN(update_case_light());
1062 1083
   #endif
1063 1084
 
1064 1085
   #if ENABLED(MK2_MULTIPLEXER)
1086
+    SETUP_LOG("MK2_MULTIPLEXER");
1065 1087
     SET_OUTPUT(E_MUX0_PIN);
1066 1088
     SET_OUTPUT(E_MUX1_PIN);
1067 1089
     SET_OUTPUT(E_MUX2_PIN);
1068 1090
   #endif
1069 1091
 
1070 1092
   #if HAS_FANMUX
1071
-    fanmux_init();
1093
+    SETUP_RUN(fanmux_init());
1072 1094
   #endif
1073 1095
 
1074 1096
   #if ENABLED(MIXING_EXTRUDER)
1075
-    mixer.init();
1097
+    SETUP_RUN(mixer.init());
1076 1098
   #endif
1077 1099
 
1078 1100
   #if ENABLED(BLTOUCH)
1079
-    bltouch.init(/*set_voltage=*/true);
1101
+    SETUP_RUN(bltouch.init(/*set_voltage=*/true));
1080 1102
   #endif
1081 1103
 
1082 1104
   #if ENABLED(I2C_POSITION_ENCODERS)
1083
-    I2CPEM.init();
1105
+    SETUP_RUN(I2CPEM.init());
1084 1106
   #endif
1085 1107
 
1086 1108
   #if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
1109
+    SETUP_LOG("i2c...");
1087 1110
     i2c.onReceive(i2c_on_receive);
1088 1111
     i2c.onRequest(i2c_on_request);
1089 1112
   #endif
1090 1113
 
1091 1114
   #if DO_SWITCH_EXTRUDER
1092
-    move_extruder_servo(0);   // Initialize extruder servo
1115
+    SETUP_RUN(move_extruder_servo(0));  // Initialize extruder servo
1093 1116
   #endif
1094 1117
 
1095 1118
   #if ENABLED(SWITCHING_NOZZLE)
1119
+    SETUP_LOG("SWITCHING_NOZZLE");
1096 1120
     // Initialize nozzle servo(s)
1097 1121
     #if SWITCHING_NOZZLE_TWO_SERVOS
1098 1122
       lower_nozzle(0);
@@ -1103,11 +1127,11 @@ void setup() {
1103 1127
   #endif
1104 1128
 
1105 1129
   #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
1106
-    mpe_settings_init();
1130
+    SETUP_RUN(mpe_settings_init());
1107 1131
   #endif
1108 1132
 
1109 1133
   #if ENABLED(PARKING_EXTRUDER)
1110
-    pe_solenoid_init();
1134
+    SETUP_RUN(pe_solenoid_init());
1111 1135
   #endif
1112 1136
 
1113 1137
   #if ENABLED(SWITCHING_TOOLHEAD)
@@ -1115,48 +1139,47 @@ void setup() {
1115 1139
   #endif
1116 1140
 
1117 1141
   #if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
1118
-    est_init();
1142
+    SETUP_RUN(est_init());
1119 1143
   #endif
1120 1144
 
1121 1145
   #if ENABLED(POWER_LOSS_RECOVERY)
1122
-    recovery.check();
1146
+    SETUP_RUN(recovery.check());
1123 1147
   #endif
1124 1148
 
1125 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 1151
   #endif
1128 1152
 
1129 1153
   #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
1130
-    init_closedloop();
1154
+    SETUP_RUN(init_closedloop());
1131 1155
   #endif
1132 1156
 
1133 1157
   #ifdef STARTUP_COMMANDS
1158
+    SETUP_LOG("STARTUP_COMMANDS");
1134 1159
     queue.inject_P(PSTR(STARTUP_COMMANDS));
1135 1160
   #endif
1136 1161
 
1137 1162
   #if ENABLED(INIT_SDCARD_ON_BOOT) && !HAS_SPI_LCD
1138
-    card.beginautostart();
1163
+    SETUP_RUN(card.beginautostart());
1139 1164
   #endif
1140 1165
 
1141 1166
   #if ENABLED(HOST_PROMPT_SUPPORT)
1142
-    host_action_prompt_end();
1167
+    SETUP_RUN(host_action_prompt_end());
1143 1168
   #endif
1144 1169
 
1145 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 1172
   #endif
1148 1173
 
1149 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 1176
   #endif
1156 1177
 
1157 1178
   #if ENABLED(MAX7219_DEBUG)
1158
-    max7219.init();
1179
+    SETUP_RUN(max7219.init());
1159 1180
   #endif
1181
+
1182
+  SETUP_LOG("setup() completed.");
1160 1183
 }
1161 1184
 
1162 1185
 /**

Loading…
Cancel
Save