This commit is contained in:
Nav
2025-01-28 00:21:26 +00:00
parent 91db0eb6e8
commit ad542ab77e
9 changed files with 17 additions and 45 deletions

View File

@@ -12,10 +12,5 @@ namespace DebugToolDrivers::Wch
public:
WchFirmwareVersion firmwareVersion;
std::optional<WchLinkVariant> variant;
explicit DeviceInfo(WchFirmwareVersion firmwareVersion, std::optional<WchLinkVariant> variant)
: firmwareVersion(firmwareVersion)
, variant(variant)
{}
};
}

View File

@@ -58,7 +58,7 @@ namespace DebugToolDrivers::Wch::Protocols::WchLink
}
void WchLinkInterface::setClockSpeed(WchLinkTargetClockSpeed speed, WchTargetId targetId) {
const auto speedIdsBySpeed = BiMap<WchLinkTargetClockSpeed, std::uint8_t>{
static const auto speedIdsBySpeed = BiMap<WchLinkTargetClockSpeed, std::uint8_t>{
{WchLinkTargetClockSpeed::CLK_6000_KHZ, 0x01},
{WchLinkTargetClockSpeed::CLK_4000_KHZ, 0x02},
{WchLinkTargetClockSpeed::CLK_400_KHZ, 0x03},
@@ -155,7 +155,7 @@ namespace DebugToolDrivers::Wch::Protocols::WchLink
const auto response = this->sendCommandAndWaitForResponse(
Commands::PreparePartialFlashBlockWrite{
static_cast<Targets::TargetMemorySize>(startAddress + (packetSize * i)),
static_cast<Targets::TargetMemoryAddress>(startAddress + (packetSize * i)),
static_cast<std::uint8_t>(segmentSize)
}
);

View File

@@ -30,7 +30,7 @@ namespace DebugToolDrivers::Wch::Protocols::WchLink
: public ::DebugToolDrivers::Protocols::RiscVDebugSpec::DebugTransportModuleInterface
{
public:
static constexpr Targets::TargetMemorySize MAX_PARTIAL_BLOCK_WRITE_SIZE = 64;
static constexpr auto MAX_PARTIAL_BLOCK_WRITE_SIZE = Targets::TargetMemorySize{64};
WchLinkInterface(Usb::UsbInterface& usbInterface, Usb::UsbDevice& usbDevice);

View File

@@ -273,7 +273,7 @@ namespace DebugToolDrivers::Wch
return this->wchLinkInterface.eraseProgramMemory();
}
// Ignore other (non-program memory) erase requests, for now.
Logger::debug("Ignoring erase operation on `" + memorySegmentDescriptor.key + "` segment - not supported");
}
void WchLinkDebugInterface::enableProgrammingMode() {
@@ -282,7 +282,7 @@ namespace DebugToolDrivers::Wch
*
* 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().
* we'll be utilising at this point.
*/
}
@@ -326,14 +326,14 @@ namespace DebugToolDrivers::Wch
)
};
static constexpr auto ebreakBytes = std::to_array<unsigned char>({
static constexpr auto EBREAK_OPCODE = std::to_array<unsigned char>({
static_cast<unsigned char>(::Targets::RiscV::Opcodes::Ebreak),
static_cast<unsigned char>(::Targets::RiscV::Opcodes::Ebreak >> 8),
static_cast<unsigned char>(::Targets::RiscV::Opcodes::Ebreak >> 16),
static_cast<unsigned char>(::Targets::RiscV::Opcodes::Ebreak >> 24)
});
static constexpr auto compressedEbreakBytes = std::to_array<unsigned char>({
static constexpr auto COMPRESSED_EBREAK_OPCODE = std::to_array<unsigned char>({
static_cast<unsigned char>(::Targets::RiscV::Opcodes::EbreakCompressed),
static_cast<unsigned char>(::Targets::RiscV::Opcodes::EbreakCompressed >> 8)
});
@@ -343,8 +343,8 @@ namespace DebugToolDrivers::Wch
softwareBreakpoint.memorySegmentDescriptor,
softwareBreakpoint.address,
softwareBreakpoint.size == 2
? TargetMemoryBufferSpan{compressedEbreakBytes}
: TargetMemoryBufferSpan{ebreakBytes}
? TargetMemoryBufferSpan{COMPRESSED_EBREAK_OPCODE}
: TargetMemoryBufferSpan{EBREAK_OPCODE}
);
this->softwareBreakpointRegistry.insert(softwareBreakpoint);