Delta programming - where we only upload what's changed
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user