Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
14 years ago

Tutorial: Using the USB-Blaster as an SOPC/Qsys Avalon-MM master

Hi all,

I've put together a tutorial on how to use the Altera JTAG-to-Avalon-MM master and Altera Verification IP Avalon-MM BFM Master under both SOPC builder and Qsys.

http://www.ovro.caltech.edu/~dwh/correlator/pdf/altera_jtag_to_avalon_mm_tutorial.pdf (http://www.ovro.caltech.edu/%7edwh/correlator/pdf/altera_jtag_to_avalon_mm_tutorial.pdf)

http://www.ovro.caltech.edu/~dwh/correlator/pdf/altera_jtag_to_avalon_mm_tutorial.zip (http://www.ovro.caltech.edu/%7edwh/correlator/pdf/altera_jtag_to_avalon_mm_tutorial.zip)

The tutorial walks the user through the creation of an SOPC or Qsys system design, and provides scripts that automate the re-generation of the system. The tutorial shows how to simulate using Modelsim-ASE, and shows how to communicate with the hardware using System Console, quartus_stp, and then how to run a TCP/IP server under System Console or quartus_stp, and then communicate with that server from client code written in Tcl/Tk (a simple GUI) and a command-line C interface.

Let me know if you like it, or have feedback/suggestions on how to improve the document.

Cheers,

Dave

119 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If you do not use 8/10B encoding, then you have to synchronize the links yourself. For example, I have used the transceiver sync pattern detect logic, and hard-coded it to the start of a PRBS sequence and used that to synchronize lanes.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Dave,

    There are 2 more issues I am facing while using JTAG to Avalon MM Master over USB Blaster Cable using the jtag_write and jtag_read scripts:

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

    Issue-1:

    I have put together Nios_II based system in QSYS wherein I am using mailbox.

    Mailbox is used to push commands from host on sender interface and Nios_II is supposed to read these commands from receiver interface.

    Mailbox sender interface is connected to JTAG to Avalon MM bridge (as I want to push the messages from Host via USB blaster cable to JTAG-Avalon bridge)

    Mailbox has 2-bits avalon address connected to it to access 4 registers inside.

    On system console, I am using the TCL script jtag_write to push message in to the mailbox.

    Issue is avalon address given is on byte boundary and the address has to be on 32-bit boundary.

    If I do:

    jtag_write 0x00009001 (to write in to mailbox pointer register)

    System Console issues error saying the address should be 32-bits aligned.

    How can I access the mailbox directly from JTAG-AvalonMM bridge directly?

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

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

    Issue-2:

    My SRAM is on 0x0000_0000 and SDRAM is on 0x8000_0000.

    When I write on SRAM using jtag_write and verify using jtag_read, it works fine.

    My observation is when I write on SDRAM address 0x8000_0000 and read back, it gives me the same data as SRAM

    Theoretically, JTAG address should support 32-bits ... I am not sure why this is happening.

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

    Regards

    Sagar.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi!

    I hope it’s okay to dig up this thread. First of all, Thank you for the tutorial. It’s a shame Intel/Altera doesn't provide more information on this topic.

    Is there a way to start the SystemConsole directly in a terminal (i.e. like quartus_sh) without going through the Qsys GUI? I’d use your quartus_stp implementation but with it I’m getting this error:

    Edit: In the meantime I’ve found the system-console binary in quartus/sopc_builder/bin/system-console. With the --cli and/or --script parameters one can easily use it directly from a terminal or on a server for e.g. integration checks or remote programming. So everything’s solved! I can program the 8MiB SDRAM over JTAG using the Qsys SDRAM Controller! :)

    
    tcl> tcl> 
    JTAG: USB-Blaster , FPGA: @1: EP2C(15|20) (0x020B30DD)
    tcl> 
             Hub info: 0x8086E04
          VIR m-width: 4
          VIR n-width: 1
      Manufacturer ID: 0x6E
      Number of nodes: 1
           IP Version: 1
    tcl> jtag_print_node_info
    invalid command name "jtag_print_node_infojtag_print_node_info"
    tcl> 
    tcl> jtag_print_node_info
           Node index:    0
        Node instance:    0 (0x0)
    Node manufacturer:  110 (0x6E)
              Node ID:  132 (0x84)
         Node purpose:    1 (0x1)
         Node version:    1 (0x1)
    tcl> jtag_read 0 0
    Sending 4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A007B000000040000107A007CFC00
    Received 4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A4A0000
    Error: incorrect number of response bytes! (Got 0, expected 8)
    tcl> 
    

    [additional output added by me for debugging purposes, nothing else changed]. In SystemConsole master_read/write_32 on that address works perfectly fine.

    I’m using Quartus 13.0.1 Web Edition with an Altera DE1 board.

    Could it be that the JTAG commands changed for 13.0? Or why am I getting a zero length response back?

    I’ve tried to load the SystemConsole packages in a quartus_sh Shell but apparently it’s not intended to be used that way.

    Thank you for any advice!

    Best regards,

    Michael
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Michael,

    --- Quote Start ---

    I hope it’s okay to dig up this thread.

    --- Quote End ---

    Sure :)

    I wrote the quartus_stp as a work-around while I figured out the SystemConsole version. Earlier versions of SC had a broken Tcl implementation, but I'm pretty sure it got fixed - look at the Tcl code, I'm usually pretty good at leaving comments in there.

    Given that Altera/Intel probably isn't putting any effort into quartus_stp, I'd recommend using SystemConsole. I think from your comments above SC is working for you. If not, let me know, and I'll fire up a board and see if I can break it in the same way you do.

    Cheers,

    Dave
  • SBinS's avatar
    SBinS
    Icon for New Contributor rankNew Contributor

    Hi, I am working on the tutorial and get stuck at the master_write or master_read command line. I'm using the Quartus Prime Lite 19.1 and Platform Designer (formerly Qsys), I wrote those line command in TCL console in System Console and get the error saying the transaction is taking longer than 10 seconds and continue for another 50 seconds, then it said the system console is giving up. I tried everything to rectify the problem like correcting the path for the environment variable, update to latest Quartus Prime (on having the problem I used version 18.1). Is there any specific set up before using the command line that I need to set in my computer? Any helps are indeed great.

  • covfefe's avatar
    covfefe
    Icon for Occasional Contributor rankOccasional Contributor

    @Altera_Forum Thank you for these files.

    I have been able to use them on System Console 12.1 CLI for awhile now. It works great.

    I recently updated to newer versions (Version 18.0, Version 21.1 850, Version 22.2 94) CLI and unfortunately there I cannot send commands from the client to the server anymore. It crashes here:

    proc client_handler {client} {
    [...]
    # Execute the command and return the response
    # puts "CLIENT ($client): $cmd"
    if {[catch {eval $cmd} rsp]} {

    The same exact code works on the GUI (non-CLI).

    I can connect just fine. I can modify the TCP starting script, and execute commands anywhere (ex: puts [get_service_types]) outside of server_accept, & client_handler.

    Executing the same one inside of either, Java VM JRE crashes (similarly to any command passed through by the client).

    Would anyone have an idea of what is happening?

    right here it crashes XXserver_acceptXX
    #
    # A fatal error has been detected by the Java Runtime Environment:
    #
    #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006182ba52, pid=23628, tid=0x000000000000550c
    #
    # JRE version: OpenJDK Runtime Environment (8.0_322-b06) (build 1.8.0_322-b06)
    # Java VM: OpenJDK 64-Bit Server VM (25.322-b06 mixed mode windows-amd64 compressed oops)
    # Problematic frame:
    # V  [jvm.dll+0x13ba52]
    #
    # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
    #
    # An error report file with more information is saved as:
    # C:\Program Files (STL)\quartus_systemconsole_21_1\sopc_builder\bin\hs_err_pid23628.log
    #
    # If you would like to submit a bug report, please visit:
    #   https://github.com/adoptium/adoptium-support/issues
    #
    # Start the server on the specified port
    proc server_listen {port} {
    	puts "right here it works XXserver_listenXX"
    		puts [get_service_types]
    		puts "it just worked"
    		
    	global jtag
    	if {[catch {socket -server server_accept $port} result]} {
    
    #		error "Error: Server start-up failed\n -> $result"
    		puts "Error: Server start-up failed\n -> $result"
                    exit
    	}
    	set jtag(port)   $port
    	set jtag(socket) $result
    	return
    }
    # Server client-accept callback
    proc server_accept {client addr port} {
    		puts "right here it crashes XXserver_acceptXX"
    		puts [get_service_types]
    		puts "uh oh"