diff --git a/jtag_boundary_scanner_gui/win32/JTAGBoundaryScanner.c b/jtag_boundary_scanner_gui/win32/JTAGBoundaryScanner.c index 6ec07ed..477683b 100644 --- a/jtag_boundary_scanner_gui/win32/JTAGBoundaryScanner.c +++ b/jtag_boundary_scanner_gui/win32/JTAGBoundaryScanner.c @@ -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. @@ -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) @@ -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; @@ -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. @@ -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 : "); diff --git a/lib_jtag_core/src/bsdl_parser/bsdl_loader.c b/lib_jtag_core/src/bsdl_parser/bsdl_loader.c index f500968..4f32909 100644 --- a/lib_jtag_core/src/bsdl_parser/bsdl_loader.c +++ b/lib_jtag_core/src/bsdl_parser/bsdl_loader.c @@ -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) { @@ -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++; } } diff --git a/lib_jtag_core/src/bsdl_parser/bsdl_loader.h b/lib_jtag_core/src/bsdl_parser/bsdl_loader.h index 5e542a9..dd3f885 100644 --- a/lib_jtag_core/src/bsdl_parser/bsdl_loader.h +++ b/lib_jtag_core/src/bsdl_parser/bsdl_loader.h @@ -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]; diff --git a/lib_jtag_core/src/jtag_core.c b/lib_jtag_core/src/jtag_core.c index e590b97..82bdab4 100644 --- a/lib_jtag_core/src/jtag_core.c +++ b/lib_jtag_core/src/jtag_core.c @@ -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; @@ -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; } diff --git a/lib_jtag_core/src/jtag_core.h b/lib_jtag_core/src/jtag_core.h index b8bdf68..a61bd69 100644 --- a/lib_jtag_core/src/jtag_core.h +++ b/lib_jtag_core/src/jtag_core.h @@ -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 diff --git a/lib_jtag_core/src/script/script.c b/lib_jtag_core/src/script/script.c index 9f3e32f..0c14188 100644 --- a/lib_jtag_core/src/script/script.c +++ b/lib_jtag_core/src/script/script.c @@ -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; @@ -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) {