├── .gitignore ├── .travis.yml ├── .travis_test ├── Makefile └── travis_test.c ├── Makefile ├── README.md ├── beaglescope ├── Makefile └── beaglescope_driver.c ├── docs ├── BBB-ADC.pdf ├── BeagleboneBlackP8HeaderTable.pdf ├── BeagleboneBlackP9HeaderTable.pdf ├── Beaglescope - short presentation.pdf ├── Introductory_slides.pdf ├── clpru_and_C_usage.notes ├── current_remoteproc_drivers.notes ├── interrupt_frequency_beaglescope_driver.txt └── wiki_generic_sf_stack.png ├── driver ├── Makefile ├── dc782a.c ├── parallel_interface.c ├── parallel_interface.h ├── pi-bus.c └── test.patch ├── dtc └── PI-TEST-00A0.dts ├── examples ├── README.md ├── firmware_exmples │ ├── PRU_inline_asm_blinky │ │ ├── AM335x_PRU.cmd │ │ ├── Makefile │ │ ├── main_pru1.c │ │ ├── pru1-asm-blinky.asm │ │ └── resource_table_pru1.h │ ├── pru1_to_pru0_to_arm │ │ ├── AM335x_PRU.cmd │ │ ├── Makefile │ │ ├── main_pru0.c │ │ ├── main_pru1.c │ │ ├── pru_defs.h │ │ ├── resource_table_pru0.h │ │ └── resource_table_pru1.h │ ├── pru_blinky │ │ ├── PRU_gpioToggle │ │ │ ├── .ccsproject │ │ │ ├── .cproject │ │ │ ├── .project │ │ │ ├── .settings │ │ │ │ ├── org.eclipse.cdt.codan.core.prefs │ │ │ │ └── org.eclipse.cdt.debug.core.prefs │ │ │ ├── AM335x_PRU.cmd │ │ │ ├── Makefile │ │ │ ├── PRU_gpioToggle.c │ │ │ └── resource_table_empty.h │ │ └── deploy.sh │ ├── pru_logic_replicate │ │ ├── PRU_triggeredOutput │ │ │ ├── .bashrc │ │ │ ├── .ccsproject │ │ │ ├── .cproject │ │ │ ├── .project │ │ │ ├── .settings │ │ │ │ ├── org.eclipse.cdt.codan.core.prefs │ │ │ │ └── org.eclipse.cdt.debug.core.prefs │ │ │ ├── AM335x_PRU.cmd │ │ │ ├── Makefile │ │ │ ├── PRU_triggeredOutput.c │ │ │ └── resource_table_empty.h │ │ └── deploy.sh │ └── pru_pin_state_reader │ │ ├── PRU_PIN_STATE_READER │ │ ├── .ccsproject │ │ ├── .cproject │ │ ├── .project │ │ ├── .settings │ │ │ ├── org.eclipse.cdt.codan.core.prefs │ │ │ └── org.eclipse.cdt.debug.core.prefs │ │ ├── AM335x_PRU.cmd │ │ ├── Makefile │ │ ├── main.c │ │ └── resource_table_1.h │ │ └── deploy.sh ├── include │ ├── ReadMe.txt │ ├── am335x │ │ ├── pru_cfg.h │ │ ├── pru_ctrl.h │ │ ├── pru_ecap.h │ │ ├── pru_iep.h │ │ ├── pru_intc.h │ │ ├── pru_uart.h │ │ ├── sys_mailbox.h │ │ └── sys_pwmss.h │ ├── am437x │ │ ├── pru_cfg.h │ │ ├── pru_ctrl.h │ │ ├── pru_ecap.h │ │ ├── pru_iep.h │ │ ├── pru_intc.h │ │ ├── pru_uart.h │ │ ├── sys_adc0TscSs.h │ │ ├── sys_adc1MagSs.h │ │ ├── sys_mailbox.h │ │ └── sys_pwmss.h │ ├── am571x │ │ ├── pru_cfg.h │ │ ├── pru_ctrl.h │ │ ├── pru_ecap.h │ │ ├── pru_iep.h │ │ ├── pru_intc.h │ │ ├── pru_uart.h │ │ ├── sys_mailbox.h │ │ └── sys_pwmss.h │ ├── am572x_1_1 │ │ ├── pru_cfg.h │ │ ├── pru_ctrl.h │ │ ├── pru_ecap.h │ │ ├── pru_iep.h │ │ ├── pru_intc.h │ │ ├── pru_uart.h │ │ ├── sys_mailbox.h │ │ └── sys_pwmss.h │ ├── am572x_2_0 │ │ ├── pru_cfg.h │ │ ├── pru_ctrl.h │ │ ├── pru_ecap.h │ │ ├── pru_iep.h │ │ ├── pru_intc.h │ │ ├── pru_uart.h │ │ ├── sys_mailbox.h │ │ └── sys_pwmss.h │ ├── k2g │ │ ├── pru_cfg.h │ │ ├── pru_ctrl.h │ │ ├── pru_ecap.h │ │ ├── pru_iep.h │ │ ├── pru_intc.h │ │ └── pru_uart.h │ ├── pru_rpmsg.h │ ├── pru_types.h │ ├── pru_virtio_ids.h │ ├── pru_virtio_ring.h │ ├── pru_virtqueue.h │ ├── rsc_types.h │ └── types.h ├── kernel_examples │ └── n-blinky │ │ ├── Makefile │ │ ├── firmware │ │ ├── AM335x_PRU.cmd │ │ ├── Makefile │ │ ├── deploy.sh │ │ ├── main_pru1.c │ │ └── resource_table_1.h │ │ └── module │ │ ├── Makefile │ │ └── rpmsg_pru_parallel_example.c └── lib │ ├── rpmsg_lib.lib │ └── src │ ├── Makefile │ └── rpmsg_lib │ ├── .ccsproject │ ├── .cproject │ ├── .project │ ├── .settings │ ├── org.eclipse.cdt.codan.core.prefs │ └── org.eclipse.cdt.debug.core.prefs │ ├── Makefile │ ├── pru_rpmsg.c │ └── pru_virtqueue.c ├── firmware ├── AM335x_PRU.cmd ├── Makefile ├── README.md ├── common_pru_defs.h ├── main_pru0.c ├── main_pru1.c ├── main_pru1_def.asm ├── resource_table_pru0.h ├── resource_table_pru1.h └── test.patch └── quickstart.md /.gitignore: -------------------------------------------------------------------------------- 1 | gen/ 2 | tags 3 | .*.swp 4 | *.dwo 5 | *.ko 6 | *.ko.cmd 7 | *.o 8 | *.o.cmd 9 | *.mod.c 10 | *.mod.o.cmd 11 | modules.order 12 | Module.symvers 13 | .tmp_versions/ 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | ####################################################################################### 4 | 5 | 6 | os: 7 | - linux 8 | 9 | 10 | ####################################################################################### 11 | 12 | 13 | before_install: 14 | 15 | - sudo apt-get update -qq 16 | 17 | # downloading the latest version of the linaro toolchain. 18 | - wget -c https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz 19 | - tar xf gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz 20 | - export PATH=$PATH:$PWD/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/ 21 | - arm-linux-gnueabihf-gcc --version 22 | 23 | - sudo apt-get install bc 24 | 25 | 26 | ####################################################################################### 27 | 28 | 29 | before_script: 30 | 31 | #DST_PROJECT is the beaglescope project directory 32 | - export DST_PROJECT=$PWD 33 | 34 | # The SOURCE_VERSION and SOURCE_LOCATION together define the complete link to the gzipped tar file of 35 | # linux source code and its .config file against which the beaglescope project is build to test it. 36 | # 37 | # SOURCE_BRANCH="a.branch" 38 | # SOURCE_VERSION="x.y.z" 39 | # SOURCE_REPO="the_repo" 40 | # SOURCE_LOCATION="https://example-location.com/source" 41 | # Combined source link will be = "https://example-location.com/source/the_repo/archive/a.branch-x.y.z.tar.gz" 42 | # and 43 | # Combined .config link will be = "http://rcn-ee.net/deb/jessie-armhf/v$SOURCE_VERSION/defconfig" 44 | 45 | - export SOURCE_BRANCH="4.4.12" 46 | - export SOURCE_VERSION="ti-r31" 47 | - export SOURCE_REPO="linux-stable-rcn-ee" 48 | - export SOURCE_LOCATION="https://github.com/RobertCNelson" 49 | 50 | # download and extract the linux source code. 51 | - wget "$SOURCE_LOCATION/$SOURCE_REPO/archive/$SOURCE_BRANCH-$SOURCE_VERSION.tar.gz" 52 | - tar -zvxf $SOURCE_BRANCH-$SOURCE_VERSION.tar.gz 53 | 54 | # DST_KERNEL is the path to the linux source code 55 | - export DST_KERNEL=$PWD/$SOURCE_REPO-$SOURCE_BRANCH-$SOURCE_VERSION 56 | 57 | 58 | ####################################################################################### 59 | 60 | 61 | script: 62 | 63 | # exporting the variable to be used by make utility 64 | - export ARCH=arm 65 | - export CROSS_COMPILE=arm-linux-gnueabihf- 66 | 67 | # download the .config file for the chosen linux version and 68 | # preparing the kernel source 69 | 70 | - cd $DST_KERNEL 71 | - make -j3 mrproper ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOCALVERSION=-$SOURCE_VERSION 72 | - wget -c "http://rcn-ee.net/deb/jessie-armhf/v$SOURCE_BRANCH-$SOURCE_VERSION/defconfig" -O .config 73 | - make -j3 modules ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOCALVERSION=-$SOURCE_VERSION 2>&1 74 | 75 | # building the project 76 | - cd $DST_PROJECT/ 77 | - make KDIR=$DST_KERNEL ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOCALVERSION=-$SOURCE_VERSION 78 | -------------------------------------------------------------------------------- /.travis_test/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Makefile for travis_test.ko 3 | 4 | obj-m += travis_test.o 5 | 6 | 7 | KDIR?=/lib/modules/$(shell uname -r)/build 8 | 9 | 10 | travis_test: travis_test.c 11 | make -C $(KDIR) M=$(PWD) modules 12 | 13 | .PHONY: clean 14 | clean: 15 | make -C $(KDIR) M=$(PWD) clean 16 | -------------------------------------------------------------------------------- /.travis_test/travis_test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * travis_test.c - An simple loadable kernel module to test the working of travis CI. 3 | * 4 | * This program has been developed by ZeekHuge. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation version 2. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | 24 | 25 | static int __init init_travis_test(void) 26 | { 27 | printk(KERN_DEBUG "travis_test kernel was loaded.\n"); 28 | return 0; 29 | } 30 | module_init(init_travis_test); 31 | 32 | 33 | static void __exit exit_travis_test(void) 34 | { 35 | printk(KERN_DEBUG "travis_test kernel was unloaded.\n"); 36 | } 37 | module_exit(exit_travis_test); 38 | 39 | 40 | MODULE_LICENSE("GPL v2"); 41 | MODULE_AUTHOR("ZeekHuge"); -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ################################################## 2 | # Makefile for the BeagleScop project 3 | ################################################## 4 | 5 | SUBDIRS=driver/ 6 | 7 | KDIR?=/lib/modules/$(shell uname -r)/build 8 | 9 | .PHONY: all 10 | all: 11 | @cd $(SUBDIRS) && $(MAKE) 12 | 13 | .PHONY: clean 14 | clean: 15 | @cd $(SUBDIRS) && $(MAKE) clean 16 | 17 | travis_test: 18 | cd .travis_test && $(MAKE) 19 | -------------------------------------------------------------------------------- /beaglescope/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile written by Zubeen Tolani 3 | # Copyright (C) 2016 Zubeen Tolani 4 | # 5 | # 6 | 7 | obj-m += beaglescope_driver.o 8 | 9 | KDIR?=/lib/modules/$(shell uname -r)/build 10 | INSTALL?=/lib/modules/$(shell uname -r)/kernel/drivers/testing 11 | OP=$(patsubst %.o,%.ko,$(obj-m)) 12 | MODNAME=$(patsubst %.o,%,$(obj-m)) 13 | 14 | .PHONY: all driver 15 | all: driver 16 | 17 | driver: 18 | @make -C $(KDIR) M=$(PWD) modules 19 | 20 | .PHONY: install install-driver install-testing 21 | 22 | install: all 23 | @mkdir -p $(INSTALL) 24 | @for file in $(OP) ; do \ 25 | echo " - copying $$file driver to $(INSTALL)" ; \ 26 | cp $$file $(INSTALL) ; \ 27 | done 28 | @echo " - executing depmod -a" 29 | @depmod -a 30 | 31 | .PHONY: load 32 | load: install 33 | @for file in $(MODNAME) ; do \ 34 | echo " - rmmod $$file" ; \ 35 | rmmod $$file | true ; \ 36 | done 37 | @for file in $(MODNAME) ; do \ 38 | echo " - modprobe $$file" ; \ 39 | modprobe $$file ; \ 40 | done 41 | 42 | .PHONY: clean 43 | clean: 44 | @make -C $(KDIR) M=$(PWD) clean 45 | @cd testing && $(MAKE) clean 46 | -------------------------------------------------------------------------------- /docs/BBB-ADC.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeekhuge/BeagleScope/757017f3d533ee048d40c8289b70054ada85e945/docs/BBB-ADC.pdf -------------------------------------------------------------------------------- /docs/BeagleboneBlackP8HeaderTable.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeekhuge/BeagleScope/757017f3d533ee048d40c8289b70054ada85e945/docs/BeagleboneBlackP8HeaderTable.pdf -------------------------------------------------------------------------------- /docs/BeagleboneBlackP9HeaderTable.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeekhuge/BeagleScope/757017f3d533ee048d40c8289b70054ada85e945/docs/BeagleboneBlackP9HeaderTable.pdf -------------------------------------------------------------------------------- /docs/Beaglescope - short presentation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeekhuge/BeagleScope/757017f3d533ee048d40c8289b70054ada85e945/docs/Beaglescope - short presentation.pdf -------------------------------------------------------------------------------- /docs/Introductory_slides.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeekhuge/BeagleScope/757017f3d533ee048d40c8289b70054ada85e945/docs/Introductory_slides.pdf -------------------------------------------------------------------------------- /docs/interrupt_frequency_beaglescope_driver.txt: -------------------------------------------------------------------------------- 1 | The results of testing done to get an approximate number of interrupts 2 | being generated by the PRU core, based on the RPMsg framework, while 3 | sending data to the ARM. This test is based on the current version 4 | of beaglescope_driver 5 | 6 | Following instructions have been used for testing 7 | 8 | (all paths with reference to /sys/bus/iio/devices/iio\:device0/) 9 | To change the sampling frequency 10 | $ echo > in_voltage0_sampling_frequency 11 | 12 | -------------------- 13 | 14 | To start buffered capture 15 | $ echo 1 > buffer/enable 16 | 17 | -------------------- 18 | 19 | To stop buffered capture 20 | $ echo 0 > buffer/enable 21 | 22 | -------------------- 23 | 24 | To see the number of interrupts related to PRUs 25 | $ cat /proc/interrupts 26 | 27 | -------------------- 28 | 29 | Output of /proc/interrupts : 30 | 31 | root@beaglebone:~# cat /proc/interrupts 32 | CPU0 33 | 16: 131197 INTC 68 Level gp_timer 34 | 19: 1 INTC 78 Level wkup_m3_txev 35 | 20: 7315 INTC 12 Level 49000000.edma_ccint 36 | 22: 106 INTC 14 Level 49000000.edma_ccerrint 37 | 26: 0 INTC 96 Level 44e07000.gpio 38 | 33: 0 44e07000.gpio 6 Edge 48060000.mmc cd 39 | 59: 0 INTC 98 Level 4804c000.gpio 40 | 92: 0 INTC 32 Level 481ac000.gpio 41 | 125: 0 INTC 62 Level 481ae000.gpio 42 | 158: 24 INTC 72 Level 44e09000.serial 43 | 159: 3615 INTC 70 Level 44e0b000.i2c 44 | 160: 36 INTC 30 Level 4819c000.i2c 45 | 161: 13 INTC 64 Level mmc0 46 | 162: 22688 INTC 28 Level mmc1 47 | 164: 0 INTC 77 Level wkup_m3 48 | 170: 0 INTC 75 Level rtc0 49 | 171: 0 INTC 76 Level rtc0 50 | 175: 0 INTC 41 Level 4a100000.ethernet 51 | 176: 0 INTC 42 Level 4a100000.ethernet 52 | 178: 0 INTC 109 Level 53100000.sham 53 | 180: 0 INTC 80 Level 48038000.mcasp_tx 54 | 181: 0 INTC 81 Level 48038000.mcasp_rx 55 | 182: 0 INTC 82 Level 4803c000.mcasp_tx 56 | 183: 0 INTC 83 Level 4803c000.mcasp_rx 57 | 184: 0 INTC 111 Level 48310000.rng 58 | 186: 5390 INTC 18 Level musb-hdrc.0.auto 59 | 187: 1 INTC 19 Level musb-hdrc.1.auto 60 | 188: 0 INTC 17 Level 47400000.dma-controller 61 | 189: 0 INTC 7 Level tps65217 62 | 198: 1 4a320000.intc 16 Edge remoteproc2 63 | 211: 0 INTC 71 Level 4802a000.i2c 64 | IPI0: 0 CPU wakeup interrupts 65 | IPI1: 0 Timer broadcast interrupts 66 | IPI2: 0 Rescheduling interrupts 67 | IPI3: 0 Function call interrupts 68 | IPI4: 0 Single function call interrupts 69 | IPI5: 0 CPU stop interrupts 70 | IPI6: 0 IRQ work interrupts 71 | IPI7: 0 completion interrupts 72 | Err: 0 73 | 74 | 75 | Interrupt from PRUs: 76 | The IRQ number 198 is the interrupt from the PRUs that looks 77 | like : 78 | 79 | 198: 1 4a320000.intc 16 Edge remoteproc2 80 | 81 | 82 | 83 | --------------------------------------------------------------------- 84 | 85 | 86 | HOW THE TESTING WAS DONE: 87 | 88 | START: 89 | 90 | - Sampling frequency was set 91 | - Initial number of interrupts was noted. 92 | - buffered capture was started using : 93 | $ echo 1 > buffer/enable && sleep 3 & echo 0 > buffer/enable 94 | - Final number of interrupts was noted. 95 | 96 | goto START; 97 | 98 | ---------------------------------------------------------------------- 99 | 100 | TEST RESULTS: 101 | 102 | Sampling frequency - 500000 = 500KHz 103 | Initial interrupt number - 327698 104 | Final interrupt number (after 3 second) - 365863 105 | Number of Interrupts in those 3 seconds - 38165 106 | Number of interrupts per second - 12722 (approx.) 107 | Number of interrupts per second per KHz - 2544 108 | 109 | Sampling frequency - 800000 = 800KHz 110 | Initial interrupt number - 418294 111 | Final interrupt number (after 3 second) - 479752 112 | Number of Interrupts in those 3 seconds - 61458 113 | Number of interrupts per second - 20486 114 | Number of interrupts per second per KHz - 2560 115 | 116 | Sampling frequency - 900900 = 900.9KHz 117 | Initial interrupt number - 475019 118 | Final interrupt number (after 3 second) - 552846 119 | Number of Interrupts in those 3 seconds - 77827 120 | Number of interrupts per second - 25949 121 | Number of interrupts per second per KHz - 2882 122 | -------------------------------------------------------------------------------- /docs/wiki_generic_sf_stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeekhuge/BeagleScope/757017f3d533ee048d40c8289b70054ada85e945/docs/wiki_generic_sf_stack.png -------------------------------------------------------------------------------- /driver/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile written by Zubeen Tolani 3 | # Copyright (C) 2016 Zubeen Tolani 4 | # 5 | # 6 | 7 | # The drivers should be arranged from down to bottom 8 | # hierarchy order. 9 | # The arrangement of the modules is as: 10 | # 11 | # [beaglescope_driver] 12 | # \ 13 | # \ [pi_bus] 14 | # \ / 15 | # \/ \/ 16 | # [parallel_interface] 17 | # 18 | obj-m += dc782a.o 19 | obj-m += pi-bus.o 20 | obj-m += parallel_interface.o 21 | 22 | KDIR?=/lib/modules/$(shell uname -r)/build 23 | INSTALL?=/lib/modules/$(shell uname -r)/kernel/drivers/testing 24 | OP=$(patsubst %.o,%.ko,$(obj-m)) 25 | MODNAME=$(patsubst %.o,%,$(obj-m)) 26 | 27 | .PHONY: all driver 28 | all: driver 29 | 30 | driver: 31 | @make -C $(KDIR) M=$(PWD) modules 32 | 33 | .PHONY: install install-driver install-testing 34 | 35 | install: all 36 | @mkdir -p $(INSTALL) 37 | @for file in $(OP) ; do \ 38 | echo " - copying $$file driver to $(INSTALL)" ; \ 39 | cp $$file $(INSTALL) ; \ 40 | done 41 | @echo " - executing depmod -a" 42 | @depmod -a 43 | 44 | .PHONY: load 45 | load: install 46 | @for file in $(MODNAME) ; do \ 47 | echo " - rmmod $$file" ; \ 48 | rmmod $$file | true ; \ 49 | done 50 | @for file in $(MODNAME) ; do \ 51 | echo " - modprobe $$file" ; \ 52 | modprobe $$file ; \ 53 | done 54 | 55 | .PHONY: clean 56 | clean: 57 | @make -C $(KDIR) M=$(PWD) clean 58 | @cd testing && $(MAKE) clean 59 | -------------------------------------------------------------------------------- /driver/dc782a.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Zubeen Tolani 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU General Public License version 2 as published by 6 | * the Free Software Foundation. 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "parallel_interface.h" 25 | 26 | 27 | /** 28 | * Helper macro to print debug info easily. 29 | * These are temporary and will be removed/replaced in the final version. 30 | */ 31 | #define log_debug() printk(KERN_DEBUG "[%s] %s\n", __this_module.name, \ 32 | __FUNCTION__) 33 | #define log_debug_msg(...) printk(KERN_DEBUG __VA_ARGS__ ) 34 | 35 | 36 | static const struct pi_device_id dc782a_id[] = { 37 | {"dc782a", 0}, 38 | {} 39 | }; 40 | MODULE_DEVICE_TABLE(pi, dc782a_id); 41 | 42 | static int dc782a_probe (struct pi_device *dev) 43 | { 44 | log_debug(); 45 | return 0; 46 | } 47 | 48 | static void dc782a_remove (struct pi_device *dev) 49 | { 50 | log_debug(); 51 | } 52 | 53 | static struct pi_driver dc782a_driver= { 54 | .driver = { 55 | .name = KBUILD_MODNAME, 56 | .owner = THIS_MODULE, 57 | }, 58 | .id_table = dc782a_id, 59 | .probe = dc782a_probe, 60 | .remove = dc782a_remove, 61 | }; 62 | module_pi_driver(dc782a_driver); 63 | 64 | MODULE_AUTHOR("Zubeen Tolani "); 65 | MODULE_DESCRIPTION("BeagleScope Driver"); 66 | MODULE_LICENSE("GPL v2"); 67 | -------------------------------------------------------------------------------- /driver/parallel_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Zubeen Tolani 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU General Public License version 2 as published by 6 | * the Free Software Foundation. 7 | */ 8 | #ifndef __PARALLEL_INTERFACE__ 9 | #define __PARALLEL_INTERFACE__ 10 | 11 | #include 12 | #include 13 | 14 | #define PI_NAME_SIZE 32 15 | #define PI_MODULE_PREFIX "pi:" 16 | 17 | /** 18 | * pi_device_id Structure to be used in a device-driver to supply the 19 | * device id used to match a device. 20 | * 21 | * @name The name of the device that needs to be matched with 22 | * the driver. 23 | * @driver_data The device specific data that will be needed by the 24 | * device driver once its matched. 25 | */ 26 | struct pi_device_id { 27 | char name[PI_NAME_SIZE]; 28 | kernel_ulong_t driver_data; 29 | }; 30 | 31 | /** 32 | * pi_bus_host The structure to be used for bus host device. 33 | * 34 | * @dev The device member of the structure. 35 | */ 36 | struct pi_bus_host { 37 | struct device dev; 38 | }; 39 | 40 | /** 41 | * to_pi_bus_host Helper macro to get the pi_bus_host device from its 42 | * member device object. 43 | * 44 | * @__dev Pointer to the device associated with a pi_bus_host device. 45 | */ 46 | #define to_pi_bus_host(__dev)\ 47 | container_of(__dev, struct pi_bus_ctrlr, dev); 48 | 49 | #define PI_MODALIAS_LENGTH PI_NAME_SIZE 50 | 51 | /** 52 | * pi_device The structure to be used for a client device on the pi bus. 53 | * 54 | * @pibushost The bus host device to which the client device is 55 | * connected. 56 | * @modalias The modalias value associated with the device node. 57 | * @dev The member device of the pi_device structure. 58 | */ 59 | struct pi_device { 60 | struct pi_bus_host *pibushost; 61 | char modalias[PI_MODALIAS_LENGTH]; 62 | struct device dev; 63 | }; 64 | 65 | /** 66 | * to_pi_device Helper macro to get the pi_device object from its 67 | * member device object. 68 | * 69 | * @__dev Pointer to the device associated with pi_device object. 70 | */ 71 | #define to_pi_device(__dev)\ 72 | container_of(__dev, struct pi_device, dev); 73 | 74 | /** 75 | * pi_driver The structure to be used by the device-driver to register 76 | * itself as a device driver onto the pi-bus. 77 | * 78 | * @id_table The table containing ids of the device supported by the device 79 | * driver. 80 | * @driver The device_driver member of the pi_driver structure. 81 | * @probe The device driver probe method. 82 | * @remove The device driver remove method. 83 | * @callback The device driver callback method that will be called when 84 | * there is some data from the device for the driver. 85 | */ 86 | struct pi_driver { 87 | const struct pi_device_id *id_table; 88 | struct device_driver driver; 89 | int (*probe)(struct pi_device *dev); 90 | void (*remove)(struct pi_device *dev); 91 | void (*callback)(struct pi_device *, void *, int, void *, u32); 92 | }; 93 | 94 | /** 95 | * to_pi_driver Helper macro to get the pi_driver object from its 96 | * member device_driver object. 97 | * 98 | * @__drv Pointer to the device_driver associated with a pi_driver 99 | * object. 100 | */ 101 | #define to_pi_driver(__drv)\ 102 | container_of(__drv, struct pi_driver, driver); 103 | 104 | /** 105 | * pi_unregister_driver Function that can be used to unregister an 106 | * already registered device driver. 107 | * 108 | * @pidrv The pi_driver structure associated with the device driver. 109 | */ 110 | static inline void pi_unregister_driver (struct pi_driver *pidrv){ 111 | driver_unregister(&pidrv->driver); 112 | } 113 | 114 | extern int __pi_register_driver (char *name, struct module *owner, 115 | struct pi_driver *pidrv); 116 | 117 | /** 118 | * pi_register_driver Helper macro to register the device driver onto the 119 | * pi-bus. The macro should only be called when there is 120 | * something else to be done in the driver __init 121 | * function. In simpler cases, the macro module_pi_driver 122 | * can be used. 123 | * 124 | * @__drv The pi_driver associated with the device driver. 125 | */ 126 | #define pi_register_driver(__drv) \ 127 | __pi_register_driver (KBUILD_MODNAME ,THIS_MODULE, __drv) 128 | 129 | /** 130 | * module_pi_driver Helper macro for drivers that don't do anything special 131 | * in module init/exit. This eliminates a lot of 132 | * boilerplate. Each module may only use this macro once, 133 | * and calling it replaces module_init() and 134 | * module_exit(). 135 | * 136 | * @__pi_driver the pi-bus specific device driver structure of 137 | * pi_driver type. 138 | */ 139 | #define module_pi_driver(__pi_driver) \ 140 | module_driver(__pi_driver, pi_register_driver, pi_unregister_driver) 141 | 142 | extern int pi_core_register_devices(struct pi_bus_host *); 143 | extern struct pi_bus_host *pi_core_register_host(struct device *dev); 144 | extern int pi_core_unregister_host (struct pi_bus_host *pibushost); 145 | 146 | #endif /*__PARALLEL_INTERFACE__*/ 147 | -------------------------------------------------------------------------------- /driver/test.patch: -------------------------------------------------------------------------------- 1 | diff --git a/driver/beaglescope_driver.c b/driver/beaglescope_driver.c 2 | index a189c54..255e943 100644 3 | --- a/driver/beaglescope_driver.c 4 | +++ b/driver/beaglescope_driver.c 5 | @@ -58,12 +58,12 @@ static void beaglescope_driver_cb(struct rpmsg_channel *rpdev, void *data, 6 | u32 length; 7 | struct beaglescope_state *st; 8 | struct iio_dev *indio_dev; 9 | - 10 | + dev_err(&rpdev->dev, "Callback called\n"); 11 | indio_dev = dev_get_drvdata(&rpdev->dev); 12 | st = iio_priv(indio_dev); 13 | 14 | if (st->data_idx == MAX_BLOCKS_IN_FIFO){ 15 | - dev_err(&rpdev->dev, "Data fifo is full, data will not be saved in fifo"); 16 | + dev_err(&rpdev->dev, "Data fifo is full, data will not be saved in fifo\n"); 17 | return; 18 | } 19 | 20 | @@ -121,6 +121,7 @@ static int beaglescope_driver_probe (struct rpmsg_channel *rpdev) 21 | goto error_device_register; 22 | } 23 | 24 | + rpmsg_send(rpdev, "TEST", sizeof("TEST")); 25 | return 0; 26 | 27 | error_device_register: 28 | -------------------------------------------------------------------------------- /dtc/PI-TEST-00A0.dts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Zubeen Tolani 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU General Public License version 2 as published by 6 | * the Free Software Foundation. 7 | */ 8 | 9 | /dts-v1/; 10 | /plugin/; 11 | 12 | /{ 13 | compatible = "ti,beaglebone", "ti,beaglebone-black"; 14 | part-number = "BEAGLESCOPE"; 15 | version = "00A0"; 16 | 17 | aliases { 18 | pi0 = &pi0; 19 | }; 20 | 21 | /* identification */ 22 | 23 | fragment@0 { 24 | target = <&ocp>; 25 | __overlay__ { 26 | pi0: pi0@f00 { 27 | status="okay"; 28 | compatible = "ti,pibus0"; 29 | adc: adc@f00 { 30 | status="okay"; 31 | compatible = "ti,dc782a"; 32 | }; 33 | }; 34 | 35 | }; 36 | 37 | }; 38 | }; 39 | -------------------------------------------------------------------------------- /examples/firmware_exmples/PRU_inline_asm_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_exmples/PRU_inline_asm_blinky/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Makefile to make PRU_inlineASM_blinky project 4 | # 5 | # The make file is tried to be made as generic as possible 6 | # So that it can be used to compile other programs too 7 | # 8 | # Usage: 9 | # name your main source file as main_pru1.c or main_pru0.c 10 | # add targets to variable TARGETS 11 | # add other files required while linking in variable LINK_PRU1(0)_FW 12 | # add compile targets, as added to LINK_PRU1(0)_FW for other files. 13 | # 14 | 15 | # PRU_CGT environment variable must point to the TI PRU compiler directory. E.g.: 16 | #(Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 17 | #(Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 18 | 19 | ifndef PRU_CGT 20 | define ERROR_BODY 21 | 22 | ************************************************************ 23 | PRU_CGT environment variable is not set. Examples given: 24 | (Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 25 | (Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 26 | ************************************************************ 27 | 28 | endef 29 | $(error $(ERROR_BODY)) 30 | endif 31 | 32 | 33 | LINKER_COMMAND_FILE=./AM335x_PRU.cmd 34 | LIBS=--library=../../lib/rpmsg_lib.lib 35 | INCLUDE=--include_path=../../include --include_path=../../include/am335x 36 | STACK_SIZE=0x100 37 | HEAP_SIZE=0x100 38 | 39 | 40 | CFLAGS=-v3 -O2 --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) -ppd -ppa 41 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) 42 | 43 | 44 | GEN_DIR=gen 45 | 46 | PRU1_FW =$(GEN_DIR)/main_pru1_fw.out 47 | PRU0_FW =$(GEN_DIR)/main_pru0_fw.out 48 | 49 | 50 | # ----------------------------------------------------- 51 | # Variable to edit in the makefile 52 | 53 | # add the required firmwares to TARGETS 54 | # TARGETS =$(PRU1_FW) $(PRU0_FW) 55 | TARGETS =$(PRU1_FW) 56 | 57 | # add the required files while linkin the FW code 58 | # required linking files for PRU1 59 | # LINK_PRU1_FW = (GEN_DIR)/pru1-inline-asm.object (GEN_DIR)/code2_pru1.object 60 | LINK_PRU1_FW= $(GEN_DIR)/pru1-asm-blinky.object 61 | 62 | # required linking files for PRU1 63 | # LINK_PRU0_FW = (GEN_DIR)/pru0-inline-asm.object (GEN_DIR)/code2_pru1.object 64 | LINK_PRU0_FW= 65 | 66 | #------------------------------------------------------ 67 | 68 | 69 | 70 | .PHONY: all 71 | all: $(TARGETS) 72 | @echo '- Generated firmwares are : $^' 73 | 74 | 75 | $(PRU1_FW): $(GEN_DIR)/main_pru1.object $(LINK_PRU1_FW) 76 | @echo 'LD $^' 77 | @$(PRU_CGT)/bin/lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 78 | 79 | 80 | $(PRU0_FW): $(GEN_DIR)/main_pru0.object $(LINK_PRU0_FW) 81 | @echo 'LD $^' 82 | @$(PRU_CGT)/bin/lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 83 | 84 | 85 | $(GEN_DIR)/main_pru0.object: main_pru0.c 86 | @mkdir -p $(GEN_DIR) 87 | @echo 'CC $<' 88 | @$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 89 | 90 | 91 | $(GEN_DIR)/main_pru1.object: main_pru1.c 92 | @mkdir -p $(GEN_DIR) 93 | @echo 'CC $<' 94 | @$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 95 | 96 | 97 | $(GEN_DIR)/pru1-asm-blinky.object: pru1-asm-blinky.asm 98 | @mkdir -p $(GEN_DIR) 99 | @echo 'CC $<' 100 | @$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 101 | 102 | 103 | 104 | .PHONY: install install-pru1 install-pru0 copy_pru0_fw copy_pru1_fw reboot_pru_1 reboot_pru_0 105 | 106 | install: $(patsubst $(GEN_DIR)/main_pru%_fw.out, install-pru%, $(TARGETS)) 107 | 108 | 109 | install-pru1: $(PRU1_FW) copy_pru1_fw reboot_pru1 110 | install-pru0: $(PRU0_FW) copy_pru0_fw reboot_pru0 111 | 112 | copy_pru1_fw: 113 | @echo '- copying firmware to /lib/firmware/am335x_pru1_fw' 114 | @cp $(PRU1_FW) /lib/firmware/am335x-pru1-fw 115 | 116 | copy_pru0_fw: $(PRU0_FW) 117 | @echo '- copying firmware to /lib/firmware/am335x_pru0_fw' 118 | @cp $(PRU0_FW) /lib/firmware/am335x-pru0-fw 119 | 120 | reboot_pru1: 121 | @echo '- rebooting pru core 1' 122 | $(shell echo "4a338000.pru1" > /sys/bus/platform/drivers/pru-rproc/unbind 2> /dev/null) 123 | $(shell echo "4a338000.pru1" > /sys/bus/platform/drivers/pru-rproc/bind) 124 | @echo "- pru core 1 is now loaded with $(PRU1_FW)" 125 | 126 | reboot_pru0: 127 | @echo '- rebooting pru core 0' 128 | $(shell echo "4a334000.pru0" > /sys/bus/platform/drivers/pru-rproc/unbind 2> /dev/null) 129 | $(shell echo "4a334000.pru0" > /sys/bus/platform/drivers/pru-rproc/bind) 130 | @echo "- pru core 0 is now loaded with $(PRU0_FW)" 131 | 132 | 133 | .PHONY: clean 134 | clean: 135 | @echo 'CLEAN .' 136 | @rm -rf $(GEN_DIR) 137 | -------------------------------------------------------------------------------- /examples/firmware_exmples/PRU_inline_asm_blinky/main_pru1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Source Modified by Zubeen Tolani < ZeekHuge - zeekhuge@gmail.com > 3 | * Based on the examples distributed by TI 4 | * 5 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Texas Instruments Incorporated nor the names of 21 | * its contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #include 38 | #include 39 | #include "resource_table_pru1.h" 40 | 41 | // The function is defined in pru1_asm_blinky.asm in same dir 42 | // We just need to add a declaration here, the defination can be 43 | // seperately linked 44 | extern void start(void); 45 | 46 | void main(void) 47 | { 48 | start(); 49 | } 50 | 51 | -------------------------------------------------------------------------------- /examples/firmware_exmples/PRU_inline_asm_blinky/pru1-asm-blinky.asm: -------------------------------------------------------------------------------- 1 | ;* 2 | ;* Copyright (C) 2016 Zubeen Tolani 3 | ;* 4 | ;* This file is as an example to show how to develope 5 | ;* and compile inline assembly code for PRUs 6 | ;* 7 | ;* This program is free software; you can redistribute it and/or modify 8 | ;* it under the terms of the GNU General Public License version 2 as 9 | ;* published by the Free Software Foundation. 10 | 11 | 12 | .cdecls "main_pru1.c" 13 | 14 | DELAY .macro time 15 | LDI32 R0, time 16 | QBEQ $E?, R0, 0 17 | $M?: SUB R0, R0, 1 18 | QBNE $M?, R0, 0 19 | $E?: 20 | .endm 21 | 22 | 23 | .clink 24 | .global start 25 | start: 26 | LDI32 R30, 0xFFFFFFFF 27 | DELAY 100000000 28 | LDI32 R30, 0x00000000 29 | DELAY 100000000 30 | JMP start 31 | 32 | HALT 33 | -------------------------------------------------------------------------------- /examples/firmware_exmples/PRU_inline_asm_blinky/resource_table_pru1.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_exmples/pru1_to_pru0_to_arm/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_exmples/pru1_to_pru0_to_arm/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Makefile to make PRU_inlineASM_blinky project 4 | # 5 | # The make file is tried to be made as generic as possible 6 | # So that it can be used to compile other programs too 7 | # 8 | # Usage: 9 | # name your main source file as main_pru1.c or main_pru0.c 10 | # add targets to variable TARGETS 11 | # add other files required while linking in variable LINK_PRU1(0)_FW 12 | # add compile targets, as added to LINK_PRU1(0)_FW for other files. 13 | # 14 | 15 | # PRU_CGT environment variable must point to the TI PRU compiler directory. E.g.: 16 | #(Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 17 | #(Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 18 | 19 | ifndef PRU_CGT 20 | define ERROR_BODY 21 | 22 | ************************************************************ 23 | PRU_CGT environment variable is not set. Examples given: 24 | (Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 25 | (Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 26 | ************************************************************ 27 | 28 | endef 29 | $(error $(ERROR_BODY)) 30 | endif 31 | 32 | 33 | LINKER_COMMAND_FILE=./AM335x_PRU.cmd 34 | LIBS=--library=../../lib/rpmsg_lib.lib 35 | INCLUDE=--include_path=../../include --include_path=../../include/am335x 36 | STACK_SIZE=0x100 37 | HEAP_SIZE=0x100 38 | 39 | 40 | CFLAGS=-v3 -O2 --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) -ppd -ppa 41 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) 42 | 43 | 44 | GEN_DIR=gen 45 | 46 | PRU1_FW =$(GEN_DIR)/main_pru1_fw.out 47 | PRU0_FW =$(GEN_DIR)/main_pru0_fw.out 48 | 49 | 50 | # ----------------------------------------------------- 51 | # Variable to edit in the makefile 52 | 53 | # add the required firmwares to TARGETS 54 | # TARGETS =$(PRU1_FW) $(PRU0_FW) 55 | TARGETS =$(PRU1_FW) $(PRU0_FW) 56 | 57 | # add the required files while linkin the FW code 58 | # required linking files for PRU1 59 | # LINK_PRU1_FW = (GEN_DIR)/pru1-inline-asm.object (GEN_DIR)/code2_pru1.object 60 | LINK_PRU1_FW= 61 | 62 | # required linking files for PRU1 63 | # LINK_PRU0_FW = (GEN_DIR)/pru0-inline-asm.object (GEN_DIR)/code2_pru1.object 64 | LINK_PRU0_FW= 65 | 66 | #------------------------------------------------------ 67 | 68 | 69 | 70 | .PHONY: all 71 | all: $(TARGETS) 72 | @echo '- Generated firmwares are : $^' 73 | 74 | 75 | $(PRU1_FW): $(GEN_DIR)/main_pru1.object $(LINK_PRU1_FW) 76 | @echo 'LD $^' 77 | @$(PRU_CGT)/bin/lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 78 | 79 | 80 | $(PRU0_FW): $(GEN_DIR)/main_pru0.object $(LINK_PRU0_FW) 81 | @echo 'LD $^' 82 | @$(PRU_CGT)/bin/lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 83 | 84 | 85 | $(GEN_DIR)/main_pru0.object: main_pru0.c 86 | @mkdir -p $(GEN_DIR) 87 | @echo 'CC $<' 88 | @$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 89 | 90 | 91 | $(GEN_DIR)/main_pru1.object: main_pru1.c 92 | @mkdir -p $(GEN_DIR) 93 | @echo 'CC $<' 94 | @$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 95 | 96 | 97 | 98 | .PHONY: install install-pru1 install-pru0 copy_pru0_fw copy_pru1_fw reboot_pru_1 reboot_pru_0 99 | 100 | install: $(patsubst $(GEN_DIR)/main_pru%_fw.out, install-pru%, $(TARGETS)) 101 | 102 | 103 | install-pru1: $(PRU1_FW) copy_pru1_fw reboot_pru1 104 | install-pru0: $(PRU0_FW) copy_pru0_fw reboot_pru0 105 | 106 | copy_pru1_fw: 107 | @echo '- copying firmware to /lib/firmware/am335x_pru1_fw' 108 | @cp $(PRU1_FW) /lib/firmware/am335x-pru1-fw 109 | 110 | copy_pru0_fw: $(PRU0_FW) 111 | @echo '- copying firmware to /lib/firmware/am335x_pru0_fw' 112 | @cp $(PRU0_FW) /lib/firmware/am335x-pru0-fw 113 | 114 | reboot_pru1: 115 | @echo '- rebooting pru core 1' 116 | $(shell echo "4a338000.pru1" > /sys/bus/platform/drivers/pru-rproc/unbind 2> /dev/null) 117 | $(shell echo "4a338000.pru1" > /sys/bus/platform/drivers/pru-rproc/bind) 118 | @echo "- pru core 1 is now loaded with $(PRU1_FW)" 119 | 120 | reboot_pru0: 121 | @echo '- rebooting pru core 0' 122 | $(shell echo "4a334000.pru0" > /sys/bus/platform/drivers/pru-rproc/unbind 2> /dev/null) 123 | $(shell echo "4a334000.pru0" > /sys/bus/platform/drivers/pru-rproc/bind) 124 | @echo "- pru core 0 is now loaded with $(PRU0_FW)" 125 | 126 | 127 | .PHONY: clean 128 | clean: 129 | @echo 'CLEAN .' 130 | @rm -rf $(GEN_DIR) 131 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru1_to_pru0_to_arm/main_pru0.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Source Modified by Zubeen Tolani < ZeekHuge - zeekhuge@gmail.com > 3 | * Based on the examples distributed by TI 4 | * 5 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Texas Instruments Incorporated nor the names of 21 | * its contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "resource_table_pru0.h" 46 | #include "pru_defs.h" 47 | 48 | volatile register uint32_t __R31; 49 | 50 | #define HOST_ARM_TO_PRU0 HOST0_INT 51 | #define HOST_PRU1_TO_PRU0 HOST1_INT 52 | 53 | uint8_t payload[RPMSG_BUF_SIZE]; 54 | 55 | void main(void) 56 | { 57 | struct pru_rpmsg_transport transport; 58 | uint16_t src, dst, len; 59 | volatile uint8_t *status; 60 | 61 | /* allow OCP master port access by the PRU so the PRU can read external memories */ 62 | CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; 63 | 64 | /* clear the status of the PRU-ICSS system event that the ARM will use to 'kick' us */ 65 | CT_INTC.SICR_bit.STS_CLR_IDX = SE_ARM_TO_PRU0; 66 | 67 | /* Make sure the Linux drivers are ready for RPMsg communication */ 68 | status = &resourceTable.rpmsg_vdev.status; 69 | while (!(*status & VIRTIO_CONFIG_S_DRIVER_OK)); 70 | 71 | /* Initialize pru_virtqueue corresponding to vring0 (PRU to ARM Host direction) */ 72 | pru_virtqueue_init(&transport.virtqueue0, &resourceTable.rpmsg_vring0, SE_PRU0_TO_ARM, SE_ARM_TO_PRU0); 73 | 74 | /* Initialize pru_virtqueue corresponding to vring1 (ARM Host to PRU direction) */ 75 | pru_virtqueue_init(&transport.virtqueue1, &resourceTable.rpmsg_vring1, SE_PRU0_TO_ARM, SE_ARM_TO_PRU0); 76 | 77 | /* Create the RPMsg channel between the PRU and ARM user space using the transport structure. */ 78 | while (pru_rpmsg_channel(RPMSG_NS_CREATE, &transport, RPMSG_CHAN_NAME, PRU0_RPMSG_CHAN_DESC, PRU0_RPMSG_CHAN_PORT) != PRU_RPMSG_SUCCESS); 79 | while (1) { 80 | /* Check bit 30 of register R31 to see if the ARM has kicked us */ 81 | if (check_host_int(HOST_ARM_TO_PRU0)) { 82 | /* Clear the event status */ 83 | CT_INTC.SICR_bit.STS_CLR_IDX = SE_ARM_TO_PRU0; 84 | /* Receive all available messages, multiple messages can be sent per kick */ 85 | while (pru_rpmsg_receive(&transport, &src, &dst, payload, &len) == PRU_RPMSG_SUCCESS) { 86 | /* Echo the message back to the same address from which we just received */ 87 | while(1){ 88 | if (check_host_int(HOST_PRU1_TO_PRU0)){ 89 | CT_INTC.SICR_bit.STS_CLR_IDX = SE_PRU1_TO_PRU0; 90 | pru_rpmsg_send(&transport, dst, src, "Interrupted\n", sizeof("Interupted\n")); 91 | } 92 | } 93 | } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru1_to_pru0_to_arm/main_pru1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Source Modified by Zubeen Tolani < ZeekHuge - zeekhuge@gmail.com > 3 | * Based on the examples distributed by TI 4 | * 5 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Texas Instruments Incorporated nor the names of 21 | * its contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #include 38 | #include 39 | #include "resource_table_pru1.h" 40 | 41 | 42 | volatile register uint32_t __R30; 43 | volatile register uint32_t __R31; 44 | 45 | void main(void) 46 | { 47 | 48 | while (1) { 49 | generate_sys_eve(SE_PRU1_TO_PRU0); 50 | __delay_cycles(100000000); 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru1_to_pru0_to_arm/pru_defs.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _PRU_DEFS_ 3 | #define _PRU_DEFS_ 4 | 5 | /* Constants */ 6 | 7 | #define SE_PRU0_TO_ARM 16 8 | #define SE_ARM_TO_PRU0 17 9 | #define SE_PRU1_TO_PRU0 18 10 | 11 | #define HOST1_INT ((uint32_t) 1<<31) 12 | #define HOST0_INT ((uint32_t) 1<<30) 13 | 14 | #define R31_VECTOR_VALID_STROBE_BIT 5 15 | #define R31_PRU1_TO_PRU0 (SE_PRU1_TO_PRU0 - 16) 16 | 17 | #define RPMSG_CHAN_NAME "rpmsg-pru" 18 | 19 | #define PRU0_RPMSG_CHAN_DESC "Channel 30" 20 | #define PRU0_RPMSG_CHAN_PORT 30 21 | #define PRU1_RPMSG_CHAN_DESC "Channel 31" 22 | #define PRU1_RPMSG_CHAN_PORT 31 23 | 24 | #define VIRTIO_CONFIG_S_DRIVER_OK 4 25 | 26 | /* Macros */ 27 | 28 | #define check_host_int(host)\ 29 | (__R31 & host) 30 | 31 | #define generate_sys_eve(sys_eve)\ 32 | __R31 = ( (1 << R31_VECTOR_VALID_STROBE_BIT) | (SE_PRU1_TO_PRU0-16)) 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru1_to_pru0_to_arm/resource_table_pru1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Source Modified by Zubeen Tolani < ZeekHuge - zeekhuge@gmail.com > 3 | * Based on the examples distributed by TI 4 | * 5 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Texas Instruments Incorporated nor the names of 21 | * its contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | /* 38 | * ======== resource_table_empty.h ======== 39 | * 40 | * Define the resource table entries for all PRU cores. This will be 41 | * incorporated into corresponding base images, and used by the remoteproc 42 | * on the host-side to allocated/reserve resources. Note the remoteproc 43 | * driver requires that all PRU firmware be built with a resource table. 44 | * 45 | * This file contains an empty resource table. It can be used either as: 46 | * 47 | * 1) A template, or 48 | * 2) As-is if a PRU application does not need to configure PRU_INTC 49 | * or interact with the rpmsg driver 50 | * 51 | */ 52 | 53 | #ifndef _RSC_TABLE_PRU_H_ 54 | #define _RSC_TABLE_PRU_H_ 55 | 56 | #include 57 | #include 58 | #include "pru_defs.h" 59 | 60 | struct my_resource_table { 61 | struct resource_table base; 62 | 63 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 64 | }; 65 | 66 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 67 | #pragma RETAIN(pru_remoteproc_ResourceTable) 68 | struct my_resource_table pru_remoteproc_ResourceTable = { 69 | 1, /* we're the first version that implements this */ 70 | 0, /* number of entries in the table */ 71 | 0, 0, /* reserved, must be zero */ 72 | 0, /* offset[0] */ 73 | }; 74 | 75 | #endif /* _RSC_TABLE_PRU_H_ */ 76 | 77 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_blinky/PRU_gpioToggle/.ccsproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_blinky/PRU_gpioToggle/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PRU_gpioToggle 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 15 | full,incremental, 16 | 17 | 18 | 19 | 20 | 21 | com.ti.ccstudio.core.ccsNature 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.core.ccnature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_blinky/PRU_gpioToggle/.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | inEditor=false 3 | onBuild=false 4 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_blinky/PRU_gpioToggle/.settings/org.eclipse.cdt.debug.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.debug.core.toggleBreakpointModel=com.ti.ccstudio.debug.CCSBreakpointMarker 3 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_blinky/PRU_gpioToggle/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_exmples/pru_blinky/PRU_gpioToggle/Makefile: -------------------------------------------------------------------------------- 1 | # PRU_CGT environment variable must point to the TI PRU compiler directory. E.g.: 2 | #(Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 3 | #(Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 4 | ifndef PRU_CGT 5 | define ERROR_BODY 6 | 7 | ************************************************************ 8 | PRU_CGT environment variable is not set. Examples given: 9 | (Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 10 | (Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 11 | ************************************************************ 12 | 13 | endef 14 | $(error $(ERROR_BODY)) 15 | endif 16 | 17 | MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) 18 | CURRENT_DIR := $(notdir $(patsubst %/,%,$(dir $(MKFILE_PATH)))) 19 | PROJ_NAME=$(CURRENT_DIR) 20 | LINKER_COMMAND_FILE=./AM335x_PRU.cmd 21 | LIBS=--library=../../../lib/rpmsg_lib.lib 22 | INCLUDE=--include_path=../../../include --include_path=../../../include/am335x 23 | STACK_SIZE=0x100 24 | HEAP_SIZE=0x100 25 | GEN_DIR=gen 26 | 27 | #Common compiler and linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) 28 | CFLAGS=-v3 -O2 --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) -ppd -ppa 29 | #Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) 30 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) 31 | 32 | TARGET=$(GEN_DIR)/$(PROJ_NAME).out 33 | MAP=$(GEN_DIR)/$(PROJ_NAME).map 34 | SOURCES=$(wildcard *.c) 35 | #Using .object instead of .obj in order to not conflict with the CCS build process 36 | OBJECTS=$(patsubst %,$(GEN_DIR)/%,$(SOURCES:.c=.object)) 37 | 38 | all: printStart $(TARGET) printEnd 39 | 40 | printStart: 41 | @echo '' 42 | @echo '************************************************************' 43 | @echo 'Building project: $(PROJ_NAME)' 44 | 45 | printEnd: 46 | @echo '' 47 | @echo 'Finished building project: $(PROJ_NAME)' 48 | @echo '************************************************************' 49 | @echo '' 50 | 51 | # Invokes the linker (-z flag) to make the .out file 52 | $(TARGET): $(OBJECTS) $(LINKER_COMMAND_FILE) 53 | @echo '' 54 | @echo 'Building target: $@' 55 | @echo 'Invoking: PRU Linker' 56 | $(PRU_CGT)/bin/clpru $(CFLAGS) -z -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $(TARGET) $(OBJECTS) -m$(MAP) $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) 57 | @echo 'Finished building target: $@' 58 | @echo '' 59 | @echo 'Output files can be found in the "$(GEN_DIR)" directory' 60 | 61 | # Invokes the compiler on all c files in the directory to create the object files 62 | $(GEN_DIR)/%.object: %.c 63 | @mkdir -p $(GEN_DIR) 64 | @echo '' 65 | @echo 'Building file: $<' 66 | @echo 'Invoking: PRU Compiler' 67 | $(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 68 | 69 | .PHONY: all clean 70 | 71 | # Remove the $(GEN_DIR) directory 72 | clean: 73 | @echo '' 74 | @echo '************************************************************' 75 | @echo 'Cleaning project: $(PROJ_NAME)' 76 | @echo '' 77 | @echo 'Removing files in the "$(GEN_DIR)" directory' 78 | @rm -rf $(GEN_DIR) 79 | @echo '' 80 | @echo 'Finished cleaning project: $(PROJ_NAME)' 81 | @echo '************************************************************' 82 | @echo '' 83 | 84 | # Includes the dependencies that the compiler creates (-ppd and -ppa flags) 85 | -include $(OBJECTS:%.object=%.pp) 86 | 87 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_blinky/PRU_gpioToggle/PRU_gpioToggle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Source Modified by Zubeen Tolani < ZeekHuge - zeekhuge@gmail.com > 3 | * Based on the examples distributed by TI 4 | * 5 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Texas Instruments Incorporated nor the names of 21 | * its contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #include 38 | #include 39 | #include "resource_table_empty.h" 40 | 41 | volatile register uint32_t __R30; 42 | volatile register uint32_t __R31; 43 | 44 | void main(void) 45 | { 46 | volatile uint32_t gpio; 47 | 48 | /* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */ 49 | CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; 50 | 51 | /* Toggle GPO pins TODO: Figure out which to use */ 52 | gpio = 0x000F; 53 | 54 | /* TODO: Create stop condition, else it will toggle indefinitely */ 55 | while (1) { 56 | __R30 ^= gpio; 57 | __delay_cycles(100000000); 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_blinky/PRU_gpioToggle/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_exmples/pru_blinky/deploy.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ############################################################################## 4 | # 5 | # Copyright (C) 2016 Zubeen Tolani 6 | # 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions 10 | # are met: 11 | # 12 | # * Redistributions of source code must retain the above copyright 13 | # notice, this list of conditions and the following disclaimer. 14 | # 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the 18 | # distribution 19 | # 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 | 36 | # The script builds the pru_blinky project and configures the pinmuxing for $HEADER$PIN_NUM 37 | 38 | #If changing these variables, make sure the given pin can be muxed to the given pru. 39 | HEADER=P8_ 40 | PIN_NUMBER=45 41 | #PRU_CORE should be either 0 or 1 42 | PRU_CORE=1 43 | 44 | echo "*******************************************************" 45 | echo "This must be compiled on the BEAGLEBONE BLACK itself" 46 | echo "It was tested on 4.4.12-ti-r31 kernel version" 47 | echo "The source code for blinky ie PRU_gpioToggle was taken from" 48 | echo "pru-software-support-package and can be cloned from" 49 | echo "git clone git://git.ti.com/pru-software-support-package/pru-software-support-package.git" 50 | echo "******NOTE: use a resistor >470 ohms to connect to the LED, I have alredy made this mistake." 51 | echo "To continue, press any key:" 52 | read 53 | 54 | echo "-Building project" 55 | cd PRU_gpioToggle 56 | make clean 57 | make 58 | 59 | echo "-Placing the firmware" 60 | cp gen/*.out /lib/firmware/am335x-pru$PRU_CORE-fw 61 | 62 | echo "-Configuring pinmux" 63 | config-pin -a $HEADER$PIN_NUMBER pruout 64 | config-pin -q $HEADER$PIN_NUMBER 65 | 66 | echo "-Rebooting" 67 | if [ $PRU_CORE -eq 0 ] 68 | then 69 | echo "Rebooting pru-core 0" 70 | echo 'stop' > /sys/class/remoteproc/remoteproc1/state 2>/dev/null 71 | echo "am335x-pru$PRU_CORE-fw" > /sys/class/remoteproc/remoteproc1/firmware 72 | echo 'start' > /sys/class/remoteproc/remoteproc1/state 73 | else 74 | echo "Rebooting pru-core 1" 75 | echo 'stop' > /sys/class/remoteproc/remoteproc2/state 2>/dev/null 76 | echo "am335x-pru$PRU_CORE-fw" > /sys/class/remoteproc/remoteproc2/firmware 77 | echo 'start' > /sys/class/remoteproc/remoteproc2/state 78 | fi 79 | 80 | echo "Done. Blikny must be up on pin $HEADER$PIN_NUMBER" 81 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_logic_replicate/PRU_triggeredOutput/.bashrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeekhuge/BeagleScope/757017f3d533ee048d40c8289b70054ada85e945/examples/firmware_exmples/pru_logic_replicate/PRU_triggeredOutput/.bashrc -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_logic_replicate/PRU_triggeredOutput/.ccsproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_logic_replicate/PRU_triggeredOutput/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PRU_gpioToggle 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 15 | full,incremental, 16 | 17 | 18 | 19 | 20 | 21 | com.ti.ccstudio.core.ccsNature 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.core.ccnature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_logic_replicate/PRU_triggeredOutput/.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | inEditor=false 3 | onBuild=false 4 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_logic_replicate/PRU_triggeredOutput/.settings/org.eclipse.cdt.debug.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.debug.core.toggleBreakpointModel=com.ti.ccstudio.debug.CCSBreakpointMarker 3 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_logic_replicate/PRU_triggeredOutput/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_exmples/pru_logic_replicate/PRU_triggeredOutput/Makefile: -------------------------------------------------------------------------------- 1 | # PRU_CGT environment variable must point to the TI PRU compiler directory. E.g.: 2 | #(Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 3 | #(Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 4 | ifndef PRU_CGT 5 | define ERROR_BODY 6 | 7 | ************************************************************ 8 | PRU_CGT environment variable is not set. Examples given: 9 | (Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 10 | (Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 11 | ************************************************************ 12 | 13 | endef 14 | $(error $(ERROR_BODY)) 15 | endif 16 | 17 | MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) 18 | CURRENT_DIR := $(notdir $(patsubst %/,%,$(dir $(MKFILE_PATH)))) 19 | PROJ_NAME=$(CURRENT_DIR) 20 | LINKER_COMMAND_FILE=./AM335x_PRU.cmd 21 | LIBS=--library=../../../lib/rpmsg_lib.lib 22 | INCLUDE=--include_path=../../../include --include_path=../../../include/am335x 23 | STACK_SIZE=0x100 24 | HEAP_SIZE=0x100 25 | GEN_DIR=gen 26 | 27 | #Common compiler and linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) 28 | CFLAGS=-v3 -O2 --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) -ppd -ppa 29 | #Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) 30 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) 31 | 32 | TARGET=$(GEN_DIR)/$(PROJ_NAME).out 33 | MAP=$(GEN_DIR)/$(PROJ_NAME).map 34 | SOURCES=$(wildcard *.c) 35 | #Using .object instead of .obj in order to not conflict with the CCS build process 36 | OBJECTS=$(patsubst %,$(GEN_DIR)/%,$(SOURCES:.c=.object)) 37 | 38 | all: printStart $(TARGET) printEnd 39 | 40 | printStart: 41 | @echo '' 42 | @echo '************************************************************' 43 | @echo 'Building project: $(PROJ_NAME)' 44 | 45 | printEnd: 46 | @echo '' 47 | @echo 'Finished building project: $(PROJ_NAME)' 48 | @echo '************************************************************' 49 | @echo '' 50 | 51 | # Invokes the linker (-z flag) to make the .out file 52 | $(TARGET): $(OBJECTS) $(LINKER_COMMAND_FILE) 53 | @echo '' 54 | @echo 'Building target: $@' 55 | @echo 'Invoking: PRU Linker' 56 | $(PRU_CGT)/bin/clpru $(CFLAGS) -z -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $(TARGET) $(OBJECTS) -m$(MAP) $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) 57 | @echo 'Finished building target: $@' 58 | @echo '' 59 | @echo 'Output files can be found in the "$(GEN_DIR)" directory' 60 | 61 | # Invokes the compiler on all c files in the directory to create the object files 62 | $(GEN_DIR)/%.object: %.c 63 | @mkdir -p $(GEN_DIR) 64 | @echo '' 65 | @echo 'Building file: $<' 66 | @echo 'Invoking: PRU Compiler' 67 | $(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 68 | 69 | .PHONY: all clean 70 | 71 | # Remove the $(GEN_DIR) directory 72 | clean: 73 | @echo '' 74 | @echo '************************************************************' 75 | @echo 'Cleaning project: $(PROJ_NAME)' 76 | @echo '' 77 | @echo 'Removing files in the "$(GEN_DIR)" directory' 78 | @rm -rf $(GEN_DIR) 79 | @echo '' 80 | @echo 'Finished cleaning project: $(PROJ_NAME)' 81 | @echo '************************************************************' 82 | @echo '' 83 | 84 | # Includes the dependencies that the compiler creates (-ppd and -ppa flags) 85 | -include $(OBJECTS:%.object=%.pp) 86 | 87 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_logic_replicate/PRU_triggeredOutput/PRU_triggeredOutput.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Source Modified by Zubeen Tolani < ZeekHuge - zeekhuge@gmail.com > 3 | * Based on the examples distributed by TI 4 | * 5 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Texas Instruments Incorporated nor the names of 21 | * its contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #include 38 | #include 39 | #include "resource_table_empty.h" 40 | 41 | volatile register uint32_t __R30; 42 | volatile register uint32_t __R31; 43 | 44 | void main(void) 45 | { 46 | volatile uint32_t gpio_on; 47 | volatile uint32_t gpio_off; 48 | 49 | /* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */ 50 | CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; 51 | 52 | /* Toggle GPO pins TODO: Figure out which to use */ 53 | gpio_on = 0x000F; 54 | gpio_off = 0x0000; 55 | 56 | /* TODO: Create stop condition, else it will toggle indefinitely */ 57 | while (1) { 58 | if (__R31) 59 | __R30 = gpio_on; 60 | else 61 | __R30 = gpio_off; 62 | 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_logic_replicate/PRU_triggeredOutput/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_exmples/pru_logic_replicate/deploy.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ############################################################################# 4 | # 5 | # Copyright (C) 2016 Zubeen Tolani 6 | # 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions 10 | # are met: 11 | # 12 | # * Redistributions of source code must retain the above copyright 13 | # notice, this list of conditions and the following disclaimer. 14 | # 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the 18 | # distribution 19 | # 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 | 36 | 37 | # The script builds the pru_triggered_output project and configures the pinmuxing for PINS 38 | 39 | #If changing these variables, make sure the given pin can be muxed to the given pru. 40 | OUT_HEADER=P8_ 41 | OUT_PIN_NUMBER=46 42 | IN_HEADER=P8_ 43 | IN_PIN_NUMBER=45 44 | #PRU_CORE should be either 0 or 1 45 | PRU_CORE=1 46 | 47 | echo "*******************************************************" 48 | echo "This must be compiled on the BEAGLEBONE BLACK itself" 49 | echo "It was tested on 4.4.12-ti-r31 kernel version" 50 | echo "The source code for blinky ie PRU_triggeredOutput is based on examples from" 51 | echo "pru-software-support-package which can be cloned from" 52 | echo "git clone git://git.ti.com/pru-software-support-package/pru-software-support-package.git" 53 | echo "The program will replicate the logical state of $IN_HEADER$IN_PIN_NUMBER to $OUT_HEADER$OUT_PIN_NUMBER" 54 | echo "******NOTE: use a resistor >470 ohms to connect to the LED, I have alredy made this mistake." 55 | echo "To continue, press any key:" 56 | read 57 | 58 | echo "-Building project" 59 | cd PRU_triggeredOutput 60 | make clean 61 | make 62 | 63 | echo "-Placing the firmware" 64 | cp gen/*.out /lib/firmware/am335x-pru$PRU_CORE-fw 65 | 66 | echo "-Configuring pinmux" 67 | config-pin -a $OUT_HEADER$OUT_PIN_NUMBER pruout 68 | config-pin -q $OUT_HEADER$OUT_PIN_NUMBER 69 | config-pin -a $IN_HEADER$IN_PIN_NUMBER pruin 70 | config-pin -q $IN_HEADER$IN_PIN_NUMBER 71 | 72 | echo "-Rebooting" 73 | if [ $PRU_CORE -eq 0 ] 74 | then 75 | echo "Rebooting pru-core 0" 76 | echo 'stop' > /sys/class/remoteproc/remoteproc1/state 2>/dev/null 77 | echo "am335x-pru$PRU_CORE-fw" > /sys/class/remoteproc/remoteproc1/firmware 78 | echo 'start' > /sys/class/remoteproc/remoteproc1/state 79 | else 80 | echo "Rebooting pru-core 1" 81 | echo 'stop' > /sys/class/remoteproc/remoteproc2/state 2>/dev/null 82 | echo "am335x-pru$PRU_CORE-fw" > /sys/class/remoteproc/remoteproc2/firmware 83 | echo 'start' > /sys/class/remoteproc/remoteproc2/state 84 | fi 85 | 86 | echo "Done. So now $OUT_HEADER$OUT_PIN_NUMBER will acquire the state of $IN_HEADER$IN_PIN_NUMBER" 87 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_pin_state_reader/PRU_PIN_STATE_READER/.ccsproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_pin_state_reader/PRU_PIN_STATE_READER/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PRU_RPMsg_Echo_Interrupt1 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 15 | full,incremental, 16 | 17 | 18 | 19 | 20 | 21 | com.ti.ccstudio.core.ccsNature 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.core.ccnature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_pin_state_reader/PRU_PIN_STATE_READER/.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | inEditor=false 3 | onBuild=false 4 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_pin_state_reader/PRU_PIN_STATE_READER/.settings/org.eclipse.cdt.debug.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.debug.core.toggleBreakpointModel=com.ti.ccstudio.debug.CCSBreakpointMarker 3 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_pin_state_reader/PRU_PIN_STATE_READER/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_exmples/pru_pin_state_reader/PRU_PIN_STATE_READER/Makefile: -------------------------------------------------------------------------------- 1 | # PRU_CGT environment variable must point to the TI PRU compiler directory. E.g.: 2 | #(Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 3 | #(Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 4 | ifndef PRU_CGT 5 | define ERROR_BODY 6 | 7 | ************************************************************ 8 | PRU_CGT environment variable is not set. Examples given: 9 | (Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 10 | (Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 11 | ************************************************************ 12 | 13 | endef 14 | $(error $(ERROR_BODY)) 15 | endif 16 | 17 | MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) 18 | CURRENT_DIR := $(notdir $(patsubst %/,%,$(dir $(MKFILE_PATH)))) 19 | PROJ_NAME=$(CURRENT_DIR) 20 | LINKER_COMMAND_FILE=./AM335x_PRU.cmd 21 | LIBS=--library=../../../lib/rpmsg_lib.lib 22 | INCLUDE=--include_path=../../../include --include_path=../../../include/am335x 23 | STACK_SIZE=0x100 24 | HEAP_SIZE=0x100 25 | GEN_DIR=gen 26 | 27 | #Common compiler and linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) 28 | CFLAGS=-v3 -O2 --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) -ppd -ppa 29 | #Linker flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) 30 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) 31 | 32 | TARGET=$(GEN_DIR)/$(PROJ_NAME).out 33 | MAP=$(GEN_DIR)/$(PROJ_NAME).map 34 | SOURCES=$(wildcard *.c) 35 | #Using .object instead of .obj in order to not conflict with the CCS build process 36 | OBJECTS=$(patsubst %,$(GEN_DIR)/%,$(SOURCES:.c=.object)) 37 | 38 | all: printStart $(TARGET) printEnd 39 | 40 | printStart: 41 | @echo '' 42 | @echo '************************************************************' 43 | @echo 'Building project: $(PROJ_NAME)' 44 | 45 | printEnd: 46 | @echo '' 47 | @echo 'Finished building project: $(PROJ_NAME)' 48 | @echo '************************************************************' 49 | @echo '' 50 | 51 | # Invokes the linker (-z flag) to make the .out file 52 | $(TARGET): $(OBJECTS) $(LINKER_COMMAND_FILE) 53 | @echo '' 54 | @echo 'Building target: $@' 55 | @echo 'Invoking: PRU Linker' 56 | $(PRU_CGT)/bin/clpru $(CFLAGS) -z -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $(TARGET) $(OBJECTS) -m$(MAP) $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) 57 | @echo 'Finished building target: $@' 58 | @echo '' 59 | @echo 'Output files can be found in the "$(GEN_DIR)" directory' 60 | 61 | # Invokes the compiler on all c files in the directory to create the object files 62 | $(GEN_DIR)/%.object: %.c 63 | @mkdir -p $(GEN_DIR) 64 | @echo '' 65 | @echo 'Building file: $<' 66 | @echo 'Invoking: PRU Compiler' 67 | $(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 68 | 69 | .PHONY: all clean 70 | 71 | # Remove the $(GEN_DIR) directory 72 | clean: 73 | @echo '' 74 | @echo '************************************************************' 75 | @echo 'Cleaning project: $(PROJ_NAME)' 76 | @echo '' 77 | @echo 'Removing files in the "$(GEN_DIR)" directory' 78 | @rm -rf $(GEN_DIR) 79 | @echo '' 80 | @echo 'Finished cleaning project: $(PROJ_NAME)' 81 | @echo '************************************************************' 82 | @echo '' 83 | 84 | # Includes the dependencies that the compiler creates (-ppd and -ppa flags) 85 | -include $(OBJECTS:%.object=%.pp) 86 | 87 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_pin_state_reader/PRU_PIN_STATE_READER/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Source Modified by Zubeen Tolani < ZeekHuge - zeekhuge@gmail.com > 3 | * Based on the examples distributed by TI 4 | * 5 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Texas Instruments Incorporated nor the names of 21 | * its contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include "resource_table_1.h" 45 | 46 | 47 | volatile register uint32_t __R31; 48 | 49 | /* Host-1 Interrupt sets bit 31 in register R31 */ 50 | #define HOST_INT ((uint32_t) 1 << 31) 51 | 52 | /* The PRU-ICSS system events used for RPMsg are defined in the Linux device tree 53 | * PRU0 uses system event 16 (To ARM) and 17 (From ARM) 54 | * PRU1 uses system event 18 (To ARM) and 19 (From ARM) 55 | */ 56 | #define TO_ARM_HOST 18 57 | #define FROM_ARM_HOST 19 58 | 59 | /* 60 | * Using the name 'rpmsg-pru' will probe the rpmsg_pru driver found 61 | * at linux-x.y.z/drivers/rpmsg/rpmsg_pru.c 62 | */ 63 | #define CHAN_NAME "rpmsg-pru" 64 | #define CHAN_DESC "Channel 31" 65 | #define CHAN_PORT 31 66 | 67 | /* 68 | * Used to make sure the Linux drivers are ready for RPMsg communication 69 | * Found at linux-x.y.z/include/uapi/linux/virtio_config.h 70 | */ 71 | #define VIRTIO_CONFIG_S_DRIVER_OK 4 72 | 73 | 74 | /* 75 | * Used to check the state of 0 bit of the r31 ie 76 | * the state of pr1_pru1_pru_r31_0. This gpio can be 77 | * muxed to P8_45. 78 | */ 79 | #define CHECK_BIT 0x0001 80 | 81 | 82 | 83 | uint8_t payload[RPMSG_BUF_SIZE]; 84 | 85 | /* 86 | * main.c 87 | */ 88 | void main(void) 89 | { 90 | struct pru_rpmsg_transport transport; 91 | uint16_t src, dst, len; 92 | uint32_t prev_gpio_state; 93 | volatile uint8_t *status; 94 | 95 | /* allow OCP master port access by the PRU so the PRU can read external memories */ 96 | CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; 97 | 98 | /* clear the status of the PRU-ICSS system event that the ARM will use to 'kick' us */ 99 | CT_INTC.SICR_bit.STS_CLR_IDX = FROM_ARM_HOST; 100 | 101 | /* Make sure the Linux drivers are ready for RPMsg communication */ 102 | status = &resourceTable.rpmsg_vdev.status; 103 | while (!(*status & VIRTIO_CONFIG_S_DRIVER_OK)); 104 | 105 | /* Initialize pru_virtqueue corresponding to vring0 (PRU to ARM Host direction) */ 106 | pru_virtqueue_init(&transport.virtqueue0, &resourceTable.rpmsg_vring0, TO_ARM_HOST, FROM_ARM_HOST); 107 | 108 | /* Initialize pru_virtqueue corresponding to vring1 (ARM Host to PRU direction) */ 109 | pru_virtqueue_init(&transport.virtqueue1, &resourceTable.rpmsg_vring1, TO_ARM_HOST, FROM_ARM_HOST); 110 | 111 | /* Create the RPMsg channel between the PRU and ARM user space using the transport structure. */ 112 | while (pru_rpmsg_channel(RPMSG_NS_CREATE, &transport, CHAN_NAME, CHAN_DESC, CHAN_PORT) != PRU_RPMSG_SUCCESS); 113 | while (1) { 114 | /* Check bit 30 of register R31 to see if the ARM has kicked us */ 115 | if (__R31 & HOST_INT) { 116 | /* Clear the event status */ 117 | CT_INTC.SICR_bit.STS_CLR_IDX = FROM_ARM_HOST; 118 | /* Receive all available messages, multiple messages can be sent per kick */ 119 | while (pru_rpmsg_receive(&transport, &src, &dst, payload, &len) == PRU_RPMSG_SUCCESS) { 120 | while(1) 121 | if ((__R31 ^ prev_gpio_state) & CHECK_BIT) { 122 | prev_gpio_state = __R31 & CHECK_BIT; 123 | pru_rpmsg_send(&transport, dst, src, "CHANGED\n", sizeof("CHANGED\n")); 124 | } 125 | } 126 | } 127 | } 128 | } 129 | 130 | 131 | -------------------------------------------------------------------------------- /examples/firmware_exmples/pru_pin_state_reader/deploy.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | ############################################################################# 4 | # 5 | # Copyright (C) 2016 Zubeen Tolani 6 | # 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions 10 | # are met: 11 | # 12 | # * Redistributions of source code must retain the above copyright 13 | # notice, this list of conditions and the following disclaimer. 14 | # 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the 18 | # distribution 19 | # 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 | 36 | # The script builds the pru_pin_state_reader project and configures the pinmuxing for P8_45 37 | 38 | #Do not change until you are making required changes in the firmware code. 39 | HEADER=P8_ 40 | PIN_NUMBER=45 41 | #The firmware will need significant changes to port it to PRU_CORE 2 42 | PRU_CORE=1 43 | 44 | echo "*******************************************************" 45 | echo "This must be compiled on the BEAGLEBONE BLACK itself" 46 | echo "It was tested on 4.4.12-ti-r31 kernel version" 47 | echo -e "The program makes PRU continously read P8_45 and output \"CHANGED\" if the state of pin changes" 48 | echo "The firmware source is based on pru-software-support-package by TI and can be cloned from" 49 | echo "git clone git://git.ti.com/pru-software-support-package/pru-software-support-package.git" 50 | echo "******NOTE: use a resistor >470 ohms to connect to the LED, I have alredy made this mistake." 51 | echo "To continue, press any key:" 52 | read 53 | 54 | echo "-Building project" 55 | cd PRU_PIN_STATE_READER 56 | make clean 57 | make 58 | 59 | echo "-Placing the firmware" 60 | cp gen/*.out /lib/firmware/am335x-pru$PRU_CORE-fw 61 | 62 | echo "-Configuring pinmux" 63 | config-pin -a $HEADER$PIN_NUMBER pruin 64 | config-pin -q $HEADER$PIN_NUMBER 65 | 66 | echo "-Rebooting" 67 | if [ $PRU_CORE -eq 0 ] 68 | then 69 | echo "Rebooting pru-core 0" 70 | echo 'stop' > /sys/class/remoteproc/remoteproc1/state 2>/dev/null 71 | echo "am335x-pru$PRU_CORE-fw" > /sys/class/remoteproc/remoteproc1/firmware 72 | echo 'start' > /sys/class/remoteproc/remoteproc1/state 73 | else 74 | echo "Rebooting pru-core 1" 75 | echo 'stop' > /sys/class/remoteproc/remoteproc2/state 2>/dev/null 76 | echo "am335x-pru$PRU_CORE-fw" > /sys/class/remoteproc/remoteproc2/firmware 77 | echo 'start' > /sys/class/remoteproc/remoteproc2/state 78 | fi 79 | 80 | echo "********************************************************" 81 | echo -e "Done. Now \"echo S > /dev/rpmsg_pru31 && cat /dev/rpmsg_pru31\" and change the logical state of P8_45" 82 | echo "********************************************************" 83 | -------------------------------------------------------------------------------- /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/include/am335x/pru_ctrl.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_CTRL_H_ 35 | #define _PRU_CTRL_H_ 36 | 37 | /* PRU_CTRL register set */ 38 | typedef struct { 39 | 40 | /* PRU_CTRL_CTRL register bit field */ 41 | union { 42 | volatile uint32_t CTRL; 43 | 44 | volatile struct { 45 | unsigned SOFT_RST_N : 1; 46 | unsigned EN : 1; 47 | unsigned SLEEPING : 1; 48 | unsigned CTR_EN : 1; 49 | unsigned rsvd4 : 4; 50 | unsigned SINGLE_STEP : 1; 51 | unsigned rsvd9 : 6; 52 | unsigned RUNSTATE : 1; 53 | unsigned PCTR_RST_VAL : 16; 54 | } CTRL_bit; 55 | }; // 0x0 56 | 57 | 58 | /* PRU_CTRL_STS register bit field */ 59 | union { 60 | volatile uint32_t STS; 61 | 62 | volatile struct { 63 | unsigned PCTR : 16; 64 | unsigned rsvd16 : 16; 65 | } STS_bit; 66 | }; // 0x4 67 | 68 | 69 | /* PRU_CTRL_WAKEUP_EN register bit field */ 70 | union { 71 | volatile uint32_t WAKEUP_EN; 72 | 73 | volatile struct { 74 | unsigned BITWISE_ENS : 32; 75 | } WAKEUP_EN_bit; 76 | }; // 0x8 77 | 78 | 79 | /* PRU_CTRL_CYCLE register bit field */ 80 | union { 81 | volatile uint32_t CYCLE; 82 | 83 | volatile struct { 84 | unsigned CYCLECOUNT : 32; 85 | } CYCLE_bit; 86 | }; // 0xC 87 | 88 | 89 | /* PRU_CTRL_STALL register bit field */ 90 | union { 91 | volatile uint32_t STALL; 92 | 93 | volatile struct { 94 | unsigned STALLCOUNT : 32; 95 | } STALL_bit; 96 | }; // 0x10 97 | 98 | 99 | uint32_t rsvd14[3]; // 0x14 - 0x1C 100 | 101 | 102 | /* PRU_CTRL_CTBIR0 register bit field */ 103 | union { 104 | volatile uint32_t CTBIR0; 105 | 106 | volatile struct { 107 | unsigned C24_BLK_IDX : 8; 108 | unsigned rsvd8 : 8; 109 | unsigned C25_BLK_IDX : 8; 110 | unsigned rsvd24 : 8; 111 | } CTBIR0_bit; 112 | }; // 0x20 113 | 114 | 115 | /* PRU_CTRL_CTBIR1 register bit field */ 116 | union { 117 | volatile uint32_t CTBIR1; 118 | 119 | volatile struct { 120 | unsigned C26_BLK_IDX : 8; 121 | unsigned rsvd8 : 8; 122 | unsigned C27_BLK_IDX : 8; 123 | unsigned rsvd24 : 8; 124 | } CTBIR1_bit; 125 | }; // 0x24 126 | 127 | 128 | /* PRU_CTRL_CTPPR0 register bit field */ 129 | union { 130 | volatile uint32_t CTPPR0; 131 | 132 | volatile struct { 133 | unsigned C28_BLK_POINTER : 16; 134 | unsigned C29_BLK_POINTER : 16; 135 | } CTPPR0_bit; 136 | }; // 0x28 137 | 138 | 139 | /* PRU_CTRL_CTPPR1 register bit field */ 140 | union { 141 | volatile uint32_t CTPPR1; 142 | 143 | volatile struct { 144 | unsigned C30_BLK_POINTER : 16; 145 | unsigned C31_BLK_POINTER : 16; 146 | } CTPPR1_bit; 147 | }; // 0x2C 148 | 149 | } pruCtrl; 150 | 151 | /* Definition of control register structures. */ 152 | #define PRU0_CTRL (*((volatile pruCtrl*)0x22000)) 153 | #define PRU1_CTRL (*((volatile pruCtrl*)0x24000)) 154 | 155 | #endif /* _PRU_CTRL_H_ */ 156 | -------------------------------------------------------------------------------- /examples/include/am335x/pru_ecap.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_ECAP_H_ 35 | #define _PRU_ECAP_H_ 36 | 37 | /* PRU_ECAP register set */ 38 | typedef struct { 39 | 40 | /* PRU_ECAP_TSCTR register bit field */ 41 | union { 42 | volatile uint32_t TSCTR; 43 | 44 | volatile struct { 45 | unsigned TSCTR : 32; //31:0 46 | } TSCTR_bit; 47 | }; // 0x0 48 | 49 | /* PRU_ECAP_CTRPHS register bit field */ 50 | union { 51 | volatile uint32_t CTRPHS; 52 | 53 | volatile struct { 54 | unsigned CTRPHS : 32; //31:0 55 | } CTRPHS_bit; 56 | }; // 0x4 57 | 58 | /* PRU_ECAP_CAP1 register bit field */ 59 | union { 60 | volatile uint32_t CAP1; 61 | 62 | volatile struct { 63 | unsigned CAP1 : 32; //31:0 64 | } CAP1_bit; 65 | }; // 0x8 66 | 67 | /* PRU_ECAP_CAP2 register bit field */ 68 | union { 69 | volatile uint32_t CAP2; 70 | 71 | volatile struct { 72 | unsigned CAP2 : 32; //31:0 73 | } CAP2_bit; 74 | }; // 0xC 75 | 76 | /* PRU_ECAP_CAP3 register bit field */ 77 | union { 78 | volatile uint32_t CAP3; 79 | 80 | volatile struct { 81 | unsigned CAP3 : 32; //31:0 82 | } CAP3_bit; 83 | }; // 0x10 84 | 85 | /* PRU_ECAP_CAP4 register bit field */ 86 | union { 87 | volatile uint32_t CAP4; 88 | 89 | volatile struct { 90 | unsigned CAP4 : 32; //31:0 91 | } CAP4_bit; 92 | }; // 0x14 93 | 94 | uint32_t rsvd118[4]; // 0x118 - 0x124 95 | 96 | /* PRU_ECAP_ECCTL1 register bit field */ 97 | volatile uint16_t ECCTL1; // 0x28 98 | 99 | /* PRU_ECAP_ECCTL2 register bit field */ 100 | volatile uint16_t ECCTL2; // 0x2A 101 | 102 | /* PRU_ECAP_ECEINT register bit field */ 103 | volatile uint16_t ECEINT; // 0x2C 104 | 105 | /* PRU_ECAP_ECFLG register bit field */ 106 | volatile uint16_t ECFLG; // 0x2E 107 | 108 | /* PRU_ECAP_ECCLR register bit field */ 109 | volatile uint16_t ECCLR; // 0x30 110 | 111 | /* PRU_ECAP_ECFRC register bit field */ 112 | volatile uint16_t ECFRC; // 0x32 113 | 114 | uint32_t rsvd34[10]; // 0x34 - 0x58 115 | 116 | /* PRU_ECAP_REVID register bit field */ 117 | union { 118 | volatile uint32_t REVID; 119 | 120 | volatile struct { 121 | unsigned REV : 32; //31:0 122 | } REVID_bit; 123 | }; // 0x5C 124 | } pruEcap; 125 | 126 | volatile __far pruEcap CT_ECAP __attribute__((cregister("PRU_ECAP", near), peripheral)); 127 | 128 | #endif /* _PRU_ECAP_H_ */ 129 | -------------------------------------------------------------------------------- /examples/include/am437x/pru_ctrl.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_CTRL_H_ 35 | #define _PRU_CTRL_H_ 36 | 37 | /* PRU CTRL register set */ 38 | typedef struct { 39 | 40 | /* PRU_CTRL_CTRL register bit field */ 41 | union { 42 | volatile uint32_t CTRL; 43 | 44 | volatile struct { 45 | uint32_t SOFT_RST_N : 1; // 0 46 | uint32_t ENABLE : 1; // 1 47 | uint32_t SLEEPING : 1; // 2 48 | uint32_t COUNTER_ENABLE : 1; // 3 49 | uint32_t rsvd4 : 4; // 7:4 50 | uint32_t SINGLE_STEP : 1; // 8 51 | uint32_t rsvd9 : 6; // 14:9 52 | uint32_t RUNSTATE : 1; // 15 53 | uint32_t PCOUNTER_RST_VAL : 16; // 31:16 54 | } CTRL_bit; 55 | }; // 0x0 56 | 57 | /* PRU_CTRL_STS register bit field */ 58 | union { 59 | volatile uint32_t STS; 60 | 61 | volatile struct { 62 | uint32_t PCOUNTER : 16; // 15:0 63 | uint32_t rsvd16 : 16; // 31:16 64 | } STS_bit; 65 | }; // 0x4 66 | 67 | /* PRU_CTRL_WAKEUP_EN register bit field */ 68 | union { 69 | volatile uint32_t WAKEUP_EN; 70 | 71 | volatile struct { 72 | uint32_t BITWISE_ENABLES : 32; // 31:0 73 | } WAKEUP_EN_bit; 74 | }; // 0x8 75 | 76 | /* PRU_CTRL_CYCLE register bit field */ 77 | union { 78 | volatile uint32_t CYCLE; 79 | 80 | volatile struct { 81 | uint32_t CYCLECOUNT : 32; // 31:0 82 | } CYCLE_bit; 83 | }; // 0xc 84 | 85 | /* PRU_CTRL_STALL register bit field */ 86 | union { 87 | volatile uint32_t STALL; 88 | 89 | volatile struct { 90 | uint32_t STALLCOUNT : 32; // 31:0 91 | } STALL_bit; 92 | }; // 0x10 93 | 94 | uint8_t rsvd14[12]; // 0x14 - 0x1f 95 | 96 | /* PRU_CTRL_CTBIR0 register bit field */ 97 | union { 98 | volatile uint32_t CTBIR0; 99 | 100 | volatile struct { 101 | uint32_t C24_BLK_INDEX : 8; // 7:0 102 | uint32_t rsvd8 : 8; // 15:8 103 | uint32_t C25_BLK_INDEX : 8; // 23:16 104 | uint32_t rsvd24 : 8; // 31:24 105 | } CTBIR0_bit; 106 | }; // 0x20 107 | 108 | /* PRU_CTRL_CTBIR1 register bit field */ 109 | union { 110 | volatile uint32_t CTBIR1; 111 | 112 | volatile struct { 113 | uint32_t C26_BLK_INDEX : 8; // 7:0 114 | uint32_t rsvd8 : 8; // 15:8 115 | uint32_t C27_BLK_INDEX : 8; // 23:16 116 | uint32_t rsvd24 : 8; // 31:24 117 | } CTBIR1_bit; 118 | }; // 0x24 119 | 120 | /* PRU_CTRL_CTPPR0 register bit field */ 121 | union { 122 | volatile uint32_t CTPPR0; 123 | 124 | volatile struct { 125 | uint32_t C28_POINTER : 16; // 15:0 126 | uint32_t C29_POINTER : 16; // 31:16 127 | } CTPPR0_bit; 128 | }; // 0x28 129 | 130 | /* PRU_CTRL_CTPPR1 register bit field */ 131 | union { 132 | volatile uint32_t CTPPR1; 133 | 134 | volatile struct { 135 | uint32_t C30_POINTER : 16; // 15:0 136 | uint32_t C31_POINTER : 16; // 31:16 137 | } CTPPR1_bit; 138 | }; // 0x2c 139 | 140 | } pruCtrl; 141 | 142 | /* Definition of control register structures. */ 143 | #define PRU0_CTRL (*((volatile pruCtrl*)0x22000)) 144 | #define PRU1_CTRL (*((volatile pruCtrl*)0x24000)) 145 | 146 | #endif /* _PRU_CTRL_H_ */ 147 | 148 | -------------------------------------------------------------------------------- /examples/include/am437x/pru_ecap.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_ECAP_H_ 35 | #define _PRU_ECAP_H_ 36 | 37 | /* PRU ECAP register set */ 38 | typedef struct { 39 | 40 | /* PRU_ECAP_TSCTR register bit field */ 41 | union { 42 | volatile uint32_t TSCTR; 43 | 44 | volatile struct { 45 | uint32_t TSCTR : 32; // 31:0 46 | } TSCTR_bit; 47 | }; // 0x0 48 | 49 | /* PRU_ECAP_CTRPHS register bit field */ 50 | union { 51 | volatile uint32_t CTRPHS; 52 | 53 | volatile struct { 54 | uint32_t CTRPHS : 32; // 31:0 55 | } CTRPHS_bit; 56 | }; // 0x4 57 | 58 | /* PRU_ECAP_CAP1 register bit field */ 59 | union { 60 | volatile uint32_t CAP1; 61 | 62 | volatile struct { 63 | uint32_t CAP1 : 32; // 31:0 64 | } CAP1_bit; 65 | }; // 0x8 66 | 67 | /* PRU_ECAP_CAP2 register bit field */ 68 | union { 69 | volatile uint32_t CAP2; 70 | 71 | volatile struct { 72 | uint32_t CAP2 : 32; // 31:0 73 | } CAP2_bit; 74 | }; // 0xc 75 | 76 | /* PRU_ECAP_CAP3 register bit field */ 77 | union { 78 | volatile uint32_t CAP3; 79 | 80 | volatile struct { 81 | uint32_t CAP3 : 32; // 31:0 82 | } CAP3_bit; 83 | }; // 0x10 84 | 85 | /* PRU_ECAP_CAP4 register bit field */ 86 | union { 87 | volatile uint32_t CAP4; 88 | 89 | volatile struct { 90 | uint32_t CAP4 : 32; // 31:0 91 | } CAP4_bit; 92 | }; // 0x14 93 | 94 | uint8_t rsvd18[16]; // 0x18 - 0x27 95 | 96 | /* PRU_ECAP_ECCTL1 register bit field */ 97 | volatile uint16_t ECCTL1; // 0x28 98 | 99 | /* PRU_ECAP_ECCTL2 register bit field */ 100 | volatile uint16_t ECCTL2; // 0x2a 101 | 102 | /* PRU_ECAP_ECEINT register bit field */ 103 | volatile uint16_t ECEINT; // 0x2c 104 | 105 | /* PRU_ECAP_ECFLG register bit field */ 106 | volatile uint16_t ECFLG; // 0x2e 107 | 108 | /* PRU_ECAP_ECCLR register bit field */ 109 | volatile uint16_t ECCLR; // 0x30 110 | 111 | /* PRU_ECAP_ECFRC register bit field */ 112 | volatile uint16_t ECFRC; // 0x32 113 | 114 | uint8_t rsvd34[40]; // 0x34 - 0x5b 115 | 116 | /* PRU_ECAP_REVID register bit field */ 117 | union { 118 | volatile uint32_t REVID; 119 | 120 | volatile struct { 121 | uint32_t REV : 32; // 31:0 122 | } REVID_bit; 123 | }; // 0x5c 124 | 125 | } pruEcap; 126 | 127 | volatile __far pruEcap CT_ECAP __attribute__((cregister("PRU_ECAP", near), peripheral)); 128 | 129 | #endif /* _PRU_ECAP_H_ */ 130 | 131 | -------------------------------------------------------------------------------- /examples/include/am571x/pru_ctrl.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_CTRL_H_ 35 | #define _PRU_CTRL_H_ 36 | 37 | /* PRU CTRL register set */ 38 | typedef struct { 39 | 40 | /* PRU_CTRL_CTRL register bit field */ 41 | union { 42 | volatile uint32_t CTRL; 43 | 44 | volatile struct { 45 | uint32_t SOFT_RST_N : 1; // 0 46 | uint32_t ENABLE : 1; // 1 47 | uint32_t SLEEPING : 1; // 2 48 | uint32_t COUNTER_ENABLE : 1; // 3 49 | uint32_t rsvd4 : 4; // 7:4 50 | uint32_t SINGLE_STEP : 1; // 8 51 | uint32_t rsvd9 : 5; // 13:9 52 | uint32_t BIG_ENDIAN : 1; // 14 53 | uint32_t RUNSTATE : 1; // 15 54 | uint32_t PCOUNTER_RST_VAL : 16; // 31:16 55 | } CTRL_bit; 56 | }; // 0x0 57 | 58 | /* PRU_CTRL_STS register bit field */ 59 | union { 60 | volatile uint32_t STS; 61 | 62 | volatile struct { 63 | uint32_t PCOUNTER : 16; // 15:0 64 | uint32_t rsvd16 : 16; // 31:16 65 | } STS_bit; 66 | }; // 0x4 67 | 68 | /* PRU_CTRL_WAKEUP_EN register bit field */ 69 | union { 70 | volatile uint32_t WAKEUP_EN; 71 | 72 | volatile struct { 73 | uint32_t BITWISE_ENABLES : 32; // 31:0 74 | } WAKEUP_EN_bit; 75 | }; // 0x8 76 | 77 | /* PRU_CTRL_CYCLE register bit field */ 78 | union { 79 | volatile uint32_t CYCLE; 80 | 81 | volatile struct { 82 | uint32_t CYCLECOUNT : 32; // 31:0 83 | } CYCLE_bit; 84 | }; // 0xc 85 | 86 | /* PRU_CTRL_STALL register bit field */ 87 | union { 88 | volatile uint32_t STALL; 89 | 90 | volatile struct { 91 | uint32_t STALLCOUNT : 32; // 31:0 92 | } STALL_bit; 93 | }; // 0x10 94 | 95 | uint8_t rsvd14[12]; // 0x14 - 0x1f 96 | 97 | /* PRU_CTRL_CTBIR0 register bit field */ 98 | union { 99 | volatile uint32_t CTBIR0; 100 | 101 | volatile struct { 102 | uint32_t C24_BLK_INDEX : 8; // 7:0 103 | uint32_t rsvd8 : 8; // 15:8 104 | uint32_t C25_BLK_INDEX : 8; // 23:16 105 | uint32_t rsvd24 : 8; // 31:24 106 | } CTBIR0_bit; 107 | }; // 0x20 108 | 109 | /* PRU_CTRL_CTBIR1 register bit field */ 110 | union { 111 | volatile uint32_t CTBIR1; 112 | 113 | volatile struct { 114 | uint32_t C26_BLK_INDEX : 8; // 7:0 115 | uint32_t rsvd8 : 8; // 15:8 116 | uint32_t C27_BLK_INDEX : 8; // 23:16 117 | uint32_t rsvd24 : 8; // 31:24 118 | } CTBIR1_bit; 119 | }; // 0x24 120 | 121 | /* PRU_CTRL_CTPPR0 register bit field */ 122 | union { 123 | volatile uint32_t CTPPR0; 124 | 125 | volatile struct { 126 | uint32_t C28_POINTER : 16; // 15:0 127 | uint32_t C29_POINTER : 16; // 31:16 128 | } CTPPR0_bit; 129 | }; // 0x28 130 | 131 | /* PRU_CTRL_CTPPR1 register bit field */ 132 | union { 133 | volatile uint32_t CTPPR1; 134 | 135 | volatile struct { 136 | uint32_t C30_POINTER : 16; // 15:0 137 | uint32_t C31_POINTER : 16; // 31:16 138 | } CTPPR1_bit; 139 | }; // 0x2c 140 | 141 | } pruCtrl; 142 | 143 | /* Definition of control register structures. */ 144 | #define PRU0_CTRL (*((volatile pruCtrl*)0x22000)) 145 | #define PRU1_CTRL (*((volatile pruCtrl*)0x24000)) 146 | 147 | #endif /* _PRU_CTRL_H_ */ 148 | 149 | -------------------------------------------------------------------------------- /examples/include/am571x/pru_ecap.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_ECAP_H_ 35 | #define _PRU_ECAP_H_ 36 | 37 | /* PRU ECAP register set */ 38 | typedef struct { 39 | 40 | /* PRU_ECAP_TSCNT register bit field */ 41 | union { 42 | volatile uint32_t TSCNT; 43 | 44 | volatile struct { 45 | uint32_t TSCNT : 32; // 31:0 46 | } TSCNT_bit; 47 | }; // 0x0 48 | 49 | /* PRU_ECAP_CNTPHS register bit field */ 50 | union { 51 | volatile uint32_t CNTPHS; 52 | 53 | volatile struct { 54 | uint32_t CNTPHS : 32; // 31:0 55 | } CNTPHS_bit; 56 | }; // 0x4 57 | 58 | /* PRU_ECAP_CAP1 register bit field */ 59 | union { 60 | volatile uint32_t CAP1; 61 | 62 | volatile struct { 63 | uint32_t CAP1 : 32; // 31:0 64 | } CAP1_bit; 65 | }; // 0x8 66 | 67 | /* PRU_ECAP_CAP2 register bit field */ 68 | union { 69 | volatile uint32_t CAP2; 70 | 71 | volatile struct { 72 | uint32_t CAP2 : 32; // 31:0 73 | } CAP2_bit; 74 | }; // 0xc 75 | 76 | /* PRU_ECAP_CAP3 register bit field */ 77 | union { 78 | volatile uint32_t CAP3; 79 | 80 | volatile struct { 81 | uint32_t CAP3 : 32; // 31:0 82 | } CAP3_bit; 83 | }; // 0x10 84 | 85 | /* PRU_ECAP_CAP4 register bit field */ 86 | union { 87 | volatile uint32_t CAP4; 88 | 89 | volatile struct { 90 | uint32_t CAP4 : 32; // 31:0 91 | } CAP4_bit; 92 | }; // 0x14 93 | 94 | uint8_t rsvd18[16]; // 0x18 - 0x27 95 | 96 | /* PRU_ECAP_ECCTL1 register bit field */ 97 | volatile uint16_t ECCTL1; // 0x28 98 | 99 | /* PRU_ECAP_ECCTL2 register bit field */ 100 | volatile uint16_t ECCTL2; // 0x2a 101 | 102 | /* PRU_ECAP_ECEINT register bit field */ 103 | volatile uint16_t ECEINT; // 0x2c 104 | 105 | /* PRU_ECAP_ECFLG register bit field */ 106 | volatile uint16_t ECFLG; // 0x2e 107 | 108 | /* PRU_ECAP_ECCLR register bit field */ 109 | volatile uint16_t ECCLR; // 0x30 110 | 111 | uint8_t rsvd32[2]; // 0x32 - 0x33 112 | 113 | /* PRU_ECAP_ECFRC register bit field */ 114 | volatile uint16_t ECFRC; // 0x34 115 | 116 | uint8_t rsvd36[38]; // 0x36 - 0x5b 117 | 118 | /* PRU_ECAP_PID register bit field */ 119 | union { 120 | volatile uint32_t PID; 121 | 122 | volatile struct { 123 | uint32_t REVISION : 32; // 31:0 124 | } PID_bit; 125 | }; // 0x5c 126 | 127 | } pruEcap; 128 | 129 | volatile __far pruEcap CT_ECAP __attribute__((cregister("PRU_ECAP", near), peripheral)); 130 | 131 | #endif /* _PRU_ECAP_H_ */ 132 | 133 | -------------------------------------------------------------------------------- /examples/include/am572x_1_1/pru_ctrl.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_CTRL_H_ 35 | #define _PRU_CTRL_H_ 36 | 37 | /* PRU CTRL register set */ 38 | typedef struct { 39 | 40 | /* PRU_CTRL_CONTROL register bit field */ 41 | union { 42 | volatile uint32_t CONTROL; 43 | 44 | volatile struct { 45 | uint32_t SOFT_RST_N : 1; // 0 46 | uint32_t ENABLE : 1; // 1 47 | uint32_t SLEEPING : 1; // 2 48 | uint32_t COUNTER_ENABLE : 1; // 3 49 | uint32_t rsvd4 : 4; // 7:4 50 | uint32_t SINGLE_STEP : 1; // 8 51 | uint32_t rsvd9 : 5; // 13:9 52 | uint32_t BIG_ENDIAN : 1; // 14 53 | uint32_t RUNSTATE : 1; // 15 54 | uint32_t PCOUNTER_RST_VAL : 16; // 31:16 55 | } CONTROL_bit; 56 | }; // 0x0 57 | 58 | /* PRU_CTRL_STATUS register bit field */ 59 | union { 60 | volatile uint32_t STATUS; 61 | 62 | volatile struct { 63 | uint32_t PCOUNTER : 16; // 15:0 64 | uint32_t rsvd16 : 16; // 31:16 65 | } STATUS_bit; 66 | }; // 0x4 67 | 68 | /* PRU_CTRL_WAKEUP_EN register bit field */ 69 | union { 70 | volatile uint32_t WAKEUP_EN; 71 | 72 | volatile struct { 73 | uint32_t BITWISE_ENABLES : 32; // 31:0 74 | } WAKEUP_EN_bit; 75 | }; // 0x8 76 | 77 | /* PRU_CTRL_CYCLE register bit field */ 78 | union { 79 | volatile uint32_t CYCLE; 80 | 81 | volatile struct { 82 | uint32_t CYCLECOUNT : 32; // 31:0 83 | } CYCLE_bit; 84 | }; // 0xc 85 | 86 | /* PRU_CTRL_STALL register bit field */ 87 | union { 88 | volatile uint32_t STALL; 89 | 90 | volatile struct { 91 | uint32_t STALLCOUNT : 32; // 31:0 92 | } STALL_bit; 93 | }; // 0x10 94 | 95 | uint8_t rsvd14[12]; // 0x14 - 0x1f 96 | 97 | /* PRU_CTRL_CTBIR0 register bit field */ 98 | union { 99 | volatile uint32_t CTBIR0; 100 | 101 | volatile struct { 102 | uint32_t C24_BLK_INDEX : 8; // 7:0 103 | uint32_t rsvd8 : 8; // 15:8 104 | uint32_t C25_BLK_INDEX : 8; // 23:16 105 | uint32_t rsvd24 : 8; // 31:24 106 | } CTBIR0_bit; 107 | }; // 0x20 108 | 109 | /* PRU_CTRL_CTBIR1 register bit field */ 110 | union { 111 | volatile uint32_t CTBIR1; 112 | 113 | volatile struct { 114 | uint32_t C26_BLK_INDEX : 8; // 7:0 115 | uint32_t rsvd8 : 8; // 15:8 116 | uint32_t C27_BLK_INDEX : 8; // 23:16 117 | uint32_t rsvd24 : 8; // 31:24 118 | } CTBIR1_bit; 119 | }; // 0x24 120 | 121 | /* PRU_CTRL_CTPPR0 register bit field */ 122 | union { 123 | volatile uint32_t CTPPR0; 124 | 125 | volatile struct { 126 | uint32_t C28_POINTER : 16; // 15:0 127 | uint32_t C29_POINTER : 16; // 31:16 128 | } CTPPR0_bit; 129 | }; // 0x28 130 | 131 | /* PRU_CTRL_CTPPR1 register bit field */ 132 | union { 133 | volatile uint32_t CTPPR1; 134 | 135 | volatile struct { 136 | uint32_t C30_POINTER : 16; // 15:0 137 | uint32_t C31_POINTER : 16; // 31:16 138 | } CTPPR1_bit; 139 | }; // 0x2c 140 | 141 | } pruCtrl; 142 | 143 | /* Definition of control register structures. */ 144 | #define PRU0_CTRL (*((volatile pruCtrl*)0x22000)) 145 | #define PRU1_CTRL (*((volatile pruCtrl*)0x24000)) 146 | 147 | #endif /* _PRU_CTRL_H_ */ 148 | 149 | -------------------------------------------------------------------------------- /examples/include/am572x_1_1/pru_ecap.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_ECAP_H_ 35 | #define _PRU_ECAP_H_ 36 | 37 | /* PRU ECAP register set */ 38 | typedef struct { 39 | 40 | /* PRU_ECAP_TSCNT register bit field */ 41 | union { 42 | volatile uint32_t TSCNT; 43 | 44 | volatile struct { 45 | uint32_t TSCNT : 32; // 31:0 46 | } TSCNT_bit; 47 | }; // 0x0 48 | 49 | /* PRU_ECAP_CNTPHS register bit field */ 50 | union { 51 | volatile uint32_t CNTPHS; 52 | 53 | volatile struct { 54 | uint32_t CNTPHS : 32; // 31:0 55 | } CNTPHS_bit; 56 | }; // 0x4 57 | 58 | /* PRU_ECAP_CAP1 register bit field */ 59 | union { 60 | volatile uint32_t CAP1; 61 | 62 | volatile struct { 63 | uint32_t CAP1 : 32; // 31:0 64 | } CAP1_bit; 65 | }; // 0x8 66 | 67 | /* PRU_ECAP_CAP2 register bit field */ 68 | union { 69 | volatile uint32_t CAP2; 70 | 71 | volatile struct { 72 | uint32_t CAP2 : 32; // 31:0 73 | } CAP2_bit; 74 | }; // 0xc 75 | 76 | /* PRU_ECAP_CAP3 register bit field */ 77 | union { 78 | volatile uint32_t CAP3; 79 | 80 | volatile struct { 81 | uint32_t CAP3 : 32; // 31:0 82 | } CAP3_bit; 83 | }; // 0x10 84 | 85 | /* PRU_ECAP_CAP4 register bit field */ 86 | union { 87 | volatile uint32_t CAP4; 88 | 89 | volatile struct { 90 | uint32_t CAP4 : 32; // 31:0 91 | } CAP4_bit; 92 | }; // 0x14 93 | 94 | uint8_t rsvd18[16]; // 0x18 - 0x27 95 | 96 | /* PRU_ECAP_ECCTL1 register bit field */ 97 | volatile uint16_t ECCTL1; // 0x28 98 | 99 | /* PRU_ECAP_ECCTL2 register bit field */ 100 | volatile uint16_t ECCTL2; // 0x2a 101 | 102 | /* PRU_ECAP_ECEINT register bit field */ 103 | volatile uint16_t ECEINT; // 0x2c 104 | 105 | /* PRU_ECAP_ECFLG register bit field */ 106 | volatile uint16_t ECFLG; // 0x2e 107 | 108 | /* PRU_ECAP_ECCLR register bit field */ 109 | volatile uint16_t ECCLR; // 0x30 110 | 111 | uint8_t rsvd32[2]; // 0x32 - 0x33 112 | 113 | /* PRU_ECAP_ECFRC register bit field */ 114 | volatile uint16_t ECFRC; // 0x34 115 | 116 | uint8_t rsvd36[38]; // 0x36 - 0x5b 117 | 118 | /* PRU_ECAP_PID register bit field */ 119 | union { 120 | volatile uint32_t PID; 121 | 122 | volatile struct { 123 | uint32_t REVISION : 32; // 31:0 124 | } PID_bit; 125 | }; // 0x5c 126 | 127 | } pruEcap; 128 | 129 | volatile __far pruEcap CT_ECAP __attribute__((cregister("PRU_ECAP", near), peripheral)); 130 | 131 | #endif /* _PRU_ECAP_H_ */ 132 | 133 | -------------------------------------------------------------------------------- /examples/include/am572x_2_0/pru_ctrl.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_CTRL_H_ 35 | #define _PRU_CTRL_H_ 36 | 37 | /* PRU CTRL register set */ 38 | typedef struct { 39 | 40 | /* PRU_CTRL_CONTROL register bit field */ 41 | union { 42 | volatile uint32_t CONTROL; 43 | 44 | volatile struct { 45 | uint32_t SOFT_RST_N : 1; // 0 46 | uint32_t ENABLE : 1; // 1 47 | uint32_t SLEEPING : 1; // 2 48 | uint32_t COUNTER_ENABLE : 1; // 3 49 | uint32_t rsvd4 : 4; // 7:4 50 | uint32_t SINGLE_STEP : 1; // 8 51 | uint32_t rsvd9 : 5; // 13:9 52 | uint32_t BIG_ENDIAN : 1; // 14 53 | uint32_t RUNSTATE : 1; // 15 54 | uint32_t PCOUNTER_RST_VAL : 16; // 31:16 55 | } CONTROL_bit; 56 | }; // 0x0 57 | 58 | /* PRU_CTRL_STATUS register bit field */ 59 | union { 60 | volatile uint32_t STATUS; 61 | 62 | volatile struct { 63 | uint32_t PCOUNTER : 16; // 15:0 64 | uint32_t rsvd16 : 16; // 31:16 65 | } STATUS_bit; 66 | }; // 0x4 67 | 68 | /* PRU_CTRL_WAKEUP_EN register bit field */ 69 | union { 70 | volatile uint32_t WAKEUP_EN; 71 | 72 | volatile struct { 73 | uint32_t BITWISE_ENABLES : 32; // 31:0 74 | } WAKEUP_EN_bit; 75 | }; // 0x8 76 | 77 | /* PRU_CTRL_CYCLE register bit field */ 78 | union { 79 | volatile uint32_t CYCLE; 80 | 81 | volatile struct { 82 | uint32_t CYCLECOUNT : 32; // 31:0 83 | } CYCLE_bit; 84 | }; // 0xc 85 | 86 | /* PRU_CTRL_STALL register bit field */ 87 | union { 88 | volatile uint32_t STALL; 89 | 90 | volatile struct { 91 | uint32_t STALLCOUNT : 32; // 31:0 92 | } STALL_bit; 93 | }; // 0x10 94 | 95 | uint8_t rsvd14[12]; // 0x14 - 0x1f 96 | 97 | /* PRU_CTRL_CTBIR0 register bit field */ 98 | union { 99 | volatile uint32_t CTBIR0; 100 | 101 | volatile struct { 102 | uint32_t C24_BLK_INDEX : 8; // 7:0 103 | uint32_t rsvd8 : 8; // 15:8 104 | uint32_t C25_BLK_INDEX : 8; // 23:16 105 | uint32_t rsvd24 : 8; // 31:24 106 | } CTBIR0_bit; 107 | }; // 0x20 108 | 109 | /* PRU_CTRL_CTBIR1 register bit field */ 110 | union { 111 | volatile uint32_t CTBIR1; 112 | 113 | volatile struct { 114 | uint32_t C26_BLK_INDEX : 8; // 7:0 115 | uint32_t rsvd8 : 8; // 15:8 116 | uint32_t C27_BLK_INDEX : 8; // 23:16 117 | uint32_t rsvd24 : 8; // 31:24 118 | } CTBIR1_bit; 119 | }; // 0x24 120 | 121 | /* PRU_CTRL_CTPPR0 register bit field */ 122 | union { 123 | volatile uint32_t CTPPR0; 124 | 125 | volatile struct { 126 | uint32_t C28_POINTER : 16; // 15:0 127 | uint32_t C29_POINTER : 16; // 31:16 128 | } CTPPR0_bit; 129 | }; // 0x28 130 | 131 | /* PRU_CTRL_CTPPR1 register bit field */ 132 | union { 133 | volatile uint32_t CTPPR1; 134 | 135 | volatile struct { 136 | uint32_t C30_POINTER : 16; // 15:0 137 | uint32_t C31_POINTER : 16; // 31:16 138 | } CTPPR1_bit; 139 | }; // 0x2c 140 | 141 | } pruCtrl; 142 | 143 | /* Definition of control register structures. */ 144 | #define PRU0_CTRL (*((volatile pruCtrl*)0x22000)) 145 | #define PRU1_CTRL (*((volatile pruCtrl*)0x24000)) 146 | 147 | #endif /* _PRU_CTRL_H_ */ 148 | 149 | -------------------------------------------------------------------------------- /examples/include/am572x_2_0/pru_ecap.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_ECAP_H_ 35 | #define _PRU_ECAP_H_ 36 | 37 | /* PRU ECAP register set */ 38 | typedef struct { 39 | 40 | /* PRU_ECAP_TSCNT register bit field */ 41 | union { 42 | volatile uint32_t TSCNT; 43 | 44 | volatile struct { 45 | uint32_t TSCNT : 32; // 31:0 46 | } TSCNT_bit; 47 | }; // 0x0 48 | 49 | /* PRU_ECAP_CNTPHS register bit field */ 50 | union { 51 | volatile uint32_t CNTPHS; 52 | 53 | volatile struct { 54 | uint32_t CNTPHS : 32; // 31:0 55 | } CNTPHS_bit; 56 | }; // 0x4 57 | 58 | /* PRU_ECAP_CAP1 register bit field */ 59 | union { 60 | volatile uint32_t CAP1; 61 | 62 | volatile struct { 63 | uint32_t CAP1 : 32; // 31:0 64 | } CAP1_bit; 65 | }; // 0x8 66 | 67 | /* PRU_ECAP_CAP2 register bit field */ 68 | union { 69 | volatile uint32_t CAP2; 70 | 71 | volatile struct { 72 | uint32_t CAP2 : 32; // 31:0 73 | } CAP2_bit; 74 | }; // 0xc 75 | 76 | /* PRU_ECAP_CAP3 register bit field */ 77 | union { 78 | volatile uint32_t CAP3; 79 | 80 | volatile struct { 81 | uint32_t CAP3 : 32; // 31:0 82 | } CAP3_bit; 83 | }; // 0x10 84 | 85 | /* PRU_ECAP_CAP4 register bit field */ 86 | union { 87 | volatile uint32_t CAP4; 88 | 89 | volatile struct { 90 | uint32_t CAP4 : 32; // 31:0 91 | } CAP4_bit; 92 | }; // 0x14 93 | 94 | uint8_t rsvd18[16]; // 0x18 - 0x27 95 | 96 | /* PRU_ECAP_ECCTL1 register bit field */ 97 | volatile uint16_t ECCTL1; // 0x28 98 | 99 | /* PRU_ECAP_ECCTL2 register bit field */ 100 | volatile uint16_t ECCTL2; // 0x2a 101 | 102 | /* PRU_ECAP_ECEINT register bit field */ 103 | volatile uint16_t ECEINT; // 0x2c 104 | 105 | /* PRU_ECAP_ECFLG register bit field */ 106 | volatile uint16_t ECFLG; // 0x2e 107 | 108 | /* PRU_ECAP_ECCLR register bit field */ 109 | volatile uint16_t ECCLR; // 0x30 110 | 111 | uint8_t rsvd32[2]; // 0x32 - 0x33 112 | 113 | /* PRU_ECAP_ECFRC register bit field */ 114 | volatile uint16_t ECFRC; // 0x34 115 | 116 | uint8_t rsvd36[38]; // 0x36 - 0x5b 117 | 118 | /* PRU_ECAP_PID register bit field */ 119 | union { 120 | volatile uint32_t PID; 121 | 122 | volatile struct { 123 | uint32_t REVISION : 32; // 31:0 124 | } PID_bit; 125 | }; // 0x5c 126 | 127 | } pruEcap; 128 | 129 | volatile __far pruEcap CT_ECAP __attribute__((cregister("PRU_ECAP", near), peripheral)); 130 | 131 | #endif /* _PRU_ECAP_H_ */ 132 | 133 | -------------------------------------------------------------------------------- /examples/include/k2g/pru_ctrl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 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_CTRL_H_ 35 | #define _PRU_CTRL_H_ 36 | 37 | /* PRU CTRL register set */ 38 | typedef struct { 39 | 40 | /* PRU_CTRL_CONTROL register bit field */ 41 | union { 42 | volatile uint32_t CONTROL; 43 | 44 | volatile struct { 45 | uint32_t SOFT_RST_N : 1; // 0 46 | uint32_t ENABLE : 1; // 1 47 | uint32_t SLEEPING : 1; // 2 48 | uint32_t COUNTER_ENABLE : 1; // 3 49 | uint32_t rsvd4 : 4; // 7:4 50 | uint32_t SINGLE_STEP : 1; // 8 51 | uint32_t rsvd9 : 5; // 13:9 52 | uint32_t BIG_ENDIAN : 1; // 14 53 | uint32_t RUNSTATE : 1; // 15 54 | uint32_t PCOUNTER_RST_VAL : 16; // 31:16 55 | } CONTROL_bit; 56 | }; // 0x0 57 | 58 | /* PRU_CTRL_STATUS register bit field */ 59 | union { 60 | volatile uint32_t STATUS; 61 | 62 | volatile struct { 63 | uint32_t PCOUNTER : 16; // 15:0 64 | uint32_t rsvd16 : 16; // 31:16 65 | } STATUS_bit; 66 | }; // 0x4 67 | 68 | /* PRU_CTRL_WAKEUP_EN register bit field */ 69 | union { 70 | volatile uint32_t WAKEUP_EN; 71 | 72 | volatile struct { 73 | uint32_t BITWISE_ENABLES : 32; // 31:0 74 | } WAKEUP_EN_bit; 75 | }; // 0x8 76 | 77 | /* PRU_CTRL_CYCLE register bit field */ 78 | union { 79 | volatile uint32_t CYCLE; 80 | 81 | volatile struct { 82 | uint32_t CYCLECOUNT : 32; // 31:0 83 | } CYCLE_bit; 84 | }; // 0xc 85 | 86 | /* PRU_CTRL_STALL register bit field */ 87 | union { 88 | volatile uint32_t STALL; 89 | 90 | volatile struct { 91 | uint32_t STALLCOUNT : 32; // 31:0 92 | } STALL_bit; 93 | }; // 0x10 94 | 95 | uint8_t rsvd14[12]; // 0x14 - 0x1f 96 | 97 | /* PRU_CTRL_CTBIR0 register bit field */ 98 | union { 99 | volatile uint32_t CTBIR0; 100 | 101 | volatile struct { 102 | uint32_t C24_BLK_INDEX : 8; // 7:0 103 | uint32_t rsvd8 : 8; // 15:8 104 | uint32_t C25_BLK_INDEX : 8; // 23:16 105 | uint32_t rsvd24 : 8; // 31:24 106 | } CTBIR0_bit; 107 | }; // 0x20 108 | 109 | /* PRU_CTRL_CTBIR1 register bit field */ 110 | union { 111 | volatile uint32_t CTBIR1; 112 | 113 | volatile struct { 114 | uint32_t C26_BLK_INDEX : 8; // 7:0 115 | uint32_t rsvd8 : 8; // 15:8 116 | uint32_t C27_BLK_INDEX : 8; // 23:16 117 | uint32_t rsvd24 : 8; // 31:24 118 | } CTBIR1_bit; 119 | }; // 0x24 120 | 121 | /* PRU_CTRL_CTPPR0 register bit field */ 122 | union { 123 | volatile uint32_t CTPPR0; 124 | 125 | volatile struct { 126 | uint32_t C28_POINTER : 16; // 15:0 127 | uint32_t C29_POINTER : 16; // 31:16 128 | } CTPPR0_bit; 129 | }; // 0x28 130 | 131 | /* PRU_CTRL_CTPPR1 register bit field */ 132 | union { 133 | volatile uint32_t CTPPR1; 134 | 135 | volatile struct { 136 | uint32_t C30_POINTER : 16; // 15:0 137 | uint32_t C31_POINTER : 16; // 31:16 138 | } CTPPR1_bit; 139 | }; // 0x2c 140 | 141 | } pruCtrl; 142 | 143 | /* Definition of control register structures. */ 144 | #define PRU0_CTRL (*((volatile pruCtrl*)0x22000)) 145 | #define PRU1_CTRL (*((volatile pruCtrl*)0x24000)) 146 | 147 | #endif /* _PRU_CTRL_H_ */ 148 | 149 | -------------------------------------------------------------------------------- /examples/include/k2g/pru_ecap.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_ECAP_H_ 35 | #define _PRU_ECAP_H_ 36 | 37 | /* PRU ECAP register set */ 38 | typedef struct { 39 | 40 | /* PRU_ECAP_TSCNT register bit field */ 41 | union { 42 | volatile uint32_t TSCNT; 43 | 44 | volatile struct { 45 | uint32_t TSCNT : 32; // 31:0 46 | } TSCNT_bit; 47 | }; // 0x0 48 | 49 | /* PRU_ECAP_CNTPHS register bit field */ 50 | union { 51 | volatile uint32_t CNTPHS; 52 | 53 | volatile struct { 54 | uint32_t CNTPHS : 32; // 31:0 55 | } CNTPHS_bit; 56 | }; // 0x4 57 | 58 | /* PRU_ECAP_CAP1 register bit field */ 59 | union { 60 | volatile uint32_t CAP1; 61 | 62 | volatile struct { 63 | uint32_t CAP1 : 32; // 31:0 64 | } CAP1_bit; 65 | }; // 0x8 66 | 67 | /* PRU_ECAP_CAP2 register bit field */ 68 | union { 69 | volatile uint32_t CAP2; 70 | 71 | volatile struct { 72 | uint32_t CAP2 : 32; // 31:0 73 | } CAP2_bit; 74 | }; // 0xc 75 | 76 | /* PRU_ECAP_CAP3 register bit field */ 77 | union { 78 | volatile uint32_t CAP3; 79 | 80 | volatile struct { 81 | uint32_t CAP3 : 32; // 31:0 82 | } CAP3_bit; 83 | }; // 0x10 84 | 85 | /* PRU_ECAP_CAP4 register bit field */ 86 | union { 87 | volatile uint32_t CAP4; 88 | 89 | volatile struct { 90 | uint32_t CAP4 : 32; // 31:0 91 | } CAP4_bit; 92 | }; // 0x14 93 | 94 | uint8_t rsvd18[16]; // 0x18 - 0x27 95 | 96 | /* PRU_ECAP_ECCTL1 register bit field */ 97 | volatile uint16_t ECCTL1; // 0x28 98 | 99 | /* PRU_ECAP_ECCTL2 register bit field */ 100 | volatile uint16_t ECCTL2; // 0x2a 101 | 102 | /* PRU_ECAP_ECEINT register bit field */ 103 | volatile uint16_t ECEINT; // 0x2c 104 | 105 | /* PRU_ECAP_ECFLG register bit field */ 106 | volatile uint16_t ECFLG; // 0x2e 107 | 108 | /* PRU_ECAP_ECCLR register bit field */ 109 | volatile uint16_t ECCLR; // 0x30 110 | 111 | uint8_t rsvd32[2]; // 0x32 - 0x33 112 | 113 | /* PRU_ECAP_ECFRC register bit field */ 114 | volatile uint16_t ECFRC; // 0x34 115 | 116 | uint8_t rsvd36[38]; // 0x36 - 0x5b 117 | 118 | /* PRU_ECAP_PID register bit field */ 119 | union { 120 | volatile uint32_t PID; 121 | 122 | volatile struct { 123 | uint32_t REVISION : 32; // 31:0 124 | } PID_bit; 125 | }; // 0x5c 126 | 127 | } pruEcap; 128 | 129 | volatile __far pruEcap CT_ECAP __attribute__((cregister("PRU_ECAP", near), peripheral)); 130 | 131 | #endif /* _PRU_ECAP_H_ */ 132 | 133 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /examples/kernel_examples/n-blinky/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2016 Zubeen Tolani 3 | # 4 | # Makefile to compile n-blinky 5 | # 6 | 7 | .PHONY:all 8 | all: firmware module 9 | 10 | .PHONY:firmware 11 | firmware: 12 | cd firmware; make 13 | 14 | .PHONY:module 15 | module: 16 | cd module; make 17 | 18 | .PHONY:clean 19 | clean: 20 | cd firmware; $(MAKE) clean 21 | cd module; $(MAKE) clean 22 | 23 | -------------------------------------------------------------------------------- /examples/kernel_examples/n-blinky/firmware/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/kernel_examples/n-blinky/firmware/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Makefile to make PRU_inlineASM_blinky project 4 | # 5 | # The make file is tried to be made as generic as possible 6 | # So that it can be used to compile other programs too 7 | # 8 | # Usage: 9 | # name your main source file as main_pru1.c or main_pru0.c 10 | # add targets to variable TARGETS 11 | # add other files required while linking in variable LINK_PRU1(0)_FW 12 | # add compile targets, as added to LINK_PRU1(0)_FW for other files. 13 | # 14 | 15 | # PRU_CGT environment variable must point to the TI PRU compiler directory. E.g.: 16 | #(Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 17 | #(Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 18 | 19 | ifndef PRU_CGT 20 | define ERROR_BODY 21 | 22 | ************************************************************ 23 | PRU_CGT environment variable is not set. Examples given: 24 | (Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 25 | (Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 26 | ************************************************************ 27 | 28 | endef 29 | $(error $(ERROR_BODY)) 30 | endif 31 | 32 | 33 | LINKER_COMMAND_FILE=./AM335x_PRU.cmd 34 | LIBS=--library=../../../lib/rpmsg_lib.lib 35 | INCLUDE=--include_path=../../../include --include_path=../../../include/am335x 36 | STACK_SIZE=0x100 37 | HEAP_SIZE=0x100 38 | 39 | 40 | CFLAGS=-v3 -O2 --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) -ppd -ppa 41 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) 42 | 43 | 44 | GEN_DIR=gen 45 | 46 | PRU1_FW =$(GEN_DIR)/main_pru1_fw.out 47 | PRU0_FW =$(GEN_DIR)/main_pru0_fw.out 48 | 49 | 50 | # ----------------------------------------------------- 51 | # Variable to edit in the makefile 52 | 53 | # add the required firmwares to TARGETS 54 | # TARGETS =$(PRU1_FW) $(PRU0_FW) 55 | TARGETS =$(PRU1_FW) 56 | 57 | # add the required files while linkin the FW code 58 | # required linking files for PRU1 59 | # LINK_PRU1_FW = (GEN_DIR)/pru1-inline-asm.object (GEN_DIR)/code2_pru1.object 60 | LINK_PRU1_FW= 61 | 62 | # required linking files for PRU1 63 | # LINK_PRU0_FW = (GEN_DIR)/pru0-inline-asm.object (GEN_DIR)/code2_pru1.object 64 | LINK_PRU0_FW= 65 | 66 | #------------------------------------------------------ 67 | 68 | 69 | 70 | .PHONY: all 71 | all: $(TARGETS) 72 | @echo '- Generated firmwares are : $^' 73 | 74 | 75 | $(PRU1_FW): $(GEN_DIR)/main_pru1.object $(LINK_PRU1_FW) 76 | @echo 'LD $^' 77 | @$(PRU_CGT)/bin/lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 78 | 79 | 80 | $(PRU0_FW): $(GEN_DIR)/main_pru0.object $(LINK_PRU0_FW) 81 | @echo 'LD $^' 82 | @$(PRU_CGT)/bin/lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 83 | 84 | 85 | $(GEN_DIR)/main_pru0.object: main_pru0.c 86 | @mkdir -p $(GEN_DIR) 87 | @echo 'CC $<' 88 | @$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 89 | 90 | 91 | $(GEN_DIR)/main_pru1.object: main_pru1.c 92 | @mkdir -p $(GEN_DIR) 93 | @echo 'CC $<' 94 | @$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 95 | 96 | 97 | 98 | .PHONY: install install-pru1 install-pru0 copy_pru0_fw copy_pru1_fw reboot_pru_1 reboot_pru_0 99 | 100 | install: $(patsubst $(GEN_DIR)/main_pru%_fw.out, install-pru%, $(TARGETS)) 101 | 102 | 103 | install-pru1: $(PRU1_FW) copy_pru1_fw reboot_pru1 104 | install-pru0: $(PRU0_FW) copy_pru0_fw reboot_pru0 105 | 106 | copy_pru1_fw: 107 | @echo '- copying firmware to /lib/firmware/am335x_pru1_fw' 108 | @cp $(PRU1_FW) /lib/firmware/am335x-pru1-fw 109 | 110 | copy_pru0_fw: $(PRU0_FW) 111 | @echo '- copying firmware to /lib/firmware/am335x_pru0_fw' 112 | @cp $(PRU0_FW) /lib/firmware/am335x-pru0-fw 113 | 114 | reboot_pru1: 115 | @echo '- rebooting pru core 1' 116 | $(shell echo "4a338000.pru1" > /sys/bus/platform/drivers/pru-rproc/unbind 2> /dev/null) 117 | $(shell echo "4a338000.pru1" > /sys/bus/platform/drivers/pru-rproc/bind) 118 | @echo "- pru core 1 is now loaded with $(PRU1_FW)" 119 | 120 | reboot_pru0: 121 | @echo '- rebooting pru core 0' 122 | $(shell echo "4a334000.pru0" > /sys/bus/platform/drivers/pru-rproc/unbind 2> /dev/null) 123 | $(shell echo "4a334000.pru0" > /sys/bus/platform/drivers/pru-rproc/bind) 124 | @echo "- pru core 0 is now loaded with $(PRU0_FW)" 125 | 126 | 127 | .PHONY: clean 128 | clean: 129 | @echo 'CLEAN .' 130 | @rm -rf $(GEN_DIR) 131 | -------------------------------------------------------------------------------- /examples/kernel_examples/n-blinky/firmware/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ############################################################################## 4 | # 5 | # Copyright (C) 2016 Zubeen Tolani 6 | # 7 | # 8 | # Redistribution and use in source and binary forms, with or without 9 | # modification, are permitted provided that the following conditions 10 | # are met: 11 | # 12 | # * Redistributions of source code must retain the above copyright 13 | # notice, this list of conditions and the following disclaimer. 14 | # 15 | # * Redistributions in binary form must reproduce the above copyright 16 | # notice, this list of conditions and the following disclaimer in the 17 | # documentation and/or other materials provided with the 18 | # distribution 19 | # 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 | 36 | # The script configures the pinmuxing for PINS and reboots PRUs 37 | #Dont change. If changing these variables, make sure the given pin can be muxed to the given pru. 38 | 39 | HEADER=P8_ 40 | PINS="27 28 29 39 40 41 42 43 44 45 46" 41 | 42 | #PRU_CORE should be either 0 or 1 43 | PRU_CORE=1 44 | 45 | echo "*******************************************************" 46 | echo "This must be compiled on the BEAGLEBONE BLACK itself" 47 | echo "It was tested on 4.4.11-ti-r29 kernel version" 48 | echo "The source code for n-blinky-fw is based on examples from" 49 | echo "pru-software-support-package which can be cloned from" 50 | echo "git clone git://git.ti.com/pru-software-support-package/pru-software-support-package.git" 51 | echo "" 52 | echo "n-blinky-fw along with the kernel module will toggle all the PRU0 gpios routed to P8" 53 | echo "n number of times where n is the input to /dev/rpmsg_pru_parallel_example" 54 | echo "For more details see README.md" 55 | echo "******NOTE: use a resistor >470 ohms to connect to the LED, I have alredy made this mistake." 56 | echo "To continue, press any key:" 57 | read 58 | 59 | echo "-Placing the firmware" 60 | cp gen/*.out /lib/firmware/am335x-pru$PRU_CORE-fw 61 | 62 | echo "-Configuring pinmux" 63 | for PIN_NUMBER in $PINS 64 | do 65 | config-pin -a $HEADER$PIN_NUMBER pruout 66 | config-pin -q $HEADER$PIN_NUMBER 67 | done 68 | 69 | echo "-Rebooting" 70 | if [ $PRU_CORE -eq 0 ] 71 | then 72 | echo "Rebooting pru-core 0" 73 | echo 'stop' > /sys/class/remoteproc/remoteproc1/state 2>/dev/null 74 | echo "am335x-pru$PRU_CORE-fw" > /sys/class/remoteproc/remoteproc1/firmware 75 | echo 'start' > /sys/class/remoteproc/remoteproc1/state 76 | else 77 | echo "Rebooting pru-core 1" 78 | echo 'stop' > /sys/class/remoteproc/remoteproc2/state 2>/dev/null 79 | echo "am335x-pru$PRU_CORE-fw" > /sys/class/remoteproc/remoteproc2/firmware 80 | echo 'start' > /sys/class/remoteproc/remoteproc2/state 81 | fi 82 | 83 | echo "******************************************************************************" 84 | echo "Done. So now $OUT_HEADER$OUT_PIN_NUMBER will toggle n number of times where" 85 | echo "n is echo n > /dev/rpmsg_pru_parallel_example" 86 | echo "******************************************************************************" 87 | -------------------------------------------------------------------------------- /examples/kernel_examples/n-blinky/module/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile written by Zubeen Tolani 3 | # Copyright (C) 2016 Zubeen Tolani 4 | # 5 | # Makefile to compile rpmsg_pru_parallel_example.c 6 | # 7 | 8 | obj-m += rpmsg_pru_parallel_example.o 9 | 10 | KDIR?=/lib/modules/$(shell uname -r)/build 11 | 12 | 13 | .PHONY: all 14 | all: 15 | @make -C $(KDIR) M=$(PWD) modules 16 | 17 | .PHONY: clean 18 | clean: 19 | @make -C $(KDIR) M=$(PWD) clean 20 | 21 | -------------------------------------------------------------------------------- /examples/lib/rpmsg_lib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zeekhuge/BeagleScope/757017f3d533ee048d40c8289b70054ada85e945/examples/lib/rpmsg_lib.lib -------------------------------------------------------------------------------- /examples/lib/src/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS=rpmsg_lib 2 | 3 | all: $(SUBDIRS) 4 | 5 | $(SUBDIRS): 6 | @$(MAKE) -C $@ 7 | 8 | clean: 9 | @for d in $(SUBDIRS); do (cd $$d; $(MAKE) clean ); done 10 | 11 | .PHONY: all clean $(SUBDIRS) 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/lib/src/rpmsg_lib/.ccsproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /examples/lib/src/rpmsg_lib/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | rpmsg_lib 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 15 | full,incremental, 16 | 17 | 18 | 19 | 20 | 21 | com.ti.ccstudio.core.ccsNature 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 24 | org.eclipse.cdt.core.ccnature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /examples/lib/src/rpmsg_lib/.settings/org.eclipse.cdt.codan.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | inEditor=false 3 | onBuild=false 4 | -------------------------------------------------------------------------------- /examples/lib/src/rpmsg_lib/.settings/org.eclipse.cdt.debug.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.cdt.debug.core.toggleBreakpointModel=com.ti.ccstudio.debug.CCSBreakpointMarker 3 | -------------------------------------------------------------------------------- /examples/lib/src/rpmsg_lib/Makefile: -------------------------------------------------------------------------------- 1 | # PRU_CGT environment variable must point to the TI PRU compiler directory. E.g.: 2 | #(Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 3 | #(Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 4 | ifndef PRU_CGT 5 | define ERROR_BODY 6 | 7 | ************************************************************ 8 | PRU_CGT environment variable is not set. Examples given: 9 | (Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 10 | (Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 11 | ************************************************************ 12 | 13 | endef 14 | $(error $(ERROR_BODY)) 15 | endif 16 | 17 | MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) 18 | CURRENT_DIR := $(notdir $(patsubst %/,%,$(dir $(MKFILE_PATH)))) 19 | PROJ_NAME=$(CURRENT_DIR) 20 | INCLUDE=--include_path=../../../include 21 | GEN_DIR=gen 22 | 23 | #Common compiler flags (Defined in 'PRU Optimizing C/C++ Compiler User's Guide) 24 | CFLAGS=-v3 -O2 --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) -ppd -ppa 25 | 26 | TARGET=$(GEN_DIR)/$(PROJ_NAME).lib 27 | SOURCES=$(wildcard *.c) 28 | #Using .object instead of .obj in order to not conflict with the CCS build process 29 | OBJECTS=$(patsubst %,$(GEN_DIR)/%,$(SOURCES:.c=.object)) 30 | 31 | all: printStart $(TARGET) printEnd 32 | 33 | printStart: 34 | @echo '' 35 | @echo '************************************************************' 36 | @echo 'Building project: $(PROJ_NAME)' 37 | 38 | printEnd: 39 | @echo '' 40 | @echo 'Finished building project: $(PROJ_NAME)' 41 | @echo '************************************************************' 42 | @echo '' 43 | 44 | # Invokes the archiver to make the .lib file 45 | $(TARGET): $(OBJECTS) 46 | @echo '' 47 | @echo 'Building target: $@' 48 | @echo 'Invoking: PRU Archiver' 49 | $(PRU_CGT)/bin/arpru r $(TARGET) $(OBJECTS) 50 | @echo 'Finished building target: $@' 51 | @echo '' 52 | @echo 'Output files can be found in the "$(GEN_DIR)" directory' 53 | 54 | # Invokes the compiler on all c files in the directory to create the object files 55 | $(GEN_DIR)/%.object: %.c 56 | @mkdir -p $(GEN_DIR) 57 | @echo '' 58 | @echo 'Building file: $<' 59 | @echo 'Invoking: PRU Compiler' 60 | $(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 61 | 62 | .PHONY: all clean 63 | 64 | # Remove the $(GEN_DIR) directory 65 | clean: 66 | @echo '' 67 | @echo '************************************************************' 68 | @echo 'Cleaning project: $(PROJ_NAME)' 69 | @echo '' 70 | @echo 'Removing files in the "$(GEN_DIR)" directory' 71 | @rm -rf $(GEN_DIR) 72 | @echo '' 73 | @echo 'Finished cleaning project: $(PROJ_NAME)' 74 | @echo '************************************************************' 75 | @echo '' 76 | 77 | # Includes the dependencies that the compiler creates (-ppd and -ppa flags) 78 | -include $(OBJECTS:%.object=%.pp) 79 | 80 | -------------------------------------------------------------------------------- /examples/lib/src/rpmsg_lib/pru_rpmsg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 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 | * File : pru_rpmsg.c 36 | * 37 | * Summary : An RPMsg implementation for the PRU to use while communicating 38 | * with the ARM host. 39 | * 40 | * Notes : 41 | * - Implementaion of the interface described in "pru_rpmsg.h" 42 | */ 43 | 44 | #include 45 | 46 | struct pru_rpmsg_hdr { 47 | uint32_t src; 48 | uint32_t dst; 49 | uint32_t reserved; 50 | uint16_t len; 51 | uint16_t flags; 52 | uint8_t data[0]; 53 | }; 54 | 55 | struct pru_rpmsg_ns_msg { 56 | char name[RPMSG_NAME_SIZE]; 57 | char desc[RPMSG_NAME_SIZE]; 58 | uint32_t addr; 59 | uint32_t flags; 60 | }; 61 | 62 | int16_t pru_rpmsg_send( 63 | struct pru_rpmsg_transport *transport, 64 | uint32_t src, 65 | uint32_t dst, 66 | void *data, 67 | uint16_t len 68 | ) 69 | { 70 | struct pru_rpmsg_hdr *msg; 71 | uint32_t msg_len; 72 | int16_t head; 73 | struct pru_virtqueue *virtqueue; 74 | 75 | /* 76 | * The length of our payload is larger than the maximum RPMsg buffer size 77 | * allowed 78 | */ 79 | if (len > (RPMSG_BUF_SIZE - sizeof(struct pru_rpmsg_hdr))) 80 | return PRU_RPMSG_BUF_TOO_SMALL; 81 | 82 | virtqueue = &transport->virtqueue0; 83 | 84 | /* Get an available buffer */ 85 | head = pru_virtqueue_get_avail_buf(virtqueue, (void **)&msg, &msg_len); 86 | 87 | if (head < 0) 88 | return PRU_RPMSG_NO_BUF_AVAILABLE; 89 | 90 | /* Copy local data buffer to the descriptor buffer address */ 91 | memcpy(msg->data, data, len); 92 | msg->len = len; 93 | msg->dst = dst; 94 | msg->src = src; 95 | msg->flags = 0; 96 | msg->reserved = 0; 97 | 98 | /* Add the used buffer */ 99 | if (pru_virtqueue_add_used_buf(virtqueue, head, msg_len) < 0) 100 | return PRU_RPMSG_INVALID_HEAD; 101 | 102 | /* Kick the ARM host */ 103 | pru_virtqueue_kick(virtqueue); 104 | 105 | return PRU_RPMSG_SUCCESS; 106 | } 107 | 108 | int16_t pru_rpmsg_receive( 109 | struct pru_rpmsg_transport *transport, 110 | uint16_t *src, 111 | uint16_t *dst, 112 | void *data, 113 | uint16_t *len 114 | ) 115 | { 116 | int16_t head; 117 | struct pru_rpmsg_hdr *msg; 118 | uint32_t msg_len; 119 | struct pru_virtqueue *virtqueue; 120 | 121 | virtqueue = &transport->virtqueue1; 122 | 123 | /* Get an available buffer */ 124 | head = pru_virtqueue_get_avail_buf(virtqueue, (void **)&msg, &msg_len); 125 | 126 | if (head < 0) 127 | return PRU_RPMSG_NO_BUF_AVAILABLE; 128 | 129 | 130 | /* Copy the message payload to the local data buffer provided */ 131 | memcpy(data, msg->data, msg->len); 132 | *src = msg->src; 133 | *dst = msg->dst; 134 | *len = msg->len; 135 | 136 | /* Add the used buffer */ 137 | if (pru_virtqueue_add_used_buf(virtqueue, head, msg_len) < 0) 138 | return PRU_RPMSG_INVALID_HEAD; 139 | 140 | /* Kick the ARM host */ 141 | pru_virtqueue_kick(virtqueue); 142 | 143 | return PRU_RPMSG_SUCCESS; 144 | } 145 | 146 | int16_t pru_rpmsg_channel( 147 | enum pru_rpmsg_ns_flags flags, 148 | struct pru_rpmsg_transport *transport, 149 | char *name, 150 | char *desc, 151 | int32_t port 152 | ) 153 | { 154 | struct pru_rpmsg_ns_msg ns_msg; 155 | uint8_t i; 156 | 157 | for (i = 0; i < RPMSG_NAME_SIZE; i++) { 158 | ns_msg.name[i] = name[i]; 159 | ns_msg.desc[i] = desc[i]; 160 | } 161 | ns_msg.addr = port; 162 | ns_msg.flags = flags; 163 | 164 | return pru_rpmsg_send(transport, port, 53, &ns_msg, sizeof(ns_msg)); 165 | } 166 | -------------------------------------------------------------------------------- /examples/lib/src/rpmsg_lib/pru_virtqueue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 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 | * File : pru_virtqueue.c 36 | * 37 | * Summary : A virtual queue implementation to simplify vring usage. 38 | * 39 | * Notes : 40 | * - Implementaion of the interface described in "pru_virtqueue.h" 41 | */ 42 | #include 43 | 44 | volatile register uint32_t __R31; 45 | 46 | /* bit 5 is the valid strobe to generate system events with __R31 */ 47 | #define INT_ENABLE (1 << 5) 48 | 49 | /* __R31[3:0] can generate 15-0 which maps to system events 31-16 50 | * e.g. to generate PRU-ICSS System Event 17 (pru_mst_intr[1]) 51 | * __R31 = (INT_ENABLE | (17 - INT_OFFSET)); 52 | */ 53 | #define INT_OFFSET 16 54 | 55 | void pru_virtqueue_init( 56 | struct pru_virtqueue *vq, 57 | struct fw_rsc_vdev_vring *vring, 58 | uint32_t to_arm_event, 59 | uint32_t from_arm_event 60 | ) 61 | { 62 | vq->id = vring->notifyid; 63 | vq->to_arm_event = to_arm_event; 64 | vq->from_arm_event = from_arm_event; 65 | vq->last_avail_idx = 0; 66 | 67 | vring_init(&vq->vring, vring->num, (void*)vring->da, vring->align); 68 | } 69 | 70 | int16_t pru_virtqueue_get_avail_buf( 71 | struct pru_virtqueue *vq, 72 | void **buf, 73 | uint32_t *len 74 | ) 75 | { 76 | int16_t head; 77 | struct vring_desc desc; 78 | struct vring_avail *avail; 79 | 80 | avail = vq->vring.avail; 81 | 82 | /* There's nothing available */ 83 | if (vq->last_avail_idx == avail->idx) 84 | return PRU_VIRTQUEUE_NO_BUF_AVAILABLE; 85 | 86 | /* 87 | * Grab the next descriptor number the ARM host is advertising, and 88 | * increment the last available index we've seen. 89 | */ 90 | head = avail->ring[vq->last_avail_idx++ & (vq->vring.num - 1)]; 91 | 92 | desc = vq->vring.desc[head]; 93 | *buf = (void *)(uint32_t)desc.addr; 94 | *len = desc.len; 95 | 96 | return (head); 97 | } 98 | 99 | int16_t pru_virtqueue_add_used_buf( 100 | struct pru_virtqueue *vq, 101 | int16_t head, 102 | uint32_t len 103 | ) 104 | { 105 | struct vring_used_elem *used_elem; 106 | uint32_t num; 107 | struct vring_used *used; 108 | 109 | num = vq->vring.num; 110 | used = vq->vring.used; 111 | 112 | if (head > num) 113 | return PRU_VIRTQUEUE_INVALID_HEAD; 114 | 115 | /* 116 | * The virtqueue's vring contains a ring of used buffers. Get a pointer to 117 | * the next entry in that used ring. 118 | */ 119 | used_elem = &used->ring[used->idx++ & (num - 1)]; 120 | used_elem->id = head; 121 | used_elem->len = len; 122 | 123 | return PRU_VIRTQUEUE_SUCCESS; 124 | } 125 | 126 | int16_t pru_virtqueue_kick( 127 | struct pru_virtqueue *vq 128 | ) 129 | { 130 | /* If requested, do not kick the ARM host */ 131 | if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) 132 | return PRU_VIRTQUEUE_NO_KICK; 133 | 134 | /* Generate a system event to kick the ARM */ 135 | __R31 = (INT_ENABLE | (vq->to_arm_event - INT_OFFSET)); 136 | 137 | return PRU_VIRTQUEUE_SUCCESS; 138 | } 139 | -------------------------------------------------------------------------------- /firmware/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 | -------------------------------------------------------------------------------- /firmware/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2016 Zubeen Tolani 3 | # Makefile to make PRU_inlineASM_blinky project 4 | # 5 | # The make file is tried to be made as generic as possible 6 | # So that it can be used to compile other programs too 7 | # 8 | # Usage: 9 | # name your main source file as main_pru1.c or main_pru0.c 10 | # add targets to variable TARGETS 11 | # add other files required while linking in variable LINK_PRU1(0)_FW 12 | # add compile targets, as added to LINK_PRU1(0)_FW for other files. 13 | # 14 | 15 | # PRU_CGT environment variable must point to the TI PRU compiler directory. E.g.: 16 | #(Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 17 | #(Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 18 | 19 | ifndef PRU_CGT 20 | define ERROR_BODY 21 | 22 | ************************************************************ 23 | PRU_CGT environment variable is not set. Examples given: 24 | (Linux) export PRU_CGT=/home/jason/ti/ccs_v6_1_0/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 25 | (Windows) set PRU_CGT=C:/TI/ccs_v6_0_1/ccsv6/tools/compiler/ti-cgt-pru_2.1.0 26 | ************************************************************ 27 | 28 | endef 29 | $(error $(ERROR_BODY)) 30 | endif 31 | 32 | 33 | LINKER_COMMAND_FILE=./AM335x_PRU.cmd 34 | LIBS=--library=../examples/lib/rpmsg_lib.lib 35 | INCLUDE=--include_path=../examples/include --include_path=../examples/include/am335x 36 | STACK_SIZE=0x100 37 | HEAP_SIZE=0x100 38 | 39 | 40 | CFLAGS=-v3 -O2 --display_error_number --endian=little --hardware_mac=on --obj_directory=$(GEN_DIR) --pp_directory=$(GEN_DIR) -ppd -ppa 41 | LFLAGS=--reread_libs --warn_sections --stack_size=$(STACK_SIZE) --heap_size=$(HEAP_SIZE) 42 | 43 | 44 | GEN_DIR=gen 45 | 46 | PRU1_FW =$(GEN_DIR)/main_pru1_fw.out 47 | PRU0_FW =$(GEN_DIR)/main_pru0_fw.out 48 | 49 | 50 | # ----------------------------------------------------- 51 | # Variable to edit in the makefile 52 | 53 | # add the required firmwares to TARGETS 54 | # TARGETS =$(PRU1_FW) $(PRU0_FW) 55 | TARGETS =$(PRU1_FW) $(PRU0_FW) 56 | 57 | # add the required files while linkin the FW code 58 | # required linking files for PRU1 59 | # LINK_PRU1_FW = (GEN_DIR)/pru1-inline-asm.object (GEN_DIR)/code2_pru1.object 60 | LINK_PRU1_FW= $(GEN_DIR)/main_pru1_def.object 61 | 62 | # required linking files for PRU1 63 | # LINK_PRU0_FW = (GEN_DIR)/pru0-inline-asm.object (GEN_DIR)/code2_pru1.object 64 | LINK_PRU0_FW= 65 | 66 | #------------------------------------------------------ 67 | 68 | 69 | 70 | .PHONY: all 71 | all: $(TARGETS) 72 | @echo '- Generated firmwares are : $^' 73 | 74 | 75 | $(PRU1_FW): $(GEN_DIR)/main_pru1.object $(LINK_PRU1_FW) 76 | @echo 'LD $^' 77 | @$(PRU_CGT)/bin/lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 78 | 79 | 80 | $(PRU0_FW): $(GEN_DIR)/main_pru0.object $(LINK_PRU0_FW) 81 | @echo 'LD $^' 82 | @$(PRU_CGT)/bin/lnkpru -i$(PRU_CGT)/lib -i$(PRU_CGT)/include $(LFLAGS) -o $@ $^ $(LINKER_COMMAND_FILE) --library=libc.a $(LIBS) $^ 83 | 84 | 85 | $(GEN_DIR)/main_pru0.object: main_pru0.c 86 | @mkdir -p $(GEN_DIR) 87 | @echo 'CC $<' 88 | @$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 89 | 90 | 91 | $(GEN_DIR)/main_pru1.object: main_pru1.c 92 | @mkdir -p $(GEN_DIR) 93 | @echo 'CC $<' 94 | @$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 95 | 96 | 97 | $(GEN_DIR)/main_pru1_def.object: main_pru1_def.asm 98 | @mkdir -p $(GEN_DIR) 99 | @echo 'CC $<' 100 | @$(PRU_CGT)/bin/clpru --include_path=$(PRU_CGT)/include $(INCLUDE) $(CFLAGS) -fe $@ $< 101 | 102 | 103 | 104 | .PHONY: install install-pru1 install-pru0 copy_pru0_fw copy_pru1_fw reboot_pru_1 reboot_pru_0 105 | 106 | install: $(patsubst $(GEN_DIR)/main_pru%_fw.out, install-pru%, $(TARGETS)) 107 | 108 | 109 | install-pru1: $(PRU1_FW) copy_pru1_fw reboot_pru1 110 | install-pru0: $(PRU0_FW) copy_pru0_fw reboot_pru0 111 | 112 | copy_pru1_fw: 113 | @echo '- copying firmware to /lib/firmware/am335x_pru1_fw' 114 | @cp $(PRU1_FW) /lib/firmware/am335x-pru1-fw 115 | 116 | copy_pru0_fw: $(PRU0_FW) 117 | @echo '- copying firmware to /lib/firmware/am335x_pru0_fw' 118 | @cp $(PRU0_FW) /lib/firmware/am335x-pru0-fw 119 | 120 | reboot_pru1: 121 | @echo '- rebooting pru core 1' 122 | $(shell echo "4a338000.pru1" > /sys/bus/platform/drivers/pru-rproc/unbind 2> /dev/null) 123 | $(shell echo "4a338000.pru1" > /sys/bus/platform/drivers/pru-rproc/bind) 124 | @echo "- pru core 1 is now loaded with $(PRU1_FW)" 125 | 126 | reboot_pru0: 127 | @echo '- rebooting pru core 0' 128 | $(shell echo "4a334000.pru0" > /sys/bus/platform/drivers/pru-rproc/unbind 2> /dev/null) 129 | $(shell echo "4a334000.pru0" > /sys/bus/platform/drivers/pru-rproc/bind) 130 | @echo "- pru core 0 is now loaded with $(PRU0_FW)" 131 | 132 | 133 | .PHONY: clean 134 | clean: 135 | @echo 'CLEAN .' 136 | @rm -rf $(GEN_DIR) 137 | -------------------------------------------------------------------------------- /firmware/README.md: -------------------------------------------------------------------------------- 1 | # firmware 2 | PRU firmware source code for BeagleScope project. 3 | The firmware is used to perform high speed input data sampling. 4 | 5 | ### Features - 6 | - RAW_READ mode - To read a single sample. 7 | - BLOCK_READ mode - To sample continuously and send data to the kernel in block of 44 bytes 8 | - Configurable duty cycle 9 | - Configurable sampling frequency 10 | - P8_46 used as the clock pin 11 | 12 | ### Compiling the source 13 | To compile : 14 | 15 | $ make 16 | To compile and install the firmware on the PRUs : 17 | 18 | $ make install 19 | To configure P8_46 as output and mux it to PRU 20 | 21 | $ config-pin P8_46 pruout 22 | 23 | ### Working 24 | 25 | The firmware takes 1 x 12 byte long message from the userspace through '/dev/rpmsg_pru30' char file. This message is actually the configuration data. The message is composed of : 26 | * CYCLE_BTWN_SAMPLE - 4 byte long 27 | * CYCLE_BEFORE_SAMPLE - 2 byte long 28 | * CYCLE_AFTER_SAMPLE - 2 byte long 29 | * MISC_CONFIG_DATA - 4 byte long 30 | 31 | ##### The sampling process goes as ( assume each point to consume only one cycle ): 32 | * Clock pin is pulled high 33 | * Wait for CYCLE_BEFORE_SAMPLE cycles 34 | * Input data is sampled through the GPIs 35 | * Wait for CYCL_AFTER_SAMPLE cycles 36 | * Clock pin is pulled low 37 | * House keeping instruction 1 38 | * House keeping instruction 2 39 | * Interrupt check 40 | * Wait for CYCLE_BTWN_SAMPLE cycles 41 | 42 | The instructions above are executed inside a loop. 43 | 44 | Thus as the above demo of sampling process suggest, the total time period is = CYCLE_BEFORE_SAMPLE + CYCLE_AFTER_SAMPLE + CYCLE_BTWN_SAMPLE + 5 45 | 46 | ##### Important points 47 | * The least value of CYCLE_BEFORE_SAMPLE, CYCLE_AFTER_SAMPLE and CYCLE_BTWN_SAMPLE can be 1 48 | * The value of CYCLE_BEFORE_SAMPLE, CYCLE_AFTER_SAMPLE and CYCLE_BTWN_SAMPLE should always be an odd number. 49 | 50 | ### Testing the firmware 51 | To test the firmware, configuration data needs to be send to the PRUs from kernel space using the character file '/dev/rpmsg_pru30'. 52 | 53 | This can be a bit difficult/confusing because of the way raw data is send thorough character device files. 54 | 55 | * Assume : 56 | * CYCLE_BTWN_SAMPLE = 0x00989681 = 00989681 57 | * CYCLE_BEFORE_SAMPLE = 0xabcd = abcd 58 | * CYCLE_AFTER_SAMPLE = 0x0103 = 0103 59 | 60 | * Then swap their bytes 61 | * CYCLE_BTWN_SAMPLE = 81969800 62 | * CYCLE_AFTER_SAMPLE = cdab 63 | * CYCLE_BEFORE_SAMPLE = 0301 64 | 65 | * Format suitable to be used with echo 66 | * CYCLE_BTWN_SAMPLE = \x81\x96\x98\x00 67 | * CYCLE_AFTER_SAMPLE = \xcd\xab 68 | * CYCLE_BEFORE_SAMPLE = \x03\x01 69 | 70 | * write them to the char device file using the sequence 71 | 72 | CYCLE_BTWN_SAMPLE CYCLE_AFTER_SAMPLE CYCLE_BEFORE_SAMPLE 73 | 74 | ie, for this example it will be : 75 | 76 | \x81\x96\x98\x00\ xcd\xab\ x03\x01 77 | 78 | appending the constant MISC_CONFIG_DATA the message to be send becomes (notice the spaces have been removed) : 79 | 80 | \x81\x96\x98\x00\xcd\xab\x03\x01\x01\x00\x00\x80 81 | 82 | To send it execute following command: 83 | 84 | echo -e '\x81\x96\x98\x00\xcd\xab\x03\x01\x01\x00\x00\x80' > /dev/rpmsg_pru30 && xxd -c 4 /dev/rpmsg_pru30 85 | -------------------------------------------------------------------------------- /firmware/common_pru_defs.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) 2016 Zubeen Tolani 4 | * 5 | * The code is developed as a part of BeagleScope project 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | */ 11 | 12 | #ifndef _COMMON_PRU_DEFS_ 13 | #define _COMMON_PRU_DEFS_ 14 | 15 | /* 16 | * Interrupts ( system events ) that will be used to interrupt the 17 | * two PRUs. 18 | * INT_P0_to_ARM : interrupt from PRU0 to ARM 19 | * INT_ARM_to_P0 : interrupt from ARM to PRU0 20 | * INT_P1_to_P0 : interrupt from PRU1 to PRU0 21 | * INT_P0_to_P1 : interrupt from PRU0 to PRU1 22 | */ 23 | #define INT_P0_to_ARM 16 24 | #define INT_ARM_to_P0 17 25 | #define INT_P1_to_P0 18 26 | #define INT_P0_to_P1 19 27 | 28 | /* 29 | * Register R31 values to generate interrupt 30 | * R31_P1_to_P0 : The value that when written to R31 register will 31 | * generate INT_P1_to_P0 interript 32 | */ 33 | #define R31_P1_to_P0 (1<<5) | (INT_P1_to_P0 - 16) 34 | #define R31_P0_to_P1 (1<<5) | (INT_P0_to_P1 - 16) 35 | 36 | /* Interrupt mappings 37 | * CHNL_PRU0_TO_PRU1 : The INTC channel to which the INT_P0_to_P1 interrupt 38 | * is be mapped. 39 | * HOST_PRU0_TO_PRU1 : The Host to which CHNL_PRU0_TO_PRU1 channel is 40 | * mapped. PRU1 will be checking status of this host to check 41 | * the occurence of INT_P0_to_P1 interrupt. It is recommended 42 | * to map channel N to Host N. 43 | * CHNL_ARM_TO_PRU0 : The INTC channel to which the INT_ARM_to_P0 interrupt 44 | * is be mapped. 45 | * HOST_ARM_TO_PRU0 : The Host to which CHNL_ARM_TO_PRU0 channel is 46 | * mapped. PRU0 will be checking status of this host to check 47 | * the occurence of INT_ARM_to_P0 interrupt. It is recommended 48 | * to map channel N to Host N. 49 | * CHNL_PRU0_TO_ARM : The INTC channel to which the INT_P0_to_ARM interrupt 50 | * is be mapped. 51 | * HOST_PRU0_TO_ARM : The Host to which CHNL_PRU0_TO_ARM channel is 52 | * mapped. This is to generate INT_P0_to_ARM interrupt. The 53 | * host is internally mapped to the ARM INTC, and hence generates 54 | * an ARM interrupt. 55 | */ 56 | #define CHNL_PRU0_TO_PRU1 1 57 | #define HOST_PRU0_TO_PRU1 1 58 | #define CHNL_ARM_TO_PRU0 0 59 | #define HOST_ARM_TO_PRU0 0 60 | #define CHNL_PRU0_TO_ARM 2 61 | #define HOST_PRU0_TO_ARM 2 62 | 63 | /* 64 | * HOST0 and HOST1 check bits 65 | * HOST_PRU0_TO_PRU1_CB : The check bit to check HOST_PRU0_TO_PRU1 interrupt 66 | * Since the value of HOST_PRU0_TO_PRU1 is 1, HOST_PRU0_TO_PRU1_CB 67 | * has the value 31 68 | * HOST_ARM_TO_PRU0_CB : The check bit to check HOST_ARM_TO_PRU0 interrupt 69 | * Since the value of HOST_ARM_TO_PRU0 is 0, HOST_ARM_TO_PRU0_CB 70 | * has the value 30 71 | */ 72 | #define HOST_PRU0_TO_PRU1_CB 31 73 | #define HOST_ARM_TO_PRU0_CB 30 74 | 75 | /* Address of the external peripherals 76 | * SHARED_MEM_ADDR : Absolute local address of the 12 KB shared RAM that will be 77 | * used to communicate sampling configuration data between the two 78 | * PRUs 79 | */ 80 | #define SHARED_MEM_ADDR 0x00010000 81 | 82 | /* 83 | * Scratch Pad Bank IDs 84 | * The scratch pad inside the PRU-ICSS has 3 banks. Each bank has different 85 | * ID numbers. 86 | * SP_BANK_0 : ID number for scratch pad bank 0 87 | * SP_BANK_1 : ID number for scratch pad bank 1 88 | * SP_BANK_2 : ID number for scratch pad bank 2 89 | */ 90 | #define SP_BANK_0 10 91 | #define SP_BANK_1 11 92 | #define SP_BANK_2 12 93 | 94 | /* 95 | * PRU1 to PRU0 data 96 | * The constants are related to the sampled data that is sent by PRU1 to 97 | * PRU0 98 | * DATA_START_REGISTER : The register from where the sampled data starts to 99 | * be stored on PRU1. 100 | * 101 | * DATA_START_REGISTER_NUMBER : The register number of DATA_START_REGISTER. 102 | * 103 | * DATA_SIZE : The size of Data that PRU1 will transfer into the banks for 104 | * each interrupt to PRU0. 105 | * 106 | * FAKE_DATA : Any random data that will be used as fake input data to PRU1 107 | * for testing purposes. 108 | */ 109 | #define DATA_START_REGISTER R6 110 | #define DATA_START_REGISTER_NUMBER 6 111 | #define DATA_SIZE 44 112 | #define FAKE_DATA 0x38 113 | 114 | /* 115 | * Sample data read mode 116 | * The constants are used for different sampling data modes. 117 | * 118 | * RAW_READ : In this mode, PRU1 reads a single instantaneous sample and sends 119 | * the sample value to the PRU0, which is further sent to the kernel 120 | * 121 | * BLOCK_READ : This mode of reading the samples is a continuous mode and PRU1 122 | * keeps on sampling the data until the SAMPLING_START_BIT is cleared. 123 | * The samples are read and sent to PRU0 in blocks of 44 bytes, which are 124 | * further sent to the kernel 125 | */ 126 | #define RAW_READ 0 127 | #define BLOCK_READ 1 128 | 129 | 130 | #endif /* _COMMON_PRU_DEFS_ */ 131 | -------------------------------------------------------------------------------- /firmware/resource_table_pru1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Source Modified by Zubeen Tolani < ZeekHuge - zeekhuge@gmail.com > 3 | * Based on the examples distributed by TI 4 | * 5 | * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 6 | * 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the 18 | * distribution. 19 | * 20 | * * Neither the name of Texas Instruments Incorporated nor the names of 21 | * its contributors may be used to endorse or promote products derived 22 | * from this software without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 28 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | /* 38 | * ======== resource_table_empty.h ======== 39 | * 40 | * Define the resource table entries for all PRU cores. This will be 41 | * incorporated into corresponding base images, and used by the remoteproc 42 | * on the host-side to allocated/reserve resources. Note the remoteproc 43 | * driver requires that all PRU firmware be built with a resource table. 44 | * 45 | * This file contains an empty resource table. It can be used either as: 46 | * 47 | * 1) A template, or 48 | * 2) As-is if a PRU application does not need to configure PRU_INTC 49 | * or interact with the rpmsg driver 50 | * 51 | */ 52 | 53 | #ifndef _RSC_TABLE_PRU_H_ 54 | #define _RSC_TABLE_PRU_H_ 55 | 56 | #include 57 | #include 58 | #include "common_pru_defs.h" 59 | 60 | 61 | 62 | struct my_resource_table { 63 | struct resource_table base; 64 | 65 | uint32_t offset[1]; /* Should match 'num' in actual definition */ 66 | }; 67 | 68 | #pragma DATA_SECTION(pru_remoteproc_ResourceTable, ".resource_table") 69 | #pragma RETAIN(pru_remoteproc_ResourceTable) 70 | struct my_resource_table pru_remoteproc_ResourceTable = { 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 | 0,/* offsets to entries */ 75 | }; 76 | 77 | #endif /* _RSC_TABLE_PRU_H_ */ 78 | 79 | -------------------------------------------------------------------------------- /firmware/test.patch: -------------------------------------------------------------------------------- 1 | diff --git a/firmware/main_pru1_def.asm b/firmware/main_pru1_def.asm 2 | index 13e66dd..4d20149 100644 3 | --- a/firmware/main_pru1_def.asm 4 | +++ b/firmware/main_pru1_def.asm 5 | @@ -221,9 +221,9 @@ CLK_TOGGLE .macro 6 | 7 | TAKE_SAMPLE_8 .macro RX 8 | CLK_TOGGLE 9 | - MOV RX, R31 10 | - ;LDI RX, FAKE_DATA 11 | - CLK_TOGGLE 12 | + ;MOV RX, R31 13 | + LDI RX, FAKE_DATA 14 | + ;CLK_TOGGLE 15 | .endm 16 | 17 | ;******************************************************************** 18 | -------------------------------------------------------------------------------- /quickstart.md: -------------------------------------------------------------------------------- 1 | ### PRU Setup 2 | To start contributing to the project, one should start with building up the [blinky example](https://github.com/ZeekHuge/BeagleScope/tree/port_to_4.4.12-ti-r31%2B/examples/firmware_exmples/pru_blinky). 3 | 4 | [This post](https://www.zeekhuge.me/post/ptp_blinky/) might prove to be helpful in the process. Getting the blinky example working will assure that you have a working setup to compile PRU firmware. 5 | 6 | Once the blinky example works, the firmware side can be. 7 | 8 | ### Compile the Source 9 | - To compile source look into the [build section](https://github.com/ZeekHuge/BeagleScope#build-the-source) of the readme. 10 | 11 | ### Understand working 12 | To understand the working, you can 13 | 14 | - Look into the [project wiki](https://github.com/ZeekHuge/BeagleScope/wiki). 15 | - Look into the [weekly project reports](https://groups.google.com/forum/#!topic/beagleboard-gsoc/aSFxmYjrWuA) to understand how all this came along. 16 | - Read the commit messages that have been edited while developing the code, they can really be helpful. 17 | 18 | ### Contact 19 | - You can mail me for any queries/ doubts. 20 | - You can communicate me on the freenode IRC channel `#beagle`. 21 | 22 | --- 23 | 24 | **Contributions will be accepted in form of pull-requests as well as patches.** 25 | --------------------------------------------------------------------------------