2120 views|2 replies

71

Posts

0

Resources
The OP
 

RISC-V MCU Development (Part 7): Code Debugging [Copy link]

MounRiver Studio (MRS) can work with online debugging downloaders such as GD-Link, WCH-Link, and JLink to support code debugging functions for RISC-V/ARM core MCU projects such as GDVFx series, CH56x, CH57x, CH58x, CH32Fx, and CH32Vx. This article mainly introduces the code debugging operation of MRS for RISC-V core MCUs.

[Start debugging] Take the CH32V103C8T6 chip project as an example. First, make sure the project can be compiled, then click the menu bar button to start the debugging mode. Normally, the debugging mode will stop at the position shown in the figure. There is a temporary breakpoint at this position:

[Change the default breakpoint position] Of course, if you want the project to stop directly at the beginning of the main function, you can also manually change the position of this breakpoint. Click the drop-down button next to the debug icon, select "Debug Configurations", select the Startup tab in the pop-up page, and set set breakpoint at to main.

After the configuration is completed, click Debug in the lower right corner, or save and exit the configuration, click the menu bar button, and enter the debug mode and it will stop at the position just set.

[View machine code] After entering debugging, you can see the Disassembly window in the lower left corner. This window can display the assembly and address of the code near the PC. You can also right-click the blank space on the left and select show opcodes to display the machine code.

[Machine code breakpoints and jumps] You can also set breakpoints by double-clicking the blank space on the left side of the disassembly window. You can fill in the hexadecimal address in the red frame to jump to the assembly code at the location you want to view. The main window is used to display the code running location. You can double-click the left window position to add or cancel breakpoints.

[Software breakpoints] Because software breakpoints are used, there is no limit on the number of breakpoints in theory, but too many breakpoints will cause the program simulation to slow down.

[Variable View] The Variables window on the right will display the values of the variables in the current function. You can also modify the value of the variable you want to change in this window, but please note that it is only modified to Ram. After power is restarted, the value will return to the actual size.

[Add monitoring variables] Expertions can customize the variables to be monitored and can also modify them. The effect is the same as in the Variables window.

[Error Interrupt] The Registers window below displays the CSR+GPR registers of the RISCV kernel, which can be used to observe the kernel status. Several registers can help locate the problem when a HARDFAULT error occurs. When entering the hardware error interrupt processing function, mepc displays the address at the time of the error, mcause displays the cause, and mtval displays the value taken by the CPU when the error occurs. The meaning of the mcause value is shown in the figure below.

[Breakpoints Window] The Breakpoints window can display the locations of all set breakpoints, and you can enable or delete segment breakpoints here.

[Memory Window] The Memory window can be used to query the values of different addresses. For example, if we query 0x2000000, click the green plus sign under the window and enter the address to be queried in the pop-up window. You can also change the data in different addresses here. Please note that you should check whether this address can be read and written according to the chip manual.

[Peripheral Register Window] The Peripherals window allows you to select the peripheral registers you want to observe. In addition to the peripheral register name, the content displayed also includes the address and description information.

This post is from MCU

Latest reply

Too many software breakpoints will increase the amount of calculation   Details Published on 2021-10-10 10:48
 

1668

Posts

0

Resources
2
 

Too many software breakpoints will increase the amount of calculation

This post is from MCU

Comments

Indeed, MRS now supports hardware breakpoints for some MCU models from WCH.  Details Published on 2021-10-11 10:59
 
 

71

Posts

0

Resources
3
 
Hot Ximi Show published on 2021-10-10 10:48 Too many software breakpoints will increase the amount of calculation

Indeed, MRS now supports hardware breakpoints for some MCU models from WCH.

This post is from MCU
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list