Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
Commit c3de7ef6 authored by Jason Kridner's avatar Jason Kridner
Browse files

books/pru-cookbook: fix references to code

parent c4a51c22
Branches
No related merge requests found
......@@ -113,14 +113,14 @@ via the PRU that can be used out of the box.
Just run:
.. code-block:: bash
.. code-block:: shell-session
bone$ sudo rc_test_servos -f 10 -p 1.5
The ``-f 10`` says to use a frequency of 10 Hz and the ``-p 1.5`` says to set the position to ``1.5``. The range of positions is
``-1.5`` to ``1.5``. Run ``rc_test_servos -h`` to see all the options.
.. code-block:: bash
.. code-block:: shell-session
bone$ rc_test_servos -h
......@@ -229,9 +229,9 @@ Solution
The forth encoder can be implemented on the PRU. If you run ``rc_test_encoders_eqep``
on the Blue, you will see the output of encoders E1-E3 which are connected to the eEQP hardware.
.. code-block:: bash
.. code-block:: shell-session
bone$ *rc_test_encoders_eqep*
bone$ rc_test_encoders_eqep
Raw encoder positions
E1 | E2 | E3 |
......@@ -288,13 +288,13 @@ Solution
The forth encoder is implemented on the PRU and accessed with `sudo rc_test_encoders_pru`
.. note::
This command needs root permission, so the `sudo` is needed.
This command needs root permission, so the `sudo` is needed. The default password is `temppwd`.
Here's what you will see
.. code-block:: bash
.. code-block:: shell-session
bone$ *sudo rc_test_encoders_pru*
bone$ sudo rc_test_encoders_pru
[sudo] password for debian:
Raw encoder position
......@@ -343,17 +343,17 @@ If you want to be running a newer image, there are instructions on the site for
.. _case_installing_beaglelogic:
.. code-block:: bash
.. code-block:: shell-session
:caption: Installing BeagleLogic
bone$ *git clone https://github.com/abhishek-kakkar/BeagleLogic*
bone$ *cd BeagleLogic/kernel*
bone$ *mv beaglelogic-00A0.dts beaglelogic-00A0.dts.orig*
bone$ *wget https://gist.githubusercontent.com/abhishek-kakkar/0761ef7b10822cff4b3efd194837f49c/raw/eb2cf6cfb59ff5ccb1710dcd7d4a40cc01cfc050/beaglelogic-00A0.dts*
bone$ *make overlay*
bone$ *sudo cp beaglelogic-00A0.dtbo /lib/firmware/*
bone$ *sudo update-initramfs -u -k \`uname -r`*
bone$ *sudo reboot*
bone$ git clone https://github.com/abhishek-kakkar/BeagleLogic
bone$ cd BeagleLogic/kernel
bone$ mv beaglelogic-00A0.dts beaglelogic-00A0.dts.orig
bone$ wget https://gist.githubusercontent.com/abhishek-kakkar/0761ef7b10822cff4b3efd194837f49c/raw/eb2cf6cfb59ff5ccb1710dcd7d4a40cc01cfc050/beaglelogic-00A0.dts
bone$ make overlay
bone$ sudo cp beaglelogic-00A0.dtbo /lib/firmware/
bone$ sudo update-initramfs -u -k \`uname -r`
bone$ sudo reboot
Once the Bone has rebooted, browse to 192.168.7.2:4000 where you'll see
:ref:`case_beaglelogic_capture`. Here you can easily select the sample
......@@ -386,17 +386,17 @@ logic analyzer on the Bone with no additional hardware needed.
The kernel interface makes it easy to control the PRUs through the
command line. For example
.. code-block:: bash
.. code-block:: shell-session
bone$ *dd if=/dev/beaglelogic of=mydump bs=1M count=1*
bone$ dd if=/dev/beaglelogic of=mydump bs=1M count=1
will capture a binary dump from the PRUs. The sample rate and number of
bits per sample can be controlled through ``/sys/``.
.. code-block:: bash
.. code-block:: shell-session
bone$ *cd /sys/devices/virtual/misc/beaglelogic*
bone$ *ls*
bone$ cd /sys/devices/virtual/misc/beaglelogic
bone$ ls
buffers filltestpattern power state uevent
bufunitsize lasterror samplerate subsystem
dev memalloc sampleunit triggerflags
......@@ -407,9 +407,9 @@ bits per sample can be controlled through ``/sys/``.
You can set the sample rate by simply writing to ``samplerate``.
.. code-block:: bash
.. code-block:: shell-session
bone$ *echo 100000000 > samplerate*
bone$ echo 100000000 > samplerate
`sysfs attributes Reference <https://beaglelogic.readthedocs.io/en/latest/sysfs_attributes.html>`_
has more details on configuring via sysfs.
......@@ -417,9 +417,9 @@ has more details on configuring via sysfs.
If you run ``dmesg -Hw`` in another window you can see when a capture
is started and stopped.
.. code-block:: bash
.. code-block:: shell-session
bone$ *dmesg -Hw*
bone$ dmesg -Hw
[Jul25 08:46] misc beaglelogic: capture started with sample rate=100000000 Hz, sampleunit=1, triggerflags=0
[ +0.086261] misc beaglelogic: capture session ended
......@@ -583,11 +583,11 @@ explaining how the PRUs get this type of performance.
.. _case_e1.31_example:
.. literalinclude:: code/e1.31-test.py
.. literalinclude:: ../code/01start/e1.31-test.py
:caption: e1.31-test.py -Example of generating packets to control the NeoPixels
:linenos:
:download:`e1.31-test.py <code/e1.31-test.py>`
:download:`e1.31-test.py <../code/01start/e1.31-test.py>`
.. TODO document the code
......@@ -748,10 +748,10 @@ following instructions at https://xlights.org/releases/.
Run xLights and you'll see :ref:`case_xlights_setup`.
.. code-block:: bash
.. code-block:: shell-session
host$ *chmod +x xLights-2021.18-x86_64.AppImage*
host$ *./xLights-2021.18-x86_64.AppImage*
host$ chmod +x xLights-2021.18-x86_64.AppImage
host$ ./xLights-2021.18-x86_64.AppImage
.. TODO update the figures.
......@@ -985,7 +985,7 @@ You can `build simpPRU <https://simppru.readthedocs.io/en/latest/install/build/>
source, more easily just `install it <https://simppru.readthedocs.io/en/latest/install/install/>`_.
On the Beagle run:
.. code-block:: bash
.. code-block:: shell-session
bone$ wget https://github.com/VedantParanjape/simpPRU/releases/download/1.4/simppru-1.4-armhf.deb
bone$ sudo dpkg -i simppru-1.4-armhf.deb
......@@ -996,15 +996,15 @@ Now, suppose you wanted to run the
`LED blink <https://simppru.readthedocs.io/en/latest/examples/led_blink/>`_
example which is reproduced here.
.. literalinclude:: code/blink.sim
.. literalinclude:: ../code/01start/blink.sim
:caption: LED Blink (blink.sim)
:linenos:
:download:`blink.sim <code/blink.sim>`
:download:`blink.sim <../code/01start/blink.sim>`
Just run simppru
.. code-block:: bash
.. code-block:: shell-session
bone$ simppru blink.sim --load
Detected TI AM335x PocketBeagle
......@@ -1019,7 +1019,7 @@ Detected TI AM335x PocketBeagle
The +--load+ flag caused the compiled code to be copied to +/lib/firmware+.
To start just do:
.. code-block:: bash
.. code-block:: shell-session
bone$ cd /dev/remoteproc/pruss-core0/
bone$ ls
......
......@@ -9,8 +9,9 @@ latest software image on your beagle, how to run the Cloud9 IDE and how to
blink an LED.
If you already have your Beagle and know your way around it, you can find the
code (and the whole book) on the PRU Cookbook github site:
https://github.com/MarkAYoder/PRUCookbook.
code at https://git.beagleboard.org/beagleboard/pru-cookbook-code and book
contents at https://git.beagleboard.org/docs/docs.beagleboard.io under the
books/pru-cookbook directory.
Selecting a Beagle
********************
......@@ -256,12 +257,12 @@ as shown in :ref:`start_c9_show_home`.
If you want to edit files beyond your home directory you can link to the root file system by:
.. code-block:: bash
.. code-block:: shell-session
bone$ *cd*
bone$ *ln -s / root*
bone$ *cd root*
bone$ *ls*
bone$ cd
bone$ ln -s / root
bone$ cd root
bone$ ls
bbb-uEnv.txt boot etc ID.txt lost+found mnt opt root sbin sys usr
bin dev home lib media nfs-uEnv.txt proc run srv tmp var
......@@ -322,11 +323,11 @@ is some code that blinks the ``USR3`` LED ten times using the PRU.
.. _start_hello:
.. literalinclude:: code/hello.pru0.c
.. literalinclude:: ../code/02start/hello.pru0.c
:caption: hello.pru0.c
:linenos:
:download:`hello.pru0.c <code/hello.pru0.c>`
:download:`hello.pru0.c <../code/02start/hello.pru0.c>`
Later chapters will go into details of how this code works, but if you want
to run it right now do the following.
......
......@@ -32,15 +32,15 @@ Solution
It's all on a GitHub repository.
.. code-block:: bash
.. code-block:: shell-session
bone$ git clone https://github.com/MarkAYoder/PRUCookbook.git
bone$ git clone https://git.beagleboard.org/beagleboard/pru-cookbook-code
.. note::
#TODO#: The version of code used needs to be noted in the documentation.
.. note::
#TODO#: There needs to be a code-only repo that is validated against the documentation
code to be identical for specific version. The version needs to be noted in the
documentation.
#TODO#: Why is this documented in multiple places?
.. _compiling_with_clpru_and_lnkpru:
......@@ -58,7 +58,7 @@ Solution
The PRU compiler and linker are already installed on many images.
They are called ``clpru`` and ``lnkpru``. Do the following to see if ``clpru`` is installed.
.. code-block:: bash
.. code-block:: shell-session
bone$ which clpru
/usr/bin/clpru
......@@ -69,7 +69,7 @@ They are called ``clpru`` and ``lnkpru``. Do the following to see if ``clpru``
https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#TI_PRU_Code_Generation_Tools
to install it.
.. code-block:: bash
.. code-block:: shell-session
bone$ sudo apt update
bone$ sudo apt install ti-pru-cgt-installer
......@@ -85,7 +85,7 @@ In fact there are PRU versions of many of the standard code generation tools.
code tools
~~~~~~~~~~~
.. code-block:: bash
.. code-block:: shell-session
bone$ ls /usr/bin/*pru
/usr/bin/abspru /usr/bin/clistpru /usr/bin/hexpru /usr/bin/ofdpru
......@@ -109,13 +109,13 @@ Solution
Edit ``/boot/uEnv.txt`` and enble pru_rproc by doing the following.
.. code-block:: bash
.. code-block:: shell-session
bone$ *sudo vi /boot/uEnv.txt*
bone$ sudo vi /boot/uEnv.txt
Around line 40 you will see:
.. code-block:: bash
.. code-block:: shell-session
###pru_rproc (4.19.x-ti kernel)
uboot_overlay_pru=AM335X-PRU-RPROC-4-19-TI-00A0.dtbo
......@@ -123,7 +123,7 @@ Around line 40 you will see:
Uncomment the ``uboot_overlay`` line as shown and then reboot.
``/dev/remoteproc`` should now be there.
.. code-block:: bash
.. code-block:: shell-session
bone$ sudo reboot
bone$ ls -ls /dev/remoteproc/
......@@ -144,15 +144,15 @@ Solution
Change to the directory of the code you want to run.
.. code-block:: bash
.. code-block:: shell-session
bone$ cd PRUCookbook/docs/06io/code
bone$ cd pru-cookbook-code/06io
bone$ ls
gpio.pru0.c Makefile setup.sh
Source the setup file.
.. code-block:: bash
.. code-block:: shell-session
bone$ source setup.sh
TARGET=gpio.pru0
......@@ -163,7 +163,7 @@ Source the setup file.
Now you are ready to compile and run. This is automated for you in the Makefile
.. code-block:: bash
.. code-block:: shell-session
bone$ make
/var/lib/cloud9/common/Makefile:28: MODEL=TI_AM335x_BeagleBone_Black,TARGET=gpio.pru0,COMMON=/var/lib/cloud9/common
......@@ -197,7 +197,7 @@ The file extension ``.pru0`` specifies the number of the PRU you are using
You can override the ``TARGET`` on the command line.
.. code-block:: bash
.. code-block:: shell-session
bone$ cp gpio.pru0.c gpio.pru1.c
bone$ export TARGET=gpio.pru1
......@@ -206,7 +206,7 @@ Notice the ``TARGET`` doesn't have the ``.c`` on the end.
You can also specify them when running ``make``.
.. code-block:: bash
.. code-block:: shell-session
bone$ cp gpio.pru0.c gpio.pru1.c
bone$ make TARGET=gpio.pru1
......@@ -215,11 +215,11 @@ The setup file also contains instructions to figure out which Beagle you are run
and then configure the pins accordingly.
.. literalinclude:: code/gpio_setup.sh
.. literalinclude:: ../code/06io/gpio_setup.sh
:caption: gpio_setup.sh
:linenos:
:download:`gpio_setup.sh <code/gpio_setup.sh>`
:download:`gpio_setup.sh <../code/06io/gpio_setup.sh>`
.. table::
......@@ -257,7 +257,7 @@ Solution
It's easy, if you already have ``TARGET`` set up:
.. code-block:: bash
.. code-block:: shell-session
bone$ make stop
- Stopping PRU 0
......@@ -272,7 +272,7 @@ is stopped.
This assumes ``TARGET`` is set to the PRU you are using.
If you want to control the other PRU use:
.. code-block:: bash
.. code-block:: shell-session
bone$ cp gpio.pru0.c gpio.pru1.c
bone$ make TARGET=gpio.pru1
......@@ -304,11 +304,11 @@ It's assumed you already know how Makefiles work. If not, there are
many resources online that can bring you up to speed.
Here is the local ``Makefile`` used throughout this book.
.. literalinclude:: code/Makefile
.. literalinclude:: ../code/06io/Makefile
:caption: Local Makefile
:linenos:
:download:`Makefile <code/Makefile>`
:download:`Makefile <../code/06io/Makefile>`
Each of the local Makefiles refer to the same standard Makefile. The details
of how the Makefile works is beyond the scope of this cookbook.
......@@ -335,11 +335,11 @@ The ``am57xx_pru.cmd`` does the same for the AI.
Both files can be found in ``/var/lib/cloud9/common``.
.. literalinclude:: code/am335x_pru.cmd
.. literalinclude:: ../code/06io/am335x_pru.cmd
:caption: am335x_pru.cmd
:linenos:
:download:`am335x_pru.cmd <code/am335x_pru.cmd>`
:download:`am335x_pru.cmd <../code/06io/am335x_pru.cmd>`
.. TODO does this need updating?
......@@ -412,7 +412,7 @@ The PRUs appear in the Linux file space at ``/dev/remoteproc/``.
Finding the PRUs
~~~~~~~~~~~~~~~~~~~
.. code-block:: bash
.. code-block:: shell-session
bone$ cd /dev/remoteproc/
bone$ ls
......@@ -420,7 +420,7 @@ Finding the PRUs
Or if you are on the AI:
.. code-block:: bash
.. code-block:: shell-session
bone$ cd /dev/remoteproc/
bone$ ls
......@@ -430,7 +430,7 @@ You see there that the AI has two pairs of PRUs, plus a couple of DSPs and other
Here we see PRU 0 and PRU 1 in the path. Let's follow PRU 0.
.. code-block:: bash
.. code-block:: shell-session
bone$ cd pruss-core0
bone$ ls
......@@ -439,7 +439,7 @@ Here we see PRU 0 and PRU 1 in the path. Let's follow PRU 0.
Here we see the files that control PRU 0. ``firmware`` tells where in ``/lib/firmware``
to look for the code to run on the PRU.
.. code-block:: bash
.. code-block:: shell-session
bone$ cat firmware
am335x-pru0-fw
......@@ -464,11 +464,11 @@ everything is already configured for you.
If you are on the Black or Pocket you'll need to run the following script.
.. literalinclude:: code/servos_setup.sh
.. literalinclude:: ../code/06io/servos_setup.sh
:caption: servos_setup.sh
:linenos:
:download:`servos_setup.sh <code/servos_setup.sh>`
:download:`servos_setup.sh <../code/06io/servos_setup.sh>`
Discussion
-----------
......@@ -494,11 +494,11 @@ It depends on which Beagle you are running on. If you are on the AI or Blue,
everything is already configured for you.
If you are on the Black or Pocket you'll need to run the following script.
.. literalinclude:: code/encoder_setup.sh
.. literalinclude:: ../code/06io/encoder_setup.sh
:caption: encoder_setup.sh
:linenos:
:download:`encoder_setup.sh <code/encoder_setup.sh>`
:download:`encoder_setup.sh <../code/06io/encoder_setup.sh>`
Discussion
-----------
......
......@@ -43,37 +43,37 @@ constant. Our new ``delay_cycles`` can take a runtime delay value.
.. _more_delay-test:
.. literalinclude:: code/delay-test.pru0.c
.. literalinclude:: ../code/07more/delay-test.pru0.c
:caption: delay-test.pru0.c
:linenos:
:download:`delay-test.pru0.c <code/delay-test.pru0.c>`
:download:`delay-test.pru0.c <../code/07more/delay-test.pru0.c>`
:ref:`more_delay` is the assembly code.
.. _more_delay:
.. literalinclude:: code/delay.pru0.asm
.. literalinclude:: ../code/07more/delay.pru0.asm
:caption: delay.pru0.asm
:linenos:
:download:`delay.pru0.asm <code/delay.pru0.asm>`
:download:`delay.pru0.asm <../code/07more/delay.pru0.asm>`
The ``Makefile`` has one addition that needs to be made to compile both :ref:`more_delay-test`
and :ref:`more_delay`. If you look in the local ``Makefile`` you'll see:
.. _more_makefile:
.. literalinclude:: code/Makefile
.. literalinclude:: ../code/07more/Makefile
:caption: Makefile
:linenos:
:download:`Makefile <code/Makefile>`
:download:`Makefile <../code/07more/Makefile>`
This Makefle includes a common Makfile at ``/var/lib/cloud9/common/Makefile``, this the Makefile
you need to edit. Edit ``/var/lib/cloud9/common/Makefile`` and go to line 195.
.. code-block:: bash
.. code-block:: shell-session
$(GEN_DIR)/%.out: $(GEN_DIR)/%.o *$(GEN_DIR)/$(TARGETasm).o*
@mkdir -p $(GEN_DIR)
......@@ -87,10 +87,10 @@ this addition once you are done with this example since it will break the other
The following will compile and run everything.
.. code-block:: bash
.. code-block:: shell-session
bone$ *config-pin P9_31 pruout*
bone$ *make TARGET=delay-test.pru0 TARGETasm=delay.pru0*
bone$ config-pin P9_31 pruout
bone$ make TARGET=delay-test.pru0 TARGETasm=delay.pru0
/var/lib/cloud9/common/Makefile:29: MODEL=TI_AM335x_BeagleBone_Black,TARGET=delay-test.pru0
- Stopping PRU 0
- copying firmware file /tmp/cloud9-examples/delay-test.pru0.out to /lib/firmware/am335x-pru0-fw
......@@ -166,21 +166,21 @@ Solution
.. _more_test2:
.. literalinclude:: code/delay-test2.pru0.c
.. literalinclude:: ../code/07more/delay-test2.pru0.c
:caption: delay-test2.pru0.c
:linenos:
:download:`delay-test2.pru0.c <code/delay-test2.pru0.c>`
:download:`delay-test2.pru0.c <../code/07more/delay-test2.pru0.c>`
:ref:`more_delay2` is the assembly code.
.. _more_delay2:
.. literalinclude:: code/delay2.pru0.asm
.. literalinclude:: ../code/07more/delay2.pru0.asm
:caption: delay2.pru0.asm
:linenos:
:download:`delay2.pru0.asm <code/delay2.pru0.asm>`
:download:`delay2.pru0.asm <../code/07more/delay2.pru0.asm>`
An additional feature is shown in line 4 of :ref:`more_delay2`. The
``.cdecls "delay-test2.pru0.c"`` says to include any defines from ``delay-test2.pru0.c``
......@@ -206,11 +206,11 @@ many times the PRU stalled fetching an instruction.
.. _more_cycle:
.. literalinclude:: code/cycle.pru0.c
.. literalinclude:: ../code/07more/cycle.pru0.c
:caption: cycle.pru0.c - Code to count cycles.
:linenos:
:download:`cycle.pru0.c <code/cycle.pru0.c>`
:download:`cycle.pru0.c <../code/07more/cycle.pru0.c>`
Discission
------------
......@@ -244,26 +244,26 @@ You can see where ``cycle`` and ``stall`` are stored by looking into :ref:`more_
.. _more_cycle_list0:
.. literalinclude:: code/cycle.pru0.lst
.. literalinclude:: ../code/07more/cycle.pru0.lst
:caption: /tmp/cloud9-examples/cycle.pru0.lst Lines 113..119
:lines: 113-119
:lineno-start: 113
:linenos:
:download:`cycle.pru0.lst <code/cycle.pru0.lst>`
:download:`cycle.pru0.lst <../code/07more/cycle.pru0.lst>`
Here the ``LDI32`` instruction loads the address ``0x22000`` into ``r0``. This is the offset to
the ``CTRL`` registers. Later in the file we see :ref:`more_cycle_list1`.
.. _more_cycle_list1:
.. literalinclude:: code/cycle.pru0.lst
.. literalinclude:: ../code/07more/cycle.pru0.lst
:caption: /tmp/cloud9-examples/cycle.pru0.lst Lines 146..152
:lines: 146-152
:lineno-start: 146
:linenos:
:download:`cycle.pru0.lst <code/cycle.pru0.lst>`
:download:`cycle.pru0.lst <../code/07more/cycle.pru0.lst>`
The first ``LBBO`` takes the contents of ``r0`` and adds the offset 12 to it and copies 4 bytes
......@@ -274,10 +274,10 @@ thus ``STALL`` is now in ``r0``.
Now fire up **prudebug** and look at those registers.
.. code-block:: bash
.. code-block:: shell-session
bone$ *sudo prudebug*
PRU0> *r*
bone$ sudo prudebug
PRU0> r
r
r
Register info for PRU0
......@@ -319,28 +319,28 @@ The ``pass:[__]xout()`` and ``pass:[__]xin()`` intrinsics are able to transfer u
.. _more_xout:
.. literalinclude:: code/xout.pru0.c
.. literalinclude:: ../code/07more/xout.pru0.c
:caption: xout.pru0.c
:linenos:
:download:`xout.pru0.c <code/xout.pru0.c>`
:download:`xout.pru0.c <../code/07more/xout.pru0.c>`
PRU 1 waits at line 41 until PRU 0 signals it. :ref:`more_xin` sends an
interrupt to PRU 0 and waits for it to send the data.
.. _more_xin:
.. literalinclude:: code/xin.pru1.c
.. literalinclude:: ../code/07more/xin.pru1.c
:caption: xin.pru1.c
:linenos:
:download:`xin.pru1.c <code/xin.pru1.c>`
:download:`xin.pru1.c <../code/07more/xin.pru1.c>`
Use ``prudebug`` to see registers R5-R10 are transferred from PRU 0 to PRU 1.
.. code-block:: bash
.. code-block:: shell-session
PRU0> *r*
PRU0> r
Register info for PRU0
Control register: 0x00000001
Reset PC:0x0000 STOPPED, FREE_RUN, COUNTER_DISABLED, NOT_SLEEPING, PROC_DISABLED
......@@ -441,8 +441,8 @@ If you really need speed, considering using ``pass:[__]xout()`` and ``pass:[__]x
Copyright
==========
.. literalinclude:: code/copyright.c
.. literalinclude:: ../code/07more/copyright.c
:caption: copyright.c
:linenos:
:download:`copyright.c <code/copyright.c>`
:download:`copyright.c <../code/07more/copyright.c>`
......@@ -155,7 +155,7 @@ Solution
The ``show-pins.pl`` command does what you want, but you have to set it up first.
.. code-block:: bash
.. code-block:: shell-session
bone$ cd ~/bin
bone$ ln -s /opt/scripts/device/bone/show-pins.pl .
......@@ -164,7 +164,7 @@ This creates a symbolic link to the ``show-pins.pl`` command that is rather hidd
away. The link is put in the ``bin`` directory which is in the default command
``$PATH``. Now you can run ``show-pins.pl`` from anywhere.
.. code-block:: bash
.. code-block:: shell-session
bone$ *show-pins.pl*
P9.19a 16 R6 7 fast rx up i2c4_scl
......@@ -180,7 +180,7 @@ which direction they are set by using ``gpioinfo`` and the chip number.
Unfortunately you subtract one from the port number to get the chip number.
So ``P8.35b`` is on chip number 2.
.. code-block:: bash
.. code-block:: shell-session
bone$ *gpioinfo 2*
line 0: unnamed unused *input* active-high
......@@ -194,7 +194,7 @@ Here we see both (lines 0 and 1) are set to input.
Adding ``-v`` gives more details.
.. code-block:: bash
.. code-block:: shell-session
bone$ *show-pins.pl -v*
...
......@@ -210,7 +210,7 @@ Adding ``-v`` gives more details.
The best way to use ``show-pins.pl`` is with ``grep``. To see all the pru pins try:
.. code-block:: bash
.. code-block:: shell-session
bone$ *show-pins.pl | grep -i pru | sort*
P8.13 100 D3 c fast rx pr1_pru1_gpi7
......@@ -236,7 +236,7 @@ Problem
I want to configure another pin for the PRU, but I get an error.
.. code-block:: bash
.. code-block:: shell-session
bone$ *config-pin P9_31 pruout*
ERROR: open() for /sys/devices/platform/ocp/ocp:P9_31_pinmux/state failed, No such file or directory
......@@ -271,14 +271,14 @@ We see that when ``P9_31a`` is set to ``MODE13`` it will be a PRU **out** pin.
Next, find which kernel you are running.
.. code-block:: bash
.. code-block:: shell-session
bone$ uname -a
Linux ai 4.14.108-ti-r131 #1buster SMP PREEMPT Tue Mar 24 19:18:36 UTC 2020 armv7l GNU/Linux
I'm running the 4.14 version. Now look in ``/opt/source`` for your kernel.
.. code-block:: bash
.. code-block:: shell-session
bone$ cd /opt/source/
bone$ ls
......@@ -290,7 +290,7 @@ I'm running the 4.14 version. Now look in ``/opt/source`` for your kernel.
``am5729-beagleboneai.dts`` is the file we need to edit. Search for ``P9_31``. You'l see:
.. code-block:: bash
.. code-block:: shell-session
:linenos:
DRA7XX_CORE_IOPAD(0x36DC, MUX_MODE14) // B13: P9.30: mcasp1_axr10.off //
......@@ -301,7 +301,7 @@ Change the ``MUX_MODE14`` to ``MUX_MODE13`` for output, or ``MUX_MODE12`` for in
Compile and install. The first time will take a while since it recompiles all the dts files.
.. code-block:: bash
.. code-block:: shell-session
:linenos:
bone$ make
......@@ -358,11 +358,11 @@ the adapted code.
.. _ai_pwm1:
.. literalinclude:: code/pwm1.pru2_1.c
.. literalinclude:: ../code/08ai/pwm1.pru2_1.c
:caption: pwm1.pru2_1.c
:linenos:
:download:`pwm1.pru2_1.c <code/pwm1.pru2_1.c>`
:download:`pwm1.pru2_1.c <../code/08ai/pwm1.pru2_1.c>`
One line 6 ``P9_31`` is defined as ``(0x1:ref:`10)``, which means shift ``1`` over by 10 bits.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment