Project

General

Profile

PRU Hello world - ARM/remoteproc load, CCS attach

Objective

The objective of this example is to demonstrate the technique of starting a PRU program from the ARM/Linux using remoteproc and then using Code Composer to "attach" to this program through the JTAG.

This example will demonstrate the use of a wait loop at the start of the program so you have time to attach the debugger. The wait loop will wait for a specified amount of time (60 seconds in this example) and then run the program as usual.

Prerequisites

Steps

Modify Source Code

  • Start with program from previous demo. Hello World - CCS Load
  • Add a wait for debugger loop
        int ii;
    ...
    
        // wait for 60 seconds
        for (ii = 0; ii < 60; ++ii)
        {
            __delay_cycles(CYCLES_PER_SECOND);
        }
    
  • Build program (Project->Build Program)

Copy program to target

  • Copy to target
    • Open a Terminal View (Windows->Show View->Other...->Terminal)
      • Start a terminal (shift-ctrl-alt-T), Choose terminal of type "Local Terminal", hit OK
        cd <workspace_directory>/pru_hello/Debug
        ssh am62x mkdir -p /lib/firmware/pru_demos
        scp pru_hello.out am62x:/lib/firmware/pru_demos
        
  • Fix up PRU_0 link in /lib/firmware
    ssh am62x ln -sf /lib/firmware/pru_demos/pru_hello.out /lib/firmware/am62x-pru0-fw
    
    • Verify link
      ssh am62x ls -l /lib/firmware/am62x-pru0*
      lrwxrwxrwx 1 root root 37 Apr 20 19:37 /lib/firmware/am62x-pru0-fw -> /lib/firmware/pru_demos/pru_hello.out
      

Use remoteproc to start program on PRU_0

  • Use remoteproc, see which processor is which
    ssh am62x tail /sys/class/remoteproc/*/name
    ssh am62x tail /sys/class/remoteproc/*/state
    
    • remoteproc2 corresponds to PRU_0
    • Output of the name files should be something like:
      ==> /sys/class/remoteproc/remoteproc0/name <==
      5000000.m4fss
      
      ==> /sys/class/remoteproc/remoteproc1/name <==
      78000000.r5f
      
      ==> /sys/class/remoteproc/remoteproc2/name <==
      30074000.pru
      
      ==> /sys/class/remoteproc/remoteproc3/name <==
      30078000.pru
      
    • Output of the state files should be something like:
      ==> /sys/class/remoteproc/remoteproc0/state <==
      running
      
      ==> /sys/class/remoteproc/remoteproc1/state <==
      attached
      
      ==> /sys/class/remoteproc/remoteproc2/state <==
      offline
      
      ==> /sys/class/remoteproc/remoteproc3/state <==
      offline
      
  • Start PRU_0. This will load the software and start it running.
    ssh am62x "echo start >/sys/class/remoteproc/remoteproc2/state" 
    ssh am62x tail /sys/class/remoteproc/remoteproc2/state
    
    • The output from the first command will generate on the target console, messages like:
      [12750.919679] remoteproc remoteproc2: powering up 30074000.pru
      [12750.930343] remoteproc remoteproc2: Booting fw image am62x-pru0-fw, size 175168
      [12750.937829] remoteproc remoteproc2: remote processor 30074000.pru is now up
      

Start the Debugger

  • CCS - launch target config
    • In the Target Configurations view, select am62x.ccxml->right-mouse->Launch Selected Configuration
  • In Debug view, select PRU_0-> Connect Target
  • Load the symbols
    • Run->Load->Load symbols
    • Note that CPU Reset and Load Program have been replaced by the Load Symbols.
  • Target probably stopped in the wait loop
  • Breaking out of the loop
    • Alternative 1: Change the value of the variable
      • Variables view
      • Select the "value" for the loop variable (i.e. ii), change to 60, hit enter
    • Alternative 2: Use "Move to line"
      • Select the line after the loop. Right-mouse->Move to Line
  • Set breakpoint for line after fputs output
  • run
  • see initial message and periodic output

Summary

  • Demonstrated starting the program using remoteproc
    • Note that the PRU is different from the M4 MCU in that a resource table is not required when starting from remoteproc
  • Added a wait loop to wait up to 60 seconds.
  • Demonstrated attaching to the program from Code Composer
  • Demonstrated two ways to get out of the wait loop

Go to top
Add picture from clipboard (Maximum size: 1 GB)