Re: [Machinekit] compile/link PRU program

2019-05-01 Thread Charles Steinkuehler
On 5/1/2019 5:58 PM, Jon Elson wrote:
> I have the latest Machinekit build (4.19.31-bone-rt-r31 #1stretch PREEMPT 
> RT) and am trying to set up to build PRU programs.
> I got the compiler includes and pasm running, now when I compile a program 
> using prussdrv, I don't have the prussdrv library.
> 
> The error I get is :
> /usr/bin/ld: cannot find -lprussdrv
> collect2: error: ld returned 1 exit status
> 
> Does anybody know what package to install to get these files?

AFAIK, there isn't a package.

You can build from the Machinekit source tree, or the original source
from github (see /pru_sw/app_loader):

https://github.com/beagleboard/am335x_pru_package

The Submakefile in src/hal/support has the hooks for building prussdrv
(and the pasm assembler) in the Machinekit source tree (very similar
to the LinuxCNC Makefile & Submakefile setup if you're familiar with
that).

NOTE: The Machinekit build considers prussdrv.c just another C file,
which is the easiest way to build (just add the files to your project
and include them in your build process).  If you want to actually
install prussdrv as a system-wide library, the original Makefile from
the beagleboard am335x_pru_package is more appropriate for that.

-- 
Charles Steinkuehler
char...@steinkuehler.net

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


[Machinekit] compile/link PRU program

2019-05-01 Thread Jon Elson
I have the latest Machinekit build (4.19.31-bone-rt-r31 #1stretch PREEMPT 
RT) and am trying to set up to build PRU programs.
I got the compiler includes and pasm running, now when I compile a program 
using prussdrv, I don't have the prussdrv library.

The error I get is :
/usr/bin/ld: cannot find -lprussdrv
collect2: error: ld returned 1 exit status

Does anybody know what package to install to get these files?

Thanks,

Jon

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] compiling c with prussdrv

2019-05-01 Thread Charles Steinkuehler
On 5/1/2019 5:27 PM, Jon Elson wrote:
> So, I have some old test programs with compiled ARM and PRU binaries, and 
> they seem to work.  Now, I need to create new programs on the 
> 4.19.32-bone-rt-r31 kernel.
> I didn't know where to find the includes for the prussdrv, so I got them 
> off my old bone system.  That might be a mistake, they seem to conflict 
> with the current docs and also the code which I did compile on a previous 
> system.
> 
> Anyway, when compiling with this command :
> g++ $1.c -o $1 -lpthread -lprussdrv
> 
> I get these errors :
> test.c: In function ‘int main()’:
> test.c:74:50: error: too few arguments to function ‘int 
> prussdrv_exec_program(int, const char*, int)’
>   prussdrv_exec_program (PRU_NUM, "./test.bin");
>   ^
> In file included from test.c:13:0:
> /usr/include/prussdrv.h:172:9: note: declared here
>  int prussdrv_exec_program(int prunum, const char *filename, int 
> disabled);

You're missing the disabled flag.

>  ^
> test.c:75:43: error: too few arguments to function ‘int 
> prussdrv_pru_wait_event(unsigned int, int*)’
>   prussdrv_pru_wait_event (PRU_EVTOUT_0);
>^
> In file included from test.c:13:0:
> /usr/include/prussdrv.h:160:9: note: declared here
>  int prussdrv_pru_wait_event(unsigned int host_interrupt, int 
> *event_count);
>  ^~~

You're missing *event_count

> Both of these function calls SEEM to have the right number of arguments!
> 
> How should I install the right include files for the pruss driver?

There is no "pruss driver", the UIO driver used to talk to the PRU is
part of the kernel source.

The prussdrv library used to facilitate controlling the PRU was
written by TI, and I think I initially got it from github somewhwere
(likely in the old BeagleBone PRU support files repo).  The version I
use has been pulled into the Machinekit source tree, see the files
with "prussdrv" in the name:

https://github.com/machinekit/machinekit/tree/master/src/hal/support/pru

-- 
Charles Steinkuehler
char...@steinkuehler.net

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


[Machinekit] compiling c with prussdrv

2019-05-01 Thread Jon Elson
So, I have some old test programs with compiled ARM and PRU binaries, and 
they seem to work.  Now, I need to create new programs on the 
4.19.32-bone-rt-r31 kernel.
I didn't know where to find the includes for the prussdrv, so I got them 
off my old bone system.  That might be a mistake, they seem to conflict 
with the current docs and also the code which I did compile on a previous 
system.

Anyway, when compiling with this command :
g++ $1.c -o $1 -lpthread -lprussdrv

I get these errors :
test.c: In function ‘int main()’:
test.c:74:50: error: too few arguments to function ‘int 
prussdrv_exec_program(int, const char*, int)’
  prussdrv_exec_program (PRU_NUM, "./test.bin");
  ^
In file included from test.c:13:0:
/usr/include/prussdrv.h:172:9: note: declared here
 int prussdrv_exec_program(int prunum, const char *filename, int 
disabled);
 ^
test.c:75:43: error: too few arguments to function ‘int 
prussdrv_pru_wait_event(unsigned int, int*)’
  prussdrv_pru_wait_event (PRU_EVTOUT_0);
   ^
In file included from test.c:13:0:
/usr/include/prussdrv.h:160:9: note: declared here
 int prussdrv_pru_wait_event(unsigned int host_interrupt, int 
*event_count);
 ^~~
Both of these function calls SEEM to have the right number of arguments!

How should I install the right include files for the pruss driver?

Thanks,

Jon

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Robert Nelson
On Wed, May 1, 2019 at 5:03 PM Charles Steinkuehler
 wrote:
>
> On 5/1/2019 4:21 PM, Robert Nelson wrote:
> > On Wed, May 1, 2019 at 4:12 PM Jon Elson  wrote:
> >>
> >> OK, now I seem to have (maybe) got it!  So, I put in :
> >> ###Custom Cape
> >> dtb_overlay=/lib/firmware/cape-universalh-00A0.dtbo
> >>
> >> And I seem to have both the uio_pruss module loaded, AND all the P8 pins 
> >> available!
> >
> > So, you shouldn't have to force that overlay, as out of the box, we
> > have cape-universal auto-loading..
>
> Does U-Boot automatically change the universal overlay loaded when you
> disable on-board "capes" like the eMMC and HDMI?

That is correct, u-boot will pick the correct path based on the
enable/disables of the onboard devices set in /boot/uEnv.txt

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

Now even more crazy then that, in v4.14.x-ti and v4.19.x-(all)+, we
merged in the cape-universal rewrite, that even when other random
overlays are loaded, the config-pin pinmux's will still show up..

This why all overlays now have a

Px_yz_pinmux { status = "disabled";}; section at the start:

https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-CAN0-00A0.dts#L31-L40

PS, a dynamic generated config-pin vs the classic static config-pin
then makes this work very well..

https://github.com/beagleboard/bb.org-overlays/tree/master/tools/pmunts_muntsos

( i have it set as default for buster, as it's not 100% compatible
with the classic config-pin output..)

Regards,

-- 
Robert Nelson
https://rcn-ee.com/

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Charles Steinkuehler
On 5/1/2019 4:21 PM, Robert Nelson wrote:
> On Wed, May 1, 2019 at 4:12 PM Jon Elson  wrote:
>>
>> OK, now I seem to have (maybe) got it!  So, I put in :
>> ###Custom Cape
>> dtb_overlay=/lib/firmware/cape-universalh-00A0.dtbo
>>
>> And I seem to have both the uio_pruss module loaded, AND all the P8 pins 
>> available!
> 
> So, you shouldn't have to force that overlay, as out of the box, we
> have cape-universal auto-loading..

Does U-Boot automatically change the universal overlay loaded when you
disable on-board "capes" like the eMMC and HDMI?

-- 
Charles Steinkuehler
char...@steinkuehler.net

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Robert Nelson
On Wed, May 1, 2019 at 4:12 PM Jon Elson  wrote:
>
> OK, now I seem to have (maybe) got it!  So, I put in :
> ###Custom Cape
> dtb_overlay=/lib/firmware/cape-universalh-00A0.dtbo
>
> And I seem to have both the uio_pruss module loaded, AND all the P8 pins 
> available!

So, you shouldn't have to force that overlay, as out of the box, we
have cape-universal auto-loading..

Regards,

-- 
Robert Nelson
https://rcn-ee.com/

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Jon Elson
OK, now I seem to have (maybe) got it!  So, I put in :
###Custom Cape
dtb_overlay=/lib/firmware/cape-universalh-00A0.dtbo

And I seem to have both the uio_pruss module loaded, AND all the P8 pins 
available!

Thanks to both Charles and Robert for getting me through all this.

Jon

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Robert Nelson
On Wed, May 1, 2019 at 4:04 PM Jon Elson  wrote:
>
>
>
> On Wednesday, May 1, 2019 at 3:38:22 PM UTC-5, Robert Nelson wrote:
>>
>>
>> No, it's a variable, last one get's set and used..
>>
>>
> OK, ever so SLOWLY, I'm starting to understand a little bit.
> So, am I supposed to use the AM335X-PRU-UIO-00A0.dtbo WITH the 
> cape-universalh-00A0.dtbo ?
> If so, how do I tell uboot to do that?

Docs: https://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays

"cape-universal" will be autoloaded by u-boot...

As long as:

"dtb=something.dtb" is NOT set and "enable_uboot_overlays=1" and
"enable_uboot_cape_universal=1" is set..

Using:

sudo /opt/scripts/tools/version.sh

we can see the important bits of what you currently have set..

Regards,

-- 
Robert Nelson
https://rcn-ee.com/

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Jon Elson


On Wednesday, May 1, 2019 at 3:38:22 PM UTC-5, Robert Nelson wrote:
>
>
> No, it's a variable, last one get's set and used.. 
>
>
> OK, ever so SLOWLY, I'm starting to understand a little bit.
So, am I supposed to use the AM335X-PRU-UIO-00A0.dtbo WITH the 
cape-universalh-00A0.dtbo ?
If so, how do I tell uboot to do that?

Thanks,

Jon

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Jon Elson


On Wednesday, May 1, 2019 at 3:38:22 PM UTC-5, Robert Nelson wrote:
>
>
> No, it's a variable, last one get's set and used.. 
>
>
> OK, sorry to be dense, but I don't get what the right syntax for this is.  
There's a line :
enable_uboot_cape_universal=1

Do I change this to something like :

enable_uboot_cape_universalh=1

OR, is it here :
cmdline=coherent_pool=1M net.ifnames=0 quiet cape_universal=enable
and change to :
cmdline=coherent_pool=1M net.ifnames=0 quiet cape_universalh=enable

or something completely different?

Thanks,

Jon

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Robert Nelson
On Wed, May 1, 2019 at 3:07 PM Jon Elson  wrote:
>
>
>
> On Wednesday, May 1, 2019 at 2:50:24 PM UTC-5, Charles Steinkuehler wrote:
>>
>>
>> You'll need to disable HDMI to use those PRU pins on P8:
>>
>>
>> ...I think you then need to either load a different universal overlay
>> or a second chunk of the overlay that will add support for those pins.
>>
>>
> Yes, getting CLOSER!!  So, I commented out the HDMI line, and then added  
> universalh right after the PRU-UIO overlay, like this:
> uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
> uboot_overlay_pru=/lib/firmware/cape-universalh-00A0.dtbo

No, it's a variable, last one get's set and used..

Regards,

-- 
Robert Nelson
https://rcn-ee.com/

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Jon Elson
Meanwhile, there seems to be a discrepancy/deficiency in config-pin.

I can set a pin for gpio with pullup, or pruin, but I have not found ANY 
syntax that allows you to set a pin for pruin WITH pullup.

the internal help with -? is pretty confusing.  I KNOW the hardware can do 
this, as I used to do it with a .dtbo the old way.
And, in fact, it might be working and it is just the config-pin -q option 
doesn't display the combined setting.

Anybody know?

Thanks,

Jon

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Jon Elson


On Wednesday, May 1, 2019 at 2:50:24 PM UTC-5, Charles Steinkuehler wrote:
>
>
> You'll need to disable HDMI to use those PRU pins on P8: 
>   
>
> ...I think you then need to either load a different universal overlay 
> or a second chunk of the overlay that will add support for those pins. 
>
>
> Yes, getting CLOSER!!  So, I commented out the HDMI line, and then added  
universalh right after the PRU-UIO overlay, like this:
uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo
uboot_overlay_pru=/lib/firmware/cape-universalh-00A0.dtbo
And, now, I do see the additional IO pins, but uio_pruss is not loaded.
cape-universalh was already part of this build.

Was the above the right way to do this?

Thanks,

Jon

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Charles Steinkuehler
On 5/1/2019 2:03 PM, Jon Elson wrote:
> 
> 
> On Tuesday, April 30, 2019 at 6:00:51 PM UTC-5, Charles Steinkuehler wrote:
>>
>> Is there a reason you like beating your head against the wall? 
>>
>> Just let U-Boot load the universal and PRU-UIO overlays, and use 
>> config-pin to setup the PRU direct inputs/outputs. 
>>
>> YES, config-pin is clearly what I needed, but never found anywhere in the 
> docs/discussion!  OK, so now, I'm trying to get it to work, but run into:
> $ sudo config-pin P8_45 pruout
> [sudo] password for elson: 
> P8_45 pinmux file not found!
> bash: /sys/devices/platform/ocp/ocp*P8_45_pinmux/state: No such file or 
> directory
> Cannot write pinmux file: /sys/devices/platform/ocp/ocp*P8_45_pinmux/state

You'll need to disable HDMI to use those PRU pins on P8:

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

...I think you then need to either load a different universal overlay
or a second chunk of the overlay that will add support for those pins.

*checks source URL provided on eLinux page*

https://github.com/beagleboard/bb.org-overlays/

Yep, if I'm reading things right, it looks like you want to load
"cape-universalh-00A0.dts":

https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/cape-universalh-00A0.dts

...which will create pinmux entries for the HDMI pins.

-- 
Charles Steinkuehler
char...@steinkuehler.net

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Jon Elson


On Tuesday, April 30, 2019 at 6:00:51 PM UTC-5, Charles Steinkuehler wrote:
>
> Is there a reason you like beating your head against the wall? 
>
> Just let U-Boot load the universal and PRU-UIO overlays, and use 
> config-pin to setup the PRU direct inputs/outputs. 
>
>
> YES, config-pin is clearly what I needed, but never found anywhere in the 
docs/discussion!  OK, so now, I'm trying to get it to work, but run into:
$ sudo config-pin P8_45 pruout
[sudo] password for elson: 
P8_45 pinmux file not found!
bash: /sys/devices/platform/ocp/ocp*P8_45_pinmux/state: No such file or 
directory
Cannot write pinmux file: /sys/devices/platform/ocp/ocp*P8_45_pinmux/state

RC Nelson has a discussion on this, it started quite a while ago so some of 
it is out of date, but I have not gotten it to work, yet.
https://github.com/beagleboard/bb.org-overlays/issues/76

Thanks,

Jon

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.


Re: [Machinekit] Re: how to configure PRU pins ?

2019-05-01 Thread Jon Elson


On Tuesday, April 30, 2019 at 6:00:51 PM UTC-5, Charles Steinkuehler wrote:
>
> Is there a reason you like beating your head against the wall? 
>
> Just let U-Boot load the universal and PRU-UIO overlays, and use 
> config-pin to setup the PRU direct inputs/outputs. 
>
> ...or do you really want to create a custom overlay? 
>
>
> Well, maybe I am beating my head for no reason!  But, I don't know any 
better.
So, by default, the uEnv.txt file loads :
/lib/firmware/AM335X-PRU-UIO-00A0.dtbo

But, I do want to configure a bunch of pins for PRU1 as outputs and a few 
inputs, and maybe set the pullup/down settings.  This also involves pinmux 
MODE settings.
OK, so how do I use config-pin?  Is there a doc online for that?

Thanks,

Jon

-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to machinekit+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.