From 9c891f0cbb357e93a4bc5ca7cdfe06fa960a123d Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 9 Mar 2022 22:01:08 +0000 Subject: [PATCH] Improved handling of GDB flash memory write attempt --- src/DebugServers/GdbRsp/GdbRspDebugServer.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp b/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp index 81e2f2bd..0ffb78f8 100644 --- a/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp +++ b/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp @@ -219,8 +219,17 @@ namespace Bloom::DebugServers::Gdb Logger::debug("Handling WriteMemory packet"); try { - auto memoryType = this->getMemoryTypeFromGdbAddress(packet.startAddress); - auto startAddress = this->removeMemoryTypeIndicatorFromGdbAddress(packet.startAddress); + const auto memoryType = this->getMemoryTypeFromGdbAddress(packet.startAddress); + + if (memoryType == Targets::TargetMemoryType::FLASH) { + Logger::error( + "GDB client requested a flash memory write - This is not currently supported by Bloom." + ); + this->clientConnection->writePacket(ResponsePacket({'E', '0', '1'})); + return; + } + + const auto startAddress = this->removeMemoryTypeIndicatorFromGdbAddress(packet.startAddress); this->targetControllerConsole.writeMemory(memoryType, startAddress, packet.buffer); this->clientConnection->writePacket(ResponsePacket({'O', 'K'}));