https://mp.weixin.qq.com/s/zPNyrBOhsytkRrZTDTEvpw

介绍riscv-debug的使用实例:配置Triggers功能。

1. Trigger

Trigger是指硬件触发器:A debugger can use hardware triggers to halt a hart when a certain event occurs.

2. Trigger Module

Triggers can:

a. cause a breakpoint exception, entry into Debug Mode,

b. or a trace action without having to execute a special instruction.

This makes them invaluable when debugging code from ROM.

They can trigger:

a. on execution of instructions at a given memory address,

b. or on the address/data in loads/stores.

These are all features that can be useful without having the Debug Module present, so the Trigger Module is broken out as a separate piece that can be implemented separately.

Triggers不会在调试模式触发:

用以下方法检测某个序号的触发器是否支持:

3. 实例1

A. (补)tselect=0:选择第0个触发器;

B. 写tdata1寄存器,其中:

a. type=2:The trigger is an address/data match trigger;

tdata1和mcontrol的地址相同,实际上是同一个寄存器:

mcontrol格式如下:

b. action=1:Enter Debug Mode. (Only supported when the trigger's dmode is 1.)

c. dmode=1:根据b的要求,dmode应该为1,其意义为:

d. match=0:Matches when the value equals tdata2;就是说与tdata2中的值进行匹配;

e. m=s=u=1:触发器在M/S/U模式下触发:

f. execute=1:When set, the trigger fires on the virtual address or opcode of an instruction that is executed. 对执行的指令地址或者指令码进行匹配;结合上面的配置,即指令地址或指令码等于tdata2中的值时,触发器触发;

g. tdata1=0x105c是指低16位的值:

那么高位的值呢?

隐含的要求:

a) type=2;

b) dmode=1;

文档写的比较粗糙,其他位应该为0。

本实例的before体现在mcontrol的timing位:

这一位值为0,意义为:The action for this trigger will be taken just before the instruction that triggered it is executed, but after all preceding instructions are committed.

C. tdata2=0x80001234:待匹配的指令地址为0x80001234;

4. 实例2

与实例1相比,区别如下:

A. 相较于实例1匹配指令地址,这里匹配的是读内存地址:load=1;

B. 相较于实例1中指令执行前触发,这里在读内存之后触发:timing=1:

5. 实例3

这里实例中使用了两个触发器:Trigger 0和Trigger 1.

1) Trigger 0

实现Enter Debug Mode right before a write to an address greater than 0x80007c80:

a. timing=0:在指令执行前触发;

b. match=2:大于0x80007c80:Matches when the value is greater than (unsigned) or equal to tdata2.

c. store=1:匹配a write to an address;

d. tdata2=0x80007c80:保存待匹配的内存地址;

2) Trigger 1

实现Enter Debug Mode right before a write to an address less than 0x80007c80:

a. timing=0;

b. match=3:Matches when the value is less than (unsigned) tdata2;

c. store=1;

d. tdata2=0x80007cf0:注意这里不是0x80007cef,因为要求是包括0x80007cef这个地址,而匹配时是排除tdata2这个地址,所以只能把要求的地址加1之后存入tdata2;

6. 实例4

a. timing=0:在指令执行前触发;

b. store=1:匹配一个写内存操作;

c. match=1:

这里匹配tdata2寄存器的高M位,M的计算方法是XLEN-1减去最低的0位的序号:

a. XLEN=32, XLEN-1=31;

b. 0x81237fff中最低的0位是第15位:

c. 所以M=31-15=16;也就是说匹配tdata2的高16位;

d. 也就是把要写的内存地址的高16位与tdata2的高16位进行匹配,那么可以触发的内存地址的范围即是:0x81230000-0x8123ffff;

7. 实例5

这里匹配针对两个内存地址范围的读操作,需要使用两个Trigger。其中:

a. timing=1:表示读操作完成之后触发;

b. load=1:表示匹配的是读内存操作;

c. chain=1:表示两个trigger组合使用:While this trigger does not match, it prevents the trigger with the next index from matching.

1) Trigger 1

要匹配的内存地址范围是:0xXXXX3090-0xXXXX309f;

A. match=4:Matches when the lower half of the value equals the lower half of tdata2 after the lower half of the value is ANDed with the upper half of tdata2.

a. 首先把待匹配值的低一半V与tdata2的高一半相与:V & 0xfff0;

b. 然后把结果与tdata2的低一半相比较,即(V & 0xfff0) =? 0x3090;

c. 如果相等则触发;效果是匹配的内存地址的低一半是0x3090-0x309f;

B. chain=1:这里只匹配了低一半的地址,还有高一半的地址需要匹配,需要与Trigger 2组合使用;

2) Trigger 2

要匹配的内存地址范围是:0x8675XXXX-0x9675XXXX;

A. match=5:Matches when the upper half of the value equals the lower half of tdata2 after the upper half of the value is ANDed with the upper half of tdata2.

a. 首先把待匹配值的高一半V与tdata2的高一半相与:V & 0xefff;

b. 然后把结果与tdata2的低一半相比较,即(V & 0xefff) =? 0x8675;

c. 如果相等则触发;效果是匹配的内存地址的高一半是0x8675-0x9675;

Rocket - debug - Example: Triggers的更多相关文章

  1. Rocket - debug - TLDebugModuleInner - Hart Bus Access

    https://mp.weixin.qq.com/s/deNMEyJ1idJDVoZwwo0A1A 简单介绍TLDebugModuleInner中核心总线访问(Hart Bus Access). 参考 ...

  2. Rocket - debug - Periphery

    https://mp.weixin.qq.com/s/uGxn-Xec0LkwdaSsCtQBvw 简单介绍Periphery的实现. 1. ExportDebugDMI/ExportDebugJTA ...

  3. Rocket - debug - DebugTransport

    https://mp.weixin.qq.com/s/EcsuTjb4hFF9Ncig9Gfhew 简单介绍DebugTransport的实现. 1. JtagDTMConfig 1) JtagDTM ...

  4. Rocket - debug - TLDebugModule

    https://mp.weixin.qq.com/s/EhUb1z5oiIw6dJ-90ifDJA 简单介绍TLDebugModule中的实现. 1. device device是一个设备描述符,包含 ...

  5. Rocket - debug - TLDebugModuleInner - ROM Generation

    https://mp.weixin.qq.com/s/j_CgHU4PnY82NMwJzOqHYg 简单介绍Variable ROM Generation. 1. jalAbstract jalAbs ...

  6. Rocket - debug - Example: DMI

    https://mp.weixin.qq.com/s/7suuJ7m2BKCpsHk1K2FzJQ 介绍riscv-debug的使用实例:如何使用DMI. 1. dm Debug Module实现了调 ...

  7. Rocket - debug - Example: Read Memory

    https://mp.weixin.qq.com/s/ChXNTbx94WDC72GvmE9bGA 介绍riscv-debug的使用实例:使用三种方法读取内存. 1. Using System Bus ...

  8. Rocket - debug - Example: Accessing Registers Using Program Buffer

    https://mp.weixin.qq.com/s/8yYLVg-RXX3XX0T431lxeA 介绍riscv debug接口的使用实例:使用Program Buffer读取寄存器. 1. Wri ...

  9. Rocket - debug - Example: Accessing Registers Using Abstract Command

    https://mp.weixin.qq.com/s/RdJzE06mMkh2x__vVj_fEA 介绍riscv debug接口的使用实例:使用抽象命令读取寄存器. 1. Read s0 using ...

随机推荐

  1. 阿里云函数计算上部署.NET Core 3.1

    使用阿里云ECS或者其他常见的VPS服务部署应用的时候,需要手动配置环境,并且监测ECS的行为,做补丁之类的,搞得有点复杂.好在很多云厂商(阿里云.Azure等)提供了Serverless服务,借助于 ...

  2. React 导入组件前段浏览器报错 “Cannot read property 'Component' of undefined”

    问题出在这个花括号上,当你写{React}的时候,他只会导入React,并不会导入下面你要用到的Component组件, 所以,将括号去掉就可以了. 别忘记保存.

  3. DHCP报文(1)

    DHCP报文 1.地址申请类型(4步工作原理,常考) (1)此题是典型的四步工作原理,在其配置过程中由于没有分配IP地址,用的是广播形式,所以其4中报文类型的目的IP地址均为255.255.255.2 ...

  4. 关于 k210 的 micropython 添加 ussl 模块,实现 https 访问支持的那些事。

    起因 事情已经过去快一周了吧,继上次修复 maixpy k210 的 esp8285 at 通信后,突然遇到泽畔大大问,要不要做 ussl 的支持? 评估了一下各方的实现,想了一下自己也刚好在做网络层 ...

  5. STM32 TIM1高级定时器RCR重复计数器的理解

    STM32 TIM1高级定时器RCR重复计数器的理解 TIMx_RCR重复计数器寄存器,重复计数器只支持高级定时器TIM1和TIM8,下面看标准外设库的TIM结构体的封装: typedef struc ...

  6. Linux文件操作命令并举例说明其作用

    ls ,常用于查看当前文件下有工作中需要的文件 cd, 常用于进行切换文件的位置 vim,常用于编辑软件系统相关的配置文件 ps –ef|grep jdk,常用语显示跟jdk有关的进程   |:表示 ...

  7. 第一行Kotlin系列(一)kotlin按钮点击事件

    按钮findViewBuId <Button android:id="@+id/mButton4" android:layout_width="wrap_conte ...

  8. [hdu3644 A Chocolate Manufacturer's Problem]模拟退火,简单多边形内最大圆

    题意:判断简单多边形内是否可以放一个半径为R的圆 思路:如果这个多边形是正多边形,令r(x,y)为圆心在(x,y)处多边形内最大圆的半径,不难发现,f(x,y)越靠近正多边形的中心,r越大,所以可以利 ...

  9. [ACdream 1211 Reactor Cooling]无源无汇有上下界的可行流

    题意:无源无汇有上下界的可行流 模型 思路:首先将所有边的容量设为上界减去下界,然后对一个点i,设i的所有入边的下界和为to[i],所有出边的下界和为from[i],令它们的差为dif[i]=to[i ...

  10. springDataJPQL实现增删改查及分页,原生sql查询,根据方法命名规则实现查询以及Specification查询

    一.使用方法 1.在dao中定义开一个方法,使用方法的参数设置jpql,并且使用方法的返回值接受查询结果,在方法上添加@query注解,在注解中写jpql语句进行增删改查,测试 2.使用原生的sql语 ...