Accessing BeaglePlay GPIOs and CSI

Hi,

I have some questions on the BeaglePlay.

  1. GPIO’s: How do I read/write to the GPIOs? I don’t see the config-pin tool, so I’ve tried doing this using “gpioset” and “gpioget”, but all the microbus pins as well as the user button return “device or resource busy”. I’m not sure if exporting the pin ( sudo echo xx > /sys/class/gpio/export ) will work. Its not clear to me how these pins are mapped to gpio numbers. I’m definitely missing something here and a would appreciate it if someone could point me in the right direction.

  2. Is there a device tree file available for the Sony IMX219 (RPi Camera Module 2) camera? This camera is not detected on the BeaglePlay.

Thanks in Advance
Renier

This might help, but is not a complete solution.
k3-am625-beagleplay-csi2-imx219.dts (1.7 KB)

  • Copy this file to /opt/source/dtb-5.10-ti/src/arm64/overlays
  • cd /opt/source/dtb-5.10-ti/
  • make the following change to Makefile:
debian@BeaglePlay:/opt/source/dtb-5.10-ti/src/arm64$ git diff
diff --git a/src/arm64/overlays/Makefile b/src/arm64/overlays/Makefile
index 1b2f6e4..82cce7b 100644
--- a/src/arm64/overlays/Makefile
+++ b/src/arm64/overlays/Makefile
@@ -29,7 +29,8 @@ dtbo-$(CONFIG_ARCH_K3) += \
        robotics-cape.dtbo \
        k3-am625-beagleplay-bcfserial-no-firmware.dtbo \
        k3-am625-beagleplay-csi2-ov5640.dtbo \
-       k3-am625-beagleplay-lt-lcd185.dtbo
+       k3-am625-beagleplay-lt-lcd185.dtbo \
+       k3-am625-beagleplay-csi2-imx219.dtbo

  • make

this should generate src/arm64/overlays/k3-am625-beagleplay-csi2-imx219.dtbo overlay file that is copied over to /boot/firmware and /boot/firmware/extlinux/extlinux.conf is updated accordingly.

NOTE:

  • I do have arducam imx219 probing
  • I dont seem to be able to use bayer2rgb to be able to do the capture properly
# Set to Bayer 8 bit mode as that is all that bayer2rgb can support.
media-ctl -V '"imx219 4-0010":0[SRGGB8_1X8/640x480]'
# This is'nt working - complains of out of memory, but have'nt debugged.
gst-launch-1.0 v4l2src device=/dev/video0 io-mode=4 ! video/x-bayer,width=640,height=480,format=rggb ! bayer2rgb ! video/x-raw,format=BGRx ! autovideosink

# This just dumps a black screen
gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-bayer,width=640,height=480,format=rggb ! bayer2rgb ! video/x-raw,format=BGRx ! autovideosink

on GPIO access directly for mikrobus - you might want to disable the mikrobus nodes to natively control the gpios… I think the mikrobus might be taking control of the gpios.

gpioinfo is the command you want.

To free up IO, you need to disable nodes in the device tree that currently control those IO.

Here’s a device tree overlay that disables the LEDs:

/dts-v1/;
/plugin/;

/ {

        fragment@0 {
                target-path = "/";

                __overlay__ {
                        leds {
                                status = "disabled";
                        };
                };
        };
};

compile this

dtc -I dts -O dtb leds-disable.dts -o leds-disable.dtbo

and copy it to the boot overlay folder

sudo cp leds-disable.dtbo /boot/firmware/overlays/

add a line to the end of /boot/overlays/extlinux/extlinux.conf to use this overlay on boot:

fdtoverlays /overlays/leds-disable.dtbo

and reboot.

gpioinfo will show these pins are unused

	line   3:       "USR0"       unused  output  active-high
	line   4:       "USR1"       unused  output  active-high
	line   5:       "USR2"       unused  output  active-high
	line   6:       "USR3"       unused  output  active-high

now you can use these pins with gpiod. Also note that these pins are part of gpiochip2. here’s some python that grabs gpiochip2, gpioline 3, and flashes one of the LEDs.

import gpiod
import time

LED_USR0_PIN = 3

gpiochip = gpiod.Chip("gpiochip2", gpiod.Chip.OPEN_BY_NAME)
led_usr0_line = gpiochip.get_line(LED_USR0_PIN) 
led_usr0_line.request(consumer="gpio-example", type=gpiod.LINE_REQ_DIR_OUT)     
led_usr0_line.set_value(1)
time.sleep(0.5)
led_usr0_line.set_value(0)      
time.sleep(0.5)
led_usr0_line.release()
1 Like

Thanks for the feedback @Nishanth_Menon and @toddm.

I’m getting the same results for the CSI camera where it dumps a black screen. I’ve noticed that the driver used is the j721e-csi2rx. Is this correct?

debian@BeaglePlay:~$ v4l2-ctl --all
Driver Info:
	Driver name      : j721e-csi2rx
	Card type        : j721e-csi2rx
	Bus info         : platform:30102000.ticsi2rx
	Driver version   : 5.10.162
	Capabilities     : 0xa5200001
		Video Capture
		Read/Write
		Streaming
		Extended Pix Format
		Device Capabilities
	Device Caps      : 0x25200001
		Video Capture
		Read/Write
		Streaming
		Extended Pix Format
Media Driver Info:
	Driver name      : j721e-csi2rx
	Model            : TI-CSI2RX
	Serial           : 
	Bus info         : platform:30102000.ticsi2rx
	Media version    : 5.10.162
	Hardware revision: 0x00000001 (1)
	Driver version   : 5.10.162
Interface Info:
	ID               : 0x03000015
	Type             : V4L Video
Entity Info:
	ID               : 0x00000013 (19)
	Name             : 30102000.ticsi2rx context 0
	Function         : V4L2 I/O
	Pad 0x01000014   : 0: Sink
	  Link 0x02000017: from remote pad 0x1000003 of entity '30102000.ticsi2rx': Data, Enabled, Immutable
Priority: 2
Video input : 0 (30102000.ticsi2rx context 0: ok)


I’ve noticed that the driver used is the j721e-csi2rx. Is this correct

Yep
Same csi2 Rx driver for all k3 devices.

Hi toddm,

i would like to use the CS from the mikrobus as an unused output active-high could you tell me how to know what overlay it is. I used linux-mikrobus but it didn’t work.
Thanks

@gravel,

I’m not sure how to disable the linux-mikrobus node with an overlay. It doesn’t seem to respect the status = “disabled”

that’s also what I was thinking.
thx for the help