Fix and add STM32 SDIO DMA (#21476)
This commit is contained in:
@ -29,6 +29,7 @@
|
||||
#include "../libs/hex_print.h"
|
||||
#include "../HAL/shared/eeprom_if.h"
|
||||
#include "../HAL/shared/Delay.h"
|
||||
#include "../sd/cardreader.h"
|
||||
|
||||
extern void dump_delay_accuracy_check();
|
||||
|
||||
@ -126,19 +127,19 @@
|
||||
#endif
|
||||
|
||||
case 4: { // D4 Read / Write PIN
|
||||
// const uint8_t pin = parser.byteval('P');
|
||||
// const bool is_out = parser.boolval('F'),
|
||||
// val = parser.byteval('V', LOW);
|
||||
//const bool is_out = parser.boolval('F');
|
||||
//const uint8_t pin = parser.byteval('P'),
|
||||
// val = parser.byteval('V', LOW);
|
||||
if (parser.seenval('X')) {
|
||||
// TODO: Write the hex bytes after the X
|
||||
//while (len--) {
|
||||
//}
|
||||
}
|
||||
else {
|
||||
// while (len--) {
|
||||
// TODO: Read bytes from EEPROM
|
||||
// print_hex_byte(eeprom_read_byte(*(adr++));
|
||||
// }
|
||||
//while (len--) {
|
||||
//// TODO: Read bytes from EEPROM
|
||||
// print_hex_byte(eeprom_read_byte(adr++));
|
||||
//}
|
||||
SERIAL_EOL();
|
||||
}
|
||||
} break;
|
||||
@ -155,10 +156,10 @@
|
||||
//while (len--) {}
|
||||
}
|
||||
else {
|
||||
// while (len--) {
|
||||
// TODO: Read bytes from EEPROM
|
||||
// print_hex_byte(eeprom_read_byte(adr++));
|
||||
// }
|
||||
//while (len--) {
|
||||
//// TODO: Read bytes from EEPROM
|
||||
// print_hex_byte(eeprom_read_byte(adr++));
|
||||
//}
|
||||
SERIAL_EOL();
|
||||
}
|
||||
} break;
|
||||
@ -186,22 +187,76 @@
|
||||
SERIAL_ECHOLNPGM("FAILURE: Watchdog did not trigger board reset.");
|
||||
} break;
|
||||
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
case 451: { // Trigger all kind of faults to test exception catcher
|
||||
SERIAL_ECHOLNPGM("Disabling heaters");
|
||||
thermalManager.disable_all_heaters();
|
||||
delay(1000); // Allow time to print
|
||||
volatile uint8_t type[5] = { parser.byteval('T', 1) };
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
||||
// The code below is obviously wrong and it's full of quirks to fool the compiler from optimizing away the code
|
||||
switch (type[0]) {
|
||||
case 1: default: *(int*)0 = 451; break; // Write at bad address
|
||||
case 2: { volatile int a = 0; volatile int b = 452 / a; *(int*)&a = b; } break; // Divide by zero (some CPUs accept this, like ARM)
|
||||
case 3: { *(uint32_t*)&type[1] = 453; volatile int a = *(int*)&type[1]; type[0] = a / 255; } break; // Unaligned access (some CPUs accept this)
|
||||
case 4: { volatile void (*func)() = (volatile void (*)()) 0xE0000000; func(); } break; // Invalid instruction
|
||||
case 101: { // D101 Test SD Write
|
||||
card.openFileWrite("test.gco");
|
||||
if (!card.isFileOpen()) {
|
||||
SERIAL_ECHOLNPAIR("Failed to open test.gco to write.");
|
||||
return;
|
||||
}
|
||||
__attribute__((aligned(sizeof(size_t)))) uint8_t buf[512];
|
||||
|
||||
uint16_t c;
|
||||
for (c = 0; c < COUNT(buf); c++)
|
||||
buf[c] = 'A' + (c % ('Z' - 'A'));
|
||||
|
||||
c = 1024 * 4;
|
||||
while (c--) {
|
||||
TERN_(USE_WATCHDOG, watchdog_refresh());
|
||||
card.write(buf, COUNT(buf));
|
||||
}
|
||||
SERIAL_ECHOLNPGM(" done");
|
||||
card.closefile();
|
||||
} break;
|
||||
|
||||
case 102: { // D102 Test SD Read
|
||||
card.openFileRead("test.gco");
|
||||
if (!card.isFileOpen()) {
|
||||
SERIAL_ECHOLNPAIR("Failed to open test.gco to read.");
|
||||
return;
|
||||
}
|
||||
__attribute__((aligned(sizeof(size_t)))) uint8_t buf[512];
|
||||
uint16_t c = 1024 * 4;
|
||||
while (c--) {
|
||||
TERN_(USE_WATCHDOG, watchdog_refresh());
|
||||
card.read(buf, COUNT(buf));
|
||||
bool error = false;
|
||||
for (uint16_t i = 0; i < COUNT(buf); i++) {
|
||||
if (buf[i] != ('A' + (i % ('Z' - 'A')))) {
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
SERIAL_ECHOLNPGM(" Read error!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
SERIAL_ECHOLNPGM(" done");
|
||||
card.closefile();
|
||||
} break;
|
||||
|
||||
#endif // SDSUPPORT
|
||||
|
||||
#if ENABLED(POSTMORTEM_DEBUGGING)
|
||||
|
||||
case 451: { // Trigger all kind of faults to test exception catcher
|
||||
SERIAL_ECHOLNPGM("Disabling heaters");
|
||||
thermalManager.disable_all_heaters();
|
||||
delay(1000); // Allow time to print
|
||||
volatile uint8_t type[5] = { parser.byteval('T', 1) };
|
||||
|
||||
// The code below is obviously wrong and it's full of quirks to fool the compiler from optimizing away the code
|
||||
switch (type[0]) {
|
||||
case 1: default: *(int*)0 = 451; break; // Write at bad address
|
||||
case 2: { volatile int a = 0; volatile int b = 452 / a; *(int*)&a = b; } break; // Divide by zero (some CPUs accept this, like ARM)
|
||||
case 3: { *(uint32_t*)&type[1] = 453; volatile int a = *(int*)&type[1]; type[0] = a / 255; } break; // Unaligned access (some CPUs accept this)
|
||||
case 4: { volatile void (*func)() = (volatile void (*)()) 0xE0000000; func(); } break; // Invalid instruction
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user