resource_table and PRU question

I am using a BeagleBone Black Wireless and use the multiple GPIOs for valve and pump control, both I2C buses to read pressure and temperature sensors and several analog input lines. All this is used with a custom PCB board for our product.

I am using Debian. output from version.sh is shown below.

I use the PRU to read A/D and control the valves for this application and need to use P9_31. I can get P9_31 to work as a pruout with PRU0 when the following line exists inside resource_table_0.h

struct my_resource_table {
	struct resource_table base;

	uint32_t offset[1]; /* Should match 'num' in actual definition */

	/* rpmsg vdev entry */
	struct fw_rsc_vdev rpmsg_vdev;
	struct fw_rsc_vdev_vring rpmsg_vring0;
	struct fw_rsc_vdev_vring rpmsg_vring1;

	/* intc definition */
	struct fw_rsc_custom pru_ints;
};

But, if this the line
uint32_t offset[1]; /* Should match 'num' in actual definition */

uses offset ‘1’ I lose the use of remoteproc. It fails to initialize. And if it set to offset ‘2’, P9_31 causes loss of connection over wifi to the BeagleBone Black Wireless and I have to restart the unit to regain access.

I really don’t understand what resourcetable does and how it works and don’t know where to start to address or understand this issue further. Although I could conceivably use a GPIO from P8 since we aren’t using HDMI, our board is built to connect directly through P9 so I would have to jumper to P8 and make a mod on our PCB revs we have in house. I’d rather not do that if there is a software solution.

sudo /opt/scripts/tools/version.sh
[sudo] password for debian:
git:/opt/scripts/:[e4e4854ef8ff9ada5c85553376043ee7679167ca]
eeprom:[A335BNLTBWA51824BBWG0173]
model:[TI_AM335x_BeagleBone_Black_Wireless]
dogtag:[BeagleBoard.org Debian Buster IoT Image 2021-02-15]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot SPL 2019.04-00002-gc9b3922522 (Aug 24 2020 - 16:42:18 -0500)]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2019.04-00002-gc9b3922522]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
UBOOT: Loaded Overlay:[AM335X-PRU-RPROC-4-19-TI-00A0]
UBOOT: Loaded Overlay:[BB-ADC-00A0.bb.org-overlays]
UBOOT: Loaded Overlay:[BB-BBBW-WL1835-00A0.bb.org-overlays]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0.bb.org-overlays]
kernel:[4.19.94-ti-r64]
nodejs:[v10.23.1]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[disable_uboot_overlay_audio=1]
uboot_overlay_options:[uboot_overlay_pru=AM335X-PRU-RPROC-4-19-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.14.20210809.0-0~buster+20210816]
pkg:[bb-customizations]:[1.20210810.1-0~buster+20210810]
pkg:[bb-usb-gadgets]:[1.20200504.0-0~buster+20200504]
pkg:[bb-wl18xx-firmware]:[1.20200813.1-0~buster+20200813]
pkg:[kmod]:[26-1]
pkg:[librobotcontrol]:[1.0.5-git20200715.0-0~buster+20200716]
pkg:[firmware-ti-connectivity]:[20190717-2rcnee1~buster+20200305]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal input bluetooth netdev i2c gpio admin spi iio docker tisdk weston-launch xenomai cloud9ide pwm eqep remoteproc]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk1p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet]
dmesg | grep remote
[ 55.971494] Bluetooth: hci0: change remote baud rate command in firmware
[ 74.676397] remoteproc remoteproc0: wkup_m3 is available
[ 74.800399] remoteproc remoteproc0: powering up wkup_m3
[ 74.800427] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217148
[ 74.800683] remoteproc remoteproc0: remote processor wkup_m3 is now up
[ 77.795989] remoteproc remoteproc1: 4a334000.pru is available
[ 77.819969] remoteproc remoteproc2: 4a338000.pru is available
[ 621.001635] remoteproc remoteproc1: powering up 4a334000.pru
[ 621.001927] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 27404
[ 621.001961] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 661.398061] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 996.901750] remoteproc remoteproc1: powering up 4a334000.pru
[ 996.906732] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 27404
[ 996.906776] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 1002.073804] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 1200.244696] remoteproc remoteproc1: powering up 4a334000.pru
[ 1200.245317] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 113828
[ 1200.262932] remoteproc remoteproc1: registered virtio0 (type 7)
[ 1200.262953] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 1709.015692] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 1714.922610] remoteproc remoteproc1: powering up 4a334000.pru
[ 1714.923252] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 113900
[ 1714.932851] remoteproc remoteproc1: unsupported resource 512
[ 1714.932961] remoteproc remoteproc1: unsupported resource 512
[ 1714.961817] remoteproc remoteproc1: registered virtio0 (type 7)
[ 1714.961829] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 1768.721718] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 1830.174449] remoteproc remoteproc1: powering up 4a334000.pru
[ 1830.175077] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 113900
[ 1830.189140] remoteproc remoteproc1: unsupported resource 512
[ 1830.189251] remoteproc remoteproc1: unsupported resource 512
[ 1830.217923] remoteproc remoteproc1: registered virtio0 (type 7)
[ 1830.217934] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 1843.680682] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 1844.094700] remoteproc remoteproc1: powering up 4a334000.pru
[ 1844.095324] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 113900
[ 1844.106270] remoteproc remoteproc1: unsupported resource 512
[ 1844.106381] remoteproc remoteproc1: unsupported resource 512
[ 1844.143641] remoteproc remoteproc1: registered virtio0 (type 7)
[ 1844.143660] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 1897.386005] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 1906.529732] remoteproc remoteproc1: powering up 4a334000.pru
[ 1906.530436] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 113900
[ 1906.540949] remoteproc remoteproc1: unsupported resource 512
[ 1906.541059] remoteproc remoteproc1: unsupported resource 512
[ 1906.580919] remoteproc remoteproc1: registered virtio0 (type 7)
[ 1906.580930] remoteproc remoteproc1: remote processor 4a334000.pru is now up
dmesg | grep pru
[ 77.795989] remoteproc remoteproc1: 4a334000.pru is available
[ 77.796185] pru-rproc 4a334000.pru: PRU rproc node pru@4a334000 probed successfully
[ 77.819969] remoteproc remoteproc2: 4a338000.pru is available
[ 77.820136] pru-rproc 4a338000.pru: PRU rproc node pru@4a338000 probed successfully
[ 621.001635] remoteproc remoteproc1: powering up 4a334000.pru
[ 621.001927] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 27404
[ 621.001961] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 661.398061] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 996.901750] remoteproc remoteproc1: powering up 4a334000.pru
[ 996.906732] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 27404
[ 996.906776] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 1002.073804] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 1200.244696] remoteproc remoteproc1: powering up 4a334000.pru
[ 1200.245317] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 113828
[ 1200.254541] pruss 4a300000.pruss: configured system_events[63-0] = 00000000,00030000
[ 1200.254563] pruss 4a300000.pruss: configured intr_channels = 0x00000005 host_intr = 0x00000005
[ 1200.262953] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 1200.355633] virtio_rpmsg_bus virtio0: creating channel rpmsg-pru addr 0x1e
[ 1200.442073] rpmsg_pru virtio0.rpmsg-pru.-1.30: new rpmsg_pru device: /dev/rpmsg_pru30
[ 1709.015632] pruss 4a300000.pruss: unconfigured system_events[63-0] = 00000000,00030000
[ 1709.015652] pruss 4a300000.pruss: unconfigured host_intr = 0x00000005
[ 1709.015692] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 1714.922610] remoteproc remoteproc1: powering up 4a334000.pru
[ 1714.923252] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 113900
[ 1714.933350] pruss_intc_irq_set_affinity: event 16 not configured: ch = -1, host = -1
[ 1714.961829] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 1768.721644] pruss 4a300000.pruss: unconfigured system_events[63-0] = 00000000,00030000
[ 1768.721665] pruss 4a300000.pruss: unconfigured host_intr = 0x00000005
[ 1768.721718] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 1830.174449] remoteproc remoteproc1: powering up 4a334000.pru
[ 1830.175077] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 113900
[ 1830.189617] pruss_intc_irq_set_affinity: event 16 not configured: ch = -1, host = -1
[ 1830.217934] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 1843.680606] pruss 4a300000.pruss: unconfigured system_events[63-0] = 00000000,00030000
[ 1843.680627] pruss 4a300000.pruss: unconfigured host_intr = 0x00000005
[ 1843.680682] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 1844.094700] remoteproc remoteproc1: powering up 4a334000.pru
[ 1844.095324] remoteproc remoteproc1: Booting fw image am335x-pru0-fw, size 113900
[ 1844.106758] pruss_intc_irq_set_affinity: event 16 not configured: ch = -1, host = -1
[ 1844.143660] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 1897.385932] pruss 4a300000.pruss: unconfiguredsystem_events[63-0]= 00000000,00030000
[ 1897.385952] pruss 4a300000.pruss: unconfiguredhost_intr= 0x00000005
[ 1897.386005] remoteproc remoteproc1: stopped remote processor 4a334000.pru
[ 1906.529732] remoteproc remoteproc1: powering up 4a334000.pru
[ 1906.530436] remoteproc remoteproc1: Booting fwimage am335x-pru0-fw, size 113900
[ 1906.546738] pruss_intc_irq_set_affinity: event16 not configured: ch = -1, host = -1
[ 1906.580930] remoteproc remoteproc1: remote processor 4a334000.pru is now up
dmesg | grep pinctrl-single
[ 1.021766] pinctrl-single44e10800.pinmux: 142 pins, size 568
[ 1.493471] pinctrl-single44e10800.pinmux: pin PIN74 already requested by 481a6000.serial; cannot claim for leds
[ 1.503927] pinctrl-single44e10800.pinmux: pin-74 (leds) status -22
[ 1.510346] pinctrl-single44e10800.pinmux: could not request pin 74 (PIN74)from group pinmux_bt_pins ondevice pinctrl-single
dmesg | grep gpio-of-helper
debian@beaglebone:/var/lib/cloud9/EDEN/BackPack$ eady
lsusb
Bus 001 Device 001:ID 1d6b:0002 Linux Foundation2.0 root hub
END

Check resource_table_0.h « PRU_RPMsg_LED0 « pru_fw « pru_cape - pru-software-support-package/pru-software-support-package - The PRU Software Support Package

Since you define two SW resources in your table, you should use uint32_t offset[2] . But make sure you initialize both offset[0] and offset[1] with valid values, as done in the TI example above.

The kernel driver will read and parse your resource table. It even seems to succeed in some of your experiments:

[ 1200.254541] pruss 4a300000.pruss: configured system_events[63-0] = 00000000,00030000
[ 1200.254563] pruss 4a300000.pruss: configured intr_channels = 0x00000005 host_intr = 0x00000005
[ 1200.262953] remoteproc remoteproc1: remote processor 4a334000.pru is now up
[ 1200.355633] virtio_rpmsg_bus virtio0: creating channel rpmsg-pru addr 0x1e
[ 1200.442073] rpmsg_pru virtio0.rpmsg-pru.-1.30: new rpmsg_pru device: /dev/rpmsg_pru30

Regarding pinctrl, try to set it explicitly by a command:

$ config-pin P2_33 pruout

Regards,
Dimitar

Thanks for your advice and the link. I will dig into this TI resource a bit more to try to understand what this all does. I readily admit that I took this and ran with it, because of some pressing deadlines, without taking the time to really dig in and understand what it is doing.

That, said, this all appears to be related to setup of virtio for remoteproc. Any idea why it would interfere with using P9_31 as pruout? That’s the real mystery I need to solve.

My program actually runs config-pin for every pin we use in this system during the program initialization. And in writing some code to use to explore this problem I actually run config-pin P9_31 pruout and it configures it without any issue or error message. config-pin -q P9_31 returns that it is set as pruout too.

Puzzling…