├── swig ├── using_swig.md ├── extconf.rb ├── pruss.i ├── binding.gyp ├── README.md └── generate.sh ├── prussd ├── prussd.conf └── prussd.service ├── drivers ├── pruss_api.ko ├── rpmsg_client_sample.ko ├── test_example_rpmsg │ ├── PRU1 │ │ ├── am335x-pru0-fw │ │ ├── am335x-pru1-fw │ │ ├── gen2 │ │ │ ├── main.object │ │ │ ├── am335x-pru1-fw │ │ │ ├── PRU_RPMsg_Echo_Interrupt1.out │ │ │ └── main.pp │ │ ├── Makefile │ │ └── AM335x_PRU.cmd │ └── PRU0 │ │ ├── main.c │ │ ├── resource_table_empty.h │ │ └── AM335x_PRU.cmd ├── Makefile └── rpmsg_client_sample.c ├── Documentation ├── uml.png ├── workflow.jpg ├── beagle_logo.png ├── cpp-bindings-uml.jpg ├── stepper_driver-uml.jpg └── SWIG.md ├── examples ├── firmware_examples │ ├── example6-memory-debug │ │ ├── Makefile │ │ └── mem_debug.c │ ├── example4-analog-wave-gen │ │ ├── PRU0 │ │ │ ├── am335x-pru0-fw │ │ │ ├── main_pru0.c │ │ │ ├── resource_table_empty.h │ │ │ └── AM335x_PRU.cmd │ │ ├── README.md │ │ ├── userspace_pwm.py │ │ ├── userspace.cpp │ │ ├── userspace1.cpp │ │ ├── Makefile │ │ └── PRU1 │ │ │ ├── Makefile │ │ │ └── AM335x_PRU.cmd │ ├── example1-usr3-blinky │ │ ├── setup.sh │ │ ├── hello.c │ │ ├── resource_table_empty.h │ │ ├── README.md │ │ ├── Makefile │ │ └── AM335x_PRU.cmd │ ├── example9-multichannel-waveform-gen │ │ ├── PRU0 │ │ │ ├── am335x-pru0-fw │ │ │ ├── main_pru0.c │ │ │ ├── README.md │ │ │ ├── resource_table_empty.h │ │ │ └── waveform_gen-2ch.asm │ │ ├── README.md │ │ ├── userspace_pwm.py │ │ ├── PRU1 │ │ │ └── Makefile │ │ └── Makefile │ ├── example8-multiple-assembly-calls │ │ ├── userspace.cpp │ │ ├── README.md │ │ ├── Makefile │ │ └── PRU0 │ │ │ ├── assembly2.asm │ │ │ ├── assembly3.asm │ │ │ ├── assembly1.asm │ │ │ ├── resource_table_empty.h │ │ │ └── pru0.c │ ├── example3-pwm │ │ ├── pwm-assembly │ │ │ ├── PRU0 │ │ │ │ ├── main_pru0.c │ │ │ │ ├── resource_table_empty.h │ │ │ │ ├── pru-asm-pwm.asm │ │ │ │ └── AM335x_PRU.cmd │ │ │ ├── userspace_pwm.py │ │ │ ├── userspace.cpp │ │ │ ├── Makefile │ │ │ └── PRU1 │ │ │ │ ├── Makefile │ │ │ │ └── AM335x_PRU.cmd │ │ ├── archive-pwm-c │ │ │ ├── pwm.c │ │ │ ├── userspace_pwm2.c │ │ │ ├── resource_table_empty.h │ │ │ ├── pwm2.c │ │ │ ├── Makefile │ │ │ └── AM335x_PRU.cmd │ │ └── README.md │ ├── example2-rpmsg-pru1 │ │ ├── userspace.cpp │ │ ├── README.md │ │ ├── PRU0 │ │ │ ├── main.c │ │ │ ├── Makefile │ │ │ ├── resource_table_empty.h │ │ │ └── AM335x_PRU.cmd │ │ ├── Makefile │ │ └── PRU1 │ │ │ ├── Makefile │ │ │ └── AM335x_PRU.cmd │ ├── example5-multichannel-pwm │ │ ├── Makefile │ │ ├── README.md │ │ ├── userspace.cpp │ │ ├── multich-pwm-c │ │ │ ├── multi.c │ │ │ ├── resource_table_empty.h │ │ │ └── Makefile │ │ ├── PRU0 │ │ │ ├── resource_table_empty.h │ │ │ ├── main_pru0.c │ │ │ └── AM335x_PRU.cmd │ │ └── PRU1 │ │ │ ├── Makefile │ │ │ └── AM335x_PRU.cmd │ ├── example7-stepper-control │ │ ├── PRU0 │ │ │ ├── resource_table_empty.h │ │ │ ├── main_pru0.c │ │ │ ├── pulse-supply.asm │ │ │ └── AM335x_PRU.cmd │ │ ├── user_test.cpp │ │ ├── archive_userspace.cpp │ │ ├── driver_lib.h │ │ ├── Makefile │ │ └── PRU1 │ │ │ └── Makefile │ └── example1-gpio-blinky │ │ ├── PRU_gpioToggle.c │ │ ├── resource_table_empty.h │ │ ├── Makefile │ │ └── AM335x_PRU.cmd ├── node-example │ ├── app │ │ └── bower.json │ ├── package.json │ ├── README.md │ └── server.js ├── README.md ├── include │ ├── types.h │ ├── ReadMe.txt │ ├── pru_virtio_ids.h │ └── pru_types.h ├── rpmsg_echo.cpp └── mem_read_write.cpp ├── node-bindings ├── util │ ├── errno.js │ └── sock.js ├── package.json ├── pruss.js └── pru.js ├── .codedocs ├── .gitignore ├── .travis.yml ├── cpp-bindings └── pruss.h └── install.sh /swig/using_swig.md: -------------------------------------------------------------------------------- 1 | ../Documentation/SWIG.md -------------------------------------------------------------------------------- /prussd/prussd.conf: -------------------------------------------------------------------------------- 1 | FIRMWARE=DIR/examples/firmware_examples 2 | RPMSG_CHANNELS= 3 | -------------------------------------------------------------------------------- /drivers/pruss_api.ko: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/drivers/pruss_api.ko -------------------------------------------------------------------------------- /Documentation/uml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/Documentation/uml.png -------------------------------------------------------------------------------- /swig/extconf.rb: -------------------------------------------------------------------------------- 1 | require 'mkmf' 2 | $libs = append_library($libs, "supc++") 3 | create_makefile('pruss') 4 | -------------------------------------------------------------------------------- /Documentation/workflow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/Documentation/workflow.jpg -------------------------------------------------------------------------------- /Documentation/beagle_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/Documentation/beagle_logo.png -------------------------------------------------------------------------------- /drivers/rpmsg_client_sample.ko: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/drivers/rpmsg_client_sample.ko -------------------------------------------------------------------------------- /swig/pruss.i: -------------------------------------------------------------------------------- 1 | %module pruss 2 | %{ 3 | #include "pruss.h" 4 | %} 5 | 6 | %include "std_string.i" 7 | %include "pruss.h" 8 | -------------------------------------------------------------------------------- /Documentation/cpp-bindings-uml.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/Documentation/cpp-bindings-uml.jpg -------------------------------------------------------------------------------- /Documentation/stepper_driver-uml.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/Documentation/stepper_driver-uml.jpg -------------------------------------------------------------------------------- /drivers/test_example_rpmsg/PRU1/am335x-pru0-fw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/drivers/test_example_rpmsg/PRU1/am335x-pru0-fw -------------------------------------------------------------------------------- /drivers/test_example_rpmsg/PRU1/am335x-pru1-fw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/drivers/test_example_rpmsg/PRU1/am335x-pru1-fw -------------------------------------------------------------------------------- /drivers/test_example_rpmsg/PRU1/gen2/main.object: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/drivers/test_example_rpmsg/PRU1/gen2/main.object -------------------------------------------------------------------------------- /drivers/test_example_rpmsg/PRU1/gen2/am335x-pru1-fw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/drivers/test_example_rpmsg/PRU1/gen2/am335x-pru1-fw -------------------------------------------------------------------------------- /swig/binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "pruss", 5 | "sources": [ "pruss.cpp", "pruss_wrap.cxx" ] 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /examples/firmware_examples/example6-memory-debug/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | g++ mem_debug.c ../../../cpp-bindings/pruss.cpp -o debug.o 3 | ./debug.o 4 | 5 | clean: 6 | rm debug.o 7 | -------------------------------------------------------------------------------- /examples/node-example/app/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prussapp", 3 | "version": "0.1.0", 4 | "dependencies": { 5 | "bootstrap": "~3.2.0", 6 | "jquery": "3" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /drivers/test_example_rpmsg/PRU1/gen2/PRU_RPMsg_Echo_Interrupt1.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/drivers/test_example_rpmsg/PRU1/gen2/PRU_RPMsg_Echo_Interrupt1.out -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | # Instructions to Run 4 | 5 | After installing the project:- 6 | 7 | - `cd` into the specific example in the `firmware_examples/` directory and run `make`. 8 | -------------------------------------------------------------------------------- /examples/firmware_examples/example4-analog-wave-gen/PRU0/am335x-pru0-fw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/examples/firmware_examples/example4-analog-wave-gen/PRU0/am335x-pru0-fw -------------------------------------------------------------------------------- /node-bindings/util/errno.js: -------------------------------------------------------------------------------- 1 | errno = { 2 | EPERM: -1, 3 | ENOENT: -2, 4 | EACCES: -13, 5 | ENODEV: -19, 6 | EINVAL: -22, 7 | ETIME: -62, 8 | EALREADY: 114 9 | } 10 | 11 | module.exports = errno; 12 | -------------------------------------------------------------------------------- /examples/firmware_examples/example1-usr3-blinky/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export PRUN=1 3 | export TARGET=hello 4 | echo PRUN=$PRUN 5 | echo TARGET=$TARGET 6 | 7 | echo none > /sys/class/leds/beaglebone\:green\:usr3/trigger 8 | -------------------------------------------------------------------------------- /examples/firmware_examples/example9-multichannel-waveform-gen/PRU0/am335x-pru0-fw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pratimugale/PRUSS-Bindings/HEAD/examples/firmware_examples/example9-multichannel-waveform-gen/PRU0/am335x-pru0-fw -------------------------------------------------------------------------------- /examples/node-example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodepruss-example", 3 | "main": "server.js", 4 | "dependencies": { 5 | "express": "~4.0.0", 6 | "body-parser": "~1.0.1", 7 | "pruss": "../../node-bindings" 8 | } 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /examples/firmware_examples/example8-multiple-assembly-calls/userspace.cpp: -------------------------------------------------------------------------------- 1 | #include "pruss.h" 2 | 3 | using namespace std; 4 | 5 | int main(){ 6 | PRUSS& p = PRUSS::get(); 7 | 8 | PRU p0 = p.pru0; 9 | 10 | p0.enable(); 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/pwm-assembly/PRU0/main_pru0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "resource_table_empty.h" 4 | 5 | #define PRU_SHARED 0x00010000 6 | 7 | extern void start(void); 8 | 9 | void main(void){ 10 | start(); 11 | } 12 | -------------------------------------------------------------------------------- /examples/firmware_examples/example9-multichannel-waveform-gen/PRU0/main_pru0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "resource_table_empty.h" 5 | 6 | extern void start(void); 7 | 8 | void main(void){ 9 | 10 | start(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /node-bindings/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pruss", 3 | "version": "0.1.0", 4 | "description": "Bindings to interact with the PRUs on the BeagleBone", 5 | "main": "pruss.js", 6 | "keywords": [ 7 | "PRU", 8 | "PRUSS", 9 | "remoteproc" 10 | ], 11 | "author": "Muneeb Mohammed", 12 | "license": "GPL-3.0" 13 | } 14 | -------------------------------------------------------------------------------- /examples/firmware_examples/example4-analog-wave-gen/PRU0/main_pru0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "resource_table_empty.h" 5 | 6 | extern void start(void); 7 | 8 | void main(void){ 9 | 10 | // Start the execution of the pulse-supply.asm prgram endlessly 11 | start(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /node-bindings/util/sock.js: -------------------------------------------------------------------------------- 1 | const net = require('net'); 2 | const SOCKFILE = '/tmp/prussd.sock' 3 | 4 | function socketSend(message, callback) { 5 | const client = net.createConnection(SOCKFILE, () => { 6 | client.write(message+'\n'); 7 | client.end(); 8 | }) 9 | .on('data', (data) => { 10 | callback(data.toString()) 11 | }) 12 | } 13 | 14 | module.exports = socketSend; 15 | -------------------------------------------------------------------------------- /examples/include/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * types.h - standard redefined types 3 | */ 4 | 5 | #ifndef _TYPES_H_ 6 | #define _TYPES_H_ 7 | 8 | typedef uint8_t __u8; 9 | typedef uint16_t __u16; 10 | typedef uint32_t __u32; 11 | typedef uint64_t __u64; 12 | 13 | typedef uint8_t u8; 14 | typedef uint16_t u16; 15 | typedef uint32_t u32; 16 | typedef uint64_t u64; 17 | 18 | #endif /* _TYPES_H_ */ 19 | -------------------------------------------------------------------------------- /prussd/prussd.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Daemon Service to serve PRU access requests for non-root processes 3 | ConditionPathExists=|DIR 4 | 5 | [Service] 6 | WorkingDirectory=DIR/prussd 7 | ExecStart=DIR/prussd/prussd.py 8 | ExecStopPost=/bin/sh -c 'rm /tmp/prussd.sock' 9 | Restart=on-failure 10 | StandardOutput=null 11 | 12 | [Install] 13 | WantedBy=multi-user.target 14 | Alias=prussd.service 15 | -------------------------------------------------------------------------------- /examples/firmware_examples/example9-multichannel-waveform-gen/PRU0/README.md: -------------------------------------------------------------------------------- 1 | # NOTE 2 | 3 | The assembly files which are used are: 4 | 1. 8-channel: `waveform_gen.asm` 5 | 2. 4-channel: `waveform_gen-4ch.asm` 6 | 3. 3-channel: `waveform_gen-2ch.asm` 7 | 8 | The following files are temporary/archive versions: 9 | 1. `waveform_gen-test.asm` 10 | 2. `temp.asm` 11 | 3. `waveform_gen-test.asm` 12 | 4. `archive-pulse-supply.asm` 13 | -------------------------------------------------------------------------------- /examples/firmware_examples/example2-rpmsg-pru1/userspace.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "pruss.h" 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | PRUSS& p = PRUSS::get(); 9 | PRU p1 = p.pru1; 10 | p1.enable(); 11 | 12 | string s; 13 | cout << "Enter a message : "; 14 | getline(cin, s); 15 | p1.sendMsg_string(s); 16 | 17 | cout << "Message from PRU : "<< p1.getMsg(); 18 | p1.disable(); 19 | p.shutDown(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /examples/firmware_examples/example5-multichannel-pwm/Makefile: -------------------------------------------------------------------------------- 1 | all: clean install 2 | 3 | install: 4 | @config-pin P9-28 pruout 5 | @config-pin P9-29 pruout 6 | @config-pin P9-30 pruout 7 | @config-pin P9-31 pruout 8 | @cd ./PRU0/ && make 9 | @cd ./PRU0/ && sudo make install 10 | @cd ./PRU1/ && make 11 | @g++ userspace.cpp ../../../cpp-bindings/pruss.cpp 12 | @./a.out 13 | 14 | clean: 15 | @cd ./PRU0/ && make clean 16 | @cd ./PRU1/ && make clean 17 | -------------------------------------------------------------------------------- /examples/node-example/README.md: -------------------------------------------------------------------------------- 1 | # Instructions to run the server example 2 | 3 | Clone the repository and cd into the node-example directory 4 | ``` 5 | git clone https://github.com/MuneebMohammed/PRUSS-Bindings.git 6 | cd examples/node-example/ 7 | ``` 8 | Run npm install and start the server 9 | ``` 10 | npm install 11 | node server.js 12 | ``` 13 | The server should be started on `192.168.7.2:8088` 14 | Go to the address in the browser and play with the demo app 15 | -------------------------------------------------------------------------------- /examples/rpmsg_echo.cpp: -------------------------------------------------------------------------------- 1 | #include "../cpp-bindings/pruss.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | PRUSS& p = PRUSS::get(); 9 | PRU p1 = p.pru1; 10 | p1.enable(); 11 | /*if(!p0.load("./firmware_examples/rpmsg_echo/gen/rpmsg_echo.out")) 12 | cout << "Firmware loaded\n"; 13 | else 14 | return -1;*/ 15 | string s; 16 | cout << "Enter a message: "; 17 | getline(cin, s); 18 | p1.sendMsg_string(s); 19 | cout << "Loopback : "<< p1.getMsg(); 20 | p1.disable(); 21 | p.shutDown(); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /examples/firmware_examples/example2-rpmsg-pru1/README.md: -------------------------------------------------------------------------------- 1 | # RPMsg 2 | 3 | This example demonstrates an RPMsg loopback program on the BBB.
4 | 5 | Debian Version: BeagleBoard.org Debian Image 2018-10-07 (use `$ cat /etc/issue` to find)
6 | Kernel Version: 4.14.71-r80 (`$ uname -r`) 7 | 8 | Installation:
9 | `sudo make` 10 | 11 | This example comes installed with `pruapi_1.0-1_armhf.deb` in [releases](https://github.com/pratimugale/PRUSS-Bindings/releases)
12 | Go to `/usr/bin` and run `$ ./userspace.o` if installation is done from the .deb package. 13 | -------------------------------------------------------------------------------- /examples/firmware_examples/example4-analog-wave-gen/README.md: -------------------------------------------------------------------------------- 1 | # Analog Wave Generator 2 | 3 | The PWM code can be modified to generate analog-like waveforms by altering the PWM duty-cycle rapidly over time. This is because the PWM frequency can be very fast due to the 200 MHz PRU. The code will output any periodic waveform that is passed to it, with a maximum periodic sample length of about 12KB(PRU SRAM) in this example. The program can be stopped by echoing stop in the appropriate sysfs entry(I'm not using a button interrupt to stop the execution). 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /examples/firmware_examples/example5-multichannel-pwm/README.md: -------------------------------------------------------------------------------- 1 | # Software Generation of Multichannel PWM. 2 | 3 | Software generation of PWM requires a certain amount of processing time to manage the signal level decision process, so it is only suitable for low base frequency waveform generation. 4 | Signals of this type are suitable for DC control applications such as LED or lamp intensity control, brush-type DC motor speed control, analogue meter driving, or any situation requiring a low-dynamic DC control voltage. 5 | 6 | Since the PRU can operate at a considerably high frequency, multiple channels can be generated with good precision. 7 | -------------------------------------------------------------------------------- /examples/firmware_examples/example9-multichannel-waveform-gen/README.md: -------------------------------------------------------------------------------- 1 | # Multi-Channel Waveform Generator. 2 | 3 | ## Current Progress: 8-channel 4 | 5 | Output Videos: 6 | 1. [https://www.youtube.com/watch?v=0COg9I88yyQ](https://www.youtube.com/watch?v=0COg9I88yyQ): Sine waves being at a 180 degree phase difference
7 | 2. [://www.youtube.com/watch?v=WIY_7yH4kKo](https://www.youtube.com/watch?v=WIY_7yH4kKo): y = sin(x) and y = x periodic waveform 8 | 9 | The sample values of two waveforms are interweaved together in the PRU SRAM. 10 | PRU0 - Creates different waveforms on different channels using PWM 11 | PRU1 - For sample values transfer. 12 | -------------------------------------------------------------------------------- /.codedocs: -------------------------------------------------------------------------------- 1 | IMAGE_PATH = Documentation/ 2 | HTML_EXTRA_FILES = Documentation/workflow.jpg 3 | USE_MDFILE_AS_MAINPAGE = README.md 4 | HTML_EXTRA_FILES = Documentation/workflow.jpg 5 | PROJECT_NAME = "PRU User Space API" 6 | PROJECT_NUMBER = v1.0.0 7 | PROJECT_BRIEF = "An API to control the BeagleBone PRUs using the RemoteProc and RPMsg framework." 8 | PROJECT_LOGO = Documentation/beagle_logo.png 9 | INPUT = README.md cpp-bindings/ 10 | RECURSIVE = YES 11 | FILE_PATTERNS = *.md \ 12 | *.cpp \ 13 | *.h 14 | EXCLUDE_PATTERNS = *.c \ 15 | *.py 16 | MARKDOWN_SUPPORT = YES 17 | -------------------------------------------------------------------------------- /drivers/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for compiling out-of-tree 2 | # Install Linux Headers first by "sudo apt install linux-headers-`uname -r`" 3 | # Headers should install in /usr/src 4 | 5 | KDIR := /lib/modules/$(shell uname -r)/build 6 | 7 | obj-m += rpmsg_client_sample.o 8 | obj-m += pruss_api.o 9 | 10 | all: 11 | $(MAKE) -C $(KDIR) M=$$PWD 12 | 13 | install: 14 | scp hello*.ko bone:. 15 | 16 | print: 17 | @echo KERNELRELEASE= $(KERNELRELEASE) 18 | @echo CONFIG_EXAMPLES= $(CONFIG_EXAMPLES) 19 | @echo obj-m= $(obj-m) 20 | 21 | clean: 22 | rm -rf .tmp_versions *.o 23 | rm -rf .rpmsg_client_sample* rpmsg_client_sample*.mod.c 24 | rm -rf .rpmsg_pru* rpmsg_pru*.mod.c 25 | rm modules.order Module.symvers .built-in.o.cmd 26 | -------------------------------------------------------------------------------- /examples/firmware_examples/example8-multiple-assembly-calls/README.md: -------------------------------------------------------------------------------- 1 | # Calling multiple .asm files from C-program 2 | 3 | ## Some background details: 4 | 5 | 1. The `clpru` compiler uses C/C++ code to generate assembly language code. 6 | 2. The assembler built into `clpru` translates assembly language code into machine object (.object) files. 7 | 3. The `lnkpru` linker combines the object files into a single executable object file (.out). 8 | 4. The generated `.out` file can be executed directly on a PRU device. To do so on a BB, it must be renamed to `am335x-pru0-fw` or `am335x-pru1-fw` and placed in the `/lib/firmware` directory. 9 | 5. On starting the PRU, it will be loaded with the respective firmware in this `/lib/firmware` directory. 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Binary files 10 | *.o 11 | 12 | # Swig Intermediate Files 13 | *_wrap.c 14 | *_wrap.cxx 15 | *.gch 16 | *.swp 17 | 18 | gen/ 19 | 20 | # Perl module 21 | *.pm 22 | 23 | # Node modules and packages 24 | bower_components/ 25 | node_modules/ 26 | 27 | # Distribution / Packaging 28 | .Python 29 | build/ 30 | develop-eggs/ 31 | dist/ 32 | downloads/ 33 | eggs/ 34 | .eggs/ 35 | lib64/ 36 | parts/ 37 | sdist/ 38 | var/ 39 | wheels/ 40 | *.egg-info/ 41 | .installed.cfg 42 | *.egg 43 | MANIFEST 44 | *.project 45 | *.cproject 46 | *.ccsproject 47 | *.settings/ 48 | 49 | # Vim temporary files: 50 | *.swo 51 | *.swp 52 | *.swn 53 | *.swm 54 | 55 | # My temp output file 56 | a.out 57 | -------------------------------------------------------------------------------- /drivers/test_example_rpmsg/PRU1/gen2/main.pp: -------------------------------------------------------------------------------- 1 | gen/main.object: main.c 2 | gen/main.object: /usr/share/ti/cgt-pru//include/stdint.h 3 | gen/main.object: /usr/share/ti/cgt-pru//include/stdio.h 4 | gen/main.object: /usr/share/ti/cgt-pru//include/linkage.h 5 | gen/main.object: /usr/share/ti/cgt-pru//include/stdarg.h 6 | gen/main.object: ../../../../../include/am335x/pru_cfg.h 7 | gen/main.object: ../../../../../include/am335x/pru_intc.h 8 | gen/main.object: ../../../../../include/rsc_types.h 9 | gen/main.object: ../../../../../include/pru_types.h 10 | gen/main.object: ../../../../../include/pru_rpmsg.h 11 | gen/main.object: ../../../../../include/pru_virtqueue.h 12 | gen/main.object: ../../../../../include/pru_virtio_ring.h 13 | gen/main.object: resource_table_1.h 14 | gen/main.object: /usr/share/ti/cgt-pru//include/stddef.h 15 | gen/main.object: ../../../../../include/pru_virtio_ids.h 16 | -------------------------------------------------------------------------------- /examples/include/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Programmable Real-time Unit (PRU) Software Support Package 2 | ------------------------------------------------------------ 3 | ============================================================ 4 | INCLUDE 5 | ============================================================ 6 | 7 | DESCRIPTION 8 | 9 | This directory provides header files for PRU firmware. 10 | 11 | For more details about these header files, visit: 12 | 13 | http://processors.wiki.ti.com/index.php/PRU-ICSS_Header_Files 14 | 15 | 16 | 17 | ADDITIONAL RESOURCES 18 | 19 | For more information about the PRU, visit: 20 | 21 | PRU-ICSS Wiki - http://processors.wiki.ti.com/index.php/PRU-ICSS 22 | PRU Training Slides - http://www.ti.com/sitarabootcamp 23 | PRU Evaluation Hardware - http://www.ti.com/tool/PRUCAPE 24 | Support - http://e2e.ti.com 25 | 26 | -------------------------------------------------------------------------------- /examples/firmware_examples/example1-usr3-blinky/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "resource_table_empty.h" 4 | 5 | #define GPIO1 0x4804C000 6 | #define GPIO_CLEARDATAOUT 0x190 7 | #define GPIO_SETDATAOUT 0x194 8 | #define USR0 (1<<21) 9 | #define USR1 (1<<22) 10 | #define USR2 (1<<23) 11 | #define USR3 (1<<24) 12 | unsigned int volatile * const GPIO1_CLEAR = (unsigned int *) (GPIO1 + GPIO_CLEARDATAOUT); 13 | unsigned int volatile * const GPIO1_SET = (unsigned int *) (GPIO1 + GPIO_SETDATAOUT); 14 | 15 | volatile register unsigned int __R30; 16 | volatile register unsigned int __R31; 17 | 18 | void main(void) { 19 | int i; 20 | 21 | /* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */ 22 | CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; 23 | 24 | for(i=0; i<5; i++) { 25 | *GPIO1_SET = USR3; // The the USR3 LED on 26 | __delay_cycles(500000000/5); // Wait 1/2 second 27 | 28 | *GPIO1_CLEAR = USR3; 29 | __delay_cycles(500000000/5); 30 | } 31 | __halt(); 32 | } 33 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/pwm-assembly/userspace_pwm.py: -------------------------------------------------------------------------------- 1 | # this program function must be added to the prussd.py daemon and then a seperate userspace program will be written in cpp 2 | 3 | import struct 4 | 5 | frequency = input("Frequency of PWM in Hz (from 1Hz to 1Mhz): ") 6 | multiplier = 1000000.0/frequency 7 | 8 | duty_cycle = input("Duty Cycle of PWM ") 9 | 10 | on_samples = duty_cycle * 100 11 | total_samples = 100 12 | 13 | on_samples *= multiplier 14 | total_samples *= multiplier 15 | 16 | print("On cycles: ", int(on_samples)) 17 | print("Total cycles: ", int(total_samples)) 18 | 19 | data = [int(on_samples), int(total_samples)] 20 | 21 | if isinstance(data[0], int): 22 | with open('/dev/rpmsg_pru31', 'wb') as f: 23 | f.write(struct.pack('i'*2, *data)) 24 | f.close() 25 | elif isinstance(value, str): 26 | with open('/dev/rpmsg_pru31', 'w') as f: 27 | f.write(data) 28 | f.close() 29 | else: 30 | raise TypeError('Can only write string or int') 31 | -------------------------------------------------------------------------------- /examples/firmware_examples/example4-analog-wave-gen/userspace_pwm.py: -------------------------------------------------------------------------------- 1 | # this program function must be added to the prussd.py daemon and then a seperate userspace program will be written in cpp 2 | 3 | import struct 4 | 5 | frequency = input("Frequency of PWM in Hz (from 1Hz to 1Mhz): ") 6 | multiplier = 1000000.0/frequency 7 | 8 | duty_cycle = input("Duty Cycle of PWM ") 9 | 10 | on_samples = duty_cycle * 100 11 | total_samples = 100 12 | 13 | on_samples *= multiplier 14 | total_samples *= multiplier 15 | 16 | print("On cycles: ", int(on_samples)) 17 | print("Total cycles: ", int(total_samples)) 18 | 19 | data = [int(on_samples), int(total_samples)] 20 | 21 | if isinstance(data[0], int): 22 | with open('/dev/rpmsg_pru31', 'wb') as f: 23 | f.write(struct.pack('i'*2, *data)) 24 | f.close() 25 | elif isinstance(value, str): 26 | with open('/dev/rpmsg_pru31', 'w') as f: 27 | f.write(data) 28 | f.close() 29 | else: 30 | raise TypeError('Can only write string or int') 31 | -------------------------------------------------------------------------------- /examples/firmware_examples/example9-multichannel-waveform-gen/userspace_pwm.py: -------------------------------------------------------------------------------- 1 | # this program function must be added to the prussd.py daemon and then a seperate userspace program will be written in cpp 2 | 3 | import struct 4 | 5 | frequency = input("Frequency of PWM in Hz (from 1Hz to 1Mhz): ") 6 | multiplier = 1000000.0/frequency 7 | 8 | duty_cycle = input("Duty Cycle of PWM ") 9 | 10 | on_samples = duty_cycle * 100 11 | total_samples = 100 12 | 13 | on_samples *= multiplier 14 | total_samples *= multiplier 15 | 16 | print("On cycles: ", int(on_samples)) 17 | print("Total cycles: ", int(total_samples)) 18 | 19 | data = [int(on_samples), int(total_samples)] 20 | 21 | if isinstance(data[0], int): 22 | with open('/dev/rpmsg_pru31', 'wb') as f: 23 | f.write(struct.pack('i'*2, *data)) 24 | f.close() 25 | elif isinstance(value, str): 26 | with open('/dev/rpmsg_pru31', 'w') as f: 27 | f.write(data) 28 | f.close() 29 | else: 30 | raise TypeError('Can only write string or int') 31 | -------------------------------------------------------------------------------- /examples/firmware_examples/example4-analog-wave-gen/userspace.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "pruss.h" 5 | 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | PRUSS& p = PRUSS::get(); 11 | PRU p1 = p.pru1; 12 | p1.enable(); // Starts PRU1 (rpmsg_pru31 character device file is created here) 13 | 14 | 15 | uint8_t i; 16 | uint8_t waveform[102]; 17 | float gain = 50.0f; 18 | float phase = 0.0f; 19 | float bias = 50.0f; 20 | float freq = 2.0f * 3.14159f / 100.0f; 21 | 22 | for (i = 0; i < 100; i++){ 23 | waveform[i] = (uint8_t)(bias + (gain * sin((i*freq) + phase))); 24 | } 25 | 26 | uint8_t samplestep = 1; //delay factor 27 | uint8_t numbersamples = 100; 28 | 29 | p1.sendMsg_raw(to_string(samplestep)); 30 | p1.sendMsg_raw(to_string(numbersamples)); 31 | 32 | for(i = 0; i < 100; i++){ 33 | p1.sendMsg_raw(to_string(waveform[i])); 34 | } 35 | 36 | p1.disable(); 37 | 38 | PRU p0 = p.pru0; 39 | p0.enable(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /examples/firmware_examples/example8-multiple-assembly-calls/Makefile: -------------------------------------------------------------------------------- 1 | all: clean install userspace 2 | 3 | install: 4 | @config-pin P9-31 pruout 5 | @config-pin P9-30 pruout 6 | @config-pin P9-29 pruout 7 | @echo '------------------------------------------------------------------------- ' 8 | @echo 'Compiling and Loading Firmware For PRU0' 9 | @cd ./PRU0/ && make 10 | @cd ./PRU0/ && sudo make install 11 | @echo '------------------------------------------------------------------------- ' 12 | 13 | userspace: 14 | @g++ userspace.cpp ../../../cpp-bindings/pruss.cpp -o multi-asm.o 15 | @echo '------------------------------------------------------------------------- ' 16 | @echo 'Running the UserSpace Program' 17 | @echo '------------------------------------------------------------------------- ' 18 | @./multi-asm.o 19 | @echo '------------------------------------------------------------------------- ' 20 | @echo 'Execution Complete' 21 | @echo '------------------------------------------------------------------------- ' 22 | 23 | clean: 24 | @cd ./PRU0/ && make clean 25 | -------------------------------------------------------------------------------- /examples/firmware_examples/example4-analog-wave-gen/userspace1.cpp: -------------------------------------------------------------------------------- 1 | #include "../../../cpp-bindings/pruss.h" 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | PRUSS& p = PRUSS::get(); 10 | PRU p1 = p.pru1; 11 | p1.enable(); // Starts PRU1 (rpmsg_pru31 character device file is created here) 12 | 13 | 14 | uint8_t i; 15 | uint8_t waveform[102]; 16 | float gain = 50.0f; 17 | float phase = 0.0f; 18 | float bias = 50.0f; 19 | float freq = 2.0f * 3.14159f / 100.0f; 20 | 21 | uint8_t samplestep = 1; //delay factor 22 | uint8_t numbersamples = 100; 23 | 24 | for (i = 0; i < 100; i++){ 25 | waveform[i+2] = (uint8_t)(bias + (gain * sin((i*freq) + phase))); 26 | } 27 | 28 | 29 | p1.sendMsg_raw(to_string(samplestep)); 30 | p1.sendMsg_raw(to_string(numbersamples)); 31 | 32 | for(i = 0; i < 100; i++){ 33 | p1.sendMsg_raw(to_string(waveform[i])); 34 | } 35 | 36 | p1.disable(); 37 | 38 | PRU p0 = p.pru0; 39 | p0.enable(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /swig/README.md: -------------------------------------------------------------------------------- 1 | # Swig 2 | Swig is a tool to generate language bindings. It can be used to create interfaces for C/C++ code in various languages. 3 | Also have a look at `using_swig.md` 4 | 5 | ## Description 6 | This directory contains the C++ code along with the Swig interface file to generate bindings for the PRUSS. 7 | * pruss.cpp : Contains the main PRU class along with Methods to interact with a PRU object. 8 | * pruss.h : The header file for the PRU class containing class definitions and include files. 9 | * pruss.i : [python, perl, lua] The Swig interface file which generates a wrapper for the PRU class. 10 | * binding.gyp : [nodejs] A JSON style file which node-gyp uses to generate swig wrapper for nodejs bindings. 11 | 12 | ## Instructions to generate bindings 13 | ### python 14 | ``` 15 | bash generate.sh -python 16 | ``` 17 | ### nodejs 18 | ``` 19 | bash generate.sh -nodejs 20 | ``` 21 | ### perl 22 | ``` 23 | bash generate.sh -perl 24 | ``` 25 | ### lua 26 | ``` 27 | bash generate.sh -lua 28 | ``` 29 | ### ruby 30 | ``` 31 | bash generate.sh -ruby 32 | ``` 33 | ### tcl 34 | ``` 35 | bash generate.sh -tcl 36 | ``` 37 | -------------------------------------------------------------------------------- /examples/firmware_examples/example8-multiple-assembly-calls/PRU0/assembly2.asm: -------------------------------------------------------------------------------- 1 | ;* Source written by Pratim Ugale 2 | ;* This example is used to control a stepper motor by sending out precise number of pulse trains at required frequency(RPM). 3 | ;* The 4 byte ON_Cycles input must be in memory location 0x00010000 - 0x00010003 in little-endian byte order 4 | ;* The 4 byte Total_Cycles input must be in memory location 0x00010004 - 0x00010007 in little endian byte order 5 | ;* The 4 byte Number of Pulses input must be in memory location 0x00010008 - 0x000100011 in little-endian byte order 6 | 7 | .cdecls "pru0.c" 8 | 9 | PRU_SRAM .set 0x00010000 ; Set the location of PRU Shared Memory 10 | 11 | .clink 12 | .global start2 13 | start2: ; One time setup. 14 | SET R30, R30.t0 15 | stop: 16 | ;SET R31, R31.t5 ; Strobe interrupt configured in main_pru0.c by setting bit 5 of R31 to HIGH 17 | JMP R3.w2 ; R3.w2 -> stores the return address. The main_pru0.c program will continue its normal execution after start(). 18 | -------------------------------------------------------------------------------- /examples/firmware_examples/example8-multiple-assembly-calls/PRU0/assembly3.asm: -------------------------------------------------------------------------------- 1 | ;* Source written by Pratim Ugale 2 | ;* This example is used to control a stepper motor by sending out precise number of pulse trains at required frequency(RPM). 3 | ;* The 4 byte ON_Cycles input must be in memory location 0x00010000 - 0x00010003 in little-endian byte order 4 | ;* The 4 byte Total_Cycles input must be in memory location 0x00010004 - 0x00010007 in little endian byte order 5 | ;* The 4 byte Number of Pulses input must be in memory location 0x00010008 - 0x000100011 in little-endian byte order 6 | 7 | .cdecls "pru0.c" 8 | 9 | PRU_SRAM .set 0x00010000 ; Set the location of PRU Shared Memory 10 | 11 | .clink 12 | .global start3 13 | start3: ; One time setup. 14 | SET R30, R30.t2 15 | stop: 16 | ;SET R31, R31.t5 ; Strobe interrupt configured in main_pru0.c by setting bit 5 of R31 to HIGH 17 | JMP R3.w2 ; R3.w2 -> stores the return address. The main_pru0.c program will continue its normal execution after start(). 18 | -------------------------------------------------------------------------------- /examples/firmware_examples/example8-multiple-assembly-calls/PRU0/assembly1.asm: -------------------------------------------------------------------------------- 1 | ;* Source written by Pratim Ugale 2 | ;* This example is used to control a stepper motor by sending out precise number of pulse trains at required frequency(RPM). 3 | ;* The 4 byte ON_Cycles input must be in memory location 0x00010000 - 0x00010003 in little-endian byte order 4 | ;* The 4 byte Total_Cycles input must be in memory location 0x00010004 - 0x00010007 in little endian byte order 5 | ;* The 4 byte Number of Pulses input must be in memory location 0x00010008 - 0x000100011 in little-endian byte order 6 | 7 | .cdecls "pru0.c" 8 | 9 | PRU_SRAM .set 0x00010000 ; Set the location of PRU Shared Memory 10 | 11 | .clink 12 | .global start1 13 | start1: ; One time setup. 14 | SET R30, R30.t1 15 | 16 | stop: 17 | ;SET R31, R31.t5 ; Strobe interrupt configured in main_pru0.c by setting bit 5 of R31 to HIGH 18 | JMP R3.w2 ; R3.w2 -> stores the return address. The main_pru0.c program will continue its normal execution after start(). 19 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/archive-pwm-c/pwm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "resource_table_empty.h" 4 | 5 | volatile register uint32_t __R30; 6 | volatile register uint32_t __R31; 7 | int i; 8 | 9 | void stall(int n){ 10 | for (i = 0; i < n; i++){ 11 | __delay_cycles(1); 12 | } 13 | } 14 | 15 | int calcCycles_D(float d, int offCycles){ 16 | int cycles; 17 | if (d < 1){ 18 | cycles = (int)((offCycles * d)/(1 - d)); 19 | return cycles; 20 | } 21 | else 22 | return 0; 23 | } 24 | 25 | int calcCycles_V(float v, int offCycles){ 26 | float duty_cycle = v/3.14; 27 | int cycles; 28 | if(duty_cycle < 1) 29 | cycles = calcCycles_D(duty_cycle, offCycles); 30 | else 31 | return 0; 32 | return cycles; 33 | } 34 | 35 | void main(void){ 36 | uint32_t gpio; 37 | 38 | CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; 39 | 40 | gpio = 0x0001; 41 | 42 | int offCycles = 10000; 43 | int onCycles = calcCycles_V(1.6, offCycles); 44 | 45 | while(1){ 46 | __R30 |= gpio; 47 | stall(onCycles); 48 | __R30 &= ~gpio; 49 | stall(offCycles); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /examples/mem_read_write.cpp: -------------------------------------------------------------------------------- 1 | #include "../cpp-bindings/pruss.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | PRUSS& p = PRUSS::get(); 9 | PRU p0 = p.pru0; 10 | //p0.enable(); 11 | /*if(!p1.load("/tmp/pru0-gen/pwm2.out")) 12 | cout << "Firmware loaded\n"; 13 | else 14 | return 1;*/ 15 | //p1.mem_read(); 16 | int x; 17 | string offset; 18 | string data; 19 | Memory mem = SHARED; 20 | 21 | cout<<"1: Read; 2: Write; 0: Exit"<>x; 23 | switch(x){ 24 | case 1: 25 | cout<< "Enter address offset"<>offset; 27 | cout<< "Data returned: "<>offset; 32 | cout<< "Enter data to be written"<>data; 34 | cout<< "Return Value: "< 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | PRUSS& p = PRUSS::get(); 9 | PRU p1 = p.pru1; 10 | p1.enable(); // Starts PRU1 (rpmsg_pru31 character device file is created here) 11 | 12 | // Input duty cycle is accurate to 2 decimal places. 13 | float dc[4]; 14 | for (int i = 0; i < 4; i++){ 15 | cout << "Duty Cycle" << i << ": in ((DC%)/100) form"<>dc[i]; 17 | } 18 | 19 | float multiplier = 100; 20 | 21 | float on_samples[4]; 22 | float off_samples[4]; 23 | 24 | for (int i = 0; i < 4; i++){ 25 | if (dc[i] > 0 && dc[i] < 1){ 26 | on_samples[i] = multiplier * dc[i]; 27 | off_samples[i] = 100 - (int)on_samples[i]; 28 | } 29 | 30 | else{ 31 | return -1; 32 | } 33 | } 34 | 35 | for (int i = 0; i < 4; i++){ 36 | p1.sendMsg_raw(to_string((int)on_samples[i])); 37 | p1.getMsg(); 38 | p1.sendMsg_raw(to_string((int)off_samples[i])); 39 | p1.getMsg(); 40 | } 41 | 42 | PRU p0 = p.pru0; 43 | p0.enable(); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/archive-pwm-c/userspace_pwm2.c: -------------------------------------------------------------------------------- 1 | #include "../cpp-bindings/pruss.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | PRUSS& p = PRUSS::get(); 9 | PRU p0 = p.pru0; 10 | p0.enable(); 11 | /*if(!p1.load("/tmp/pru0-gen/pwm2.out")) 12 | cout << "Firmware loaded\n"; 13 | else 14 | return 1;*/ 15 | //p1.mem_read(); 16 | int x; 17 | string offset; 18 | string data; 19 | Memory mem = SHARED; 20 | 21 | cout<<"1: Read; 2: Write; 0: Exit"<>x; 23 | switch(x){ 24 | case 1: 25 | cout<< "Enter address offset"<>offset; 27 | cout<< "Data returned: "<>offset; 32 | cout<< "Enter data to be written"<>data; 34 | cout<< "Return Value: "< 5 | #include 6 | #include "resource_table_empty.h" 7 | 8 | #define MAXCH 4 // Maximum number of channels 9 | 10 | volatile register uint32_t __R30; 11 | volatile register uint32_t __R31; 12 | 13 | void main(void) 14 | { 15 | uint32_t ch; 16 | uint32_t on[] = {1, 2, 3, 4}; // Number of cycles to stay on 17 | uint32_t off[] = {4, 3, 2, 1}; // Number to stay off 18 | uint32_t onCount[MAXCH]; // Current count 19 | uint32_t offCount[MAXCH]; 20 | 21 | /* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */ 22 | CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; 23 | 24 | // Initialize the channel counters. 25 | for(ch=0; ch { 12 | this._prus.forEach(pru => pru.disable()); 13 | }); 14 | } 15 | 16 | get isOn() { 17 | return this._on; 18 | } 19 | 20 | get pru() { 21 | return this._prus; 22 | } 23 | 24 | bootUp(cb) { 25 | if(this._on) 26 | return cb? cb(errno.EALREADY): errno.EALREADY; 27 | send('PROBE_RPROC', (ret) => { 28 | if(ret == 0) { 29 | this._on = true; 30 | this._prus.forEach((pru) => { 31 | send('DISABLE_'+pru._no, (ret) => { 32 | pru.setState('STOPPED'); 33 | }); 34 | }); 35 | } 36 | return cb? cb(ret): ret; 37 | }); 38 | } 39 | 40 | shutDown(cb) { 41 | if(!this._on) 42 | return cb? cb(errno.EALREADY): errno.EALREADY; 43 | this._prus.forEach(pru => pru.disable()); 44 | send('UNPROBE_RPROC', (ret) => { 45 | if(ret == 0){ 46 | this._on = false; 47 | this._prus.forEach(pru => pru.setState('NONE')); 48 | } 49 | return cb? cb(ret): ret; 50 | }); 51 | } 52 | 53 | restart(cb) { 54 | shutDown((ret) => { 55 | bootUp((ret) => { 56 | return cb? cb(ret): ret; 57 | }); 58 | }); 59 | } 60 | 61 | 62 | } 63 | 64 | module.exports = new PRUSS; 65 | -------------------------------------------------------------------------------- /examples/firmware_examples/example1-usr3-blinky/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ======== resource_table_empty.h ======== 3 | * 4 | * Define the resource table entries for all PRU cores. This will be 5 | * incorporated into corresponding base images, and used by the remoteproc 6 | * on the host-side to allocated/reserve resources. Note the remoteproc 7 | * driver requires that all PRU firmware be built with a resource table. 8 | * 9 | * This file contains an empty resource table. It can be used either as: 10 | * 11 | * 1) A template, or 12 | * 2) As-is if a PRU application does not need to configure PRU_INTC 13 | * or interact with the rpmsg driver 14 | * 15 | */ 16 | 17 | #ifndef _RSC_TABLE_PRU_H_ 18 | #define _RSC_TABLE_PRU_H_ 19 | 20 | #include 21 | #include 22 | 23 | struct my_resource_table { 24 | struct resource_table base; 25 | 26 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 27 | }; 28 | 29 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 30 | #pragma RETAIN(pru_remoteproc_ResourceTable) 31 | struct my_resource_table pru_remoteproc_ResourceTable = { 32 | 1, /* we're the first version that implements this */ 33 | 0, /* number of entries in the table */ 34 | 0, 0, /* reserved, must be zero */ 35 | 0, /* offset[0] */ 36 | }; 37 | 38 | #endif /* _RSC_TABLE_PRU_H_ */ 39 | 40 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/archive-pwm-c/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ======== resource_table_empty.h ======== 3 | * 4 | * Define the resource table entries for all PRU cores. This will be 5 | * incorporated into corresponding base images, and used by the remoteproc 6 | * on the host-side to allocated/reserve resources. Note the remoteproc 7 | * driver requires that all PRU firmware be built with a resource table. 8 | * 9 | * This file contains an empty resource table. It can be used either as: 10 | * 11 | * 1) A template, or 12 | * 2) As-is if a PRU application does not need to configure PRU_INTC 13 | * or interact with the rpmsg driver 14 | * 15 | */ 16 | 17 | #ifndef _RSC_TABLE_PRU_H_ 18 | #define _RSC_TABLE_PRU_H_ 19 | 20 | #include 21 | #include 22 | 23 | struct my_resource_table { 24 | struct resource_table base; 25 | 26 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 27 | }; 28 | 29 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 30 | #pragma RETAIN(pru_remoteproc_ResourceTable) 31 | struct my_resource_table pru_remoteproc_ResourceTable = { 32 | 1, /* we're the first version that implements this */ 33 | 0, /* number of entries in the table */ 34 | 0, 0, /* reserved, must be zero */ 35 | 0, /* offset[0] */ 36 | }; 37 | 38 | #endif /* _RSC_TABLE_PRU_H_ */ 39 | 40 | -------------------------------------------------------------------------------- /examples/firmware_examples/example4-analog-wave-gen/PRU0/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ======== resource_table_empty.h ======== 3 | * 4 | * Define the resource table entries for all PRU cores. This will be 5 | * incorporated into corresponding base images, and used by the remoteproc 6 | * on the host-side to allocated/reserve resources. Note the remoteproc 7 | * driver requires that all PRU firmware be built with a resource table. 8 | * 9 | * This file contains an empty resource table. It can be used either as: 10 | * 11 | * 1) A template, or 12 | * 2) As-is if a PRU application does not need to configure PRU_INTC 13 | * or interact with the rpmsg driver 14 | * 15 | */ 16 | 17 | #ifndef _RSC_TABLE_PRU_H_ 18 | #define _RSC_TABLE_PRU_H_ 19 | 20 | #include 21 | #include 22 | 23 | struct my_resource_table { 24 | struct resource_table base; 25 | 26 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 27 | }; 28 | 29 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 30 | #pragma RETAIN(pru_remoteproc_ResourceTable) 31 | struct my_resource_table pru_remoteproc_ResourceTable = { 32 | 1, /* we're the first version that implements this */ 33 | 0, /* number of entries in the table */ 34 | 0, 0, /* reserved, must be zero */ 35 | 0, /* offset[0] */ 36 | }; 37 | 38 | #endif /* _RSC_TABLE_PRU_H_ */ 39 | 40 | -------------------------------------------------------------------------------- /examples/firmware_examples/example7-stepper-control/PRU0/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ======== resource_table_empty.h ======== 3 | * 4 | * Define the resource table entries for all PRU cores. This will be 5 | * incorporated into corresponding base images, and used by the remoteproc 6 | * on the host-side to allocated/reserve resources. Note the remoteproc 7 | * driver requires that all PRU firmware be built with a resource table. 8 | * 9 | * This file contains an empty resource table. It can be used either as: 10 | * 11 | * 1) A template, or 12 | * 2) As-is if a PRU application does not need to configure PRU_INTC 13 | * or interact with the rpmsg driver 14 | * 15 | */ 16 | 17 | #ifndef _RSC_TABLE_PRU_H_ 18 | #define _RSC_TABLE_PRU_H_ 19 | 20 | #include 21 | #include 22 | 23 | struct my_resource_table { 24 | struct resource_table base; 25 | 26 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 27 | }; 28 | 29 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 30 | #pragma RETAIN(pru_remoteproc_ResourceTable) 31 | struct my_resource_table pru_remoteproc_ResourceTable = { 32 | 1, /* we're the first version that implements this */ 33 | 0, /* number of entries in the table */ 34 | 0, 0, /* reserved, must be zero */ 35 | 0, /* offset[0] */ 36 | }; 37 | 38 | #endif /* _RSC_TABLE_PRU_H_ */ 39 | 40 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/pwm-assembly/PRU0/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ======== resource_table_empty.h ======== 3 | * 4 | * Define the resource table entries for all PRU cores. This will be 5 | * incorporated into corresponding base images, and used by the remoteproc 6 | * on the host-side to allocated/reserve resources. Note the remoteproc 7 | * driver requires that all PRU firmware be built with a resource table. 8 | * 9 | * This file contains an empty resource table. It can be used either as: 10 | * 11 | * 1) A template, or 12 | * 2) As-is if a PRU application does not need to configure PRU_INTC 13 | * or interact with the rpmsg driver 14 | * 15 | */ 16 | 17 | #ifndef _RSC_TABLE_PRU_H_ 18 | #define _RSC_TABLE_PRU_H_ 19 | 20 | #include 21 | #include 22 | 23 | struct my_resource_table { 24 | struct resource_table base; 25 | 26 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 27 | }; 28 | 29 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 30 | #pragma RETAIN(pru_remoteproc_ResourceTable) 31 | struct my_resource_table pru_remoteproc_ResourceTable = { 32 | 1, /* we're the first version that implements this */ 33 | 0, /* number of entries in the table */ 34 | 0, 0, /* reserved, must be zero */ 35 | 0, /* offset[0] */ 36 | }; 37 | 38 | #endif /* _RSC_TABLE_PRU_H_ */ 39 | 40 | -------------------------------------------------------------------------------- /examples/firmware_examples/example5-multichannel-pwm/PRU0/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ======== resource_table_empty.h ======== 3 | * 4 | * Define the resource table entries for all PRU cores. This will be 5 | * incorporated into corresponding base images, and used by the remoteproc 6 | * on the host-side to allocated/reserve resources. Note the remoteproc 7 | * driver requires that all PRU firmware be built with a resource table. 8 | * 9 | * This file contains an empty resource table. It can be used either as: 10 | * 11 | * 1) A template, or 12 | * 2) As-is if a PRU application does not need to configure PRU_INTC 13 | * or interact with the rpmsg driver 14 | * 15 | */ 16 | 17 | #ifndef _RSC_TABLE_PRU_H_ 18 | #define _RSC_TABLE_PRU_H_ 19 | 20 | #include 21 | #include 22 | 23 | struct my_resource_table { 24 | struct resource_table base; 25 | 26 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 27 | }; 28 | 29 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 30 | #pragma RETAIN(pru_remoteproc_ResourceTable) 31 | struct my_resource_table pru_remoteproc_ResourceTable = { 32 | 1, /* we're the first version that implements this */ 33 | 0, /* number of entries in the table */ 34 | 0, 0, /* reserved, must be zero */ 35 | 0, /* offset[0] */ 36 | }; 37 | 38 | #endif /* _RSC_TABLE_PRU_H_ */ 39 | 40 | -------------------------------------------------------------------------------- /examples/firmware_examples/example5-multichannel-pwm/multich-pwm-c/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ======== resource_table_empty.h ======== 3 | * 4 | * Define the resource table entries for all PRU cores. This will be 5 | * incorporated into corresponding base images, and used by the remoteproc 6 | * on the host-side to allocated/reserve resources. Note the remoteproc 7 | * driver requires that all PRU firmware be built with a resource table. 8 | * 9 | * This file contains an empty resource table. It can be used either as: 10 | * 11 | * 1) A template, or 12 | * 2) As-is if a PRU application does not need to configure PRU_INTC 13 | * or interact with the rpmsg driver 14 | * 15 | */ 16 | 17 | #ifndef _RSC_TABLE_PRU_H_ 18 | #define _RSC_TABLE_PRU_H_ 19 | 20 | #include 21 | #include 22 | 23 | struct my_resource_table { 24 | struct resource_table base; 25 | 26 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 27 | }; 28 | 29 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 30 | #pragma RETAIN(pru_remoteproc_ResourceTable) 31 | struct my_resource_table pru_remoteproc_ResourceTable = { 32 | 1, /* we're the first version that implements this */ 33 | 0, /* number of entries in the table */ 34 | 0, 0, /* reserved, must be zero */ 35 | 0, /* offset[0] */ 36 | }; 37 | 38 | #endif /* _RSC_TABLE_PRU_H_ */ 39 | 40 | -------------------------------------------------------------------------------- /examples/firmware_examples/example8-multiple-assembly-calls/PRU0/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ======== resource_table_empty.h ======== 3 | * 4 | * Define the resource table entries for all PRU cores. This will be 5 | * incorporated into corresponding base images, and used by the remoteproc 6 | * on the host-side to allocated/reserve resources. Note the remoteproc 7 | * driver requires that all PRU firmware be built with a resource table. 8 | * 9 | * This file contains an empty resource table. It can be used either as: 10 | * 11 | * 1) A template, or 12 | * 2) As-is if a PRU application does not need to configure PRU_INTC 13 | * or interact with the rpmsg driver 14 | * 15 | */ 16 | 17 | #ifndef _RSC_TABLE_PRU_H_ 18 | #define _RSC_TABLE_PRU_H_ 19 | 20 | #include 21 | #include 22 | 23 | struct my_resource_table { 24 | struct resource_table base; 25 | 26 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 27 | }; 28 | 29 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 30 | #pragma RETAIN(pru_remoteproc_ResourceTable) 31 | struct my_resource_table pru_remoteproc_ResourceTable = { 32 | 1, /* we're the first version that implements this */ 33 | 0, /* number of entries in the table */ 34 | 0, 0, /* reserved, must be zero */ 35 | 0, /* offset[0] */ 36 | }; 37 | 38 | #endif /* _RSC_TABLE_PRU_H_ */ 39 | 40 | -------------------------------------------------------------------------------- /examples/firmware_examples/example9-multichannel-waveform-gen/PRU0/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ======== resource_table_empty.h ======== 3 | * 4 | * Define the resource table entries for all PRU cores. This will be 5 | * incorporated into corresponding base images, and used by the remoteproc 6 | * on the host-side to allocated/reserve resources. Note the remoteproc 7 | * driver requires that all PRU firmware be built with a resource table. 8 | * 9 | * This file contains an empty resource table. It can be used either as: 10 | * 11 | * 1) A template, or 12 | * 2) As-is if a PRU application does not need to configure PRU_INTC 13 | * or interact with the rpmsg driver 14 | * 15 | */ 16 | 17 | #ifndef _RSC_TABLE_PRU_H_ 18 | #define _RSC_TABLE_PRU_H_ 19 | 20 | #include 21 | #include 22 | 23 | struct my_resource_table { 24 | struct resource_table base; 25 | 26 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 27 | }; 28 | 29 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 30 | #pragma RETAIN(pru_remoteproc_ResourceTable) 31 | struct my_resource_table pru_remoteproc_ResourceTable = { 32 | 1, /* we're the first version that implements this */ 33 | 0, /* number of entries in the table */ 34 | 0, 0, /* reserved, must be zero */ 35 | 0, /* offset[0] */ 36 | }; 37 | 38 | #endif /* _RSC_TABLE_PRU_H_ */ 39 | 40 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/archive-pwm-c/pwm2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "resource_table_empty.h" 4 | #define PRU_SHARED 0x00010000 5 | 6 | volatile register uint32_t __R30; 7 | volatile register uint32_t __R31; 8 | int i; 9 | 10 | void stall(int n){ 11 | for (i = 0; i < n; i++){ 12 | __delay_cycles(1); 13 | } 14 | } 15 | 16 | int calcCycles_D(float d, int offCycles){ 17 | int cycles; 18 | if (d < 1){ 19 | cycles = (int)((offCycles * d)/(1 - d)); 20 | return cycles; 21 | } 22 | if (d == 1){ 23 | return -1; 24 | } 25 | else 26 | return -2; 27 | } 28 | 29 | int calcCycles_V(float v, int offCycles){ 30 | float duty_cycle = v/3.14; 31 | int cycles; 32 | if(duty_cycle < 1) 33 | cycles = calcCycles_D(duty_cycle, offCycles); 34 | else 35 | return 0; 36 | return cycles; 37 | } 38 | 39 | void main(void){ 40 | 41 | uint32_t gpio; 42 | 43 | CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; 44 | 45 | volatile int* buffer = (volatile int *) PRU_SHARED; 46 | 47 | gpio = 0x0001; 48 | 49 | int offCycles = 10000; 50 | 51 | while(1){ 52 | int onCycles = calcCycles_D(0.1*buffer[0], offCycles); 53 | if (onCycles == -1){ 54 | __R30 |= gpio; 55 | } 56 | else{ 57 | __R30 |= gpio; 58 | stall(onCycles); 59 | __R30 &= ~gpio; 60 | stall(offCycles); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/pwm-assembly/userspace.cpp: -------------------------------------------------------------------------------- 1 | #include "../../../../cpp-bindings/pruss.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | PRUSS& p = PRUSS::get(); 9 | PRU p1 = p.pru1; 10 | 11 | // Start PRU1 core which stores input values into PRU SRAM. 12 | p1.enable(); 13 | 14 | float frequency; 15 | cout << "Frequency of PWM in Hz (from 1Hz to 1MHz): "<>frequency; 17 | float multiplier = 1000000.0/frequency; 18 | 19 | float duty_cycle; 20 | cout<< "Duty Cycle of PWM (0 to 1)"<>duty_cycle; 22 | 23 | // Invalid Duty Cycle. 24 | if(duty_cycle > 1 || duty_cycle < 0){ 25 | return -1; 26 | } 27 | 28 | // Base values for highest frequency of 1MHz. 29 | float on_samples = duty_cycle * 100; 30 | float total_samples = 100; 31 | 32 | // Adjusted values for frequencies less than 1MHz 33 | on_samples *= multiplier; 34 | total_samples *= multiplier; 35 | 36 | cout<<"On Cycles/2 = "<<(int)on_samples< __R31 |= ((uint32_t) 1 << 30); 35 | // Globally enable host interrupts 36 | CT_INTC.GER = 1; 37 | } 38 | 39 | void main(void){ 40 | 41 | // Configure GPI and GPO as Mode0 - Direct Connect 42 | CT_CFG.GPCFG0 = 0x0000; 43 | 44 | configIntc(); 45 | 46 | start(); 47 | // All Pulses have now been sent 48 | 49 | PRU0_PRU1_TRIGGER; 50 | 51 | __halt(); 52 | } 53 | -------------------------------------------------------------------------------- /examples/firmware_examples/example7-stepper-control/user_test.cpp: -------------------------------------------------------------------------------- 1 | #include "driver_lib.h" 2 | #include 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main(){ 8 | Driver& d = Driver::get(); 9 | 10 | d.wake(); 11 | d.activateMotor(360.0, 170.0, FULL, ANTICLOCKWISE); // 360 degrees rotate at 60 RPM in Full Step mode, Anticlockwise direction 12 | d.activateMotor(360.0, 60.0, HALF, ANTICLOCKWISE); 13 | d.activateMotor(360.0, 60.0, QUARTER, ANTICLOCKWISE); 14 | d.activateMotor(360.0, 160.0, EIGHT, ANTICLOCKWISE); 15 | d.activateMotor(360.0, 60.0, EIGHT); // 360 degrees rotate at 60 RPM in 1/8th Step Mode, Clockwise direction 16 | d.activateMotor(360.0, 60.0, QUARTER); 17 | d.activateMotor(360.0, 60.0, HALF); 18 | d.activateMotor(360.0, 60.0, FULL); 19 | // To demonstrate sleeping - The motor should be able to freely rotate for 10 seconds 20 | d.sleep(); 21 | usleep(5000000); 22 | d.wake(); 23 | d.activateMotor(180.0, 150.0, EIGHT, ANTICLOCKWISE); 24 | d.activateMotor(180.0, 150.0, EIGHT, CLOCKWISE); 25 | d.activateMotor(270.0, 150.0, EIGHT, ANTICLOCKWISE); 26 | d.activateMotor(270.0, 150.0, EIGHT, CLOCKWISE); 27 | d.activateMotor(180.0, 150.0, EIGHT, ANTICLOCKWISE); 28 | d.activateMotor(180.0, 150.0, EIGHT, CLOCKWISE); 29 | d.activateMotor(270.0, 150.0, EIGHT, ANTICLOCKWISE); 30 | d.activateMotor(270.0, 150.0, EIGHT, CLOCKWISE); 31 | d.sleep(); 32 | usleep(5000000); 33 | d.wake(); 34 | 35 | // To demonstrate RPM accuracy for 150 rotations. 36 | d.activateMotor(360*150.0, 150.0, EIGHT, ANTICLOCKWISE); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /examples/firmware_examples/example8-multiple-assembly-calls/PRU0/pru0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include // Interrupt Controller 4 | #include "resource_table_empty.h" // Resource Table 5 | 6 | #define PRU_SHARED 0x00010000 // PRU Shared Memory Address 7 | 8 | volatile register uint32_t __R31; // Directly access R31 to generate interrupts 9 | 10 | #define PRU0_PRU1_EVT (16) // Defining PRU0 to PRU 1 Interrupt 11 | #define PRU0_PRU1_TRIGGER (__R31 = (PRU0_PRU1_EVT - 16) | (1 << 5)) 12 | 13 | extern void start1(void); 14 | extern void start2(void); 15 | extern void start3(void); 16 | 17 | /* INTC configuration 18 | * We are going to map User event 16 to Host 0 19 | * PRU1 will then wait for r31 bit 30 (designates Host 0) to go high 20 | * */ 21 | 22 | void configIntc(void) 23 | { 24 | /* Clear any pending PRU-generated events */ 25 | __R31 = 0x00000000; 26 | /* Map event 16 to channel 0 */ 27 | CT_INTC.CMR4_bit.CH_MAP_16 = 0; 28 | /* Map channel 0 to host 0 */ 29 | CT_INTC.HMR0_bit.HINT_MAP_0 = 0; 30 | /* Ensure event 16 is cleared */ 31 | CT_INTC.SICR = 16; 32 | /* Enable event 16 */ 33 | CT_INTC.EISR = 16; 34 | /* Enable Host interrupt 1 */ 35 | CT_INTC.HIEISR |= (0 << 0); 36 | // DON'T DO -> __R31 |= ((uint32_t) 1 << 30); 37 | // Globally enable host interrupts 38 | CT_INTC.GER = 1; 39 | } 40 | 41 | void main(void){ 42 | 43 | // Configure GPI and GPO as Mode0 - Direct Connect 44 | CT_CFG.GPCFG0 = 0x0000; 45 | 46 | configIntc(); 47 | 48 | start1(); 49 | start2(); 50 | start3(); 51 | // All Pulses have now been sent 52 | 53 | PRU0_PRU1_TRIGGER; 54 | 55 | __halt(); 56 | } 57 | -------------------------------------------------------------------------------- /examples/firmware_examples/example7-stepper-control/archive_userspace.cpp: -------------------------------------------------------------------------------- 1 | #include "../../../cpp-bindings/pruss.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | PRUSS& p = PRUSS::get(); 9 | PRU p1 = p.pru1; 10 | 11 | // Start PRU1 core which stores input values into PRU SRAM. 12 | p1.enable(); 13 | 14 | float frequency; 15 | cout << "Frequency of PWM in Hz (from 1Hz to 1MHz): "<>frequency; 17 | float multiplier = 1000000.0/frequency; 18 | 19 | float duty_cycle; 20 | cout<< "Duty Cycle of PWM (0 to 1): "<>duty_cycle; 22 | 23 | int numberOfPulses; 24 | cout<< "Number of pulses to be generated: "<>numberOfPulses; 26 | 27 | // Invalid Duty Cycle. 28 | if(duty_cycle > 1 || duty_cycle < 0){ 29 | return -1; 30 | } 31 | 32 | // Base values for highest frequency of 1MHz. 33 | float on_samples = duty_cycle * 100; 34 | float total_samples = 100; 35 | 36 | // Adjusted values for frequencies less than 1MHz 37 | on_samples *= multiplier; 38 | total_samples *= multiplier; 39 | 40 | cout<<"On Cycles/2 = "<<(int)on_samples< 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "pruss.h" 11 | 12 | #define MAX_FREQUENCY 1000000.0 13 | #define EXPECTED_MESSAGE "done\n" 14 | 15 | using namespace std; 16 | 17 | enum Direction{ 18 | CLOCKWISE = 0, 19 | ANTICLOCKWISE = 1 20 | }; 21 | 22 | enum StepMode{ 23 | // Microstepping modes and their equivalent "steps per rotation" aka "pulses per rotation" they consume. 24 | FULL = 200, 25 | HALF = 400, 26 | QUARTER = 800, 27 | EIGHT = 1600 28 | }; 29 | 30 | class Driver{ 31 | private: 32 | float degrees; 33 | float rpm; 34 | bool isMotorBusy = false; 35 | StepMode stepMode; 36 | Direction direction; 37 | bool asleep; 38 | int onCycles; 39 | int totalCycles; 40 | int noOfPulses; 41 | 42 | public: 43 | Driver(); 44 | 45 | void setStepMode(StepMode stepMode); 46 | StepMode getStepMode(); 47 | void setDirection(Direction direction); 48 | Direction getDirection(); 49 | bool getIsMotorBusy(); 50 | 51 | void calculateCycles(float degrees, float rpm); 52 | int activateMotor(float degrees = 360.0, float rpm = 60.0, StepMode stepMode = EIGHT, Direction direction = CLOCKWISE); 53 | void sleep(); 54 | void wake(); 55 | bool isAsleep(); 56 | 57 | PRUSS& p = PRUSS::get(); 58 | PRU p0 = p.pru0; 59 | PRU p1 = p.pru1; 60 | 61 | ~Driver(); 62 | 63 | static Driver& get(); 64 | static int i; // gets 0 initialized 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /drivers/test_example_rpmsg/PRU0/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 3 | * 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of Texas Instruments Incorporated nor the names of 18 | * its contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #include 35 | #include "resource_table_empty.h" 36 | 37 | int main(void) 38 | { 39 | __halt(); 40 | } 41 | -------------------------------------------------------------------------------- /examples/firmware_examples/example2-rpmsg-pru1/PRU0/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 3 | * 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of Texas Instruments Incorporated nor the names of 18 | * its contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #include 35 | #include "resource_table_empty.h" 36 | 37 | int main(void) 38 | { 39 | __halt(); 40 | } 41 | -------------------------------------------------------------------------------- /examples/firmware_examples/example1-usr3-blinky/README.md: -------------------------------------------------------------------------------- 1 | # Blinky example 2 | 3 | This example makes the USR3 LED on the BeagleBone Black to blink 5 times. 4 | The example is a minimal one which should demonstrate how the PRU firmware looks like. 5 | 6 | There are 4 essential files required for one PRU core while using the Remoteproc Framework: 7 | 8 | 1. The `AM335x_PRU.cmd` linker command file. 9 | 2. A resource table 10 | 3. The actual firmware written in C (can also use assemby) 11 | 4. The `Makefile` which uses `clpru` and `lnkpru` to compile the firmware using the above 3 files. 12 | 13 | The Makefile generates a number of files of which the `.out` elf binary file needs to be placed in `/lib/firmware` as `am335x-pru0-fw` or `am335x-pru1-fw` depending upon which core the firmware is meant for. 14 | 15 | Once placed in /lib/firmware, the PRU needs to be started by echoing into the appropriate sysfs entry. One such option is 16 | - `/sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*)` 17 | 18 | 19 | To debug the PRU or to use it in single_step mode, use:
`/sys/kernel/debug/remoteproc/remoteproc1/` for PRU0
`/sys/kernel/debug/remoteproc/remoteproc2/` for PRU0. 20 | 21 | There is also a third entry called `remoteproc0` in the remoteproc directory. **IT HAS NO ROLE IN CONTROLLING THE PRU-ICSS**. It relates to the Wakeup M3 (CM3) remoteproc driver that helps with low power tasks on the Cortex M3 co-processor in the AM33xx family of devices. 22 | 23 | To echo into these sysfs entries, `echo 1 > single_step` no longer works (I have seen this mentioned on the net). The reason being when you run echo with sudo the output is redirected by your command shell which hasn't got the privileges. One way around this would be :
`echo 1 | sudo tee single_step`,
or something like `sudo sh -c "echo out > /sys/class/gpio/gpio49/direction"` 24 | 25 | Note: The bind/unbind interfaces that were used before are no longer used and don't work. 26 | -------------------------------------------------------------------------------- /examples/firmware_examples/example6-memory-debug/mem_debug.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "pruss.h" 5 | 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | PRUSS& p = PRUSS::get(); 11 | PRU p0 = p.pru0; 12 | 13 | cout<<"1. View PRU Control and General Purpose Registers \n2. Perform PRU memory actions"<>input; 16 | 17 | if (input == 1){ 18 | cout<>x; 31 | switch(x){ 32 | case 1: 33 | mem = DATA0; 34 | cout<< "Base Location: 0x0000 0000"<>x; 50 | switch(x){ 51 | case 1: 52 | cout<< "Enter address offset"<>offset; 54 | cout<< "Data returned: "<>offset; 59 | cout<< "Enter data to be written"<>data; 61 | cout<< "Return Value: "< 2 | ;* This example generates a PWM signal and is capable of producing frequencies from 1 Hz to 1 MHz 3 | ;* The 4 byte ON_Cycles input must be in memory location 0x00010000 - 0x00010003 in little-endian byte order 4 | ;* The 4 byte Total_Cycles input must be in memory location 0x00010004 - 0x00010007 in little endian byte order 5 | 6 | .cdecls "main_pru0.c" 7 | 8 | PRU_SRAM .set 0x00010000 ; Set the location of PRU Shared Memory 9 | 10 | .clink 11 | .global start 12 | start: ; One time setup. 13 | LDI32 R10, PRU_SRAM ; R10 -> Base address of PRU SRAM 14 | SUB R1, R1, R1 ; Clear the contents of R1 15 | SUB R2, R2, R2 ; Clear the contents of R2 16 | LBBO &R1, R10, 0, 4 ; R1 -> Duty Cycle.(actually ON cycles); Copy (4) bytes into R1 from memory address R10+offset(0) 17 | LBBO &R2, R10, 4, 4 ; R2 -> Total Cycles. Copy (4) bytes into R2 from memory address R10+offset(5) 18 | LDI R0, 0 ; R0 - Total sample count (goes from 0 to 100 for 1MHz) 19 | QBA sample_start 20 | 21 | sample_start: ; 22 | SET R30, R30.t0 ; GPIO P9_31 ON 23 | sample_high: ; [Loop consuming 2 PRU cycles per iteration] 24 | ADD R0, R0, 0x00000001 ; Increment counter by 1 25 | QBNE sample_high, R0, R1 ; Repeat loop until ON_Cycles 26 | NOP 27 | NOP 28 | NOP 29 | CLR R30, R30.t0 ; GPIO P9_31 OFF 30 | sample_low: ; [Loop consuming 2 PRU cycles per iteration] 31 | ADD R0, R0, 0x00000001 ; Increment counter by 1 32 | QBNE sample_low, R0, R2 ; Repeat loop until Total Cycles 33 | SUB R0, R0, R0 ; Clear the counter register 34 | QBA sample_start ; One PWM cycle is completed. Repeat again for back to back pulses. 35 | 36 | HALT 37 | -------------------------------------------------------------------------------- /examples/firmware_examples/example2-rpmsg-pru1/Makefile: -------------------------------------------------------------------------------- 1 | all: clean pru0 pru1 userspace 2 | 3 | pru0: 4 | @cd ./PRU0/ && make 5 | @echo ' ------------------------------------------------------------------' 6 | @echo ' -------------------- PRU 0 FIRMWARE COMPILED --------------------' 7 | @echo ' ------------------------------------------------------------------' 8 | @cd ./PRU0/ && sudo make install 9 | @echo ' ------------------------------------------------------------------' 10 | @echo ' -------------------- PRU 0 FIRMWARE INSTALLED --------------------' 11 | @echo ' ------------------------------------------------------------------' 12 | 13 | pru1: 14 | @cd ./PRU1/ && make 15 | @echo ' ------------------------------------------------------------------' 16 | @echo ' -------------------- PRU 1 FIRMWARE COMPILED --------------------' 17 | @echo ' ------------------------------------------------------------------' 18 | @cd ./PRU1/ && make install 19 | @echo ' ------------------------------------------------------------------' 20 | @echo ' -------------------- PRU 1 FIRMWARE INSTALLED --------------------' 21 | @echo ' ------------------------------------------------------------------' 22 | 23 | userspace: 24 | @g++ userspace.cpp ../../../cpp-bindings/pruss.cpp -o userspace.o 25 | @echo ' ------------------------------------------------------------------' 26 | @echo ' --------------------UserSpace Program Compiled--------------------' 27 | @echo ' ------------------------------------------------------------------' 28 | @./userspace.o 29 | @echo ' ------------------------------------------------------------------' 30 | @echo ' -------------------- Completed Execution --------------------' 31 | @echo ' ------------------------------------------------------------------' 32 | 33 | clean: 34 | @echo ' ------------------------------------------------------------------' 35 | @echo ' -------------------- CLEAN --------------------' 36 | @echo ' ------------------------------------------------------------------' 37 | @cd ./PRU0/ && make clean 38 | @cd ./PRU1/ && make clean 39 | -------------------------------------------------------------------------------- /examples/firmware_examples/example5-multichannel-pwm/PRU0/main_pru0.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "resource_table_empty.h" 5 | 6 | #define PRU_SHARED 0x00010000 7 | 8 | static void *pruSharedMemory; 9 | static uint8_t *pruSharedMemory_uint8; 10 | 11 | extern void setup(void); 12 | 13 | void main(void){ 14 | 15 | setup(); 16 | // Write the duty cycles manually into the PRU SRAM. (Should later be done using RPMsg.) 17 | 18 | // int i; 19 | // uint8_t values[40]; 20 | 21 | // Duty Cycle values of the channels out of 10. 22 | uint8_t duty1 = 1; //10% DC 23 | uint8_t duty2 = 4; //40% DC 24 | uint8_t duty3 = 5; //50% DC 25 | uint8_t duty4 = 9; //90% DC 26 | 27 | /* for (i = 0; i < 40; i++){ 28 | if (i%4 == 0){ 29 | if (duty1 > 0){ 30 | values[i] = 1; 31 | duty1--; 32 | } 33 | else 34 | values[i] = 0; 35 | } 36 | if (i%4 == 1){ 37 | if (duty2 > 0){ 38 | values[i] = 1; 39 | duty2--; 40 | } 41 | else 42 | values[i] = 0; 43 | } 44 | if (i%4 == 2){ 45 | if (duty3 > 0){ 46 | values[i] = 1; 47 | duty3--; 48 | } 49 | else 50 | values[i] = 0; 51 | } 52 | if (i%4 == 3){ 53 | if (duty4 > 0){ 54 | values[i] = 1; 55 | duty4--; 56 | } 57 | else 58 | values[i] = 0; 59 | } 60 | }*/ 61 | 62 | //uint16_t* sram_pointer = (uint16_t *) PRU_SHARED; 63 | pruSharedMemory = (void *) PRU_SHARED; 64 | 65 | pruSharedMemory_uint8 = (uint8_t *)pruSharedMemory; 66 | 67 | /* for(i = 0; i < 40; i++){ 68 | *(pruSharedMemory_uint8 + i) = values[i]; 69 | }*/ 70 | 71 | *(pruSharedMemory_uint8) = duty1; 72 | *(pruSharedMemory_uint8 + 1) = duty2; 73 | *(pruSharedMemory_uint8 + 2) = duty3; 74 | *(pruSharedMemory_uint8 + 3) = duty4; 75 | 76 | //start(); 77 | } 78 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | 3 | os: 4 | -linux 5 | 6 | before_install: 7 | # - sudo apt-get update 8 | - wget -c https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/arm-linux-gnueabihf/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz 9 | - tar xf gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz 10 | - export PATH=$PATH:$PWD/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/ 11 | - arm-linux-gnueabihf-gcc --version 12 | - whereis systemctl 13 | - sudo dpkg -l | grep systemd 14 | - sudo apt-get install systemd 15 | 16 | 17 | script: 18 | # exporting the variable to be used by make utility 19 | - export ARCH=arm 20 | - export CROSS_COMPILE=arm-linux-gnueabihf- 21 | #- make 22 | 23 | - export DIR=$(pwd -P) 24 | 25 | #copy the systemd unit configuration file 26 | - sudo cp -v "${DIR}/prussd/prussd.service" "/lib/systemd/system/prussd.service" 27 | 28 | #copy the config file 29 | - sudo cp -v "${DIR}/prussd/prussd.conf" "/etc/default/prussd.conf" 30 | 31 | - echo $DIR 32 | 33 | - pwd 34 | 35 | #edit the unit file to replace DIR by the actual path 36 | - sudo sed -i -e "s:DIR:${DIR}:" "/lib/systemd/system/prussd.service" 37 | 38 | #edit the config file to include paths to firmware_examples 39 | - sudo sed -i -e "s:DIR:${DIR}:" "/etc/default/prussd.conf" 40 | 41 | #mark the daemon script as executable 42 | - chmod a+x "${DIR}/prussd/prussd.py" 43 | 44 | #enable the service 45 | - sudo systemctl enable prussd.service 46 | 47 | #reload the systemctl daemons 48 | - sudo systemctl daemon-reload 49 | 50 | #start the prussd daemon 51 | - sudo systemctl start prussd.service 52 | 53 | - sudo systemctl status prussd.service 54 | 55 | #make an example 56 | - export CC=arm-linux-gnueabihf-g++ 57 | - cd examples/firmware_examples/example9-multichannel-waveform-gen/ && ${CC} userspace.cpp ../../../cpp-bindings/pruss.cpp -o travis.o 58 | -------------------------------------------------------------------------------- /examples/firmware_examples/example7-stepper-control/Makefile: -------------------------------------------------------------------------------- 1 | all: clean config pru0 pru1 userspace 2 | 3 | config: 4 | @echo ' ------------------------------------------------------------------' 5 | @echo ' -------------------- SETTING PINMUX ---------------------' 6 | @echo ' ------------------------------------------------------------------' 7 | @config-pin P9-31 pruout 8 | 9 | pru0: 10 | @cd ./PRU0/ && make 11 | @echo ' ------------------------------------------------------------------' 12 | @echo ' -------------------- PRU 0 FIRMWARE COMPILED --------------------' 13 | @echo ' ------------------------------------------------------------------' 14 | @cd ./PRU0/ && sudo make install 15 | @echo ' ------------------------------------------------------------------' 16 | @echo ' -------------------- PRU 0 FIRMWARE INSTALLED --------------------' 17 | @echo ' ------------------------------------------------------------------' 18 | 19 | pru1: 20 | @cd ./PRU1/ && make 21 | @echo ' ------------------------------------------------------------------' 22 | @echo ' -------------------- PRU 1 FIRMWARE COMPILED --------------------' 23 | @echo ' ------------------------------------------------------------------' 24 | @cd ./PRU1/ && make install 25 | @echo ' ------------------------------------------------------------------' 26 | @echo ' -------------------- PRU 1 FIRMWARE INSTALLED --------------------' 27 | @echo ' ------------------------------------------------------------------' 28 | 29 | userspace: 30 | @g++ user_test.cpp driver_lib.cpp ../../../cpp-bindings/pruss.cpp -o userspace.o 31 | @echo ' ------------------------------------------------------------------' 32 | @echo ' --------------------UserSpace Program Compiled--------------------' 33 | @echo ' ------------------------------------------------------------------' 34 | @echo 'Started Executing Stepper Motor Commands' 35 | @./userspace.o 36 | @echo ' ------------------------------------------------------------------' 37 | @echo ' -------------------- Completed Execution --------------------' 38 | @echo ' ------------------------------------------------------------------' 39 | 40 | clean: 41 | @cd ./PRU0/ && make clean 42 | @cd ./PRU1/ && make clean 43 | -------------------------------------------------------------------------------- /examples/include/pru_virtio_ids.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_VIRTIO_IDS_H 2 | #define _LINUX_VIRTIO_IDS_H 3 | /* 4 | * Virtio IDs 5 | * 6 | * This header is BSD licensed so anyone can use the definitions to implement 7 | * compatible drivers/servers. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 3. Neither the name of IBM nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. */ 31 | 32 | #define VIRTIO_ID_NET 1 /* virtio net */ 33 | #define VIRTIO_ID_BLOCK 2 /* virtio block */ 34 | #define VIRTIO_ID_CONSOLE 3 /* virtio console */ 35 | #define VIRTIO_ID_RNG 4 /* virtio rng */ 36 | #define VIRTIO_ID_BALLOON 5 /* virtio balloon */ 37 | #define VIRTIO_ID_RPMSG 7 /* virtio remote processor messaging */ 38 | #define VIRTIO_ID_SCSI 8 /* virtio scsi */ 39 | #define VIRTIO_ID_9P 9 /* 9p virtio console */ 40 | #define VIRTIO_ID_RPROC_SERIAL 11 /* virtio remoteproc serial link */ 41 | 42 | #endif /* _LINUX_VIRTIO_IDS_H */ 43 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/README.md: -------------------------------------------------------------------------------- 1 | # PWM Example 2 | 3 | The code to be demonstrated is in `pwm-assembly/` directory. 4 | **Note**: `archive-pwm-c/` demonstrates pwm generation in C but is not in use as the frequency cannot be accurately determined without using assembly. 5 | It is the example from the PRU Cookbooki. 6 | 7 | ## Installation 8 | 1. `cd pwm-assembly` 9 | 2. `make` 10 | The Makefile will do all the work, compile the user space program and run it. 11 | 12 | **Note** 13 | 1. Make sure that the proper symbolic links have been made for `clpru` and `lnkpru`. 14 | 2. uncomment `disable_uboot_overlay_video=1` in `/boot/uEnv.txt`: for config-pin. 15 | 3. Give appropriate path the PRU_CGT env variable in the Makefiles. 16 | 17 | ## Working, Communication Scheme. 18 | The PWM signal is generated by the PRU0 on P9_31 GPIO which is controlled by the LSB of R30 as seen in the assembly code. The PRU1 firmware uses the RPMsg framework to input two 4-byte integers from the userspace program and then stores it into the PRU SRAM to be read by PRU0. The integers represent the cycles for which the PRU must be ON(divided by 2) and the total cycles(divided by 2). The division by 2 is because there are two instructions which execute after the GPIO is set or cleared inside the loop. 19 | 20 | The on cycles and total cycles are calculated by the userspace program which takes frequency and duty cycle as its input. At the fastest frequency, the duty cycle is accurate up to 2 decimal places. Hence, the total PRU cycles at the fastest frequency is 100 * 2. Hence, theoretically, the fastest PWM frequency is (1/(100 * 2 * 5ns)) = 1MHz. This frequency can then be adjusted from 1 Hz to 1MHz by the userspace cpp program. There is also a lower limit on frequency because the total number of cycles will become too large to be stored in 4 bytes of memory. 21 | 22 | The on cycles are stored from 0x00010000 to 0x00010003 and the total cycles are stored from 0x00010004 to 0x00010007 i.e. in the PRU SRAM. Each address location of the PRU memory can store 1 byte of data. 23 | 24 | Frequency, Duty Cycle input -> UserSpace Program -> cpp-bindings -> Python Daemon Service -> rpmsg_pru31 channel -> PRU1 writes the data -> PRU0 reads the data and starts functioning. 25 | 26 | The Python Daemon and cpp-bindings are explained in detail in the main Documentation. 27 | 28 | 29 | -------------------------------------------------------------------------------- /cpp-bindings/pruss.h: -------------------------------------------------------------------------------- 1 | #ifndef PRUSS_H_ 2 | #define PRUSS_H_ 3 | 4 | #include 5 | #include // realpath 6 | #include // string handling 7 | #include // socket 8 | #include // socket 9 | #include // close() 10 | #include // error codes 11 | 12 | //enumeration which describes the states of a PRU Core 13 | enum State 14 | { 15 | NONE, 16 | STOPPED, 17 | RUNNING, 18 | HALTED 19 | }; 20 | 21 | //enumeration which describes which memory access is required 22 | enum Memory 23 | { 24 | DATA0 = 0, 25 | DATA1 = 1, 26 | SHARED = 3 27 | }; 28 | 29 | /** 30 | * class Socket 31 | */ 32 | class Socket 33 | { 34 | private: 35 | const char* socketpath; 36 | struct sockaddr_un addr; 37 | int fd; 38 | Socket(); 39 | bool conn(); 40 | bool disconn(); 41 | std::string sendcmd(std::string); 42 | friend class PRUSS; //Only these classes have access to the Socket class 43 | friend class PRU; //Only these classes have access to the Socket class 44 | }; 45 | 46 | /** 47 | * class PRU 48 | */ 49 | class PRU 50 | { 51 | private: 52 | int number; 53 | int chanPort; 54 | std::string chanName; 55 | Socket sock; 56 | State state = NONE; 57 | PRU(int); 58 | PRU(int, std::string); 59 | friend class PRUSS; //Only PRUSS class can call the PRU class constructors 60 | public: 61 | int enable(); 62 | int disable(); 63 | int reset(); 64 | int pause(); 65 | int resume(); 66 | std::string showRegs(); 67 | int load(std::string); 68 | void setChannel(); 69 | int setChannel(int, std::string); 70 | State getState(); 71 | int sendMsg_string(std::string); 72 | void sendMsg_raw(std::string); 73 | std::string getMsg(); 74 | int waitForEvent(); 75 | int waitForEvent(int); 76 | std::string mem_read(Memory mem, std::string); 77 | std::string mem_write(Memory mem, std::string, std::string); 78 | }; 79 | 80 | /** 81 | * class PRUSS 82 | */ 83 | class PRUSS 84 | { 85 | private: 86 | bool on = false; 87 | Socket sock; 88 | PRUSS(); 89 | ~PRUSS(); 90 | public: 91 | static PRUSS& get(); 92 | PRU pru0; 93 | PRU pru1; 94 | bool isOn(); 95 | int bootUp(); 96 | int shutDown(); 97 | void restart(); 98 | 99 | }; 100 | #endif 101 | -------------------------------------------------------------------------------- /examples/firmware_examples/example1-gpio-blinky/PRU_gpioToggle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Source Modified by Mohammed Muneeb 3 | * 4 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 5 | * 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 14 | * * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * * Neither the name of Texas Instruments Incorporated nor the names of 20 | * its contributors may be used to endorse or promote products derived 21 | * from this software without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | #include 37 | #include 38 | #include 39 | #include "resource_table_empty.h" 40 | 41 | 42 | int main(void) 43 | { 44 | volatile uint32_t gpio; 45 | volatile uint32_t R30 = read_r30(); 46 | 47 | /* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */ 48 | CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; 49 | 50 | /* Toggle GPO pins TODO: Figure out which to use */ 51 | gpio = 0x000F; 52 | 53 | /* TODO: Create stop condition, else it will toggle indefinitely */ 54 | while (1) { 55 | R30 ^= gpio; 56 | write_r30(R30); 57 | __delay_cycles(100000000); 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /examples/firmware_examples/example4-analog-wave-gen/Makefile: -------------------------------------------------------------------------------- 1 | all: clean config pru0 pru1 userspace 2 | 3 | config: 4 | @echo ' ------------------------------------------------------------------' 5 | @echo ' -------------------- SETTING PINMUX ---------------------' 6 | @echo ' ------------------------------------------------------------------' 7 | @config-pin P9-31 pruout 8 | @echo 'PWM output on GPIO pin: P9_31' 9 | 10 | pru0: 11 | @cd ./PRU0/ && make 12 | @echo ' ------------------------------------------------------------------' 13 | @echo ' -------------------- PRU 0 FIRMWARE COMPILED --------------------' 14 | @echo ' ------------------------------------------------------------------' 15 | @cd ./PRU0/ && sudo make install 16 | @echo ' ------------------------------------------------------------------' 17 | @echo ' -------------------- PRU 0 FIRMWARE INSTALLED --------------------' 18 | @echo ' ------------------------------------------------------------------' 19 | 20 | pru1: 21 | @cd ./PRU1/ && make 22 | @echo ' ------------------------------------------------------------------' 23 | @echo ' -------------------- PRU 1 FIRMWARE COMPILED --------------------' 24 | @echo ' ------------------------------------------------------------------' 25 | @cd ./PRU1/ && make install 26 | @echo ' ------------------------------------------------------------------' 27 | @echo ' -------------------- PRU 1 FIRMWARE INSTALLED --------------------' 28 | @echo ' ------------------------------------------------------------------' 29 | 30 | userspace: 31 | @g++ userspace.cpp ../../../cpp-bindings/pruss.cpp -o userspace.o 32 | @echo ' ------------------------------------------------------------------' 33 | @echo ' --------------------UserSpace Program Compiled--------------------' 34 | @echo ' ------------------------------------------------------------------' 35 | @./userspace.o 36 | @echo ' ------------------------------------------------------------------' 37 | @echo ' -------------------- Completed Execution --------------------' 38 | @echo ' ------------------------------------------------------------------' 39 | 40 | clean: 41 | @echo ' ------------------------------------------------------------------' 42 | @echo ' -------------------- CLEAN --------------------' 43 | @echo ' ------------------------------------------------------------------' 44 | @cd ./PRU0/ && make clean 45 | @cd ./PRU1/ && make clean 46 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/pwm-assembly/Makefile: -------------------------------------------------------------------------------- 1 | all: clean config pru0 pru1 userspace 2 | 3 | config: 4 | @echo ' ------------------------------------------------------------------' 5 | @echo ' -------------------- SETTING PINMUX ---------------------' 6 | @echo ' ------------------------------------------------------------------' 7 | @config-pin P9-31 pruout 8 | @echo 'PWM output on GPIO pin: P9_31' 9 | 10 | pru0: 11 | @cd ./PRU0/ && make 12 | @echo ' ------------------------------------------------------------------' 13 | @echo ' -------------------- PRU 0 FIRMWARE COMPILED --------------------' 14 | @echo ' ------------------------------------------------------------------' 15 | @cd ./PRU0/ && sudo make install 16 | @echo ' ------------------------------------------------------------------' 17 | @echo ' -------------------- PRU 0 FIRMWARE INSTALLED --------------------' 18 | @echo ' ------------------------------------------------------------------' 19 | 20 | pru1: 21 | @cd ./PRU1/ && make 22 | @echo ' ------------------------------------------------------------------' 23 | @echo ' -------------------- PRU 1 FIRMWARE COMPILED --------------------' 24 | @echo ' ------------------------------------------------------------------' 25 | @cd ./PRU1/ && make install 26 | @echo ' ------------------------------------------------------------------' 27 | @echo ' -------------------- PRU 1 FIRMWARE INSTALLED --------------------' 28 | @echo ' ------------------------------------------------------------------' 29 | 30 | userspace: 31 | @g++ userspace.cpp ../../../../cpp-bindings/pruss.cpp -o userspace.o 32 | @echo ' ------------------------------------------------------------------' 33 | @echo ' --------------------UserSpace Program Compiled--------------------' 34 | @echo ' ------------------------------------------------------------------' 35 | @./userspace.o 36 | @echo ' ------------------------------------------------------------------' 37 | @echo ' -------------------- Completed Execution --------------------' 38 | @echo ' ------------------------------------------------------------------' 39 | #@python userspace_pwm.py 40 | 41 | clean: 42 | @echo ' ------------------------------------------------------------------' 43 | @echo ' -------------------- CLEAN --------------------' 44 | @echo ' ------------------------------------------------------------------' 45 | @cd ./PRU0/ && make clean 46 | @cd ./PRU1/ && make clean 47 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/archive-pwm-c/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Copyright (c) 2017 Texas Instruments - Jason Kridner 4 | # 5 | 6 | # TARGET must be defined as the file to be compiled without the .c. 7 | # PRUN must be defined as the PRU number (0 or 1) to compile for. 8 | 9 | # PRU_CGT environment variable points to the TI PRU compiler directory. 10 | # PRU_SUPPORT points to pru-software-support-package. 11 | # GEN_DIR points to where to put the generated files. 12 | PRU_CGT:=/usr/share/ti/cgt-pru 13 | PRU_SUPPORT:=/usr/lib/ti/pru-software-support-package 14 | GEN_DIR:=/tmp/pru$(PRUN)-gen 15 | 16 | LINKER_COMMAND_FILE=AM335x_PRU.cmd 17 | LIBS=--library=$(PRU_SUPPORT)/lib/rpmsg_lib.lib 18 | INCLUDE=--include_path=$(PRU_SUPPORT)/include --include_path=$(PRU_SUPPORT)/include/am335x 19 | 20 | STACK_SIZE=0x100 21 | HEAP_SIZE=0x100 22 | 23 | CFLAGS=-v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) --asm_directory=$(GEN_DIR) -ppd -ppa --asm_listing --c_src_interlist # --absolute_listing 24 | 25 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) -m $(GEN_DIR)/$(TARGET).map 26 | 27 | # Lookup PRU by address 28 | ifeq ($(PRUN),0) 29 | PRU_ADDR=4a334000 30 | endif 31 | ifeq ($(PRUN),1) 32 | PRU_ADDR=4a338000 33 | endif 34 | 35 | PRU_DIR=$(wildcard /sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*) 36 | 37 | all: stop install start 38 | 39 | stop: 40 | @echo "- Stopping PRU $(PRUN)" 41 | @echo stop | sudo tee $(PRU_DIR)/state || echo Cannot stop $(PRUN) 42 | 43 | start: 44 | @echo "- Starting PRU $(PRUN)" 45 | @echo start | sudo tee $(PRU_DIR)/state 46 | 47 | install: $(GEN_DIR)/$(TARGET).out 48 | @echo '- copying firmware file $(GEN_DIR)/$(TARGET).out to /lib/firmware/am335x-pru$(PRUN)-fw' 49 | @sudo cp $(GEN_DIR)/$(TARGET).out /lib/firmware/am335x-pru$(PRUN)-fw 50 | 51 | $(GEN_DIR)/$(TARGET).out: $(GEN_DIR)/$(TARGET).obj 52 | @echo 'LD $^' 53 | @lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 54 | 55 | $(GEN_DIR)/$(TARGET).obj: $(TARGET).c 56 | @mkdir -p $(GEN_DIR) 57 | @echo 'CC $<' 58 | @clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -D=PRUN=$(PRUN) -fe $@ $< 59 | 60 | clean: 61 | @echo 'CLEAN . PRU $(PRUN)' 62 | @rm -rf $(GEN_DIR) 63 | -------------------------------------------------------------------------------- /examples/firmware_examples/example5-multichannel-pwm/multich-pwm-c/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Copyright (c) 2017 Texas Instruments - Jason Kridner 4 | # 5 | 6 | # TARGET must be defined as the file to be compiled without the .c. 7 | # PRUN must be defined as the PRU number (0 or 1) to compile for. 8 | 9 | # PRU_CGT environment variable points to the TI PRU compiler directory. 10 | # PRU_SUPPORT points to pru-software-support-package. 11 | # GEN_DIR points to where to put the generated files. 12 | 13 | TARGET=multi 14 | PRUN=0 15 | PRU_CGT:=/usr/share/ti/cgt-pru 16 | PRU_SUPPORT:=/usr/lib/ti/pru-software-support-package 17 | GEN_DIR:=/tmp/pru$(PRUN)-gen 18 | 19 | LINKER_COMMAND_FILE=AM335x_PRU.cmd 20 | LIBS=--library=$(PRU_SUPPORT)/lib/rpmsg_lib.lib 21 | INCLUDE=--include_path=$(PRU_SUPPORT)/include --include_path=$(PRU_SUPPORT)/include/am335x 22 | 23 | STACK_SIZE=0x100 24 | HEAP_SIZE=0x100 25 | 26 | CFLAGS=-v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) --asm_directory=$(GEN_DIR) -ppd -ppa --asm_listing --c_src_interlist # --absolute_listing 27 | 28 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) -m $(GEN_DIR)/$(TARGET).map 29 | 30 | # Lookup PRU by address 31 | ifeq ($(PRUN),0) 32 | PRU_ADDR=4a334000 33 | endif 34 | ifeq ($(PRUN),1) 35 | PRU_ADDR=4a338000 36 | endif 37 | 38 | PRU_DIR=$(wildcard /sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*) 39 | 40 | all: stop install start 41 | 42 | stop: 43 | @echo "- Stopping PRU $(PRUN)" 44 | @echo stop | sudo tee $(PRU_DIR)/state || echo Cannot stop $(PRUN) 45 | 46 | start: 47 | @echo "- Starting PRU $(PRUN)" 48 | @echo start | sudo tee $(PRU_DIR)/state 49 | 50 | install: $(GEN_DIR)/$(TARGET).out 51 | @echo '- copying firmware file $(GEN_DIR)/$(TARGET).out to /lib/firmware/am335x-pru$(PRUN)-fw' 52 | @sudo cp $(GEN_DIR)/$(TARGET).out /lib/firmware/am335x-pru$(PRUN)-fw 53 | 54 | $(GEN_DIR)/$(TARGET).out: $(GEN_DIR)/$(TARGET).obj 55 | @echo 'LD $^' 56 | @lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 57 | 58 | $(GEN_DIR)/$(TARGET).obj: $(TARGET).c 59 | @mkdir -p $(GEN_DIR) 60 | @echo 'CC $<' 61 | @clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -D=PRUN=$(PRUN) -fe $@ $< 62 | 63 | clean: 64 | @echo 'CLEAN . PRU $(PRUN)' 65 | @rm -rf $(GEN_DIR) 66 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Install script for prussd daemon service 4 | # To be run on the BeagleBone, from the cloned PRUSS-Bindings 5 | # git repository 6 | 7 | DIR=$(cd `dirname $BASH_SOURCE[0]` && pwd -P) 8 | 9 | pru_examples() { 10 | 11 | #paths needed to compile PRU firmware examples 12 | if [ ! -d /usr/share/ti/cgt-pru/bin ] ; 13 | then 14 | ln -s /usr/bin/ /usr/share/ti/cgt-pru/bin 15 | fi 16 | export PRU_CGT=/usr/share/ti/cgt-pru 17 | 18 | #run compilation scripts 19 | bash "${DIR}/examples/run.sh" blinky 20 | bash "${DIR}/examples/run.sh" rpmsg_echo 21 | bash "${DIR}/examples/run.sh" pru_pin_state_reader 22 | bash "${DIR}/examples/run.sh" pru1_to_pru0_to_arm 23 | bash "${DIR}/examples/run.sh" multi_threaded 24 | 25 | } 26 | 27 | systemd_service() { 28 | 29 | #copy the systemd unit configuration file 30 | cp -v "${DIR}/prussd/prussd.service" "/lib/systemd/system/prussd.service" 31 | 32 | #copy the config file 33 | cp -v "${DIR}/prussd/prussd.conf" "/etc/default/prussd.conf" 34 | 35 | #edit the unit file to replace DIR by the actual path 36 | sed -i -e "s:DIR:${DIR}:" "/lib/systemd/system/prussd.service" 37 | 38 | #edit the config file to include paths to firmware_examples 39 | sed -i -e "s:DIR:${DIR}:" "/etc/default/prussd.conf" 40 | 41 | #mark the daemon script as executable 42 | chmod a+x "${DIR}/prussd/prussd.py" 43 | 44 | #enable the service 45 | systemctl enable prussd.service 46 | 47 | #reload the systemctl daemons 48 | systemctl daemon-reload 49 | 50 | #start the prussd daemon 51 | systemctl start prussd.service 52 | 53 | } 54 | 55 | kernel_driver() { 56 | 57 | #Install the kernel driver present in drivers/ directory to /lib/modules/$(uname -r) in order to install it 58 | cp ./drivers/pruss_api.ko /lib/modules/$(uname -r)/ 59 | echo "Copying pruss_api.ko to /lib/modules/$(uname -r)" 60 | depmod -ae 61 | echo "Installed the pruss_api driver" 62 | 63 | } 64 | 65 | cpp_bindings() { 66 | 67 | #Install the headers present in cpp-bindings/ directory to /usr/local/include in order to install it 68 | cp "./cpp-bindings/pruss.h" "/usr/local/include/" 69 | echo "Copying pruss.h to /usr/local/include" 70 | 71 | } 72 | 73 | if [ $# -eq 0 ]; then 74 | systemd_service 75 | kernel_driver 76 | cpp_bindings 77 | fi 78 | 79 | if [ "$1" == "--examples" ] ; then 80 | pru_examples 81 | fi 82 | 83 | if [ "$1" == "--service" ] ; then 84 | systemd_service 85 | fi 86 | 87 | if [ "$1" == "--driver" ] ; then 88 | kernel_driver 89 | fi 90 | 91 | if [ "$1" == "--library" ] ; then 92 | cpp_bindings 93 | fi 94 | -------------------------------------------------------------------------------- /examples/firmware_examples/example5-multichannel-pwm/PRU1/Makefile: -------------------------------------------------------------------------------- 1 | # Source modified by Pratim Ugale 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Copyright (c) 2017 Texas Instruments - Jason Kridner 4 | # 5 | 6 | # PRUN must be defined as the PRU number (0 or 1) to compile for. 7 | PRUN=1 8 | 9 | # TARGET must be defined as the file to be compiled without the .c extension 10 | TARGET=main 11 | 12 | # PRU_CGT environment variable points to the TI PRU compiler directory. (Usually /usr/share/ti/cgt-pru) 13 | PRU_CGT:=/usr/share/ti/cgt-pru 14 | 15 | # PRU_SUPPORT points to pru-software-support-package. 16 | PRU_SUPPORT:=/usr/lib/ti/pru-software-support-package 17 | 18 | # GEN_DIR points to where to put the generated files. 19 | GEN_DIR:=/tmp/pru$(PRUN)-gen 20 | 21 | LINKER_COMMAND_FILE=AM335x_PRU.cmd 22 | LIBS=--library=$(PRU_SUPPORT)/lib/rpmsg_lib.lib 23 | INCLUDE=--include_path=$(PRU_SUPPORT)/include --include_path=$(PRU_SUPPORT)/include/am335x 24 | 25 | STACK_SIZE=0x100 26 | HEAP_SIZE=0x100 27 | 28 | CFLAGS=-v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) --asm_directory=$(GEN_DIR) -ppd -ppa --asm_listing --c_src_interlist # --absolute_listing 29 | 30 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) -m $(GEN_DIR)/$(TARGET).map 31 | 32 | # Lookup PRU by address 33 | ifeq ($(PRUN),0) 34 | PRU_ADDR=4a334000 35 | endif 36 | ifeq ($(PRUN),1) 37 | PRU_ADDR=4a338000 38 | endif 39 | 40 | PRU_DIR=$(wildcard /sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*) 41 | 42 | # PRU Start and Stop will be handled by the User Space Program itself 43 | 44 | install: $(GEN_DIR)/$(TARGET).out 45 | @echo '- copying firmware file $(GEN_DIR)/$(TARGET).out to $(GEN_DIR)/am335x-pru$(PRUN)-fw' 46 | @sudo cp $(GEN_DIR)/$(TARGET).out $(GEN_DIR)/am335x-pru$(PRUN)-fw 47 | @echo '- copying file $(GEN_DIR)/am335x-pru$(PRUN)-fw to /lib/firmware/' 48 | @sudo cp $(GEN_DIR)/am335x-pru$(PRUN)-fw /lib/firmware/ 49 | 50 | $(GEN_DIR)/$(TARGET).out: $(GEN_DIR)/$(TARGET).obj 51 | @echo 'LD $^' 52 | @lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 53 | 54 | $(GEN_DIR)/$(TARGET).obj: $(TARGET).c 55 | @mkdir -p $(GEN_DIR) 56 | @echo 'CC $<' 57 | @clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -D=PRUN=$(PRUN) -fe $@ $< 58 | 59 | clean: 60 | @echo 'CLEAN . PRU $(PRUN)' 61 | @rm -rf $(GEN_DIR) 62 | -------------------------------------------------------------------------------- /examples/firmware_examples/example1-usr3-blinky/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Copyright (c) 2017 Texas Instruments - Jason Kridner 4 | # 5 | 6 | # TARGET must be defined as the file to be compiled without the .c. 7 | # PRUN must be defined as the PRU number (0 or 1) to compile for. 8 | 9 | # PRU_CGT environment variable points to the TI PRU compiler directory. 10 | # PRU_SUPPORT points to pru-software-support-package. 11 | # GEN_DIR points to where to put the generated files. 12 | 13 | 14 | PRUN=0 15 | TARGET=hello 16 | #So that source.sh file can be ignored(increases complexity) 17 | 18 | PRU_CGT:=/usr/share/ti/cgt-pru 19 | PRU_SUPPORT:=/usr/lib/ti/pru-software-support-package 20 | GEN_DIR:=/tmp/pru$(PRUN)-gen 21 | 22 | LINKER_COMMAND_FILE=AM335x_PRU.cmd 23 | LIBS=--library=$(PRU_SUPPORT)/lib/rpmsg_lib.lib 24 | INCLUDE=--include_path=$(PRU_SUPPORT)/include --include_path=$(PRU_SUPPORT)/include/am335x 25 | 26 | STACK_SIZE=0x100 27 | HEAP_SIZE=0x100 28 | 29 | CFLAGS=-v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) --asm_directory=$(GEN_DIR) -ppd -ppa --asm_listing --c_src_interlist # --absolute_listing 30 | 31 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) -m $(GEN_DIR)/$(TARGET).map 32 | 33 | # Lookup PRU by address 34 | ifeq ($(PRUN),0) 35 | PRU_ADDR=4a334000 36 | endif 37 | ifeq ($(PRUN),1) 38 | PRU_ADDR=4a338000 39 | endif 40 | 41 | PRU_DIR=$(wildcard /sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*) 42 | 43 | all: stop install start 44 | 45 | stop: 46 | @echo "- Stopping PRU $(PRUN)" 47 | @echo stop | sudo tee $(PRU_DIR)/state || echo Cannot stop $(PRUN) 48 | 49 | start: 50 | @echo "- Starting PRU $(PRUN)" 51 | @echo start | sudo tee $(PRU_DIR)/state 52 | 53 | install: $(GEN_DIR)/$(TARGET).out 54 | @echo '- copying firmware file $(GEN_DIR)/$(TARGET).out to /lib/firmware/am335x-pru$(PRUN)-fw' 55 | @sudo cp $(GEN_DIR)/$(TARGET).out /lib/firmware/am335x-pru$(PRUN)-fw 56 | 57 | $(GEN_DIR)/$(TARGET).out: $(GEN_DIR)/$(TARGET).obj 58 | @echo 'LD $^' 59 | @lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 60 | 61 | $(GEN_DIR)/$(TARGET).obj: $(TARGET).c 62 | @mkdir -p $(GEN_DIR) 63 | @echo 'CC $<' 64 | @clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -D=PRUN=$(PRUN) -fe $@ $< 65 | 66 | clean: 67 | @echo 'CLEAN . PRU $(PRUN)' 68 | @rm -rf $(GEN_DIR) 69 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/pwm-assembly/PRU1/Makefile: -------------------------------------------------------------------------------- 1 | # Source modified by Pratim Ugale 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Copyright (c) 2017 Texas Instruments - Jason Kridner 4 | # 5 | 6 | # PRUN must be defined as the PRU number (0 or 1) to compile for. 7 | PRUN=1 8 | 9 | # TARGET must be defined as the file to be compiled without the .c extension 10 | TARGET=main 11 | 12 | # PRU_CGT environment variable points to the TI PRU compiler directory. (Usually /usr/share/ti/cgt-pru) 13 | PRU_CGT:=/usr/share/ti/cgt-pru 14 | 15 | # PRU_SUPPORT points to pru-software-support-package. 16 | PRU_SUPPORT:=/usr/lib/ti/pru-software-support-package 17 | 18 | # GEN_DIR points to where to put the generated files. 19 | GEN_DIR:=/tmp/pru$(PRUN)-gen 20 | 21 | LINKER_COMMAND_FILE=AM335x_PRU.cmd 22 | LIBS=--library=$(PRU_SUPPORT)/lib/rpmsg_lib.lib 23 | INCLUDE=--include_path=$(PRU_SUPPORT)/include --include_path=$(PRU_SUPPORT)/include/am335x 24 | 25 | STACK_SIZE=0x100 26 | HEAP_SIZE=0x100 27 | 28 | CFLAGS=-v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) --asm_directory=$(GEN_DIR) -ppd -ppa --asm_listing --c_src_interlist # --absolute_listing 29 | 30 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) -m $(GEN_DIR)/$(TARGET).map 31 | 32 | # Lookup PRU by address 33 | ifeq ($(PRUN),0) 34 | PRU_ADDR=4a334000 35 | endif 36 | ifeq ($(PRUN),1) 37 | PRU_ADDR=4a338000 38 | endif 39 | 40 | PRU_DIR=$(wildcard /sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*) 41 | 42 | # PRU Start and Stop will be handled by the User Space Program itself 43 | 44 | all: $(GEN_DIR)/$(TARGET).out 45 | 46 | install: $(GEN_DIR)/$(TARGET).out 47 | @echo '- copying firmware file $(GEN_DIR)/$(TARGET).out to $(GEN_DIR)/am335x-pru$(PRUN)-fw' 48 | @sudo cp $(GEN_DIR)/$(TARGET).out $(GEN_DIR)/am335x-pru$(PRUN)-fw 49 | @echo '- copying file $(GEN_DIR)/am335x-pru$(PRUN)-fw to /lib/firmware/' 50 | @sudo cp $(GEN_DIR)/am335x-pru$(PRUN)-fw /lib/firmware/ 51 | 52 | $(GEN_DIR)/$(TARGET).out: $(GEN_DIR)/$(TARGET).obj 53 | @echo 'LD $^' 54 | @lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 55 | 56 | $(GEN_DIR)/$(TARGET).obj: $(TARGET).c 57 | @mkdir -p $(GEN_DIR) 58 | @echo 'CC $<' 59 | @clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -D=PRUN=$(PRUN) -fe $@ $< 60 | 61 | clean: 62 | @echo 'CLEAN . PRU $(PRUN)' 63 | @rm -rf $(GEN_DIR) 64 | -------------------------------------------------------------------------------- /examples/firmware_examples/example4-analog-wave-gen/PRU1/Makefile: -------------------------------------------------------------------------------- 1 | # Source modified by Pratim Ugale 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Copyright (c) 2017 Texas Instruments - Jason Kridner 4 | # 5 | 6 | # PRUN must be defined as the PRU number (0 or 1) to compile for. 7 | PRUN=1 8 | 9 | # TARGET must be defined as the file to be compiled without the .c extension 10 | TARGET=main 11 | 12 | # PRU_CGT environment variable points to the TI PRU compiler directory. (Usually /usr/share/ti/cgt-pru) 13 | PRU_CGT:=/usr/share/ti/cgt-pru 14 | 15 | # PRU_SUPPORT points to pru-software-support-package. 16 | PRU_SUPPORT:=/usr/lib/ti/pru-software-support-package 17 | 18 | # GEN_DIR points to where to put the generated files. 19 | GEN_DIR:=/tmp/pru$(PRUN)-gen 20 | 21 | LINKER_COMMAND_FILE=AM335x_PRU.cmd 22 | LIBS=--library=$(PRU_SUPPORT)/lib/rpmsg_lib.lib 23 | INCLUDE=--include_path=$(PRU_SUPPORT)/include --include_path=$(PRU_SUPPORT)/include/am335x 24 | 25 | STACK_SIZE=0x100 26 | HEAP_SIZE=0x100 27 | 28 | CFLAGS=-v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) --asm_directory=$(GEN_DIR) -ppd -ppa --asm_listing --c_src_interlist # --absolute_listing 29 | 30 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) -m $(GEN_DIR)/$(TARGET).map 31 | 32 | # Lookup PRU by address 33 | ifeq ($(PRUN),0) 34 | PRU_ADDR=4a334000 35 | endif 36 | ifeq ($(PRUN),1) 37 | PRU_ADDR=4a338000 38 | endif 39 | 40 | PRU_DIR=$(wildcard /sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*) 41 | 42 | # PRU Start and Stop will be handled by the User Space Program itself 43 | 44 | all: $(GEN_DIR)/$(TARGET).out 45 | 46 | install: $(GEN_DIR)/$(TARGET).out 47 | @echo '- copying firmware file $(GEN_DIR)/$(TARGET).out to $(GEN_DIR)/am335x-pru$(PRUN)-fw' 48 | @sudo cp $(GEN_DIR)/$(TARGET).out $(GEN_DIR)/am335x-pru$(PRUN)-fw 49 | @echo '- copying file $(GEN_DIR)/am335x-pru$(PRUN)-fw to /lib/firmware/' 50 | @sudo cp $(GEN_DIR)/am335x-pru$(PRUN)-fw /lib/firmware/ 51 | 52 | $(GEN_DIR)/$(TARGET).out: $(GEN_DIR)/$(TARGET).obj 53 | @echo 'LD $^' 54 | @lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 55 | 56 | $(GEN_DIR)/$(TARGET).obj: $(TARGET).c 57 | @mkdir -p $(GEN_DIR) 58 | @echo 'CC $<' 59 | @clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -D=PRUN=$(PRUN) -fe $@ $< 60 | 61 | clean: 62 | @echo 'CLEAN . PRU $(PRUN)' 63 | @rm -rf $(GEN_DIR) 64 | -------------------------------------------------------------------------------- /examples/firmware_examples/example7-stepper-control/PRU1/Makefile: -------------------------------------------------------------------------------- 1 | # Source modified by Pratim Ugale 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Copyright (c) 2017 Texas Instruments - Jason Kridner 4 | # 5 | 6 | # PRUN must be defined as the PRU number (0 or 1) to compile for. 7 | PRUN=1 8 | 9 | # TARGET must be defined as the file to be compiled without the .c extension 10 | TARGET=main 11 | 12 | # PRU_CGT environment variable points to the TI PRU compiler directory. (Usually /usr/share/ti/cgt-pru) 13 | PRU_CGT:=/usr/share/ti/cgt-pru 14 | 15 | # PRU_SUPPORT points to pru-software-support-package. 16 | PRU_SUPPORT:=/usr/lib/ti/pru-software-support-package 17 | 18 | # GEN_DIR points to where to put the generated files. 19 | GEN_DIR:=/tmp/pru$(PRUN)-gen 20 | 21 | LINKER_COMMAND_FILE=AM335x_PRU.cmd 22 | LIBS=--library=$(PRU_SUPPORT)/lib/rpmsg_lib.lib 23 | INCLUDE=--include_path=$(PRU_SUPPORT)/include --include_path=$(PRU_SUPPORT)/include/am335x 24 | 25 | STACK_SIZE=0x100 26 | HEAP_SIZE=0x100 27 | 28 | CFLAGS=-v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) --asm_directory=$(GEN_DIR) -ppd -ppa --asm_listing --c_src_interlist # --absolute_listing 29 | 30 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) -m $(GEN_DIR)/$(TARGET).map 31 | 32 | # Lookup PRU by address 33 | ifeq ($(PRUN),0) 34 | PRU_ADDR=4a334000 35 | endif 36 | ifeq ($(PRUN),1) 37 | PRU_ADDR=4a338000 38 | endif 39 | 40 | PRU_DIR=$(wildcard /sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*) 41 | 42 | # PRU Start and Stop will be handled by the User Space Program itself 43 | 44 | all: $(GEN_DIR)/$(TARGET).out 45 | 46 | install: $(GEN_DIR)/$(TARGET).out 47 | @echo '- copying firmware file $(GEN_DIR)/$(TARGET).out to $(GEN_DIR)/am335x-pru$(PRUN)-fw' 48 | @sudo cp $(GEN_DIR)/$(TARGET).out $(GEN_DIR)/am335x-pru$(PRUN)-fw 49 | @echo '- copying file $(GEN_DIR)/am335x-pru$(PRUN)-fw to /lib/firmware/' 50 | @sudo cp $(GEN_DIR)/am335x-pru$(PRUN)-fw /lib/firmware/ 51 | 52 | $(GEN_DIR)/$(TARGET).out: $(GEN_DIR)/$(TARGET).obj 53 | @echo 'LD $^' 54 | @lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 55 | 56 | $(GEN_DIR)/$(TARGET).obj: $(TARGET).c 57 | @mkdir -p $(GEN_DIR) 58 | @echo 'CC $<' 59 | @clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -D=PRUN=$(PRUN) -fe $@ $< 60 | 61 | clean: 62 | @echo 'CLEAN . PRU $(PRUN)' 63 | @rm -rf $(GEN_DIR) 64 | -------------------------------------------------------------------------------- /examples/firmware_examples/example9-multichannel-waveform-gen/PRU1/Makefile: -------------------------------------------------------------------------------- 1 | # Source modified by Pratim Ugale 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Copyright (c) 2017 Texas Instruments - Jason Kridner 4 | # 5 | 6 | # PRUN must be defined as the PRU number (0 or 1) to compile for. 7 | PRUN=1 8 | 9 | # TARGET must be defined as the file to be compiled without the .c extension 10 | TARGET=main 11 | 12 | # PRU_CGT environment variable points to the TI PRU compiler directory. (Usually /usr/share/ti/cgt-pru) 13 | PRU_CGT:=/usr/share/ti/cgt-pru 14 | 15 | # PRU_SUPPORT points to pru-software-support-package. 16 | PRU_SUPPORT:=/usr/lib/ti/pru-software-support-package 17 | 18 | # GEN_DIR points to where to put the generated files. 19 | GEN_DIR:=/tmp/pru$(PRUN)-gen 20 | 21 | LINKER_COMMAND_FILE=AM335x_PRU.cmd 22 | LIBS=--library=$(PRU_SUPPORT)/lib/rpmsg_lib.lib 23 | INCLUDE=--include_path=$(PRU_SUPPORT)/include --include_path=$(PRU_SUPPORT)/include/am335x 24 | 25 | STACK_SIZE=0x100 26 | HEAP_SIZE=0x100 27 | 28 | CFLAGS=-v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) --asm_directory=$(GEN_DIR) -ppd -ppa --asm_listing --c_src_interlist # --absolute_listing 29 | 30 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) -m $(GEN_DIR)/$(TARGET).map 31 | 32 | # Lookup PRU by address 33 | ifeq ($(PRUN),0) 34 | PRU_ADDR=4a334000 35 | endif 36 | ifeq ($(PRUN),1) 37 | PRU_ADDR=4a338000 38 | endif 39 | 40 | PRU_DIR=$(wildcard /sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*) 41 | 42 | # PRU Start and Stop will be handled by the User Space Program itself 43 | 44 | all: $(GEN_DIR)/$(TARGET).out 45 | 46 | install: $(GEN_DIR)/$(TARGET).out 47 | @echo '- copying firmware file $(GEN_DIR)/$(TARGET).out to $(GEN_DIR)/am335x-pru$(PRUN)-fw' 48 | @sudo cp $(GEN_DIR)/$(TARGET).out $(GEN_DIR)/am335x-pru$(PRUN)-fw 49 | @echo '- copying file $(GEN_DIR)/am335x-pru$(PRUN)-fw to /lib/firmware/' 50 | @sudo cp $(GEN_DIR)/am335x-pru$(PRUN)-fw /lib/firmware/ 51 | 52 | $(GEN_DIR)/$(TARGET).out: $(GEN_DIR)/$(TARGET).obj 53 | @echo 'LD $^' 54 | @lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 55 | 56 | $(GEN_DIR)/$(TARGET).obj: $(TARGET).c 57 | @mkdir -p $(GEN_DIR) 58 | @echo 'CC $<' 59 | @clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -D=PRUN=$(PRUN) -fe $@ $< 60 | 61 | clean: 62 | @echo 'CLEAN . PRU $(PRUN)' 63 | @rm -rf $(GEN_DIR) 64 | -------------------------------------------------------------------------------- /drivers/test_example_rpmsg/PRU1/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Copyright (c) 2017 Texas Instruments - Jason Kridner 4 | # 5 | 6 | # TARGET must be defined as the file to be compiled without the .c. 7 | # PRUN must be defined as the PRU number (0 or 1) to compile for. 8 | 9 | # PRU_CGT environment variable points to the TI PRU compiler directory. 10 | # PRU_SUPPORT points to pru-software-support-package. 11 | # GEN_DIR points to where to put the generated files. 12 | 13 | 14 | #Added by Pratim 15 | PRUN=1 16 | TARGET=main 17 | #So that source.sh file can be ignored(increases complexity) 18 | 19 | PRU_CGT:=/usr/share/ti/cgt-pru 20 | PRU_SUPPORT:=/usr/lib/ti/pru-software-support-package 21 | GEN_DIR:=/tmp/pru$(PRUN)-gen 22 | 23 | LINKER_COMMAND_FILE=AM335x_PRU.cmd 24 | LIBS=--library=$(PRU_SUPPORT)/lib/rpmsg_lib.lib 25 | INCLUDE=--include_path=$(PRU_SUPPORT)/include --include_path=$(PRU_SUPPORT)/include/am335x 26 | 27 | STACK_SIZE=0x100 28 | HEAP_SIZE=0x100 29 | 30 | CFLAGS=-v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) --asm_directory=$(GEN_DIR) -ppd -ppa --asm_listing --c_src_interlist # --absolute_listing 31 | 32 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) -m $(GEN_DIR)/$(TARGET).map 33 | 34 | # Lookup PRU by address 35 | ifeq ($(PRUN),0) 36 | PRU_ADDR=4a334000 37 | endif 38 | ifeq ($(PRUN),1) 39 | PRU_ADDR=4a338000 40 | endif 41 | 42 | PRU_DIR=$(wildcard /sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*) 43 | 44 | all: stop install start 45 | 46 | stop: 47 | @echo "- Stopping PRU $(PRUN)" 48 | @echo stop | sudo tee $(PRU_DIR)/state || echo Cannot stop $(PRUN) 49 | 50 | start: 51 | @echo "- Starting PRU $(PRUN)" 52 | @echo start | sudo tee $(PRU_DIR)/state 53 | 54 | install: $(GEN_DIR)/$(TARGET).out 55 | @echo '- copying firmware file $(GEN_DIR)/$(TARGET).out to /lib/firmware/am335x-pru$(PRUN)-fw' 56 | @sudo cp $(GEN_DIR)/$(TARGET).out am335x-pru$(PRUN)-fw 57 | @sudo cp am335x-pru$(PRUN)-fw /lib/firmware 58 | 59 | $(GEN_DIR)/$(TARGET).out: $(GEN_DIR)/$(TARGET).obj 60 | @echo 'LD $^' 61 | @lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 62 | 63 | $(GEN_DIR)/$(TARGET).obj: $(TARGET).c 64 | @mkdir -p $(GEN_DIR) 65 | @echo 'CC $<' 66 | @clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -D=PRUN=$(PRUN) -fe $@ $< 67 | 68 | clean: 69 | @echo 'CLEAN . PRU $(PRUN)' 70 | @rm -rf $(GEN_DIR) 71 | -------------------------------------------------------------------------------- /examples/node-example/server.js: -------------------------------------------------------------------------------- 1 | 2 | var express = require('express'), 3 | app = express(), 4 | parser = require('body-parser'), 5 | fs = require('fs'), 6 | path = require('path'), 7 | pruss = require('pruss'); 8 | 9 | var pru = pruss.pru; 10 | var port = process.env.PORT || 8088; 11 | var router = express.Router(); 12 | var prussrouter = express.Router(); 13 | 14 | app.use(parser.json({ type: 'application/json' })); 15 | app.use(parser.urlencoded({ extended: true })); 16 | app.use(express.static('app')) 17 | 18 | router.get('/:no([0-1])', function(req, res){ 19 | res.json({ "status": pru[req.params.no].getState() }); 20 | }); 21 | 22 | router.get('/:no([0-1])/stop', function(req, res){ 23 | pru[req.params.no].disable((ret) => { 24 | res.json({ "return": ret }); 25 | }); 26 | }); 27 | 28 | router.get('/:no([0-1])/start', function(req, res){ 29 | pru[req.params.no].enable((ret) => { 30 | res.json({ "return": ret }); 31 | }); 32 | }); 33 | 34 | router.get('/:no([0-1])/pause', function(req, res){ 35 | pru[req.params.no].pause((ret) => { 36 | res.json({ "return": ret }); 37 | }); 38 | }); 39 | 40 | router.get('/:no([0-1])/resume', function(req, res){ 41 | pru[req.params.no].resume((ret) => { 42 | res.json({ "return": ret }); 43 | }); 44 | }); 45 | 46 | router.post('/:no([0-1])/load', function(req, res){ 47 | var filepath = req.body.file; 48 | pru[req.params.no].load(filepath, (ret) => { 49 | res.json({ "return": ret }); 50 | }); 51 | }); 52 | 53 | router.get('/:no([0-1])/message', function(req, res){ 54 | pru[req.params.no].getMsg((ret) => { 55 | res.json({ "message": ret }); 56 | }); 57 | }); 58 | 59 | 60 | router.get('/:no([0-1])/event/:time([0-9])?', function(req, res){ 61 | pru[req.params.no].waitForEvent(req.params.time, (ret) => { 62 | res.json({ "return": ret }); 63 | }); 64 | 65 | }); 66 | 67 | router.post('/:no([0-1])/message', function(req, res){ 68 | var msg = req.body.message; 69 | pru[req.params.no].sendMsg(msg, (ret) => { 70 | res.json({ "return": ret }); 71 | }); 72 | }); 73 | 74 | prussrouter.get('/', function(req, res){ 75 | var state = "off"; 76 | if(pruss.isOn()) 77 | state = "on"; 78 | res.json({ "status": state }); 79 | }); 80 | 81 | prussrouter.get('/on', function(req, res){ 82 | pruss.bootUp((ret) => { 83 | res.json({ "return": ret }); 84 | }); 85 | }); 86 | 87 | prussrouter.get('/off', function(req, res){ 88 | pruss.shutDown((ret) => { 89 | res.json({ "return": ret }); 90 | }); 91 | }); 92 | 93 | app.use('/pru', router); 94 | app.use('/pruss', prussrouter); 95 | app.listen(port); 96 | console.log('server started at port:8088'); 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /examples/firmware_examples/example2-rpmsg-pru1/PRU0/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Copyright (c) 2017 Texas Instruments - Jason Kridner 4 | # 5 | 6 | # TARGET must be defined as the file to be compiled without the .c. 7 | # PRUN must be defined as the PRU number (0 or 1) to compile for. 8 | 9 | # PRU_CGT environment variable points to the TI PRU compiler directory. 10 | # PRU_SUPPORT points to pru-software-support-package. 11 | # GEN_DIR points to where to put the generated files. 12 | 13 | 14 | #Added by Pratim 15 | PRUN=0 16 | TARGET=main 17 | #So that source.sh file can be ignored(increases complexity) 18 | 19 | PRU_CGT:=/usr/share/ti/cgt-pru 20 | PRU_SUPPORT:=/usr/lib/ti/pru-software-support-package 21 | GEN_DIR:=/tmp/pru$(PRUN)-gen 22 | 23 | LINKER_COMMAND_FILE=AM335x_PRU.cmd 24 | LIBS=--library=$(PRU_SUPPORT)/lib/rpmsg_lib.lib 25 | INCLUDE=--include_path=$(PRU_SUPPORT)/include --include_path=$(PRU_SUPPORT)/include/am335x 26 | 27 | STACK_SIZE=0x100 28 | HEAP_SIZE=0x100 29 | 30 | CFLAGS=-v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) --asm_directory=$(GEN_DIR) -ppd -ppa --asm_listing --c_src_interlist # --absolute_listing 31 | 32 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) -m $(GEN_DIR)/$(TARGET).map 33 | 34 | # Lookup PRU by address 35 | ifeq ($(PRUN),0) 36 | PRU_ADDR=4a334000 37 | endif 38 | ifeq ($(PRUN),1) 39 | PRU_ADDR=4a338000 40 | endif 41 | 42 | PRU_DIR=$(wildcard /sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*) 43 | 44 | #all: stop install start 45 | 46 | #stop: 47 | # @echo "- Stopping PRU $(PRUN)" 48 | # @echo stop | sudo tee $(PRU_DIR)/state || echo Cannot stop $(PRUN) 49 | 50 | #start: 51 | # @echo "- Starting PRU $(PRUN)" 52 | # @echo start | sudo tee $(PRU_DIR)/state 53 | 54 | install: $(GEN_DIR)/$(TARGET).out 55 | @echo '- copying firmware file $(GEN_DIR)/$(TARGET).out to $(GEN_DIR)/am335x-pru$(PRUN)-fw' 56 | @sudo cp $(GEN_DIR)/$(TARGET).out $(GEN_DIR)/am335x-pru$(PRUN)-fw 57 | @echo '- copying firmware file $(GEN_DIR)/am335x-pru$(PRUN)-fw to /lib/firmware/' 58 | @sudo cp $(GEN_DIR)/am335x-pru$(PRUN)-fw /lib/firmware/ 59 | @echo '- The PRU $(PRUN) is now loaded with the firmware and is waiting to be started.' 60 | 61 | $(GEN_DIR)/$(TARGET).out: $(GEN_DIR)/$(TARGET).obj 62 | @echo 'LD $^' 63 | @lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 64 | 65 | $(GEN_DIR)/$(TARGET).obj: $(TARGET).c 66 | @mkdir -p $(GEN_DIR) 67 | @echo 'CC $<' 68 | @clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -D=PRUN=$(PRUN) -fe $@ $< 69 | 70 | clean: 71 | @echo 'CLEAN . PRU $(PRUN)' 72 | @rm -rf $(GEN_DIR) 73 | -------------------------------------------------------------------------------- /examples/firmware_examples/example2-rpmsg-pru1/PRU1/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Copyright (c) 2017 Texas Instruments - Jason Kridner 4 | # 5 | 6 | # TARGET must be defined as the file to be compiled without the .c. 7 | # PRUN must be defined as the PRU number (0 or 1) to compile for. 8 | 9 | # PRU_CGT environment variable points to the TI PRU compiler directory. 10 | # PRU_SUPPORT points to pru-software-support-package. 11 | # GEN_DIR points to where to put the generated files. 12 | 13 | 14 | #Added by Pratim 15 | PRUN=1 16 | TARGET=main 17 | #So that source.sh file can be ignored(increases complexity) 18 | 19 | PRU_CGT:=/usr/share/ti/cgt-pru 20 | PRU_SUPPORT:=/usr/lib/ti/pru-software-support-package 21 | GEN_DIR:=/tmp/pru$(PRUN)-gen 22 | 23 | LINKER_COMMAND_FILE=AM335x_PRU.cmd 24 | LIBS=--library=$(PRU_SUPPORT)/lib/rpmsg_lib.lib 25 | INCLUDE=--include_path=$(PRU_SUPPORT)/include --include_path=$(PRU_SUPPORT)/include/am335x 26 | 27 | STACK_SIZE=0x100 28 | HEAP_SIZE=0x100 29 | 30 | CFLAGS=-v3 -O2 --printf_support=minimal --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) --asm_directory=$(GEN_DIR) -ppd -ppa --asm_listing --c_src_interlist # --absolute_listing 31 | 32 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) -m $(GEN_DIR)/$(TARGET).map 33 | 34 | # Lookup PRU by address 35 | ifeq ($(PRUN),0) 36 | PRU_ADDR=4a334000 37 | endif 38 | ifeq ($(PRUN),1) 39 | PRU_ADDR=4a338000 40 | endif 41 | 42 | PRU_DIR=$(wildcard /sys/devices/platform/ocp/4a32600*.pruss-soc-bus/4a300000.pruss/$(PRU_ADDR).*/remoteproc/remoteproc*) 43 | 44 | #all: stop install start 45 | 46 | #stop: 47 | # @echo "- Stopping PRU $(PRUN)" 48 | # @echo stop | sudo tee $(PRU_DIR)/state || echo Cannot stop $(PRUN) 49 | 50 | #start: 51 | # @echo "- Starting PRU $(PRUN)" 52 | # @echo start | sudo tee $(PRU_DIR)/state 53 | 54 | install: $(GEN_DIR)/$(TARGET).out 55 | @echo '- copying firmware file $(GEN_DIR)/$(TARGET).out to $(GEN_DIR)/am335x-pru$(PRUN)-fw' 56 | @sudo cp $(GEN_DIR)/$(TARGET).out $(GEN_DIR)/am335x-pru$(PRUN)-fw 57 | @echo '- copying firmware file $(GEN_DIR)/am335x-pru$(PRUN)-fw to /lib/firmware/' 58 | @sudo cp $(GEN_DIR)/am335x-pru$(PRUN)-fw /lib/firmware/ 59 | @echo '- The PRU $(PRUN) is now loaded with the firmware and is waiting to be started.' 60 | 61 | $(GEN_DIR)/$(TARGET).out: $(GEN_DIR)/$(TARGET).obj 62 | @echo 'LD $^' 63 | @lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 64 | 65 | $(GEN_DIR)/$(TARGET).obj: $(TARGET).c 66 | @mkdir -p $(GEN_DIR) 67 | @echo 'CC $<' 68 | @clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -D=PRUN=$(PRUN) -fe $@ $< 69 | 70 | clean: 71 | @echo 'CLEAN . PRU $(PRUN)' 72 | @rm -rf $(GEN_DIR) 73 | -------------------------------------------------------------------------------- /examples/firmware_examples/example9-multichannel-waveform-gen/Makefile: -------------------------------------------------------------------------------- 1 | all: clean config pru0 pru1 userspace 2 | 3 | config: 4 | @echo ' -----------------------------------------------------------------' 5 | @echo ' -------------------- SETTING PINMUX --------------------' 6 | @echo ' -----------------------------------------------------------------' 7 | @config-pin P9-31 pruout 8 | @echo 'Waveform 1: P9_31' 9 | @config-pin P9-30 pruout 10 | @echo 'Waveform 2: P9_30' 11 | @config-pin P9-29 pruout 12 | @echo 'Waveform 3: P9_29' 13 | @config-pin P9-28 pruout 14 | @echo 'Waveform 4: P9_28' 15 | @config-pin P9-27 pruout 16 | @echo 'Waveform 5: P9_27' 17 | @config-pin P9-25 pruout 18 | @echo 'Waveform 6: P9_25' 19 | @config-pin P8-11 pruout 20 | @echo 'Waveform 7: P8_11' 21 | @config-pin P8-12 pruout 22 | @echo 'Waveform 8: P8_12' 23 | 24 | pru0: 25 | @cd ./PRU0/ && make 26 | @echo ' -----------------------------------------------------------------' 27 | @echo ' -------------------- PRU 0 FIRMWARE COMPILED --------------------' 28 | @echo ' ------------------------------------------------------------------' 29 | @cd ./PRU0/ && sudo make install 30 | @echo ' -----------------------------------------------------------------' 31 | @echo ' -------------------- PRU 0 FIRMWARE INSTALLED --------------------' 32 | @echo ' ------------------------------------------------------------------' 33 | 34 | pru1: 35 | @cd ./PRU1/ && make 36 | @echo ' -----------------------------------------------------------------' 37 | @echo ' -------------------- PRU 1 FIRMWARE COMPILED --------------------' 38 | @echo ' ------------------------------------------------------------------' 39 | @cd ./PRU1/ && make install 40 | @echo ' -----------------------------------------------------------------' 41 | @echo ' -------------------- PRU 1 FIRMWARE INSTALLED --------------------' 42 | @echo ' ------------------------------------------------------------------' 43 | 44 | userspace: 45 | @g++ userspace.cpp ../../../cpp-bindings/pruss.cpp -o userspace2.o 46 | @echo ' -----------------------------------------------------------------' 47 | @echo ' --------------------UserSpace Program Compiled--------------------' 48 | @echo ' ------------------------------------------------------------------' 49 | @./userspace2.o 50 | @echo ' -----------------------------------------------------------------' 51 | @echo ' -------------------- Completed Execution --------------------' 52 | @echo ' ------------------------------------------------------------------' 53 | 54 | clean: 55 | @echo ' -----------------------------------------------------------------' 56 | @echo ' -------------------- CLEAN --------------------' 57 | @echo ' ------------------------------------------------------------------' 58 | @cd ./PRU0/ && make clean 59 | @cd ./PRU1/ && make clean 60 | -------------------------------------------------------------------------------- /examples/firmware_examples/example9-multichannel-waveform-gen/PRU0/waveform_gen-2ch.asm: -------------------------------------------------------------------------------- 1 | ;* Source written by Pratim Ugale 2 | ;* Demonstrates 2-channel waveform generation 3 | ;* The samples are interveaved into the PRU SRAM. 4 | 5 | .cdecls "main_pru0.c" 6 | 7 | PRU_SRAM .set 0x00010000 ; Set the location of PRU Shared Memory 8 | 9 | .clink 10 | .global start 11 | start: ; One time setup. 12 | LDI32 R10, PRU_SRAM ; R10 -> Base address of PRU SRAM 13 | SUB R5, R5, R5 ; Clear the contents of R5 14 | LBBO &R5, R10, 0, 1 ; R5 -> Total number of samples including all the waveforms. 15 | LDI R6, 100 ; Total number of cycles for each individual wave sample. 16 | LDI R11, 0 ; Sample Counter. 17 | QBA sample_start 18 | SUB R16, R16, R16 19 | 20 | sample_start: ; 21 | 22 | QBLT same_sample, R5.b0, R11.b0 23 | LDI R11, 0 24 | 25 | same_sample: ; 26 | ADD R11, R11, 0x00000001 ; Increment offset counter by 1 27 | LBBO &R7.b0, R10, R11.b0, 1; R7 -> DC of Wave 1 28 | ADD R11, R11, 0x00000001 ; Increment offset counter by 1 29 | LBBO &R8.b0, R10, R11.b0, 1; R8 -> DC of Wave 2 30 | LDI32 R12, 10000 31 | LDI R9, 0 ; DC ON counter. 32 | LDI R15, 0 ; DC OFF counter. 33 | LDI32 R13, 0 ; Pulse counter. 34 | QBLT greaterthan_zero1, R7.b0, 1 35 | LDI R7.b0, 1 36 | 37 | greaterthan_zero1: 38 | QBGT lesserthan_hun1, R7.b0, 99 39 | LDI R7.b0, 99 40 | 41 | lesserthan_hun1: 42 | QBLT greaterthan_zero2, R8.b0, 1 43 | LDI R8.b0, 1 44 | 45 | greaterthan_zero2: 46 | QBGT count_check, R8.b0, 99 47 | LDI R8.b0, 99 48 | 49 | count_check: 50 | ADD R13, R13, 1 51 | QBEQ sample_start, R13, R12 52 | 53 | start_pwm1: 54 | SET R30, R30.t0 55 | SUB R14, R6, R7 56 | 57 | pwm1_high: 58 | ADD R9, R9, 0x00000001 59 | QBNE pwm1_high, R9.b0, R7.b0 60 | CLR R30, R30.t0 61 | 62 | pwm1_low: 63 | ADD R15, R15, 0x00000001 64 | QBNE pwm1_low, R15.b0, R14.b0 65 | SUB R15, R15, R15 66 | SUB R9, R9, R9 67 | 68 | start_pwm2: 69 | SET R30, R30.t2 70 | SUB R14, R6, R8 71 | 72 | pwm2_high: 73 | ADD R9, R9, 0x00000001 74 | QBNE pwm2_high, R9.b0, R8.b0 75 | CLR R30, R30.t2 76 | 77 | pwm2_low: 78 | ADD R15, R15, 0x00000001 79 | QBNE pwm2_low, R15.b0, R14.b0 80 | SUB R15, R15, R15 81 | SUB R9, R9, R9 82 | QBA count_check 83 | 84 | done_sample: 85 | QBA sample_start 86 | 87 | stop: 88 | HALT 89 | -------------------------------------------------------------------------------- /Documentation/SWIG.md: -------------------------------------------------------------------------------- 1 | # SWIG 2 | 3 | SWIG is an interface compiler that connects programs written in C and C++ with scripting languages. It works by taking the declarations found in C/C++ header files and using them to generate the wrapper code that scripting languages need to access the underlying C/C++ code.
4 | 5 | Download SWIG from [their site](http://www.swig.org/download.html) and follow steps given [here](https://www.dev2qa.com/how-to-install-swig-on-macos-linux-and-windows/) to complete installation.
6 | 7 | ### Note : if you get swig: command not found error then go to /etc/ and source profile so that the environment variables are set. 8 | 9 | The steps explained are for python. 10 | 11 | “wrapper” functions are needed to access C/C++ which serve as a glue layer between languages. 12 | 13 | After writing the .c and .h files for the C library, do this: 14 | 15 | 1. `$ swig -python example.i` 16 | 17 | 2. ` $ gcc -c example.c example_wrap.c \`
18 | `-I/usr/bin/python2.7`
19 | This is because the python2.7 file is found in /usr/bin/ on the BeagleBone Black Debian 20 | 21 | 3. On step #2, you might encounter this error: 22 | ``` 23 | fatal error: Python.h: No such file or directory 24 | # include 25 | ^ 26 | compilation terminated. 27 | ``` 28 | Following might be possible causes – 29 | 30 | You might not have ‘Python.h’ file or 31 | You are providing wrong location of ‘Python.h’ file to compiler 32 | 33 | To get ‘Python.h’ You must install Python-dev using following command –
34 | 35 | `$ sudo apt-get install python-dev`
36 | Most probably this will already be installed on the BBB.
37 | 38 | To find the correct path of ‘Python.h’ execute following command –
39 | `$ python-config --cflags`
40 | The output will be something like this - 41 | 42 | _**-I/usr/include/python2.7** -I/usr/include/arm-linux-gnueabihf/python2.7 -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-EEvVvy/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes_
43 | 44 | **I'm using g++ instead of gcc because gcc isn't allowing dynamic memory allocation in my program**
45 | 46 | Now do `$ g++ -c -fpic example_wrap.c example.c -I/usr/include/python2.7`
47 | I thought I will have to provide -I/usr/bin/python2.7 but it clearly is -I/usr/include/python2.7
48 | 49 | This should remove the "Python.h" error and will generate **_example_wrap.o_** and **_example.o_** files.
50 | 51 | 4. Now, at last, we have to link generated objects files together to create a shared object which is analogous to dll files in windows.
`$ g++ -shared example.o example_wrap.o -o _example.so`: this will generate a “example.so” shared object file.(**Note:** Sometimes `gcc` will be needed instead of `g++`) 52 | 53 | 5. Now we are ready to test out python wrapper by importing it. Make sure you are in directory having this wrapper file. 54 | 55 | -------------------------------------------------------------------------------- /drivers/test_example_rpmsg/PRU0/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 3 | * 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of Texas Instruments Incorporated nor the names of 18 | * its contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* 35 | * ======== resource_table_empty.h ======== 36 | * 37 | * Define the resource table entries for all PRU cores. This will be 38 | * incorporated into corresponding base images, and used by the remoteproc 39 | * on the host-side to allocated/reserve resources. Note the remoteproc 40 | * driver requires that all PRU firmware be built with a resource table. 41 | * 42 | * This file contains an empty resource table. It can be used either as: 43 | * 44 | * 1) A template, or 45 | * 2) As-is if a PRU application does not need to configure PRU_INTC 46 | * or interact with the rpmsg driver 47 | * 48 | */ 49 | 50 | #ifndef _RSC_TABLE_PRU_H_ 51 | #define _RSC_TABLE_PRU_H_ 52 | 53 | #include 54 | #include 55 | 56 | struct my_resource_table { 57 | struct resource_table base; 58 | 59 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 60 | }; 61 | 62 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 63 | #pragma RETAIN(pru_remoteproc_ResourceTable) 64 | struct my_resource_table pru_remoteproc_ResourceTable = { 65 | 1, /* we're the first version that implements this */ 66 | 0, /* number of entries in the table */ 67 | 0, 0, /* reserved, must be zero */ 68 | 0, /* offset[0] */ 69 | }; 70 | 71 | #endif /* _RSC_TABLE_PRU_H_ */ 72 | 73 | -------------------------------------------------------------------------------- /examples/firmware_examples/example2-rpmsg-pru1/PRU0/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 3 | * 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of Texas Instruments Incorporated nor the names of 18 | * its contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* 35 | * ======== resource_table_empty.h ======== 36 | * 37 | * Define the resource table entries for all PRU cores. This will be 38 | * incorporated into corresponding base images, and used by the remoteproc 39 | * on the host-side to allocated/reserve resources. Note the remoteproc 40 | * driver requires that all PRU firmware be built with a resource table. 41 | * 42 | * This file contains an empty resource table. It can be used either as: 43 | * 44 | * 1) A template, or 45 | * 2) As-is if a PRU application does not need to configure PRU_INTC 46 | * or interact with the rpmsg driver 47 | * 48 | */ 49 | 50 | #ifndef _RSC_TABLE_PRU_H_ 51 | #define _RSC_TABLE_PRU_H_ 52 | 53 | #include 54 | #include 55 | 56 | struct my_resource_table { 57 | struct resource_table base; 58 | 59 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 60 | }; 61 | 62 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 63 | #pragma RETAIN(pru_remoteproc_ResourceTable) 64 | struct my_resource_table pru_remoteproc_ResourceTable = { 65 | 1, /* we're the first version that implements this */ 66 | 0, /* number of entries in the table */ 67 | 0, 0, /* reserved, must be zero */ 68 | 0, /* offset[0] */ 69 | }; 70 | 71 | #endif /* _RSC_TABLE_PRU_H_ */ 72 | 73 | -------------------------------------------------------------------------------- /drivers/rpmsg_client_sample.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Remote processor messaging - sample client driver 3 | * 4 | * Copyright (C) 2011 Texas Instruments, Inc. 5 | * Copyright (C) 2011 Google, Inc. 6 | * 7 | * Ohad Ben-Cohen 8 | * Brian Swetland 9 | * 10 | * This software is licensed under the terms of the GNU General Public 11 | * License version 2, as published by the Free Software Foundation, and 12 | * may be copied, distributed, and modified under those terms. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #define MSG "hello world!" 25 | #define MSG_LIMIT 10 26 | 27 | struct instance_data { 28 | int rx_count; 29 | }; 30 | 31 | static int rpmsg_sample_cb(struct rpmsg_device *rpdev, void *data, int len, 32 | void *priv, u32 src) 33 | { 34 | int ret; 35 | struct instance_data *idata = dev_get_drvdata(&rpdev->dev); 36 | 37 | dev_info(&rpdev->dev, "incoming msg %d (src: 0x%x)\n", 38 | ++idata->rx_count, src); 39 | 40 | print_hex_dump(KERN_DEBUG, __func__, DUMP_PREFIX_NONE, 16, 1, 41 | data, len, true); 42 | 43 | /* samples should not live forever */ 44 | if (idata->rx_count >= MSG_LIMIT) { 45 | dev_info(&rpdev->dev, "goodbye!\n"); 46 | return 0; 47 | } 48 | 49 | /* send a new message now */ 50 | ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG)); 51 | if (ret) 52 | dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); 53 | 54 | return 0; 55 | } 56 | 57 | static int rpmsg_sample_probe(struct rpmsg_device *rpdev) 58 | { 59 | int ret; 60 | struct instance_data *idata; 61 | 62 | dev_info(&rpdev->dev, "new channel: 0x%x -> 0x%x!\n", 63 | rpdev->src, rpdev->dst); 64 | 65 | idata = devm_kzalloc(&rpdev->dev, sizeof(*idata), GFP_KERNEL); 66 | if (!idata) 67 | return -ENOMEM; 68 | 69 | dev_set_drvdata(&rpdev->dev, idata); 70 | 71 | /* send a message to our remote processor */ 72 | ret = rpmsg_send(rpdev->ept, MSG, strlen(MSG)); 73 | if (ret) { 74 | dev_err(&rpdev->dev, "rpmsg_send failed: %d\n", ret); 75 | return ret; 76 | } 77 | 78 | return 0; 79 | } 80 | 81 | static void rpmsg_sample_remove(struct rpmsg_device *rpdev) 82 | { 83 | dev_info(&rpdev->dev, "rpmsg sample client driver is removed\n"); 84 | } 85 | 86 | static struct rpmsg_device_id rpmsg_driver_sample_id_table[] = { 87 | { .name = "rpmsg-client-sample" }, 88 | { }, 89 | }; 90 | MODULE_DEVICE_TABLE(rpmsg, rpmsg_driver_sample_id_table); 91 | 92 | static struct rpmsg_driver rpmsg_sample_client = { 93 | .drv.name = KBUILD_MODNAME, 94 | .id_table = rpmsg_driver_sample_id_table, 95 | .probe = rpmsg_sample_probe, 96 | .callback = rpmsg_sample_cb, 97 | .remove = rpmsg_sample_remove, 98 | }; 99 | module_rpmsg_driver(rpmsg_sample_client); 100 | 101 | MODULE_DESCRIPTION("Remote processor messaging sample client driver"); 102 | MODULE_LICENSE("GPL v2"); 103 | -------------------------------------------------------------------------------- /examples/firmware_examples/example1-gpio-blinky/resource_table_empty.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 3 | * 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of Texas Instruments Incorporated nor the names of 18 | * its contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | /* 35 | * ======== resource_table_empty.h ======== 36 | * 37 | * Define the resource table entries for all PRU cores. This will be 38 | * incorporated into corresponding base images, and used by the remoteproc 39 | * on the host-side to allocated/reserve resources. Note the remoteproc 40 | * driver requires that all PRU firmware be built with a resource table. 41 | * 42 | * This file contains an empty resource table. It can be used either as: 43 | * 44 | * 1) A template, or 45 | * 2) As-is if a PRU application does not need to configure PRU_INTC 46 | * or interact with the rpmsg driver 47 | * 48 | */ 49 | 50 | #ifndef _RSC_TABLE_PRU_H_ 51 | #define _RSC_TABLE_PRU_H_ 52 | 53 | #include 54 | #include 55 | 56 | struct my_resource_table { 57 | struct resource_table base; 58 | 59 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 60 | }; 61 | #if !defined(__GNUC__) 62 | #pragma DATA_SECTION(resourceTable, ".resource_table") 63 | #pragma RETAIN(resourceTable) 64 | #define __resource_table 65 | #else 66 | #define __resource_table __attribute__((section(".resource_table"))) 67 | #endif 68 | 69 | struct my_resource_table pru_remoteproc_ResourceTable __resource_table = { 70 | { 71 | 1, /* we're the first version that implements this */ 72 | 0, /* number of entries in the table */ 73 | { 0, 0 }, /* reserved, must be zero */ 74 | }, 75 | { 0 }, /* offset[0] */ 76 | }; 77 | 78 | #endif /* _RSC_TABLE_PRU_H_ */ 79 | 80 | -------------------------------------------------------------------------------- /examples/firmware_examples/example1-gpio-blinky/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015, Dimitar Dimitrov 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # 7 | # * Redistributions of source code must retain the above copyright 8 | # notice, this list of conditions and the following disclaimer. 9 | # * Redistributions in binary form must reproduce the above copyright 10 | # notice, this list of conditions and the following disclaimer in 11 | # the documentation and/or other materials provided with the 12 | # distribution. 13 | # * Neither the name of the copyright holders nor the names of 14 | # contributors may be used to endorse or promote products derived 15 | # from this software without specific prior written permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | # POSSIBILITY OF SUCH DAMAGE. 28 | 29 | # Very simple makefile to cross-compile for PRU 30 | 31 | 32 | # Common flags 33 | CROSS_COMPILE ?= pru- 34 | CFLAGS += -g -Os 35 | CFLAGS += -Wall -Wextra 36 | 37 | # Headers needed by the TI rpmsg library. 38 | CFLAGS += -I../../include -I../../include/am335x 39 | 40 | # Define this to squeeze code size by removing atexit, exit, constructors 41 | # and destructors from CRT. 42 | CFLAGS += -minrt 43 | 44 | # Per-PRU core flags. The -mmcu option will select the correct linker 45 | # script and will predefine mcu-specific macros. 46 | CFLAGS0 += -mmcu=am335x.pru0 47 | CFLAGS1 += -mmcu=am335x.pru1 48 | 49 | # List of source files to compile for each PRU core. 50 | SRC0 := 51 | SRC1 := PRU_gpioToggle.c 52 | 53 | # GCC's -MMD does not yield the needed C dependencies when compiling all 54 | # C source files at once. So manually list headers here. 55 | HEADERS := $(wildcard *.h) $(wildcard ../include/*.h ../include/am335x/*.h) 56 | 57 | # Where to output compiled objects 58 | OUT := gen 59 | 60 | # Final ELF image file names 61 | ELF0 := 62 | ELF1 := $(OUT)/blinky.elf 63 | 64 | # ============================ DO NOT TOUCH BELOW ============================ 65 | all: $(ELF0) $(ELF1) 66 | @echo Success: $^ 67 | 68 | %.s : %.elf 69 | $(CROSS_COMPILE)objdump -S -d $< > $@ 70 | 71 | $(OUT): 72 | mkdir $(OUT) 73 | 74 | $(ELF0): $(SRC0) $(HEADERS) | $(OUT) 75 | $(CROSS_COMPILE)gcc $(CFLAGS) $(CFLAGS0) $(SRC0) $(LDFLAGS) -o $@ 76 | 77 | $(ELF1): $(SRC1) $(HEADERS) | $(OUT) 78 | $(CROSS_COMPILE)gcc $(CFLAGS) $(CFLAGS1) $(SRC1) $(LDFLAGS) -o $@ 79 | 80 | clean: 81 | $(RM) -fr $(ELF0) $(ELF1) $(OUT) 82 | 83 | cscope: 84 | cscope -bRk 85 | 86 | .PHONY: all clean cscope 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example7-stepper-control/PRU0/pulse-supply.asm: -------------------------------------------------------------------------------- 1 | ;* Source written by Pratim Ugale 2 | ;* This example is used to control a stepper motor by sending out precise number of pulse trains at required frequency(RPM). 3 | ;* The 4 byte ON_Cycles input must be in memory location 0x00010000 - 0x00010003 in little-endian byte order 4 | ;* The 4 byte Total_Cycles input must be in memory location 0x00010004 - 0x00010007 in little endian byte order 5 | ;* The 4 byte Number of Pulses input must be in memory location 0x00010008 - 0x000100011 in little-endian byte order 6 | 7 | .cdecls "main_pru0.c" 8 | 9 | PRU_SRAM .set 0x00010000 ; Set the location of PRU Shared Memory 10 | 11 | .clink 12 | .global start 13 | start: ; One time setup. 14 | LDI32 R9, PRU_SRAM ; R9 -> Base address of PRU SRAM 15 | SUB R6, R6, R6 ; Clear the contents of R6 16 | SUB R7, R7, R7 ; Clear the contents of R7 17 | SUB R8, R8, R8 ; Clear the contents of R7 18 | LBBO &R6, R9, 0, 4 ; R6 -> Duty Cycle.(actually ON cycles); Copy (4) bytes into R6 from memory address R9+offset(0) 19 | LBBO &R7, R9, 4, 4 ; R7 -> Total Cycles. Copy (4) bytes into R7 from memory address R9+offset(4) 20 | LBBO &R8, R9, 8, 4 ; R8 -> Number of pulses to be generated. Copy (4) bytes into R8 from memory address R9+offset(8) 21 | LDI R11, 0 ; R11 -> Total sample count (goes from 0 to 100 for 1MHz) 22 | LDI R10, 0 ; R10 -> Counts the number of pulses to be generated. 23 | QBA sample_start 24 | 25 | ADD R8, R8, 1 ; To equalize the pulse count 26 | 27 | count_check: ; Sends precise number of pulses (steps) to the stepper motor. 28 | ADD R10, R10, 1 ; Increment counter 29 | QBEQ stop, R10, R8 ; Stop if the total number of pulses have been generated. 30 | 31 | sample_start: ; 32 | SET R30, R30.t0 ; GPIO P9_31 HIGH -> Each low to high signal counts as a step for the motor. 33 | sample_high: ; [Loop consuming 2 PRU cycles per iteration] 34 | ADD R11, R11, 0x00000001 ; Increment counter by 1 35 | QBNE sample_high, R11, R6 ; Repeat loop until ON_Cycles 36 | NOP 37 | NOP 38 | ; NOP ; NOPs can be removed. This will yield a better frequency. The duty cycle of the pulses is not important. 39 | ; NOP 40 | ; NOP 41 | CLR R30, R30.t0 ; GPIO P9_31 OFF 42 | sample_low: ; [Loop consuming 2 PRU cycles per iteration] 43 | ADD R11, R11, 0x00000001 ; Increment counter by 1 44 | QBNE sample_low, R11, R7 ; Repeat loop until Total Cycles 45 | SUB R11, R11, R11 ; Clear the counter register 46 | QBA count_check ; One PWM cycle is completed. Repeat again for back to back pulses. 47 | 48 | stop: 49 | ; SET R31, R31.t30 50 | ;SET R31, R31.t5 ; Strobe interrupt configured in main_pru0.c by setting bit 5 of R31 to HIGH 51 | JMP R3.w2 ; R3.w2->contains return address; jumps back to the execution of c-code from which this .asm code was called 52 | -------------------------------------------------------------------------------- /examples/include/pru_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 3 | * 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 9 | * * Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 12 | * * Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the 15 | * distribution. 16 | * 17 | * * Neither the name of Texas Instruments Incorporated nor the names of 18 | * its contributors may be used to endorse or promote products derived 19 | * from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef _PRU_TYPES_H_ 35 | #define _PRU_TYPES_H_ 36 | 37 | /* Custom Resource info: Must match drivers/remoteproc/pru_rproc.h */ 38 | #define TYPE_PRU_INTS 1 39 | 40 | /** 41 | * struct ch_map - sysevts-to-channel mapping 42 | * 43 | * @evt: the number of the sysevt 44 | * @ch: channel number assigned to a given @sysevt 45 | * 46 | * PRU system events are mapped to channels, and these channels are mapped to 47 | * hosts. Events can be mapped to channels in a one-to-one or many-to-one ratio 48 | * (multiple events per channel), and channels can be mapped to hosts in a 49 | * one-to-one or many-to-one ratio (multiple events per channel). 50 | * 51 | * @evt is the number of the sysevt, and @ch is the number of the channel to be 52 | * mapped. 53 | */ 54 | 55 | struct ch_map { 56 | uint8_t evt; 57 | uint8_t ch; 58 | }; 59 | 60 | /** 61 | * struct fw_rsc_custom_ints - custom resource to define PRU interrupts 62 | * @version: revision number of the custom ints type 63 | * @channel_host: assignment of PRU channels to hosts 64 | * @num_evts: device address of INTC 65 | * @event_channel: mapping of sysevts to channels 66 | * 67 | * PRU system events are mapped to channels, and these channels are mapped to 68 | * hosts. Events can be mapped to channels in a one-to-one or many-to-one ratio 69 | * (multiple events per channel), and channels can be mapped to hosts in a 70 | * one-to-one or many-to-one ratio (multiple events per channel). 71 | * 72 | * @da is the device address of the interrupt controller, @channel_map is 73 | * used to specify to which channel, if any, an event is mapped, and @host_map 74 | * specifies to which host, if any, a channel is mapped. 75 | */ 76 | struct fw_rsc_custom_ints { 77 | uint16_t version; 78 | uint8_t channel_host[10]; 79 | uint32_t num_evts; 80 | struct ch_map *event_channel; 81 | }; 82 | 83 | #endif /* _PRU_TYPES_H_ */ 84 | -------------------------------------------------------------------------------- /node-bindings/pru.js: -------------------------------------------------------------------------------- 1 | const path = require('path'), 2 | send = require('./util/sock'); 3 | errno = require('./util/errno'); 4 | 5 | class PRU { 6 | constructor(no) { 7 | this._no = no; 8 | this._channelName = 'rpmsg_pru'; 9 | this._channelPort = no?31:30; 10 | this._state = 'NONE'; 11 | this.reset(); 12 | } 13 | 14 | setState(state) { 15 | this._state = state; 16 | } 17 | 18 | reset(cb) { 19 | this.disable((ret) => { 20 | this.enable((ret) => { 21 | return cb? cb(data): ret; 22 | }); 23 | }); 24 | } 25 | 26 | enable(cb) { 27 | if(this._state == 'NONE') 28 | return cb? cb(errno.ENODEV): errno.ENODEV; 29 | if(this._state == 'RUNNING' || this._state == 'HALTED') 30 | return cb? cb(errno.EALREADY): errno.EALREADY; 31 | send('ENABLE_'+this._no, (ret) => { 32 | ret = parseInt(ret); 33 | if(!ret) 34 | this._state = 'RUNNING'; 35 | return cb? cb(ret): ret; 36 | }); 37 | } 38 | 39 | disable(cb) { 40 | if(this._state == 'NONE') 41 | return cb? cb(errno.ENODEV): errno.ENODEV; 42 | if(this._state == 'STOPPED') 43 | return cb? cb(errno.EALREADY): errno.EALREADY; 44 | send('DISABLE_'+this._no, (ret) => { 45 | ret = parseInt(ret); 46 | if(!ret) 47 | this._state = 'STOPPED'; 48 | return cb? cb(ret): ret; 49 | }); 50 | } 51 | 52 | pause(cb) { 53 | if(this._state == 'NONE') 54 | return cb? cb(errno.ENODEV): errno.ENODEV; 55 | if(this._state == 'HALTED' || this._state == 'STOPPED') 56 | return cb? cb(errno.EALREADY): errno.EALREADY; 57 | send('PAUSE_'+this._no, (ret) => { 58 | ret = parseInt(ret); 59 | if(!ret) 60 | this._state = 'HALTED'; 61 | return cb? cb(ret): ret; 62 | }); 63 | } 64 | resume(cb) { 65 | if(this._state == 'NONE' || this._state == 'STOPPED') 66 | return cb? cb(errno.ENODEV): errno.ENODEV; 67 | if(this._state == 'RUNNING') 68 | return cb? cb(errno.EALREADY): errno.EALREADY; 69 | send('RESUME_'+this._no, (ret) => { 70 | ret = parseInt(ret); 71 | if(!ret) 72 | this._state = 'RUNNING'; 73 | return cb? cb(ret): ret; 74 | }); 75 | } 76 | getRegs(cb) { 77 | send('GETREGS_'+this._no, (data) => { 78 | return cb? cb(data): data; 79 | }); 80 | } 81 | 82 | load(fw, cb) { 83 | if(this.state == 'NONE') 84 | return cb? cb(errno.ENODEV): errno.ENODEV; 85 | this.disable((ret) => { 86 | send('LOAD_'+this._no+" "+path.resolve(fw), (ret) => { 87 | ret = parseInt(ret); 88 | if(!ret) 89 | this.enable((ret) => { 90 | return cb? cb(ret): ret; 91 | }); 92 | else 93 | return cb? cb(ret): ret; 94 | }); 95 | }); 96 | } 97 | 98 | setChannel(port, name) { 99 | if(port < 0) 100 | return errno.EINVAL; 101 | this._channelPort = port; 102 | this._channelName = name; 103 | return 0; 104 | } 105 | 106 | getState() { 107 | return this._state; 108 | } 109 | 110 | sendMsg(msg, cb) { 111 | send('SENDMSG '+this._channelName+" "+this._channelPort+" "+msg, (ret) => { 112 | return cb? cb(ret): ret; 113 | }) 114 | } 115 | getMsg(cb){ 116 | send('GETMSG '+this._channelName+" "+this._channelPort, (data) => { 117 | return cb? cb(data): data; 118 | }) 119 | } 120 | waitForEvent(time, cb){ 121 | if(time < 0) 122 | return cb? cb(errno.EINVAL): errno.EINVAL; 123 | if(time == undefined) { 124 | send('EVENTWAIT '+this._channelName+" "+this._channelPort, (ret) => { 125 | return cb? cb(ret): ret; 126 | }); 127 | } 128 | else { 129 | send('EVENTWAIT '+this._channelName+" "+this._channelPort+" "+time, (ret) => { 130 | return cb? cb(ret): ret; 131 | }); 132 | } 133 | } 134 | 135 | } 136 | 137 | module.exports = PRU; 138 | -------------------------------------------------------------------------------- /drivers/test_example_rpmsg/PRU0/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00010000 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /drivers/test_example_rpmsg/PRU1/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015-2018 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00010000 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example1-gpio-blinky/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00000100 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example1-usr3-blinky/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00000100 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example2-rpmsg-pru1/PRU0/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00010000 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example2-rpmsg-pru1/PRU1/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015-2018 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00010000 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/archive-pwm-c/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00000100 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/pwm-assembly/PRU0/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00000100 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example3-pwm/pwm-assembly/PRU1/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015-2018 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00010000 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example4-analog-wave-gen/PRU0/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00000100 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example4-analog-wave-gen/PRU1/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015-2018 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00010000 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example5-multichannel-pwm/PRU0/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00000100 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example5-multichannel-pwm/PRU1/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015-2018 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00010000 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | -------------------------------------------------------------------------------- /examples/firmware_examples/example7-stepper-control/PRU0/AM335x_PRU.cmd: -------------------------------------------------------------------------------- 1 | /****************************************************************************/ 2 | /* AM335x_PRU.cmd */ 3 | /* Copyright (c) 2015 Texas Instruments Incorporated */ 4 | /* */ 5 | /* Description: This file is a linker command file that can be used for */ 6 | /* linking PRU programs built with the C compiler and */ 7 | /* the resulting .out file on an AM335x device. */ 8 | /****************************************************************************/ 9 | 10 | -cr /* Link using C conventions */ 11 | 12 | /* Specify the System Memory Map */ 13 | MEMORY 14 | { 15 | PAGE 0: 16 | PRU_IMEM : org = 0x00000000 len = 0x00002000 /* 8kB PRU0 Instruction RAM */ 17 | 18 | PAGE 1: 19 | 20 | /* RAM */ 21 | 22 | PRU_DMEM_0_1 : org = 0x00000000 len = 0x00002000 CREGISTER=24 /* 8kB PRU Data RAM 0_1 */ 23 | PRU_DMEM_1_0 : org = 0x00002000 len = 0x00002000 CREGISTER=25 /* 8kB PRU Data RAM 1_0 */ 24 | 25 | PAGE 2: 26 | PRU_SHAREDMEM : org = 0x00010000 len = 0x00003000 CREGISTER=28 /* 12kB Shared RAM */ 27 | 28 | DDR : org = 0x80000000 len = 0x00000100 CREGISTER=31 29 | L3OCMC : org = 0x40000000 len = 0x00010000 CREGISTER=30 30 | 31 | 32 | /* Peripherals */ 33 | 34 | PRU_CFG : org = 0x00026000 len = 0x00000044 CREGISTER=4 35 | PRU_ECAP : org = 0x00030000 len = 0x00000060 CREGISTER=3 36 | PRU_IEP : org = 0x0002E000 len = 0x0000031C CREGISTER=26 37 | PRU_INTC : org = 0x00020000 len = 0x00001504 CREGISTER=0 38 | PRU_UART : org = 0x00028000 len = 0x00000038 CREGISTER=7 39 | 40 | DCAN0 : org = 0x481CC000 len = 0x000001E8 CREGISTER=14 41 | DCAN1 : org = 0x481D0000 len = 0x000001E8 CREGISTER=15 42 | DMTIMER2 : org = 0x48040000 len = 0x0000005C CREGISTER=1 43 | PWMSS0 : org = 0x48300000 len = 0x000002C4 CREGISTER=18 44 | PWMSS1 : org = 0x48302000 len = 0x000002C4 CREGISTER=19 45 | PWMSS2 : org = 0x48304000 len = 0x000002C4 CREGISTER=20 46 | GEMAC : org = 0x4A100000 len = 0x0000128C CREGISTER=9 47 | I2C1 : org = 0x4802A000 len = 0x000000D8 CREGISTER=2 48 | I2C2 : org = 0x4819C000 len = 0x000000D8 CREGISTER=17 49 | MBX0 : org = 0x480C8000 len = 0x00000140 CREGISTER=22 50 | MCASP0_DMA : org = 0x46000000 len = 0x00000100 CREGISTER=8 51 | MCSPI0 : org = 0x48030000 len = 0x000001A4 CREGISTER=6 52 | MCSPI1 : org = 0x481A0000 len = 0x000001A4 CREGISTER=16 53 | MMCHS0 : org = 0x48060000 len = 0x00000300 CREGISTER=5 54 | SPINLOCK : org = 0x480CA000 len = 0x00000880 CREGISTER=23 55 | TPCC : org = 0x49000000 len = 0x00001098 CREGISTER=29 56 | UART1 : org = 0x48022000 len = 0x00000088 CREGISTER=11 57 | UART2 : org = 0x48024000 len = 0x00000088 CREGISTER=12 58 | 59 | RSVD10 : org = 0x48318000 len = 0x00000100 CREGISTER=10 60 | RSVD13 : org = 0x48310000 len = 0x00000100 CREGISTER=13 61 | RSVD21 : org = 0x00032400 len = 0x00000100 CREGISTER=21 62 | RSVD27 : org = 0x00032000 len = 0x00000100 CREGISTER=27 63 | 64 | } 65 | 66 | /* Specify the sections allocation into memory */ 67 | SECTIONS { 68 | /* Forces _c_int00 to the start of PRU IRAM. Not necessary when loading 69 | an ELF file, but useful when loading a binary */ 70 | .text:_c_int00* > 0x0, PAGE 0 71 | 72 | .text > PRU_IMEM, PAGE 0 73 | .stack > PRU_DMEM_0_1, PAGE 1 74 | .bss > PRU_DMEM_0_1, PAGE 1 75 | .cio > PRU_DMEM_0_1, PAGE 1 76 | .data > PRU_DMEM_0_1, PAGE 1 77 | .switch > PRU_DMEM_0_1, PAGE 1 78 | .sysmem > PRU_DMEM_0_1, PAGE 1 79 | .cinit > PRU_DMEM_0_1, PAGE 1 80 | .rodata > PRU_DMEM_0_1, PAGE 1 81 | .rofardata > PRU_DMEM_0_1, PAGE 1 82 | .farbss > PRU_DMEM_0_1, PAGE 1 83 | .fardata > PRU_DMEM_0_1, PAGE 1 84 | 85 | .resource_table > PRU_DMEM_0_1, PAGE 1 86 | } 87 | --------------------------------------------------------------------------------