From e4ffe18af0b6c6ba1647a58a1c694607b1af4955 Mon Sep 17 00:00:00 2001 From: Uwe Bonnes Date: Tue, 27 Jun 2023 18:47:52 +0200 Subject: [PATCH] Relax ID matching for the misc_dev Detect STM32 --- src/jtag.cpp | 4 ++-- src/main.cpp | 6 +++--- src/part.hpp | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/jtag.cpp b/src/jtag.cpp index 7847def882..5002a93517 100644 --- a/src/jtag.cpp +++ b/src/jtag.cpp @@ -200,7 +200,7 @@ int Jtag::detectChain(int max_dev) * GateMate and Efinix Trion T4/T8 devices */ if (tmp != 0x20000001) - found = search_and_insert_device_with_idcode(tmp & 0x0fffffff); + found = search_and_insert_device_with_idcode(tmp); if (!found) /* if masked not found -> search for full */ found = search_and_insert_device_with_idcode(tmp); @@ -231,7 +231,7 @@ bool Jtag::search_and_insert_device_with_idcode(uint32_t idcode) if (dev != fpga_list.end()) irlength = dev->second.irlength; if (irlength == -1) { - auto misc = misc_dev_list.find(idcode); + auto misc = misc_dev_list.find(idcode & MISC_DEV_MASK); if (misc != misc_dev_list.end()) irlength = misc->second.irlength; } diff --git a/src/main.cpp b/src/main.cpp index 91c4e4ab28..3d18e6ac1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -470,11 +470,11 @@ int main(int argc, char **argv) fpga_list[t].family.c_str(), fpga_list[t].model.c_str()); printf("\tirlength %d\n", fpga_list[t].irlength); - } else if (misc_dev_list.find(t) != misc_dev_list.end()) { + } else if (misc_dev_list.find(t & MISC_DEV_MASK) != misc_dev_list.end()) { printf("\tidcode 0x%x\n\ttype %s\n\tirlength %d\n", t, - misc_dev_list[t].name.c_str(), - misc_dev_list[t].irlength); + misc_dev_list[t & MISC_DEV_MASK].name.c_str(), + misc_dev_list[t & MISC_DEV_MASK].irlength); } } if (args.detect == true) { diff --git a/src/part.hpp b/src/part.hpp index 548e1766df..817d249a20 100644 --- a/src/part.hpp +++ b/src/part.hpp @@ -177,10 +177,11 @@ typedef struct { int irlength; } misc_device; +#define MISC_DEV_MASK 0x0ff00fffU static std::map misc_dev_list = { - {0x4ba00477, {"ARM cortex A9", 4}}, - {0x5ba00477, {"ARM cortex A53", 4}}, - {0xfffffffe, {"ZynqMP dummy device", 12}}, + {0x0ba00477, {"ADIv5 JTAG-DP port", 4}}, + {0x06400041, {"STM32 Device", 4}}, + {0x0ff00ffe, {"ZynqMP dummy device", 12}}, }; /* list of JTAG manufacturer ID */