Browse Source

Fix broken M100_dump_routine

pull/1/head
Scott Lahteine 5 years ago
parent
commit
deff538909
  1. 17
      Marlin/src/gcode/calibrate/M100.cpp
  2. 4
      Marlin/src/gcode/gcode.cpp

17
Marlin/src/gcode/calibrate/M100.cpp

@ -51,7 +51,7 @@
* Also, there are two support functions that can be called from a developer's C code. * Also, there are two support functions that can be called from a developer's C code.
* *
* uint16_t check_for_free_memory_corruption(PGM_P const free_memory_start); * uint16_t check_for_free_memory_corruption(PGM_P const free_memory_start);
* void M100_dump_routine(PGM_P const title, char *start, char *end); * void M100_dump_routine(PGM_P const title, const char * const start, const char * const end);
* *
* Initial version by Roxy-3D * Initial version by Roxy-3D
*/ */
@ -151,8 +151,8 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
// Start and end the dump on a nice 16 byte boundary // Start and end the dump on a nice 16 byte boundary
// (even though the values are not 16-byte aligned). // (even though the values are not 16-byte aligned).
// //
start_free_memory = (char*)((ptr_int_t)((uint32_t)start_free_memory & 0xFFFFFFF0)); // Align to 16-byte boundary start_free_memory = (char*)(ptr_int_t(uint32_t(start_free_memory) & ~0xFUL)); // Align to 16-byte boundary
end_free_memory = (char*)((ptr_int_t)((uint32_t)end_free_memory | 0x0000000F)); // Align end_free_memory to the 15th byte (at or above end_free_memory) end_free_memory = (char*)(ptr_int_t(uint32_t(end_free_memory) | 0xFUL)); // Align end_free_memory to the 15th byte (at or above end_free_memory)
// Dump command main loop // Dump command main loop
while (start_free_memory < end_free_memory) { while (start_free_memory < end_free_memory) {
@ -177,15 +177,16 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
} }
} }
void M100_dump_routine(PGM_P const title, char *start, char *end) { void M100_dump_routine(PGM_P const title, const char * const start, const char * const end) {
serialprintPGM(title); serialprintPGM(title);
SERIAL_EOL(); SERIAL_EOL();
// //
// Round the start and end locations to produce full lines of output // Round the start and end locations to produce full lines of output
// //
start = (char*)((ptr_int_t)((uint32_t)start & 0xFFFFFFF0)); // Align to 16-byte boundary dump_free_memory(
end = (char*)((ptr_int_t)((uint32_t)end | 0x0000000F)); // Align end_free_memory to the 15th byte (at or above end_free_memory) (char*)(ptr_int_t(uint32_t(start) & ~0xFUL)), // Align to 16-byte boundary
dump_free_memory(start, end); (char*)(ptr_int_t(uint32_t(end) | 0xFUL)) // Align end_free_memory to the 15th byte (at or above end_free_memory)
);
} }
#endif // M100_FREE_MEMORY_DUMPER #endif // M100_FREE_MEMORY_DUMPER
@ -211,7 +212,7 @@ inline int check_for_free_memory_corruption(PGM_P const title) {
// idle(); // idle();
serial_delay(20); serial_delay(20);
#if ENABLED(M100_FREE_MEMORY_DUMPER) #if ENABLED(M100_FREE_MEMORY_DUMPER)
M100_dump_routine(PSTR(" Memory corruption detected with end_free_memory<Heap\n"), (char*)0x1B80, (char*)0x21FF); M100_dump_routine(PSTR(" Memory corruption detected with end_free_memory<Heap\n"), (const char*)0x1B80, (const char*)0x21FF);
#endif #endif
} }

4
Marlin/src/gcode/gcode.cpp

@ -209,7 +209,7 @@ void GcodeSuite::dwell(millis_t time) {
// Placeholders for non-migrated codes // Placeholders for non-migrated codes
// //
#if ENABLED(M100_FREE_MEMORY_WATCHER) #if ENABLED(M100_FREE_MEMORY_WATCHER)
extern void M100_dump_routine(PGM_P const title, char *start, char *end); extern void M100_dump_routine(PGM_P const title, const char * const start, const char * const end);
#endif #endif
/** /**
@ -865,7 +865,7 @@ void GcodeSuite::process_next_command() {
SERIAL_ECHOLN(current_command); SERIAL_ECHOLN(current_command);
#if ENABLED(M100_FREE_MEMORY_DUMPER) #if ENABLED(M100_FREE_MEMORY_DUMPER)
SERIAL_ECHOPAIR("slot:", queue.index_r); SERIAL_ECHOPAIR("slot:", queue.index_r);
M100_dump_routine(PSTR(" Command Queue:"), queue.command_buffer, queue.command_buffer + sizeof(queue.command_buffer)); M100_dump_routine(PSTR(" Command Queue:"), &queue.command_buffer[0][0], &queue.command_buffer[BUFSIZE - 1][MAX_CMD_SIZE - 1]);
#endif #endif
} }

Loading…
Cancel
Save