Skip to content

Commit

Permalink
BSDL ID : Support 'X' bit state.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdelnero committed Oct 28, 2024
1 parent 4047f33 commit 65544dc
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 15 deletions.
19 changes: 11 additions & 8 deletions jtag_boundary_scanner_gui/win32/JTAGBoundaryScanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ int update_jtag_ids_menu(HWND hWnd)
char entityname[DEFAULT_BUFLEN];
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
unsigned long chip_id;
unsigned long chip_id, chip_id_mask;

// BSDL Auto load : check which bsdl file match with the device
// And load it.
Expand Down Expand Up @@ -627,12 +627,13 @@ int update_jtag_ids_menu(HWND hWnd)

if ( !(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
chip_id = jtagcore_get_bsdl_id(jc, filename);
chip_id_mask = 0xFFFFFFFF;
chip_id = jtagcore_get_bsdl_id(jc, filename, &chip_id_mask);
if( chip_id )
{
for(dev_nb=0;dev_nb < number_of_devices;dev_nb++)
{
if( chip_id == jtagcore_get_dev_id(jc, dev_nb) )
if( ( chip_id & chip_id_mask ) == ( jtagcore_get_dev_id(jc, dev_nb) & chip_id_mask ) )
{
// The BSDL ID match with the device.
if(jtagcore_loadbsdlfile(jc, filename, dev_nb) == JTAG_CORE_NO_ERROR)
Expand Down Expand Up @@ -686,7 +687,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
char idstring[DEFAULT_BUFLEN*2];
char *tempstring2;
int ret,state, tmp_type;
unsigned long chip_id;
unsigned long chip_id, chip_id_mask;
static unsigned char togglebit=0;
HANDLE hDlgModeless;

Expand Down Expand Up @@ -808,10 +809,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

if ( !(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
chip_id = jtagcore_get_bsdl_id(jc, filename);
chip_id_mask = 0xFFFFFFFF;
chip_id = jtagcore_get_bsdl_id(jc, filename, &chip_id_mask);
if( chip_id )
{
if( chip_id == jtagcore_get_dev_id(jc, wmId - BASE_DEV_ID) )
if( (chip_id & chip_id_mask) == ( jtagcore_get_dev_id(jc, wmId - BASE_DEV_ID) & chip_id_mask ) )
{
// The BSDL ID match with the device.

Expand Down Expand Up @@ -843,9 +845,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
memset(filename, 0, sizeof(filename));
if (fileselector(hWnd, 0, 0, filename, "Read bsdl file", TEXT("BSDL File\0*.BS*;*.TXT\0\0"), TEXT("BS*")))
{
chip_id = jtagcore_get_bsdl_id(jc, filename);
chip_id_mask = 0xFFFFFFFF;
chip_id = jtagcore_get_bsdl_id(jc, filename, &chip_id_mask);

if (chip_id != jtagcore_get_dev_id(jc, wmId - BASE_DEV_ID))
if ( (chip_id & chip_id_mask ) != ( jtagcore_get_dev_id(jc, wmId - BASE_DEV_ID) & chip_id_mask ) )
{
sprintf(tempstring, "BSDL Chip ID doesn't match. Load it anyway ?\n\n");
strcat(tempstring, "BSDL ID : ");
Expand Down
21 changes: 19 additions & 2 deletions lib_jtag_core/src/bsdl_parser/bsdl_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,8 @@ jtag_bsdl * load_bsdlfile(jtag_core * jc,char *filename)
///////////////////////
// Extract the chip ID
bsdl->chip_id = 0x00000000;
bsdl->chip_id_mask = 0xFFFFFFFF;

chipid_str = get_attribut_txt(lines,"IDCODE_REGISTER", entityname);
if(chipid_str)
{
Expand All @@ -1348,10 +1350,25 @@ jtag_bsdl * load_bsdlfile(jtag_core * jc,char *filename)
i = 0;
while(chipid_str[i]!='"' && chipid_str[i]!=';' && chipid_str[i] && i < 32)
{
if(chipid_str[i] == '1')
switch( chipid_str[i] )
{
bsdl->chip_id |= 0x80000000 >> i;
case '0':
bsdl->chip_id &= ~(0x80000000 >> i);
break;

case '1':
bsdl->chip_id |= (0x80000000 >> i);
break;

case 'x':
case 'X':
bsdl->chip_id_mask &= ~(0x80000000 >> i);
break;

default:
break;
}

i++;
}
}
Expand Down
1 change: 1 addition & 0 deletions lib_jtag_core/src/bsdl_parser/bsdl_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef struct _jtag_chain
typedef struct _jtag_bsdl
{
unsigned long chip_id;
unsigned long chip_id_mask;

char src_filename[512];
char entity_name[512];
Expand Down
6 changes: 5 additions & 1 deletion lib_jtag_core/src/jtag_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ int jtagcore_loadbsdlfile(jtag_core * jc, char * path, int device)
return JTAG_CORE_BAD_PARAMETER;
}

unsigned long jtagcore_get_bsdl_id(jtag_core * jc, char * path)
unsigned long jtagcore_get_bsdl_id(jtag_core * jc, char * path, unsigned long * mask)
{
jtag_bsdl * bsdl_file;
unsigned long chip_id;
Expand All @@ -379,6 +379,10 @@ unsigned long jtagcore_get_bsdl_id(jtag_core * jc, char * path)
if (bsdl_file)
{
chip_id = bsdl_file->chip_id;
if( mask )
{
*mask = bsdl_file->chip_id_mask;
}
unload_bsdlfile(jc,bsdl_file);
return chip_id;
}
Expand Down
2 changes: 1 addition & 1 deletion lib_jtag_core/src/jtag_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int jtagcore_get_dev_name(jtag_core * jc, int device, char * devname, char * bsd

// jtagcore_get_bsdl_id : Return the chip id present into a bsdl file

unsigned long jtagcore_get_bsdl_id(jtag_core * jc, char * path);
unsigned long jtagcore_get_bsdl_id(jtag_core * jc, char * path, unsigned long * mask);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pins/IO access functions
Expand Down
7 changes: 4 additions & 3 deletions lib_jtag_core/src/script/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ static int cmd_autoinit( script_ctx * ctx, char * line)
filefoundinfo fileinfo;
void* h_file_find;

unsigned long chip_id;
unsigned long chip_id,chip_id_mask;

jc = (jtag_core *)ctx->app_ctx;
loaded_bsdl = 0;
Expand Down Expand Up @@ -1435,12 +1435,13 @@ static int cmd_autoinit( script_ctx * ctx, char * line)

if ( ! fileinfo.isdirectory )
{
chip_id = jtagcore_get_bsdl_id(jc, filename);
chip_id_mask = 0xFFFFFFFF;
chip_id = jtagcore_get_bsdl_id(jc, filename, &chip_id_mask);
if( chip_id )
{
for(dev_nb=0;dev_nb < number_of_devices;dev_nb++)
{
if( chip_id == (jtagcore_get_dev_id(jc, dev_nb) & (~0xF0000000)) )
if( ( chip_id & chip_id_mask ) == ( jtagcore_get_dev_id(jc, dev_nb) & chip_id_mask ) )
{
if(jtagcore_get_number_of_pins(jc, dev_nb) > 0)
{
Expand Down

0 comments on commit 65544dc

Please sign in to comment.