How to get pin to mode 6 on beagle bone black
Hans Bentum
jwbentum44 at gmail.com
Wed Jan 15 09:50:35 UTC 2020
Hello,
I tried several things to put pin 8_16 into mode 6 for usage by the PRU for
high speed IO.
Up to now without any luck. I am using FreeBSD 12.1
Question: how can I put a pin on beagle bone black to mode 6?
I did the following:
To get full speed IO signals I would like to use the enhanced GPIO on the
PRU.
To do this a device tree overlay is needed. I found a nice example on the
internet. https://nilshoel.home.blog/
In this example pin P8.16 is set to input mode 6.
/dts-v1/;
/plugin/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green";
// identification
part-number = "PRU-UIO-EXAMPLE-PINS";
version = "00A0";
fragment at 0 {
target = <&am33xx_pinmux>;
__overlay__ {
example_pins: pinmux_pru_pru_pins {
pinctrl-single,pins = <
0x38 0x26 /* Pin 8_16 in gpmc_ad14 Mode 6 */
>;
};
};
};
fragment at 1 {
target-path="<&pruss>";
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&example_pins>;
status = "okay";
};
};
};
The file (egpio.dtso) is converted by
dtc –I dts –O dtb –o /boot/dtb/overlays/egpio.dtbo egpio.dtso
The egpio.dtbo is added in the file loader.conf to the line
fdt_overlays="am335x-boneblack-pruss.dtbo,egpio.dtbo"
am335x-boneblack-pruss.dtbo is to enable the pruss
/dts-v1/;
/plugin/;
/ {
compatible = "ti,am335x-bone-black", "ti,am335x-bone",
"ti,am33xx";
fragment at 0 {
target-path="/";
__overlay__ {
ocp {
#address-cells = <1>;
#size-cells
= <1>;
pruss at 4a300000 {
status = "okay";
compatible = "ti,pruss-v2";
ti,deassert-hard-reset = "pruss", "pruss";
reg = <0x4a300000 0x080000>;
ti,pintc-offset = <0x20000>;
interrupt-parent = <&intc>;
interrupts = <20 21 22 23 24 25 26 27>;
};
};
};
};
};
In the PRU(0) I start a little test program which sets a userled
to on when the pin is sampled high and sets the userled to off when the pin
is sampled low.
The pin should be in mode 6 to be able to read the high value. If I use
some timer construction in the pru assembly program bellow the leds are
blinking so the pru is up and running.
# cat rtu_w.p
.origin 0
.entrypoint START
#define GPIO0 0x44E07000
#define GPIO1 0x4804c000
#define GPIO2 0x481AC000
#define GPIO3 0x481AE000
#define GPIO_CLEARDATAOUT 0x190
#define GPIO_SETDATAOUT 0x194
#define LED_USER 1<<24
#define CONST_PRUCFG C4
#define CTPPR_0 0x24028
#define CTPPR_1 0x2402C
.macro ST32
.mparam src,dst
SBBO src,dst,#0x00,4
.endm
START:LBCO r0, CONST_PRUCFG, 4, 4
CLR r0, r0,
SBCO r0, CONST_PRUCFG, 4, 4
MOV r0, 0x00000100
MOV r1, CTPPR_0
ST32 r0, r1
MOV r0, 0x00100000
MOV r1, CTPPR_1
ST32 r0, r1
NO_CMD:QBBC L1, r31.t14 //
Quick Branch to L1 if Bit is Clear
CALL LED_USER_LANE_1_ON
QBA NO_CMD
L1: CALL LED_USER_LANE_1_OFF
QBA NO_CMD
LED_USER_LANE_1_ON: MOV r2, LED_USER
MOV r3, GPIO1 | GPIO_SETDATAOUT
SBBO r2, r3, 0, 4
RET
LED_USER_LANE_1_OFF: MOV r2, LED_USER
MOV r3, GPIO1 | GPIO_CLEARDATAOUT
SBBO r2, r3,
0, 4
RET
Makefile
pru = rtu_w
LIB_PATH = .
LIBRARIES = pthread
INCLUDES = -I. ${LIB_PATH}
INCLUDES = -I/home/freebsd/iws
EXTRA_DEFINE =
CCCFLAGS = $(EXTRA_DEFINE)
CC = clang
CFLAGS = $(EXTRA_DEFINE)
PASM = pasm
all : $(clean) $(pru)
pru : $(pru)
$(pru) : $(pru:%=%.p)
rm -rf *.o *.bin $(project) core *~
$(PASM) -V3 -b $@.p
clean:
rm -rf *.o *.bin $(project) core *~
compile wtih:
#make
Run on pru:(and give the pin signals)
# pructl –t ti –p 0 –e rtu_w.bin
I also tried to set the pinmux using the pru but no luck (as expected).
https://vadl.github.io/beagleboneblack/2016/07/29/setting-up-bbb-gpio
#define P8_16 0x44E10838
MOV r2, 0x26 // val
MOV r0, P8_16 // address
SBBO r2, r0, 0, 4 // store
For low speed setting or reading pin like
#include <libgpio.h>
gself.m_gpio2 = gpio_open(2);
gpio_pin_input (gself.m_gpio2, 22);
gpio_close(gself.m_gpio2);
works very well.
Regards,
Hans Bentum
More information about the freebsd-arm
mailing list