I add IO control in my driver, I can’t control io;
I call the following function in function lkt4304_r probe.
why?
static int lkt4304_reset(void)
{
int ret;
printk("llkt4304_reset\n");
ret = gpio_request(66, "lkt4304");
if (ret) {
printk("lkt4304_reset :Unable to request power GPIO\n");
return ret;
}
ret = gpio_direction_output(66,GPIOF_DIR_OUT);
if (ret) {
printk("lkt4304_reset :Unable to gpio_direction_output\n");
return ret;
}
gpio_set_value(66,0);
msleep(200);
gpio_set_value(66,1);
gpio_free(66);
return 0;
}
Now use the following instruction instead of the lkt4304_reset( function,
echo 66 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio66/direction
echo 0 > /sys/class/gpio/gpio66/value
echo 1 > /sys/class/gpio/gpio66/value
it is right , I can control the hardware ,the GPIO is GPIO_PI_02,the number is 66
using the following commond
echo 66 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio66/direction
echo 0 > /sys/class/gpio/gpio66/value
echo 1 > /sys/class/gpio/gpio66/value
and I add my driver lkt4304 in the directory(kernerl/drivers/i2c), config = Y
since there’s already has pin definition, could you please have a try to control GPIO directly in the kernel driver with the API, i.e. gpio_set_value()
thanks
I do it,in the function lkt4304_reset,
then I call the function lkt4304_reset in the function lkt4304_probe
gpio_set_value(66,0);
gpio_set_value(66,1);
but can not control it
static int lkt4304_reset(void)
{
int ret;
printk(“llkt4304_reset\n”);
ret = gpio_request(66, “lkt4304”);
if (ret) {
printk(“lkt4304_reset :Unable to request power GPIO\n”);
return ret;
}
ret = gpio_direction_output(66,GPIOF_DIR_OUT);
if (ret) {
printk("lkt4304_reset :Unable to gpio_direction_output\n");
return ret;
}
gpio_set_value(66,0);
msleep(200);
gpio_set_value(66,1);
gpio_free(66);
return 0;
}
this GPIO control should works once your kernel function, lkt4304_reset() being called.
BTW, how you monitor the GPIO state changes, are you probing the pin state?
thanks
And when I run the command: sudo ./apply_binaries.sh
I reported the following error
Preparing to unpack …/python3-jetson-gpio_2.0.11_arm64.deb …
qemu: Unsupported syscall: 278
ubuntu@ubuntu:~/nano/R32.4.4/Linux_for_Tegra$ sudo ./apply_binaries.sh
[sudo] password for ubuntu:
Using rootfs directory of: /home/ubuntu/nano/R32.4.4/Linux_for_Tegra/rootfs
/home/ubuntu/nano/R32.4.4/Linux_for_Tegra/nv_tegra/nv-apply-debs.sh
Root file system directory is /home/ubuntu/nano/R32.4.4/Linux_for_Tegra/rootfs
Copying public debian packages to rootfs
Start L4T BSP package installation
QEMU binary is not available, looking for QEMU from host system
Found /usr/bin/qemu-aarch64-static
Installing QEMU binary in rootfs
~/nano/R32.4.4/Linux_for_Tegra/rootfs ~/nano/R32.4.4/Linux_for_Tegra
Installing BSP Debian packages in /home/ubuntu/nano/R32.4.4/Linux_for_Tegra/rootfs
(Reading database … 142191 files and directories currently installed.)
Preparing to unpack …/nvidia-l4t-core_32.4.4-20201016124427_arm64.deb …
Pre-installing… skip compatibility checking.
Unpacking nvidia-l4t-core (32.4.4-20201016124427) over (32.4.4-20201016124427) …
Setting up nvidia-l4t-core (32.4.4-20201016124427) …
(Reading database … 142191 files and directories currently installed.)
Preparing to unpack …/jetson-gpio-common_2.0.11_arm64.deb …
Unpacking jetson-gpio-common (2.0.11) over (2.0.11) …
Preparing to unpack …/python3-jetson-gpio_2.0.11_arm64.deb …
qemu: Unsupported syscall: 278
Unpacking python3-jetson-gpio (2.0.11) over (2.0.11) …
Preparing to unpack …/python-jetson-gpio_2.0.11_arm64.deb …
Unpacking python-jetson-gpio (2.0.11) over (2.0.11) …
Preparing to unpack …/nvidia-l4t-3d-core_32.4.4-20201016124427_arm64.deb …
Unpacking nvidia-l4t-3d-core (32.4.4-20201016124427) over (32.4.4-20201016124427) …
Preparing to unpack …/nvidia-l4t-apt-source_32.4.4-20201016124427_arm64.deb …
Unpacking nvidia-l4t-apt-source (32.4.4-20201016124427) over (32.4.4-20201016124427) …
Preparing to unpack …/nvidia-l4t-camera_32.4.4-20201016124427_arm64.deb …
Unpacking nvidia-l4t-camera (32.4.4-20201016124427) over (32.4.4-20201016124427) …
Preparing to unpack …/nvidia-l4t-configs_32.4.4-20201016124427_arm64.deb …
Unpacking nvidia-l4t-configs (32.4.4-20201016124427) over (32.4.4-20201016124427) …
Preparing to unpack …/nvidia-l4t-cuda_32.4.4-20201016124427_arm64.deb …
Unpacking nvidia-l4t-cuda (32.4.4-20201016124427) over (32.4.4-20201016124427) …
Preparing to unpack …/nvidia-l4t-firmware_32.4.4-20201016124427_arm64.deb …
Unpacking nvidia-l4t-firmware (32.4.4-20201016124427) over (32.4.4-20201016124427) …
Preparing to unpack …/nvidia-l4t-graphics-demos_32.4.4-20201016124427_arm64.deb …
Unpacking nvidia-l4t-graphics-demos (32.4.4-20201016124427) over (32.4.4-20201016124427) …
Can I keep the DEB file I download when I update? in the path “/var/cache/apt/archives”
when finish apt install,the system auoremove /var/cache/apt/archives/*.deb
wo hope that I can keep it
when not using lkt4304_reset() , the I2c is working, but must using the following commond
echo 66 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio66/direction
echo 0 > /sys/class/gpio/gpio66/value
echo 1 > /sys/class/gpio/gpio66/value
what’s the full process of your lkt4304 kernel driver?
it seems to me you’re having reset function to clean some settings to make i2c not works.
those APIs to control GPIO perform same as linux commands you had point-out.
Lk4304 is a device driver written by me. After the driver is loaded, I need to reset the “reset pin”. When I load the driver, I use “echo 1> / sys / class / gpio / gpio66 / value” to pull the reset pin up. my driver can work normally
But when using “gpio_set_value(66,1);”, the driver is not work, so the I2c is right (I call lkt4304_reset in the function lkt4304_probe )
My meanning, why using “echo” and “gpio_set_value” ,The result is different