JTAG master简单的使用方法
Arth
JTAGmaster是个简单好用的调试工具,一般的调试只需要几句简单的TCL语言就可以完成,复杂的也可以做成tcl脚本直接调用。
这篇先介绍下一些简单的调试方法。
1. JTAG Master IP添加
新建qsys工程后,可以从IP Catalog目录里面找到JTAG to Avalon Master Bridge,双击加入。如下图所示。
2. 加入后连接好该IP的时钟和复位信号,并将master端口连接到需要观察调试的slave上,并给slave分配一个固定地址,这里就直接用默认的地址了。如下图所示。
3. generate并编译工程后将sof文件下载到fpga。
4. 从tools->SystemDebugging Tools里面打开SystemConsole,如下图所示
5. 打开后界面如下,我们在tclconsole中输入一些指令就可以操作我们的JTAG master了。
6. 输入指令说明
首先肯定是将我们的Tcl console和jtag master建立连接,先设置jtag master的path,注意关键字后要留有空格!
语法:set <service-path> [lindex[get_service_paths master] 0]
举例:set jd_path [lindex [get_service_paths master ] 0]
Tcl console里面打印出路径后就说明已经找到了我们在qsys中放入的的jtag master
然后open service master,用下面一条指令
语法:open_service master <service-path>
举例:open_service master$jd_path
这时候准备工作就算是完成了,我们就可以先用jtag_master_read/write之类的命令来读写slave的数据了。
比如我们想从0x0000上读取一个32位的数据,就可以用下面的一条指令
语法:master_read_32 <service-path><address> <size_in_multiples_of_32_bits>
举例:master_read_32$jd_path 0x0000 1 这就可以从jtagmaster对应的slave的0x0000地址读取一个数据了,当然数据的地址和读取的数量是可以根据自己的需求进行修改的。
写入一个32位的数据到指定地址的语法是类似的,
语法:master_write_32 <service-path><address> <list_of_32_bit_words>
举例:master_write_32$jd_path 0x0000 0x12345678 这就可以往jtag master对应的0x0000地址写入0x12345678这个数据了,写入后再回读,可以发现数据是正确的。当然,有些地址是只读的就无法写入了,这个和具体工程有关系。
用完后再close service就可以了
语法:close_service master <service-path>
举例:close_service master$jd_path
使用这些语法的时候,要注意关键字后面要留有空格。
以上介绍的只是冰山一角,欢迎有兴趣的同学一起学习。
其他常用的jtag-master语法如下,用法大同小异,稍微实验下就知道怎么用了。这里就不详细说明了。
Command | Arguments | Function |
master_write_memory | <service-path> <address> <list_of_byte_values> | Writes the list of byte values, starting at the specified base address. |
master_write_8 | <service-path> <address> <list_of_byte_values> | Writes the list of byte values, starting at the specified base address, using 8-bit accesses. |
master_write_16 | <service-path> <address> <list_of_16_bit_words> | Writes the list of 16-bit values, starting at the specified base address, using 16-bit accesses. |
master_write_from_file | <service-path> <file-name> <address> | Writes the entire contents of the file through the master, starting at the specified address. The file is treated as a binary file containing a stream of bytes. |
master_write_32 | <service-path> <address> <list_of_32_bit_words> | Writes the list of 32-bit values, starting at the specified base address, using 32-bit accesses. |
master_read_memory | <service-path> <address> <size_in_bytes> | Returns a list of<size>bytes. Read from memory starts at the specified base address. |
master_read_8 | <service-path> <address> <size_in_bytes> | Returns a list of<size>bytes. Read from memory starts at the specified base address, using 8-bit accesses. |
master_read_16 | <service-path> <address> <size_in_multiples_of_16_bits> | Returns a list of<size> 16-bit values. Read from memory starts at the specified base address, using 16-bit accesses. |
master_read_32 | <service-path> <address> <size_in_multiples_of_32_bits> | Returns a list of<size> 32-bit values. Read from memory starts at the specified base address, using 32-bit accesses. |
master_read_to_file | <service-path> <file-name> <address> <count> | Reads the number of bytes specified by<count>from the memory address specified and creates (or overwrites) a file containing the values read. The file is written as a binary file. |
master_get_register_names | <service-path> | When a register map is defined, returns a list of register names in the sla |
当然,想把jtag master用的很熟练,就建议学习下TCL脚本了。