Moving from simulated events to actual electrons on a BeagleBone Black.
Every driver up to this point ran on x86 and produced events in software. Camera pipelines eventually touch real hardware — sensors, GPIO lines, physical interfaces. This driver is the first step into that: controlling the USR0 LED on a BeagleBone Black via a character device, cross-compiled from an x86 host.
| Parameter | Value |
|---|---|
| Target board | BeagleBone Black (AM335x) |
| Kernel | 5.10.168-ti-r76 |
| GPIO | GPIO1_21 → global number 53 |
| LED | USR0 onboard |
GPIO numbering on AM335x: global = bank × 32 + pin. GPIO1_21 = 1×32+21 = 53.
| LED | Bank | Pin | Global |
|---|---|---|---|
| USR0 | 1 | 21 | 53 |
| USR1 | 1 | 22 | 54 |
| USR2 | 1 | 23 | 55 |
| USR3 | 1 | 24 | 56 |
/* Init */
gpio_is_valid(GPIO_53);
gpio_request(GPIO_53, "GPIO_53");
gpio_direction_output(GPIO_53, 0); /* output, start LOW */
gpio_export(GPIO_53, false); /* visible in /sys/class/gpio/ */
/* Exit */
gpio_unexport(GPIO_53);
gpio_free(GPIO_53);static ssize_t etx_write(struct file *filp,
const char __user *buf, size_t len, loff_t *off)
{
uint8_t rec_buf[10] = {0};
copy_from_user(rec_buf, buf, len);
if (rec_buf[0] == '1') gpio_set_value(GPIO_53, 1);
else if (rec_buf[0] == '0') gpio_set_value(GPIO_53, 0);
return len;
}# From userspace
echo 1 > /dev/etx_device # LED on
echo 0 > /dev/etx_device # LED offBuilt on a Dell Latitude 5320 (Ubuntu 22.04) targeting the BBB's ARM Cortex-A8, deployed via SCP.
CROSS_COMPILE = arm-linux-gnueabihf-
ARCH = arm
KDIR = /home/sanath/bbb-kernel/build