Forum Discussion
jtag interface from user aplication
Hi,
I'm trying to access the jtag port inside the fpga with the alt_jtag_atlantic block (also used in the jtag_uart for the niosII processor). I need access to the jtag port from a custom C/C++ program. I tried an approach like in this link : http://nioswiki.jot.com/wikihome/highspeedimagedownloaddemo but then in Visual studio (not g++). I have a problem about the "int jtagatlantic_get_error(const char * * other_info);" function from inside the jtag_atlantic dll. The error is an undefined reference :error LNK2019: unresolved external symbol "int __cdecl jtagatlantic_get_error(char const * *)" (?jtagatlantic_get_error@@YAHPAPBD@Z) referenced in function _main Does anyone has experience with this, or knows where I can find more information? Stefaan17 Replies
- Altera_Forum
Honored Contributor
I think, in Visual Studio you have write an import lib to interface jtag_atlantic_api.dll. That's nothing particular to Nios II or virtual JTAG, just a normal windows procedure. As the imported dll functions are known by name and type, this shouln't be a problem. If you experience any name-mangling problems, they could be imported by index rather than by name.
- Altera_Forum
Honored Contributor
Indeed, I created an import library, ... did all the dumpbin, lib ... stuff, and still for this one function the undefined reference is still there....
I can use the open, read, write, close functionality, so it's not an urgent problem. Anyway, get the correct error response can save some time. I wondered if somebody did this before... Stefaan - Altera_Forum
Honored Contributor
So, if you created an import library, you should be able to see from symbol files what's wrong. A link error is completely within your self-written code.
- Altera_Forum
Honored Contributor
I know it's completely on my side. The problem is I did'nt know exactly how to call the jtagatlantic_get_error function.
As in the example on the nioswiki, it returns an int. But here the visual studio compiler compains on (the exammple is made on gcc). With some tool called "PE explorer", I could find out that the function retuns an enum called JATL_ERROR. Defining the function like this, and the enum, everything works like expected. Stefaan - Altera_Forum
Honored Contributor
I rembered your post, when I stumbled upon the same enum issue with MSVC. I can supply now a small example application, including the MSVC import library and modified include file.
Best regards, Frank P.S.: As another comment, jtag_atlantic.dll is only seeing JTAG UART (NODE_ID 0x80) virtual JTAG functions. To interface any other virtual JTAG node type, you have to go through jtag_client.dll. According to the exported functions, sld_hapi.dll is providing an interface similar to virtual JTAG tcl commands provided by quartus_stp, as documented in TclScriptRefMnl.pdf. Unfortunately there's no interface documentation for both DLLs. Another option is using generic JTAG interfaces and implementing the virtual JTAG protocol, as discussed in other threads. - Altera_Forum
Honored Contributor
FvM,
I am curious as to the procedure that you used to create the jtag_atlantic.lib import library for use with MSVC environment. Can you tell me how you did it in detail? I would appreciate it. - Altera_Forum
Honored Contributor
The first step was to extract a *.def file from the dll, I used Borland IMPDEF for this action. I'm not sure if there's a similar MS tool.
As the second step, the *.def is compiled to *.lib by MS LIBIMPDEF jtag_atlantic.def jtag_atlantic.dll
Respectively, a Borland library can be generated by Borland LIB util. Regarding general Virtual JTAG operation, sld_hapi.dll seems to contain the complete functionality.LIB /DEF:jtag_atlantic.def /OUT:jtag_atlantic.lib - Altera_Forum
Honored Contributor
FvM,
Unfortunately, I am operating in the MSVC world. There is no such utility as IMPDEF.exe. However, using your method a did a bit of research and came up with a method to create the import library successfully. I tested it and it works correctly. I will attach my instructions to this post for others. Guten Tag und Danke, RNM - Altera_Forum
Honored Contributor
As you pointed out, DUMPBIN is the respective MSVC tool. I forgot about it, because I'm equipped with this software stuff very rarely.
The other point is the possible requirement of making some modifications to DLL imports to handle incompatibility issues between tool chains. - Altera_Forum
Honored Contributor
Hey guys, I was attempting to follow these instructions, and you will have to forgive me, as I am software guy...
So I downloaded the sample aplication, and planned to test it out by writing to my device through the uart jtag, and seeing it recieved using the NIOS IDE debugger. Unfortunately, I think you can only use 1 device at a time, so I have tried closing out the debugger after programming (to my fpga's ram) and I still could not recieve any text using the sample application. This lead me to believe that maybe my app wasn't running after I closed out the NIOS IDE, so I preprogrammed the ram with my flashed and redownloaded the image. This also did not work. Anyone have some tips on what I might be doing wrong? Thanks.