Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20688 Discussions

hostpc like send data to nios II via jtag (nios2-terminal.exe, jtag_atlantis.dll)

Altera_Forum
Honored Contributor II
4,038 Views

hi! 

my system: 

cyclone 3 starter kit 

quartus 2 - 9.1 ( licence + nios licence) 

nios 2 system working 

 

goal: 

i want to setup a matlab gui to switch some pio outputs of the nios. with it i want set the options of a dsp-builder-block. i also want to check some pio-inputs in my matlab gui and do something if bit 0 switches from 1 to 0 or something like that. 

i think i can do this by sending chars by alt_getchar() (small c lib) with the nios2-terminal.  

the problem is that when i start a *.m file and the nios2-terminal is waiting of my input, i have no ability to put in the char automatically via a programmed *.m file. 

 

i am also open for other hardware suggestions. 

Problem: 

only a usb-blaster-connection to the board - want no other connection. 

 

i am connected via the integrated usb blaster to the starter board.  

i need a possibility to send just a few bit to the nios via the usb (jtag uart). 

in my opinion - the nios 2 ide is also transfering data to the sopc -system by using nios2-terminal.exe. 

i read the example" high speed image download demo " but could not understand how its done. i am just a beginner with nios and also not so well in programming/compiling to understand how to use the cygwin - environment. - ok i looked in the inet - is a linuxlike environment for windows.  

i also thought about using the fdti-usb driver (set up a virtual serial connection - vcp or d2xx).  

i have no idea if it is possible so easy (without programming a new driver or something like this) 

 

what exactly can i do with nios2-terminal and how? 

(the ' --help' makes no reason for me) 

 

does anyone of you understand what i am talking about? 

need real help!!! 

 

 

greets
0 Kudos
26 Replies
Altera_Forum
Honored Contributor II
1,369 Views

Have you considered using SystemConsole to communicate with the board? 

 

You can put a JTAG to Avalon Master Bridge in the hardware and then use that to read and write registers as you desire. 

 

SystemConsole is launched from the Tools menu in SOPC builder. 

 

Once you have it working from SystemConsole there are ways to integrate that with Matlab (these will be easier in 11.0 if you can wait a month)
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

thank you for this information!  

i also thought about using systemconsole. i also looked into the manual (Chapter 12: Analyzing and Debugging Designs with the System Console). But i didn´t find anything about reading and writing registers, and how to start the systemconsole just from an external program like the cmd from windows or from matlab. i also thought that the systemconsole is used do put addional digital system blocks in the fpga means reconfig the hardware or change the hardwareconfiguration.  

 

so at the moment it is "a little bit" working. 

i got it to run by using the matlab command 

system('c:/folders/nios2-terminal.exe --quit-after=SEC < textfile1.txt'); 

but thats not a very good way, due to "--quit-after=SEC".  

its not very nice the of altera that there are so less examples and informations about nios2-termial.exe. 

 

perhaps anyone can tell me how to set and reset registers via systemconsole. i just wanna try a better way to read and write registers also without using nios2. 

i was just reading over 2 in this forum and the documentation of altera. 

i think that altera does not want me to use the programming jtag-uart connection for talking with my cyclone 3. others had the same problem. 

 

so i need help with the systemconsle to read an write registers. (also links to documentation or tutorials) cannot set it up or start it from windows command.  

 

perhaps there i also an other way to talk with my cyclone3 ? 

 

thanks you !
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

To use SystemConsole you need to first put the appropriate hardware into your design. There is a QSYS/SOPC builder component called JTAG to Avalon Master Bridge which you need to connect (in QSYS or SOPCB) to the slave which contains your registers. 

 

Then program your board, start SystemConsole and type:get_service_paths master 

The systemconsole path to all the masters on your board should be displayed. At this point I normally do this:set m [lindex [get_service_paths master] n

Which sets the variable m to the name of the master you want to work with (if you have one master then n=0, otherwise use n to choose the appropriate master). Open that master with this command:set m1 [claim_service master $m myname ""] 

Then you can read and write to the master using the master_read_xx and master_write_xx commands against $m1. 

 

This is the systemconsole user guide (http://www.altera.com/literature/hb/qts/qts_qii53028.pdf) for 10.1. 

 

Once you have your slaves working standalone then you need to connect them to Matlab. In 11.0 there are a set of Java objects which are specially designed for this, I'm not sure if it is being properly documented. 

 

Since you're on 10.1 you'll need to unzip the attached file into your sopc_builder/model/lib directory. You can then use the Matlab Java access to create an com.altera.systemconsole.matlabapi.SystemConsoleLink object. 

 

This object can open masters using the masterOpen method, the master objects it returns have a masterRead32, masterWrite32 and close methods whose functionality should be obvious. 

 

The SystemConsoleLink in 11.0 will be able to execute TCL in the SystemConsole interpreter too, but dropping the 11.0 jar into 10.1 breaks that so please don't try it. 

 

Good Luck.
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

Hi, 

 

Your SOPCB system looks right, I might connect the JTAG master to the RAM as well (it would be useful for testing). SOPCB will tell you what can be connected to what - if there is no hollow dot then you can't connect it. 

 

The JTAG to Avalon Master Bridge contains all the pieces you need - all the components you mention are inside it. 

 

You can set the registers from Nios or from SystemConsole - with the PIO component whatever wrote last will win. 

 

You don't need to connect the JTAG master to the JTAG UART (in fact you should not as the JTAG UART slave will be confused if accessed by two masters). 

 

Regards
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

Hi Wombat, 

 

I have a doubt. Does the board need to have a JTAG connector for using the system console in the way you specified?. Will the USB blaster be enough to have this functionality. I have a Terasic DE4 board with me which does not have a JTAG connector, but the USB blaster can be used in JTAG mode. 

I wanted to write some register through system console. So can i use the JTAG to Avalon Master Bridge as master to write to these register locations using master_write_32 command?. I am not using Nios II processor. 

 

Thanks in advance
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

Yes you can use the JTAG bridge and the system console tools with your board and its embedded blaster, it's just like having a real USB blaster connected to the FPGA's JTAG pins.

0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

hi wombat! 

me again.  

can you please repost the com.altera.systemconsole.matlabapi.zip? actually i am not able to download it. 

 

i´m also thinking about to talk to nios via a c programm. so i can use a mex-file in my matlab programm? do you have experience in this way or give me a hint?  

 

working 

actually i can read the memory - but only when i am direktly using the systemconsole. i´m not able to read it from matlab because there is no output from the system-console.exe given back to matlab. 

i wanna try it by using your posted matlabapi. 

so i hope you can repost it. 

 

greets
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

That's odd, I can't download it either. I have deleted the attachment to prevent others wasting their time on this. I'm afraid I don't have access to the file right now so I can't re-zip it and re-upload. 

 

Quartus II 11.0 contains the real matlabapi, this willl be released on the 6th May so if you can wait two days more then you can try the real one. 

 

Using the real matlabAPI has the advantage that the SystemConsoleLink java object will support the executeTcl method - this lets you pass TCL to the SystemConsole interpreter and get the results. That doesn't work with the 10.1 matlabapi prototype. 

 

Sorry I can't help more, but I won't have access to the matlabapi file until next week, so you'll get there faster if you can wait two more days for the 11.0 release.
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

hi wombat! 

thank you very much for this information. 

i will wait for quartus II 11.0. 

perhaps with the api i can solve my problems of communicate with nios. 

 

at the moment i am able to write data to memory by sending a tcl-skript ("tcl.tcl") via matlab: 

dos('system-console.exe --script=tcl.tcl') 

 

by using the command i get no echo from the console. 

by typing in all the tcl commands i get back the information about memoryvalues. (master_read_memory $nios 0x00000020 4) 

 

i also thought about using the jtag_atlantis.dll. 

i don´t understand how to use it. 

i can send a string via jtag_atlantis but i don´t know how to get the string to nios. i also don´t know how to reallocate the memory information from the nios to get it to the host pc. 

 

a little bit frustrating, but thank you very much for the time you spent in answering my questions. 

greets
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

Hi! 

now i have quartus 2 - 11.0 and the matlabapi but i have the next problem . 

 

i downloaded quartus 11 and its working fine. 

but the problem is - i dont know how to use the matlabapi. no help, tutorial, manual, ... available. altera has no small information about it on web!! - WHY??? 

 

i downloaded the "systemconsole-api-90.zip" from the tutorials. there is an good documentation of using the classes. 

 

but importing the class in matlab does not work. 

i tried it with an other simple java class - no problem. 

 

i also found com.altera.systemconsole.matlabapi in my quartus installationdirectory. also extrated the SystemConsoleLink.class and the other 2 *.class an copied it to my working dir in matlab. - no success . 

 

i also searched the quartus online help. but there are only informations for the tcl - api. 

 

i think matlabapi should solve my problems but after hours of searching and trying - no success. 

i really dont know how to get the information of using the matlabapi. 

 

it would be very nice of you to give me a little more help where i can find informations about using this api. 

its noc 

 

greets
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

You're probably best off looking at the matlab documentation for how to load java objects into matlab. I'm not an expert, but I think there may be some tinkering with class-paths required to get the jars to load. If the matlab JVM uses the manifest files in the jars (open them with zip to take a look) then just loading matlabapi should get things working. 

 

Once you have it loading you'll need to use the appropriate matlab APIs to create a matlab wrapper around a com.altera.systemconsole.matlabapi.SystemConsoleLink object. I'm not a matlab expert so I can't tell you exactly what the commands are to do that, but I have seen it done. 

 

There are JAVA tools which display all the public APIs available on that object, and my posts above describe the interesting ones. I suggest you start with executeTcl which takes a string and returns a string.
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

Hi! 

does anybody know how to use the matlabapi??? 

after days of trying - no success. 

i have no problems of using other java classes in matlab. 

 

i cant find the consturctor. i dont know how to use the methods and which methods. at the moment i use java decompiler and lock into 

 

com.altera.systemconsole.matlabapi 

com.altera.systemconsole.matlabapi.SystemConsoleLink 

com.altera.systemconsole.matlabapi.MatlabMethod 

com.altera.systemconsole.matlabapi.MasterLink 

 

now i can see the methods but i have no success of creating a javaobject and can not use the classes´ methods.  

 

anybody any suggestion??? 

 

i really need help or a link to a manual or documentation...
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

hi! 

the following command should create an object: 

---------------------------------------------- 

"L1 = javaObject('com.altera.systemconsole.matlabapi.SystemConsoleLink')" 

---------------------------------------------- 

 

and now my error from matlab console: 

---------------------------------------------- 

??? Error using ==> javaObject 

Java exception occurred: 

java.lang.NoClassDefFoundError: com/altera/service/Service 

 

at com.altera.systemconsole.core.SystemConsoleProvider.knownProviders(SystemConsoleProvider.java:91) 

 

at com.altera.systemconsole.core.SystemConsoleProvider.createDebugModel(SystemConsoleProvider.java:74) 

 

at com.altera.systemconsole.core.SystemConsoleProvider.createDefault(SystemConsoleProvider.java:63) 

 

at com.altera.systemconsole.matlabapi.SystemConsoleLink.<init>(SystemConsoleLink.java:31) 

 

Caused by: java.lang.ClassNotFoundException: com.altera.service.Service 

 

at java.net.URLClassLoader$1.run(Unknown Source) 

 

at java.security.AccessController.doPrivileged(Native Method) 

 

at java.net.URLClassLoader.findClass(Unknown Source) 

 

at com.mathworks.jmi.CustomURLClassLoader.findClass(ClassLoaderManager.java:754) 

 

at java.lang.ClassLoader.loadClass(Unknown Source) 

 

at java.lang.ClassLoader.loadClass(Unknown Source) 

 

at java.lang.ClassLoader.loadClassInternal(Unknown Source) 

 

... 4 more 

 

 

Error in ==> test_jar at 27 

L1 = javaObject('com.altera.systemconsole.matlabapi.SystemConsoleLink') 

---------------------------------------------- 

 

... so i think - i have to create the class first... how??? 

what is the constructor??? 

which *.jar files do i need ??? 

do i also need the sopc***.jar ?? 

 

it would be nice if someone can help me!!
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

hi! 

perhaps one of you have a suggestion or simple solution for my main-problem because its do difficult to solve the problem via matlabapi... 

 

the only thing that i wanna do is, 

to send and read x*32 bit from/to nios memory! 

i wanna do this automatically(polling) or after pressing a button 

from my selfcreated matlabgui via the connected usbblaster. 

 

perhaps one of you has a solution and you can tell me how to realize it! 

greets
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

Hi, 

 

The root of your problems is this one:java.lang.NoClassDefFoundError: com/altera/service/Service 

This indicates that java couldn't find a jar file providing this class. 

 

When it's looking for classes java checks all the jars on the class path and load the class from the first jar file it sees it in. A class might refer to another class, in which case java will search again and load the second class from the appropriate jar. 

 

It looks like you need to add some jars to your class path. 

 

The matlab Java API lets you see what the class path is by running the `javaclasspath` command. If you are still stuck then please post the results of running this command. 

 

You may be able to solve the problem yourself by adding plausible looking jars to the class path yourself. You can extend the classpath in two ways: 

 

  1. You can `edit classpath.txt` and add the full paths to the jars you need. After editing classpath.txt you will need to restart matlab - the jars should then be on the static classpath 

  2. You can use the command `javaaddpath('full/path/to.jar')` to add jars to the dynamic class path. You don't need to restart matlab to see changes to the dynamic class path, but any changes you make are lost on a restart so you might want to store your commands in startup.m or somewhere like that 

 

Which jars do you need? All the jars you need should be in quartus/sopc_builder/model/lib. You could add all the jars from this directory, or you could just add the ones you need. You will certainly need com.altera.(systemconsole.*; version ; utilities ; ui.* ; tcl.interpreter ; service.jre ) .jar - I think there are a couple more needed too. You can normally tell which jar you need because it matches the missing class name in the error message. 

 

Hope that helps, if you can't find any of the other missing classes then please post a followup.
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

hi! 

i found this 

http://www.alteraforum.com/forum/showthread.php?t=6682 

(4 links) 

 

sounds that there is no other way :( and i have to get the matlabapi work! 

mhhh...
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

hi! 

your information takes me one step further. but now - i get the following error: 

 

------------------------------- 

??? Error using ==> javaObject 

Java exception occurred: 

java.lang.NullPointerException 

 

at com.altera.systemconsole.matlabapi.SystemConsoleLink.<init>(SystemConsoleLink.java:46) 

 

at com.altera.systemconsole.matlabapi.SystemConsoleLink.<init>(SystemConsoleLink.java:31) 

 

 

Error in ==> test_jar at 29 

L1 = javaObject('com.altera.systemconsole.matlabapi.SystemConsoleLink') 

------------------------------- 

 

L1 should be my object. in this message i can read, that the function/class want to use something that isnt there and so i get an initialisation problem. 

 

the board is connected and i can see the connection working by starting system-console.exe. - so i dont think that it is a connection-problem... 

 

is com.altera.systemconsole.matlabapi.SystemConsoleLink the constructor? 

i think, that i dont have to give arguments to the SystemConsoleLink(), right? 

 

i also dont know, perhaps i have to use the MatlabMethod ? but how? 

or is it an matlabapi internal class for using the matlabapi? 

 

in my opinion i have to do the following in matlab: 

 

L1 = javaObject('com.altera.systemconsole.matlabapi.SystemConsoleLink'); 

L1.onemethod(argument) 

L1.onemethod(argument) 

L1.onemethod(argument) 

L1.closeconnection .... 

delete L1 after complete transmission. 

 

anyway - thank you for your time and the very helpful informations !!! 

greets
0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

You're right - you don't need to pass any arguments to SystemConsoleLink. It may be that you've missed something out of your class path to cause this problem, let me take a look...

0 Kudos
Altera_Forum
Honored Contributor II
1,369 Views

at the moment i use the following: 

 

com.altera.version.jar 

com.altera.utilities.jar 

com.altera.ui.jar 

com.altera.tcl.interpreter.jar 

com.altera.service.jre.jar 

com.altera.systemconsole.app.jar 

com.altera.systemconsole.dashboard.jar 

com.altera.systemconsole.designs.jar 

com.altera.systemconsole.gdbserver.jar 

com.altera.systemconsole.gui.jar 

com.altera.systemconsole.issp.jar 

com.altera.systemconsole.jar 

com.altera.systemconsole.matlabapi.jar 

com.altera.systemconsole.monitor.jar 

com.altera.systemconsole.nios2.dpx.jar 

com.altera.systemconsole.plugin.elf.jar 

com.altera.systemconsole.plugin.jtag.jar 

com.altera.systemconsole.plugin.memory.jar 

com.altera.systemconsole.plugin.pli.jar 

com.altera.systemconsole.scripting.jar 

com.altera.systemconsole.tcpchannel.jar 

com.altera.systemconsole.transceivers.jar 

com.altera.systemconsole.usb.jar 

com.altera.tcl.ui.jar 

com.altera.tools.exampledesigns.jar 

com.altera.tools.sopcformats.jar 

com.altera.ui.ientity.jar 

 

i also tryed to use all *.jar from quartus/sopc_builder/model/lib 

- no success. 

 

i thought about a problem with different versions of java. 

but i use the newest one (Java VM Version: Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode) 

 

i know the the com.altera.* was generated with 1.6.0_02-b06 (Sun Microsystems Inc.) and i tryed to find it, but i think problems could only occur with older java versions. 

 

greets
0 Kudos
Altera_Forum
Honored Contributor II
1,242 Views

Hi out there! 

in this moment - i found the following datasheet: 

http://www.altera.com/literature/ds/ds01023.pdf 

 

for me its not very funny but there on page 4 is a very very very small 

"example" of using the Matlabapi - i think. 

i know the command MasterRead32( ... ) from my studies of the informations, wombat gave me. i was searching many hours - and now that piece of zero information! on page 4 they tell me to visit altera.com :) very funny hohoho... 

i think, someone from altera is listening to my messages and laughing with his developer friends :( 

 

Nowhere on altera.com is any information about how do get the matlabapi work. i know its brand new - quartus2 10.1 or later - but how can i get the informations i need??? 

why doesn´t altera publish the information on that data sheet or give a link or something?  

 

greets
0 Kudos
Reply