pru support for 4.4.84-ti-r120

I want to use the HDMI outputs to drive external circuit. Required toggle rate is between 1MHz and 10MHz.
Have BB black.

uname -a Linux beaglebone 4.4.84-ti-r120 #1 SMP Sun Aug 27 03:11:07 UTC 2017 armv7l GNU/Linux cat /etc/debian_version 9.1
So I have to use the PRU unit.
I was searching example to have a starting point.
But it sucks already with the first step.

ll /sys/devices/bone_capemgr* ls: cannot access '/sys/devices/bone_capemgr*': No such file or directory

I load the image from here: http://debian.beagleboard.org/images/bone-debian-9.1-iot-armhf-2017-08-31-4gb.img.xz

What is my mistake?
Device tree compiler is up to date

device-tree-compiler is already the newest version (1.4.4-0rcnee3~stretch+20170719). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Found a lot of hints to use the 3.8 kernel. Think that one is already some years old, can’t be true.

Question: How to create the required device tree overlay, because /sys/devices/bone_capemgr* is not existing?

Thanks for help

That was the 3.8.13 location, this changed in 4.1.x+

For that newer image it's using u-boot overlays:

http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays

to disable hdmi follow:

http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Disable_on-board_devices

and

http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_PRU_Options

if you have any problem run:

sudo /opt/scripts/tools/version.sh

and we can debug what wrong..

Regards,

Hi Robert,
thanks for information. Beaglebone has 2 golden eggs, the PRU units. That’s unique.
It’s confusing to get access to that. It’s easy to create the program for arm and pru,
but the device tree setup isn’t that easy. Will start from scratch and follow your
recommendation.
Thank you very much
Kasimir

I have to decide to use what?

U-Boot PRU Options

With v4.4.x-ti PRU via remoteproc can be enabled by:

uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo

With mainline (boneX) PRU via uio (doesn’t work with v4.9.x-ti yet)

uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo

Think that's the key point, there are many possibilities, but only one specific
combination works. To find out which one it is .... makes not so much fun.

Is somewhere an updated roadmap available, e.g.
1.) image to load
2.) if required, packages to load on top of that
3.) system setup ( I mean hardware, not user, network etc )

I expect many people are trying to use beaglebone for "real time" applications,
I'm not the first and only one :-)
Up to now I used µP and FPGA's for that kind of applications .... and I spent not so much nights on that.

Thanks for help
Kasimir
 

Hi Robert,
this is my current status ( hop I follow your advice correctly ):

/opt/scripts/tools/version.sh
git:/opt/scripts/:[2ce750d881941c5189db9e189af90517e11c079f]
eeprom:[A335BNLT000C1914BBBK0031]
dogtag:[BeagleBoard.org Debian Image 2017-08-31]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2017.09-rc2-00002-g7c9353]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2017.09-rc2-00002-g7c9353]
kernel:[4.4.84-ti-r120]
nodejs:[v6.11.2]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg:[bb-cape-overlays]:[4.4.20170728.0-0rcnee1~stretch+20170728]
pkg:[bb-wl18xx-firmware]:[1.20170829-0rcnee1~stretch+20170829]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee0~stretch+20170830]

ls -alsrt /sys/devices/bone_capemgr*
ls: cannot access ‘/sys/devices/bone_capemgr*’: No such file or directory

I reached that point multiple times in the past … what is missing?

Thanks for help

Kasimir

Hi,
attached is my simple testcase. puls_gen.c is the loader, pru.c is the program for pru1.
It’s very simple. First I write some known values in shared memory. Then I load pru progam and activate it.
pru1 is moving 2 values ( just to see that it works ) and at the end it should toggle P8_45 (Pin40) full speed.
Makefile is included.

I’m able to compile pru.c, that works.
Currently I’m unable to compile puls_gen.c, because on that ( missing prussdrv.h )

../include/puls_gen.h:9:22: fatal error: prussdrv.h: No such file or directory #include <prussdrv.h>

Device tree is a real problem for me at the moment.
I did follow Robert’s instructions.

What is my next step? Think first my puls_gen.c should compile correctly’? Do I need a local copy of prussdrv.c?
I want to use the HDMI ( for test only P8_43 … P8_46 ) as output. It’s mode5 and should be connected to __R30 of pru1.
Up to now I didn’t find consistent information, I saw Derek Molloy’s videos, but was not able to make that happen, because
on a different directory structure.

Best case … it should be possible to modify the device tree as required out of the C-program ( Linux ), and exit from that
with status as it was. At the moment I gave up the idea …

My device tree description is also attached. But currently I’m unable to load that one.

What is your recommendation?
Any help or link to working example

Kasimir

PS was not possible to attach the files, how can I provide my data ( 6kB )?

Hi Robert,
this is my current status ( hop I follow your advice correctly ):
/opt/scripts/tools/version.sh
git:/opt/scripts/:[2ce750d881941c5189db9e189af90517e11c079f]
eeprom:[A335BNLT000C1914BBBK0031]
dogtag:[BeagleBoard.org Debian Image 2017-08-31]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot
2017.09-rc2-00002-g7c9353]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot
2017.09-rc2-00002-g7c9353]
kernel:[4.4.84-ti-r120]
nodejs:[v6.11.2]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]

uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-4-TI-00A0.dtbo]

You have them both selected, just select one...

the uio option is compatible with 3.8.13
the rproc is the method ti wants everyone to use..

uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg:[bb-cape-overlays]:[4.4.20170728.0-0rcnee1~stretch+20170728]
pkg:[bb-wl18xx-firmware]:[1.20170829-0rcnee1~stretch+20170829]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee0~stretch+20170830]

ls -alsrt /sys/devices/bone_capemgr*
ls: cannot access '/sys/devices/bone_capemgr*': No such file or directory

wrong directory, but it isn't useful when using u-boot overlays..

Regards,

Hello,
based on this description I have the following now, think the device tree should work.
Interesting is, I have to send
echo RoboticsCape > /sys/devices/platform/bone_capemgr/slots &

in background, otherwise the prompt is gone. But system is still working.
cat /sys/devices/platform/bone_capemgr/slots
0: PF---- -1
1: PF---- -1
2: PF---- -1
3: PF---- -1
4: P-O-L- 0 Override Board Name,00A0,Override Manuf,RoboticsCape

I modified the RoboticsCape for pin40 … pin43 mode5 outputs. Then compile and result is copied into /lib/firmware.

Hope it still works after reboot.
The pins are outputs now.
pin 40 (44e108a0.0) 00000025 pinctrl-single
pin 41 (44e108a4.0) 00000025 pinctrl-single
pin 42 (44e108a8.0) 00000025 pinctrl-single
pin 43 (44e108ac.0) 00000025 pinctrl-single
pin 44 (44e108b0.0) 00000025 pinctrl-single
pin 45 (44e108b4.0) 00000025 pinctrl-single
pin 46 (44e108b8.0) 00000025 pinctrl-single
pin 47 (44e108bc.0) 00000025 pinctrl-single

Hope it’s correct.
Next is compile my sources, because gcc complains -lprusdrv is not available and so on.

The pru C-Code compiles without errors.

Any idea what is still missing?

Thanks
Kasimir

Think I have to stop that project,
because it’s currently only time consuming and I can’t see a possible solution.
First I have got the message Debian is recommended, TI advise me to use Ubuntu
and different API.
So I spent a lot of time for nothing.

I’m pretty sure the Beaglebone black fit’s perfectly to my needs.
But I can’t see a consistent flow / tool set / API to do the job.

There is always somewhat missing.

Thanks for all the hints I have got.

Kasimir

Who at TI recommended Ubuntu? For TI support, use the Processor SDK (Yocto). For the best support from this community, use Robert’s Debian images used by most of the community. For Ubuntu community support, and some limited BB community support, use Ubuntu.

Some Debian examples are old, but if you follow the “smart questions” guidelines, I think we can solve the challenge together without wasting too much of your time.

Hi Jason,

have to start again from scratch. Have no preference for a specific kernel / distribution, as long
I can write C-code for ARM & PRU … and they are able to communicate via shared ram.
At least pru1 should have influence to the P8_43 … P8_46 outputs. No HDMI required.

I have a blank Beaglebone black now.

Thanks again and have a good day
Kasimir

Here’s my starting point that should work with newer images than the one documented:

https://gist.github.com/jadonk/2ecf864e1b3f250bad82c0eae12b7b64

It is just a simple LED blinking demo. You can still use mmap to access the shared memory for communications.

Hi Jason,
you you know another source for download? Think the file was moved away.

The requested URL /rootfs/bb.org/testing/2017-06-11/stretch-iot/bone-debian-stretch-iot-armhf-2017-06-11-4gb.img.xz was not found on this server.

Would like to try it out.
Thanks and have a good day
Kasimir

Use the one referenced here: (Debian 9.1 2017-08-31 4GB SD IoT )

http://beagleboard.org/latest-images

Regards,

Hi Jason,
can confirm, LED is flashing.

cd /var/lib/cloud9
root@beaglebone:/var/lib/cloud9# git clone https://gist.github.com/jadonk/2ecf864e1b3f250bad82c0eae12b7b64
Cloning into ‘2ecf864e1b3f250bad82c0eae12b7b64’…
remote: Counting objects: 84, done.
remote: Total 84 (delta 0), reused 0 (delta 0), pack-reused 84
Unpacking objects: 100% (84/84), done.
root@beaglebone:/var/lib/cloud9# cd 2ecf864e1b3f250bad82c0eae12b7b64
root@beaglebone:/var/lib/cloud9/2ecf864e1b3f250bad82c0eae12b7b64# make
CC hello-pru.c
LD gen/hello-pru.obj
CC hello-pru.c
LD gen/decay95.obj

  • Generated firmwares are : gen/hello-pru.out gen/decay95.out
    root@beaglebone:/var/lib/cloud9/2ecf864e1b3f250bad82c0eae12b7b64# echo none > /sys/class/leds/beaglebone:green:usr0/trigger
    root@beaglebone:/var/lib/cloud9/2ecf864e1b3f250bad82c0eae12b7b64# config-pin overlay cape-universala
    root@beaglebone:/var/lib/cloud9/2ecf864e1b3f250bad82c0eae12b7b64# config-pin p9.30 pruout
    root@beaglebone:/var/lib/cloud9/2ecf864e1b3f250bad82c0eae12b7b64# make run
  • copying firmware file gen/hello-pru.out to /lib/firmware/am335x-pru0-fw
    /bin/sh: 1: cannot create /sys/bus/platform/drivers/pru-rproc/unbind: Permission denied
    /bin/sh: 1: cannot create /sys/bus/platform/drivers/pru-rproc/bind: Permission denied
  • rebooting pru core 0
  • pru core 0 is now loaded with gen/hello-pru.out
    root@beaglebone:/var/lib/cloud9/2ecf864e1b3f250bad82c0eae12b7b64#

Now I have to modify my stuff.
It looks like more simple as expected.
Think with given technique I can save the existing IO configuration in my loader,
modify to my needs, load firmware and start the pru. At the end I should be able to
set the IO configuration as it was before.
But first I want to see if the pru will do what I expect …

Thank you very much for the useful hints.
Kasimir

Hi Jason,
reduced the given example to a minimum, should toggle P8.45.
It doesn’t work.
Log of make:

root@beaglebone-ln:/media/SD32/home/ln/Programme/Puls_neu/source# make
CC puls_gen.c
“puls_gen.c”, line 82: warning #112-D: statement is unreachable
“puls_gen.c”, line 70: warning #179-D: variable “i” was declared but never referenced
“puls_gen.c”, line 70: warning #179-D: variable “j” was declared but never referenced
LD gen/puls_gen.obj
CC puls_gen.c
“puls_gen.c”, line 82: warning #112-D: statement is unreachable
“puls_gen.c”, line 70: warning #179-D: variable “i” was declared but never referenced
“puls_gen.c”, line 70: warning #179-D: variable “j” was declared but never referenced
LD gen/decay95.obj

  • Generated firmwares are : gen/puls_gen.out gen/decay95.out
    root@beaglebone-ln:/media/SD32/home/ln/Programme/Puls_neu/source# config-pin overlay cape-universala
    root@beaglebone-ln:/media/SD32/home/ln/Programme/Puls_neu/source# config-pin p8.45 pruout
    root@beaglebone-ln:/media/SD32/home/ln/Programme/Puls_neu/source# config-pin -q p8.45
    P8_45 Mode: pruout
    root@beaglebone-ln:/media/SD32/home/ln/Programme/Puls_neu/source# make run
  • copying firmware file gen/puls_gen.out to /lib/firmware/am335x-pru1-fw
    /bin/sh: 1: cannot create /sys/bus/platform/drivers/pru-rproc/unbind: Permission denied
    /bin/sh: 1: cannot create /sys/bus/platform/drivers/pru-rproc/bind: Permission denied
  • rebooting pru core 0
  • pru core 1 is now loaded with gen/puls_gen.out
    root@beaglebone-ln:/media/SD32/home/ln/Programme/Puls_neu/source#

My C-code:

#include <stdint.h>
#include <pru_cfg.h>
#include <pru_ctrl.h>
#include “resource_table_empty.h”

#define INS_PER_US 200 // 5ns per instruction
#define INS_PER_DELAY_LOOP 2 // two instructions per delay loop
#define DELAY_CYCLES_US (INS_PER_US / INS_PER_DELAY_LOOP)

#define GPIO1 0x4804C000
#define GPIO_CLEARDATAOUT 0x190
#define GPIO_SETDATAOUT 0x194
#define USR0 (1<<21)
#define USR1 (1<<22)
#define USR2 (1<<23)
#define USR3 (1<<24)
unsigned int volatile * const GPIO1_CLEAR = (unsigned int *) (GPIO1 + GPIO_CLEARDATAOUT);
unsigned int volatile * const GPIO1_SET = (unsigned int *) (GPIO1 + GPIO_SETDATAOUT);

volatile register unsigned int __R30;
volatile register unsigned int __R31;
#define PRU0_GPIO (1<<2)

#ifndef DECAY_RATE
#define DECAY_RATE 100
#endif
#ifndef DELAY_CYCLES
#define DELAY_CYCLES DELAY_CYCLES_US
#endif

const int decay = DECAY_RATE;

void main(void) {
int i, j;

/* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;

//
while (1)
{
__R30 |= 0x00000001; // toggle P8_45
__R30 &= 0xFFFFFFFE;
}
__halt();
}

Makefile is attached.

At the moment it works … and I know why … I can do the next step.
What is wrong or missing?

Thanks for help and have a good day

Kasimir

Makefile (2.79 KB)

I still have the problem with pru1.

  • Generated firmwares are : gen/puls_gen.out gen/decay95.out
    root@beaglebone-ln:/media/SD32/home/ln/Programme/Puls_neu/source# config-pin overlay cape-universala
    root@beaglebone-ln:/media/SD32/home/ln/Programme/Puls_neu/source# config-pin p8.45 pruout
    root@beaglebone-ln:/media/SD32/home/ln/Programme/Puls_neu/source# config-pin -q p8.45
    P8_45 Mode: pruout
    root@beaglebone-ln:/media/SD32/home/ln/Programme/Puls_neu/source# make run
  • copying firmware file gen/puls_gen.out to /lib/firmware/am335x-pru1-fw
    **/bin/sh: 1: cannot create /sys/bus/platform/drivers/pru-**rproc/unbind: Permission denied
    **/bin/sh: 1: cannot create /sys/bus/platform/drivers/pru-**rproc/bind: Permission denied

It’s really confusing and time consuming without any result. Think the hardware is very useful and interesting,
but it’s not an easy task to make it work.