Debugging the PRU from CCS#
CCS is TI’s primary debug tool for PRU firmware.
This section assumes that the PRU core was already initialized in
Lab 4: How to Initialize the PRU. We will debug either the c_code version of
pru_add, or the assembly_code version.
Load debug symbols for the PRU core#
The debug symbols allow CCS to associate the project source code with the generated assembly code running on the PRU cores.
If the PRU project was initialized by CCS
No additional steps are needed. The debug symbols were loaded into CCS when CCS loaded the program into the PRU core. Continue to section Get familiar with the CCS environment.
If the PRU project was initialized by an MCU+ core
or
If the PRU project was initialized by a Linux core
Connect the JTAG cable to the PC, and follow the steps in Initializing the PRU from CCS to connect CCS to the EVM. However, in section Load the PRU firmware, STOP after Launch Selected Configuration and return to this page.
Right click on the appropriate PRU core and select Connect Target. Do NOT
reset the CPU! Instead, load the debug symbols by selecting
Run > Load > Load Symbols. Select the PRU binary that is currently running
on the remote core.
Get familiar with the CCS environment#
Set up the debugging windows#
We will be using these debugging windows during this lab:
View > RegistersView > Memory.View > Memory Allocationmay also be helpfulView > DisassemblyView > Variables
Take note of where the windows have appeared. Some Views may be on the Left-hand menu, the Right-hand menu, or along the bottom of the screen.
In the Debug view, select the PRU core that has the firmware loaded. The core should say Halted.
Inspect the debug interface#
Get familiar with important buttons in the Debug interface. Hover the mouse over
a button to see the button’s name.
Continueplaces the PRU firmware into a “running” statePausepauses the PRU core. The PRU core must be paused in order to view memory values, edit variables, etc.Stopcloses the debug sessionRestartmoves the Program Counter (PC) back to the program entry point. It does NOT actually reset the core under debug.
C code:
Step Intotakes one step through C code, and then pauses the PRU core. Note that a single step in C code may translate to several steps in the generated assembly code running on the PRU core. If there is a function, “Step Into” will jump into the function and pause at the first C instruction within the functionStep Overtakes one step through the C code, and then pauses the PRU core. Note that a single step in C code may translate to several steps in the generated assembly code running on the PRU core. If there is a function, “Step Over” will step over the function and pause at the first C instruction after the function
Assembly code:
Step Intotakes one step to the next assembly instruction and pauses. If there is a subroutine or function, “Step Into” will jump into the subroutine or function and pause at the first assembly instruction within the subroutine or function.Step Overtakes one step to the next assembly instruction and pauses. If there is a subroutine or function, “Step Into” will jump over the subroutine or function and pause at the first assembly instruction after the subroutine or function.
To continue debugging the assembly_code project, jump down to section Debugging Assembly Code.
Debugging C Code#
This section uses the c_code example.
If you clicked on any of the buttons in the previous step, right click on the
core and select Reset > Core reset or Restart
to get back to the program entry point. Note that resetting the core does NOT
cause the PRU’s local memory to get zeroed out.
Use the “Step Over” or “Step Into” buttons to step through the PRU function to the beginning of the while loop.
Reading and modifying values in memory#
Navigate to the Memory window.
Select
Data_Memory. In thelocationbox, enter0x0to see the stack and addresses fora,b, andcBegin stepping through the program. If this is the first time the program is running since the processor booted up, you should see the values for
aandbpopulated into 0x110 and 0x114. After stepping through the loop once, the value ofcat 0x118 should now equala + bDouble click the block of memory at 0x110 in the
memory browser. Change the value to a new number (for example, assign a new value toa). Press the enter key on the keyboard to save the new value ofa.Step through the loop again. The value of
cat 0x118 should change.
Reading and modifying variable values#
Navigate to the Variables window. Variables x, y, and z are defined
here.
Note
CCS20 and all earlier versions of CCS have a bug in the Variables window as
of OpenPRU 2026.01.00. The variables are stored in one location on the stack,
but the CCS debugger thinks that the variables are stored in a different
location. This bug does not affect PRU functionality, but it does mean that the
Variables window is not useful for debugging.
The Variables window shows the value of a variable, as well as the variable’s
location in memory.
Variables x, y, and z should be saved to the stack.
Check the linker command file to see where the stack is located:
In the Left-hand menu,
Explorerand navigate back to the PRU firmware project in the CCS workspaceIn the PRU build outputs, open the .map file
Scroll down to the
SECTION ALLOCATION MAPand look for .stack. In my case, .stack is in page 1, offset 0x0000, with a length of 0x100:
SECTION ALLOCATION MAP
output attributes/
section page origin length input sections
-------- ---- ---------- ---------- ----------------
...
.stack 1 00000000 00000100 UNINITIALIZED
00000000 00000004 rtspruv3_le.lib : boot.c.obj (.stack)
00000004 000000fc --HOLE--
Check the linker command file. The
MEMORYsection tells us which memory regions are at what address offsets in PAGE 1. TheSECTIONSsection tells us which memory region we place .stack into. In my case, .stack is placed into PRU0_DMEM_0, which is Data RAM 0:
MEMORY
{
...
PAGE 1:
/* Data RAMs */
/* 8 KB PRU Data RAM 0; */
PRU0_DMEM_0 : org = 0x00000000 len = 0x00001000
...
SECTIONS {
...
.stack > PRU0_DMEM_0, PAGE 1
In my case, the stack will begin at address 0x0 in the PRU core’s DMEM0.
From the .map file, we saw that the stack was 0x100. If we wanted to change the stack size, we would modify the stack size as per Writing C Code in CCS or Writing C Code in OpenPRU.
Now I know that the stack has a size of 0x100 and begins at address 0x0 in the
PRU’s DMEM0. Navigate back to the Debug perspective in the Left-hand menu.
In the Memory window, find the stack location. The variable values listed in
the Variables view should be visible in
the Memory window at the location listed in the Variables table.
Click on the Value cell of a variable in the Variables view. type a
new number, and press the enter key on the keyboard. The value in the
Memory view will change
Reading and modifying register values#
Navigate to the Registers window. Click on Restart to return to the program entry point.
Expand the
core registersdropdown.Step through the C code. The register values will change. PRU programs written in assembly code specify exactly which core register is doing what. However, for C code, the PRU compiler determines which values go in which registers.
Register values can be changed by clicking on the
Valuecell and typing in a new hexadecimal value.
Breakpoints#
View all breakpoints in the code under Debug > Breakpoints.
To toggle a breakpoint, either click on the left side of either the line number
in the source code view or the address in the disassembly view, or select the
line, and go Run > Toggle Breakpoint.
Add a breakpoint.
Select Run > Resume. The code will run until it reaches the breakpoint, and
then the software execution will pause. Utilize the step into/step over
commands to see what is happening in the PRU code. To set new breakpoints in the
PRU code and see them catch in runtime, select Run > Restart, set your
breakpoints in the PRU code, then select Run > Resume.
Debugging Assembly Code#
This section uses the assembly_code example.
Reading and modifying values in memory#
The assembly_code project does not read or modify values in memory. Refer to
Debugging C Code for steps on how to read and modify memory values in
the Memory window.
Reading and modifying variable values#
The assembly_code project does not read or modify variables. Refer to
Debugging C Code for steps on how to read and modify variable values in
the Variables window.
Reading and modifying register values#
Navigate to the Registers window. Click on Restart to return to the program entry point.
Expand the core registers drop down.
Step through the assembly code. The register values will change.
Register values can be changed by clicking on the
Valuecell and typing in a new hexadecimal value.
Before changing any register values, let’s take a closer look at exactly what the assembly code is doing.
Viewing and navigating assembly code#
Navigate to the
Disassemblywindow. This window shows what processor instructions were generated from the assembly code.Click the
Assembly Step Intobutton several times. Note that the yellow arrow representing the Program Counter (PC) in the main.asm view matches the yellow arrow representing the PC in the Disassembly view. One assembly instruction in main.asm will be related to one assembly instruction in theDisassemblywindow.Return to the
Registerwindow. UnderCore Registers, select PC and change it to a different memory location. The PC arrows in main.asm and theDisassemblyview should jump to the new program counter location.
Warning
Be careful when manually changing the Program Counter. The PRU firmware does not know when the PC value is manually changed, so register values, memory values, etc may be different from what the PRU firmware expects.
Click on
Restartto return to the program entry point.Click the
Assembly Step Intobutton until the PC reaches thewhile_truefunction.Notice how the command
ldi x_register, xwas interpreted in the Disassembly view.xwas converted into a static value of 1 instead of a variable that can be changed.Step all the way through the
while_trueloop. The value ofR22should update to equalR20 + R21.What if we want to change the values getting passed to the assembly instruction
add z_register, x_register, y_register?The LDI commands will overwrite any value inR20andR21every while loop.Step until the PC is pointing to
add z_register, x_register, y_register. At this point, the twoLDIcommands just executed. The very next PRU clock cycle, theADDcommand will execute.Go to the
Registersview and enter new values in forR20andR21.Step one more time.
R22should update with the sum of the new values that were entered in. Stepping through the loop again should replace all register values with the values that were hardcoded in instruction memory.
Breakpoints#
View all breakpoints in the code under Debug > Breakpoints.
To toggle a breakpoint, either click on the left side of either the line number
in the source code view or the address in the disassembly view, or select the
line, and go Run > Toggle Breakpoint.
Add a breakpoint.
Select Run > Resume. The code will run until it reaches the breakpoint, and
then the software execution will pause. Utilize the step into/step over
commands to see what is happening in the PRU code. To set new breakpoints in the
PRU code and see them catch in runtime, select Run > Restart, set your
breakpoints in the PRU code, then select Run > Resume.

