Delta programming - where we only upload what's changed

This commit is contained in:
Nav
2025-02-01 23:13:45 +00:00
parent 70ec49c7ac
commit d52c46ec2a
33 changed files with 918 additions and 289 deletions

View File

@@ -55,8 +55,8 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
debugSession.programmingSession.reset();
Logger::warning("Program memory updated");
targetControllerService.disableProgrammingMode();
Logger::warning("Program memory updated");
Logger::warning("Resetting target");
targetControllerService.resetTarget();

View File

@@ -54,8 +54,6 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
try {
targetControllerService.enableProgrammingMode();
Logger::warning("Erasing program memory, in preparation for programming");
// We don't erase a specific address range - we just erase the entire program memory.
targetControllerService.eraseMemory(
gdbTargetDescriptor.programAddressSpaceDescriptor,

View File

@@ -55,32 +55,33 @@ namespace DebugServer::Gdb::AvrGdb::CommandPackets
if (!debugSession.programmingSession.has_value()) {
debugSession.programmingSession = ProgrammingSession{this->startAddress, this->buffer};
debugSession.connection.writePacket(OkResponsePacket{});
return;
}
} else {
auto& programmingSession = debugSession.programmingSession.value();
const auto currentEndAddress = programmingSession.startAddress + programmingSession.buffer.size() - 1;
const auto expectedStartAddress = (currentEndAddress + 1);
auto& programmingSession = debugSession.programmingSession.value();
const auto currentEndAddress = programmingSession.startAddress + programmingSession.buffer.size() - 1;
const auto expectedStartAddress = (currentEndAddress + 1);
if (this->startAddress < expectedStartAddress) {
throw Exception{"Invalid start address from GDB - the buffer would overlap a previous buffer"};
}
if (this->startAddress > expectedStartAddress) {
// There is a gap in the buffer sent by GDB. Fill it with 0xFF
programmingSession.buffer.insert(
programmingSession.buffer.end(),
this->startAddress - expectedStartAddress,
0xFF
);
}
if (this->startAddress < expectedStartAddress) {
throw Exception{"Invalid start address from GDB - the buffer would overlap a previous buffer"};
}
if (this->startAddress > expectedStartAddress) {
// There is a gap in the buffer sent by GDB. Fill it with 0xFF
programmingSession.buffer.insert(
programmingSession.buffer.end(),
this->buffer.begin(),
this->buffer.end()
this->startAddress - expectedStartAddress,
0xFF
);
}
programmingSession.buffer.insert(
programmingSession.buffer.end(),
this->buffer.begin(),
this->buffer.end()
);
debugSession.connection.writePacket(OkResponsePacket{});
} catch (const Exception& exception) {

View File

@@ -80,8 +80,8 @@ namespace DebugServer::Gdb::RiscVGdb::CommandPackets
debugSession.programmingSession.reset();
Logger::warning("Program memory updated");
targetControllerService.disableProgrammingMode();
Logger::warning("Program memory updated");
Logger::warning("Resetting target");
targetControllerService.resetTarget();

View File

@@ -59,7 +59,7 @@ namespace DebugServer::Gdb::RiscVGdb::CommandPackets
throw Exception{"Memory segment (\"" + segmentDescriptor.name + "\") not writable in programming mode"};
}
Logger::warning("Erasing \"" + segmentDescriptor.name + "\" segment, in preparation for programming");
Logger::debug("Erase segment key: `" + segmentDescriptor.key + "`");
targetControllerService.enableProgrammingMode();

View File

@@ -55,32 +55,33 @@ namespace DebugServer::Gdb::RiscVGdb::CommandPackets
if (!debugSession.programmingSession.has_value()) {
debugSession.programmingSession = ProgrammingSession{this->startAddress, this->buffer};
debugSession.connection.writePacket(OkResponsePacket{});
return;
}
} else {
auto& programmingSession = debugSession.programmingSession.value();
const auto currentEndAddress = programmingSession.startAddress + programmingSession.buffer.size() - 1;
const auto expectedStartAddress = (currentEndAddress + 1);
auto& programmingSession = debugSession.programmingSession.value();
const auto currentEndAddress = programmingSession.startAddress + programmingSession.buffer.size() - 1;
const auto expectedStartAddress = (currentEndAddress + 1);
if (this->startAddress < expectedStartAddress) {
throw Exception{"Invalid start address from GDB - the buffer would overlap a previous buffer"};
}
if (this->startAddress > expectedStartAddress) {
// There is a gap in the buffer sent by GDB. Fill it with 0xFF
programmingSession.buffer.insert(
programmingSession.buffer.end(),
this->startAddress - expectedStartAddress,
0xFF
);
}
if (this->startAddress < expectedStartAddress) {
throw Exception{"Invalid start address from GDB - the buffer would overlap a previous buffer"};
}
if (this->startAddress > expectedStartAddress) {
// There is a gap in the buffer sent by GDB. Fill it with 0xFF
programmingSession.buffer.insert(
programmingSession.buffer.end(),
this->buffer.begin(),
this->buffer.end()
this->startAddress - expectedStartAddress,
0xFF
);
}
programmingSession.buffer.insert(
programmingSession.buffer.end(),
this->buffer.begin(),
this->buffer.end()
);
debugSession.connection.writePacket(OkResponsePacket{});
} catch (const Exception& exception) {