Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax ID matching for the misc_dev #351

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

Comment on lines +203 to 206
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really happy by the original code because some devices (lattice) with high nibble equal to 0 matches wrong version.
I think both mask & unmask search must be switched, but I have to check to be sure to not introduces a regression.
But If you remove mask most of the devices will never been found because in the idcode list most of devices have highest nibble masked to match all revisions, only a few number of them have full idcode.

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}},
Comment on lines +186 to +188
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is to provides the full idcode to display exact device (ARM cortex A9 and A53 differs only by upper nibble).
With this modification openFPGALoader will no more able to deal with zynq7000 & zynqMP

};

/* 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