diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp index bcaac148..be987fde 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp @@ -75,8 +75,16 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets const auto& memoryDescriptor = memoryDescriptorsByType.at(this->memoryType); + /* + * In AVR targets, RAM is mapped to many registers and peripherals - we don't want to block GDB from + * accessing them. + */ + const auto memoryStartAddress = (this->memoryType == Targets::TargetMemoryType::RAM) + ? 0x00 + : memoryDescriptor.addressRange.startAddress; + if ( - this->startAddress < memoryDescriptor.addressRange.startAddress + this->startAddress < memoryStartAddress || (this->startAddress + (this->bytes - 1)) > memoryDescriptor.addressRange.endAddress ) { /* diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp index 9eedcf2e..c6449b82 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp @@ -91,8 +91,16 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets const auto& memoryDescriptor = memoryDescriptorsByType.at(this->memoryType); + /* + * In AVR targets, RAM is mapped to many registers and peripherals - we don't want to block GDB from + * accessing them. + */ + const auto memoryStartAddress = (this->memoryType == Targets::TargetMemoryType::RAM) + ? 0x00 + : memoryDescriptor.addressRange.startAddress; + if ( - this->startAddress < memoryDescriptor.addressRange.startAddress + this->startAddress < memoryStartAddress || (this->startAddress + (this->buffer.size() - 1)) > memoryDescriptor.addressRange.endAddress ) { throw Exception(