Grouped the buffers from GDB's flash write packets so that we only flush once we have the full buffer.

This fixes an issue with GDB programming, where it was sending misaligned buffers and program memory
wasn't being properly updated.
This commit is contained in:
Nav
2022-09-17 20:12:26 +01:00
parent 65bdcd62d3
commit 18fb3b56ce
5 changed files with 130 additions and 8 deletions

View File

@@ -23,12 +23,35 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
Logger::debug("Handling FlashDone packet");
try {
if (debugSession.programmingSession.has_value()) {
const auto& programmingSession = debugSession.programmingSession.value();
targetControllerConsole.enableProgrammingMode();
targetControllerConsole.writeMemory(
Targets::TargetMemoryType::FLASH,
programmingSession.startAddress,
std::move(programmingSession.buffer)
);
debugSession.programmingSession.reset();
}
targetControllerConsole.disableProgrammingMode();
debugSession.connection.writePacket(OkResponsePacket());
} catch (const Exception& exception) {
Logger::error("Failed to disabling programming mode - " + exception.getMessage());
Logger::error("Failed to handle FlashDone packet - " + exception.getMessage());
debugSession.programmingSession.reset();
try {
targetControllerConsole.disableProgrammingMode();
} catch (const Exception& exception) {
Logger::error("Failed to disable programming mode - " + exception.getMessage());
}
debugSession.connection.writePacket(ErrorResponsePacket());
}
}