Tidying
This commit is contained in:
@@ -56,6 +56,7 @@ namespace DebugToolDrivers::Wch::Protocols::WchLink
|
|||||||
|
|
||||||
template <class CommandType>
|
template <class CommandType>
|
||||||
auto sendCommandAndWaitForResponse(const CommandType& command) {
|
auto sendCommandAndWaitForResponse(const CommandType& command) {
|
||||||
|
using Services::StringService;
|
||||||
const auto rawCommand = command.getRawCommand();
|
const auto rawCommand = command.getRawCommand();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -86,14 +87,15 @@ namespace DebugToolDrivers::Wch::Protocols::WchLink
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rawResponse[0] == 0x81) {
|
if (rawResponse[0] == 0x81) {
|
||||||
throw Exceptions::DeviceCommunicationFailure{"Error response"};
|
throw Exceptions::DeviceCommunicationFailure{
|
||||||
|
"Error response to command 0x" + StringService::toHex(command.commandId)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rawResponse[1] != command.commandId) {
|
if (rawResponse[1] != command.commandId) {
|
||||||
throw Exceptions::DeviceCommunicationFailure{
|
throw Exceptions::DeviceCommunicationFailure{
|
||||||
"Missing/invalid command ID in response from device 0x"
|
"Missing/invalid command ID in response from device 0x" + StringService::toHex(rawResponse[1])
|
||||||
+ Services::StringService::toHex(rawResponse[1]) + " - expected: 0x"
|
+ " - expected: 0x" + StringService::toHex(command.commandId)
|
||||||
+ Services::StringService::toHex(command.commandId)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -239,8 +239,8 @@ namespace DebugToolDrivers::Wch
|
|||||||
* command.
|
* command.
|
||||||
*
|
*
|
||||||
* This sometimes leads to exceptions occurring on the target, when the program buffer contains certain
|
* This sometimes leads to exceptions occurring on the target, when the program buffer contains certain
|
||||||
* instructions before the partial block write command is serviced. This is why we clear the program
|
* instructions before the partial block write command is invoked. This is why we clear the program
|
||||||
* buffer before invoking the partial block write command.
|
* buffer beforehand.
|
||||||
*/
|
*/
|
||||||
this->riscVTranslator.clearProgramBuffer();
|
this->riscVTranslator.clearProgramBuffer();
|
||||||
this->wchLinkInterface.writeFlashPartialBlock(startAddress, buffer);
|
this->wchLinkInterface.writeFlashPartialBlock(startAddress, buffer);
|
||||||
@@ -324,6 +324,16 @@ namespace DebugToolDrivers::Wch
|
|||||||
this->flashProgramOpcodes
|
this->flashProgramOpcodes
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Would this not be better placed in endProgrammingSession()? We could persist the command type we invoked
|
||||||
|
* to perform the write, and if required, reattach at the end of the programming session.
|
||||||
|
*
|
||||||
|
* I don't think that would work, because the target needs to be accessible for other operations whilst in
|
||||||
|
* programming mode. We may perform other operations in between program memory writes, but that wouldn't
|
||||||
|
* work if we left the target in an inaccessible state between writes. So I think we have to reattach here.
|
||||||
|
*
|
||||||
|
* TODO: Review after v2.0.0.
|
||||||
|
*/
|
||||||
this->deactivate();
|
this->deactivate();
|
||||||
this->wchLinkInterface.sendCommandAndWaitForResponse(Commands::Control::GetDeviceInfo{});
|
this->wchLinkInterface.sendCommandAndWaitForResponse(Commands::Control::GetDeviceInfo{});
|
||||||
this->activate();
|
this->activate();
|
||||||
@@ -350,7 +360,13 @@ namespace DebugToolDrivers::Wch
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WchLinkDebugInterface::enableProgrammingMode() {
|
void WchLinkDebugInterface::enableProgrammingMode() {
|
||||||
// Nothing to do here
|
/*
|
||||||
|
* Nothing to do here
|
||||||
|
*
|
||||||
|
* We cannot prepare the WCH-Link tool for a programming session here, as the preparation process differs
|
||||||
|
* across the two types of flash write commands (full and partial block write). We don't know which command
|
||||||
|
* we'll be utilising at this point, so we perform the preparation in writeMemory().
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void WchLinkDebugInterface::disableProgrammingMode() {
|
void WchLinkDebugInterface::disableProgrammingMode() {
|
||||||
@@ -360,7 +376,7 @@ namespace DebugToolDrivers::Wch
|
|||||||
void WchLinkDebugInterface::applyAccessRestrictions(TargetMemorySegmentDescriptor& memorySegmentDescriptor) {
|
void WchLinkDebugInterface::applyAccessRestrictions(TargetMemorySegmentDescriptor& memorySegmentDescriptor) {
|
||||||
if (memorySegmentDescriptor.type == TargetMemorySegmentType::FLASH) {
|
if (memorySegmentDescriptor.type == TargetMemorySegmentType::FLASH) {
|
||||||
/*
|
/*
|
||||||
* Actually, we *can* write to flash memory whilst in debug mode (via a partial page write), but we don't
|
* Actually, we *can* write to flash memory whilst in debug mode (via a partial block write), but we don't
|
||||||
* need to, so I'm just going to block it, for now.
|
* need to, so I'm just going to block it, for now.
|
||||||
*/
|
*/
|
||||||
memorySegmentDescriptor.debugModeAccess.writeable = false;
|
memorySegmentDescriptor.debugModeAccess.writeable = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user