diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp index 02c9b213..56d26160 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp @@ -31,6 +31,35 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame */ return TargetSignature(payloadData[3], payloadData[2], payloadData[1]); } + case Avr8PhysicalInterface::JTAG: { + /* + * When using the JTAG interface, the get device ID command returns a 32 bit JTAG ID. This takes + * the following form: + * + * VVVV PPPPPPPPPPPPPPPP MMMMMMMMMMM L + * + * - (V) - Version nibble (4 bits) + * - (P) - Part number (this is typically the AVR signature excluding the manufacture + * byte (0x1E)) (16 bits) + * - (M) - Manufacture identity (11 bits) + * - (L) - LSB indicator (1 bit) + * + * We convert this into a Avr::TargetSignature by extracting the relevant part number and assuming + * a manufacture byte of 0x1E. + * + * TODO: We're not considering the value of the LSB indicator bit. We're just assuming it will + * always be MSB. Is this assumption correct? + */ + auto jtagId = static_cast( + (payloadData[0] << 24) | (payloadData[1] << 16) | (payloadData[2] << 8) | (payloadData[3]) + ); + + return TargetSignature( + 0x1E, + static_cast((jtagId << 4) >> 24), + static_cast((jtagId << 12) >> 24) + ); + } default: { return TargetSignature(payloadData[0], payloadData[1], payloadData[2]); }