Skip to content

Commit

Permalink
Relax ID matching for the misc_dev
Browse files Browse the repository at this point in the history
Detect STM32 and AVR8
  • Loading branch information
UweBonnes committed Jun 27, 2023
1 parent 1f5d6cb commit a5f49fa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/jtag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 8 additions & 3 deletions src/part.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,15 @@ typedef struct {
int irlength;
} misc_device;

/* Maybe a manual list with per device mask is more adequate
*
* E.g Atmel AVR devices would need a mask 0x0f0003ffU
*/
#define MISC_DEV_MASK 0x0ff003ffU
static std::map <uint32_t, misc_device> misc_dev_list = {
{0x4ba00477, {"ARM cortex A9", 4}},
{0x5ba00477, {"ARM cortex A53", 4}},
{0xfffffffe, {"ZynqMP dummy device", 12}},
{0x0ba00077, {"ADIv5 JTAG-DP port", 4}},
{0x06400041, {"STM32 Device", 5}},
{0x0ff00ffe, {"ZynqMP dummy device", 12}},
};

/* list of JTAG manufacturer ID */
Expand Down
3 changes: 2 additions & 1 deletion src/xilinx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ bool Xilinx::flow_program(JedParser *jed)
*/
size_t nb_section = jed->nb_section() / (15);

ProgressBar progress("Write Flash", nb_section, 50, _quiet);
ProgressBar progress("Write XC95 Flash", nb_section, 50, _quiet);

for (size_t i = 0; i < nb_section; i++) {
uint16_t addr2 = i * 32;
Expand Down Expand Up @@ -918,6 +918,7 @@ bool Xilinx::flow_program(JedParser *jed)
_jtag->shiftDR(wr_buf, NULL, 8 * (_xc95_line_len + 2));
_jtag->toggleClk((_jtag->getClkFreq() * 50) / 1000);
_jtag->shiftDR(NULL, rd_buf, 8 * (_xc95_line_len + 2) + 2);
fprintf(stderr, "xc95 prog: i %ld ii% d loop %d\n", i, ii, loop_try);
if ((rd_buf[0] & 0x03) == 0x01)
break;
}
Expand Down

0 comments on commit a5f49fa

Please sign in to comment.