16
Author: Texas Instruments ® , Sitara™ ARM ® Processors Building Blocks for PRU Development Module 2 PRU Firmware Development This session covers how to develop firmware for the PRU-ICSS Subsystem. Oct 2014

Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

Author: Texas Instruments®, Sitara™ ARM® Processors

Building Blocks for PRU Development

Module 2 PRU Firmware Development

This session covers how to develop firmware for the PRU-ICSS Subsystem.

Oct 2014

Page 2: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

2

Page 3: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

3

TI PRU CGT C Compiler

Page 4: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

4

C Compiler

• Developed and maintained by TI CGT team – Remains very similar to other TI compilers

• Full support of C/C++ • Adds PRU-specific functionality

– Can take advantage of PRU architectural features automatically – Contains several intrinsics

• List can be found in Compiler documentation

• Full instruction-set Assembler for hand-tuned routines

For more information, visit http://www.ti.com/lit/ug/spruhv7/spruhv7.pdf.

Page 5: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

5

TI PRU CGT Assembler vs PASM • Advantages of using TI PRU Assembler over PASM

• The biggest advantage is that the TI PRU linker produces ELF files that enable source-level debugging within CCS. No more debugging in disassembly window!!

• The TI PRU assembler uses the same shell as other TI compilers. Customers only need to learn one set of conventions, directives, etc.

• TI PRU assembler will be maintained in the future, while PASM will not be updated anymore.

• The TI PRU assembler uses the powerful TI linker which allows more flexibility then PASM and facilitates linking PRU programs with host CPU image for runtime loading and symbol sharing.

• Disadvantages of using TI PRU Assembler over PASM • Have to learn new directives if already used to PASM • TI PRU assembler requires more command line options and a linker command file. • Some porting effort required for reusing legacy PASM projects.

There are some differences in the instructions and directives supported TI PRU Assembler versus PASM. Theses are listed in the TI PRU Compiler package release notes which is located at the root of the install folder.

Page 6: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

6

TI PRU CGT Assembly vs C

• Advantages of coding in Assembly over C – Code can be tweaked to save every last cycle and byte of RAM – No need to rely on the compiler to make code deterministic – Easily make use of scratchpad

• Advantages of coding in C over Assembly – More code reusability – Can directly leverage kernel headers for interaction with kernel drivers – Optimizer is extremely intelligent at optimizing routines

• “Accelerating” math via MAC unit, implementing LOOP instruction, etc. – Not mutually exclusive - inline Assembly can be easily added to a C project

Page 7: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

7

Coding Considerations

• There are some “tricks” we have to use to get the compiler to perform some operations – Variables have to be “mapped” to Constant Table entries – The compiler will automatically use the MAC unit if the --hardware_mac

switch is passed to it – Optimization can be tricky; be sure to mark variables that can change via

outside forces (e.g., host, other PRU core) as volatile

Page 8: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

8

Coding Considerations

• There are also some limitations – The C environment does not know that the final eight CT registers have a

variable offset, and thus that feature cannot be easily utilized – The compiler does not currently use the scratchpad for register state saving

• This support is tentatively planned for a future CGT release

Page 9: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

9

PRU Register Header Files

Page 10: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

10

PRU Register Headers • Created to make accessing a register easier

– Register names match those in documentation

• Code Completion feature in CCS automatically lists all members

• Developed to allow a user to program at the register-level or at a bit-field level – Note that bit-field accesses could potentially cause some issues with other

C compilers (e.g., gcc), but register-level shouldn’t • PRU cregister mechanism used to leverage constants table when possible.

• Currently provides definition for the following: • PRU INTC • PRU Config • PRU IEP

• PRU Control • PRU ECAP • PRU UART

Page 11: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

11

PRU Register Headers Layout

11

• Excerpt from config.h – Access register directly

pruCfg.SYSCFG – Or access specific bitfields

CT_CFG.SYSCFG_bit.STANDBY_INIT

• Example of how to use in C file – #include the specific header – Map the constant table entry to

register structures – Access registers or fields

Page 12: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

12

Development and Debug Options

Page 13: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

13

Development

• In CCS – Download and install PRU CGT package via App Center – Open or create new PRU projects just like with any other device – Code completion helps make register accesses easier

• The Downside – Is more difficult to debug while Linux kernel and user application also

running concurrently

Page 14: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

14

Development

• Outside of CCS – Code in your favorite text editor, build via command line

• Linux and Windows packages available – May be easier to script/automate different processes (build or otherwise)

• The Downside – Can be difficult to debug PRU code – Lacks CodeCompletion

Page 15: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

15

Debug

• In CCS – Easy to view register and variable contents – Access to breakpoints and simply stepping mechanism

• Outside CCS – Minimal debug control, but some debugfs control provided through

remoteproc – Start, halt, single-stepping is all console-based

• Clunky when done by hand, but can potentially be scripted

Page 16: Building Blocks for PRU Developmentprocessors.wiki.ti.com/images/b/b5/Sitara_boot... · Author: Texas Instruments ®, Sitara™ ARM ® Processors Building Blocks for PRU Development

16

Thank you!

For more information about the PRU, visit:

Presentation Home – www.ti.com/sitarabootcamp

PRU-ICSS Wiki – http://processors.wiki.ti.com/index.php/PRU-ICSS

PRU Evaluation Hardware – http://www.ti.com/tool/PRUCAPE

Support – http://e2e.ti.com