I am using olimex 3188 board and am trying to access gpios. When I attempt : ls -l /sys/class/gpio I get :
export
gpiochip160
gpiochip192
gpiochip224
gpiochip256
unexport
cat /sys/class/gpio/gpiochip160/ngpio returns 32
cat /sys/class/gpio/gpiochip160/label returns gpio0
cat /sys/class/gpio/gpiochip192/label returns gpio1
and so on until gpio3
I have read and understood what each block consists of, but for example I want to access pin : GPIO0_B4. Where does this pin belong?
Related
I created an USB audio gadget using USB Audio Class 1 (UAC1) to send/receive audio over USB from a Linux device (Raspberry Pi) to/from a Windows host. The gadget is already working and Windows detects the Raspberry Pi as an audio in and output.
The problem I have is, that the audio output device is called "AC Interface" and the input audio device is called "capture input terminal (AC Interface) in Windows". However, I would like to define an own name, that will be display at the host. Can somebody help me how to do this?
I tried to change the name using uac1_legacy (https://www.kernel.org/doc/Documentation/ABI/testing/configfs-usb-gadget-uac1_legacy), but I couldn't manged to add this to the script.
Or do I have to configure the USB audio gadget using gadget schemes?
# Load libcomposite
modprobe libcomposite
# Create USB Gadget
mkdir -p /sys/kernel/config/usb_gadget/g1
# Device Descriptors
echo 0x1d6b > /sys/kernel/config/usb_gadget/g1/idVendor # Linux Foundation
echo 0x0104 > /sys/kernel/config/usb_gadget/g1/idProduct # Multifunction Composite Gadget
echo 0x0100 > /sys/kernel/config/usb_gadget/g1/bcdDevice # v1.0.0
echo 0x0200 > /sys/kernel/config/usb_gadget/g1/bcdUSB # USB 2.0
echo 0xef > /sys/kernel/config/usb_gadget/g1/bDeviceClass # USB 2.0
echo 0x02 > /sys/kernel/config/usb_gadget/g1/bDeviceSubClass # USB 2.0
echo 0x01 > /sys/kernel/config/usb_gadget/g1/bDeviceProtocol # USB 2.0
mkdir -p /sys/kernel/config/usb_gadget/g1/strings/0x409
echo "000001" > /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber
echo "xy" > /sys/kernel/config/usb_gadget/g1/strings/0x409/manufacturer
echo "xy" > /sys/kernel/config/usb_gadget/g1/strings/0x409/product
# Configure UAC1 (audio)
mkdir -p /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0
echo 0x1 > /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0/c_chmask
echo 48000 > /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0/c_srate
echo 0xf > /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0/p_chmask
echo 48000 > /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0/p_srate
mkdir -p /sys/kernel/config/usb_gadget/g1/configs/c.1
echo 250 > /sys/kernel/config/usb_gadget/g1/configs/c.1/MaxPower
ln -s /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0 /sys/kernel/config/usb_gadget/g1/configs/c.1/
udevadm settle -t 5 || :
# End
ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/sonoDSP_audio/UDC
You can check f_uac1.c. For me it seems you can not change the gstrings on the fly for the predefined funcation f_uac.
static struct usb_string strings_uac1[] = {
[STR_AC_IF].s = "AC Interface",
...,
[STR_IO_IN_IT].s = "Capture Input terminal",
...,
{ }
};
What you can do is, creating a simple functionfs user space program with your custom configurations. See the following for further details on ffs.
How to load ffs?
See: https://github.com/linkjumper/configfs/blob/master/setup_usb_gadget.sh
Documentation on how to write a userspace functionfs:
See: linux/tools/usb/ffs-test.c. (Spoiler, those testfile did not work for all endpoints to me. But it is a good source as an example.)
It is a little work, but worth it.
I have a custom i.MX6 board, and I want to turn on a particular GPIO.
From the schematic, the GPIO pin is connected to KEY_COL2 pad, and the KEY_COL2 has the following options.
So, I have to export the following GPIO as per the calculation:
linux gpio number = (gpio_bank - 1) * 32 + gpio_bit
gpio number = ( 4 - 1 ) *32 +10 = 106
When I run the following command, i get the error:
# echo 106 > /sys/class/gpio/export
sh: write error: Device or resource busy
What can be the issue, am i missing anything...
After looking at the device tree, this particular GPIO was used by some other device, hence the error.
You can find the GPIO's in use with the following commands:
mount -t debugfs none /sys/kernel/debug
cat /sys/kernel/debug/gpio
I have a D525 Intel Atom (http://www.amazon.ca/Jetway-NF38QLB-525-Generation-Intel-1-80GHz13W/dp/B00ABZRTDU) which appears to have GPIO pins.
I am using the 4.2 Linux kernel and can see the directory /sys/class/gpio/ (this appeared after updating to 4.2) however I cannot seem to interact with the GPIOs. I have followed instructions here: https://www.ridgerun.com/developer/wiki/index.php/How_to_use_GPIO_signals however I just get the following error when trying to export the gpio
root#wheezy7.8:/# cd /sys/class/gpio/
root#wheezy7.8:/sys/class/gpio# GPIO=1
root#wheezy7.8:/sys/class/gpio# echo $GPIO > export
bash: echo: write error: Invalid argument
I have tried numerous pin numbers (1-32), but no luck...
Here is the output from modinfo gpio_ich
root#wheezy7.8:/sys/class/gpio# modinfo gpio_ich
filename: /lib/modules/4.2.0-040200-generic/kernel/drivers/gpio/gpio- ich.ko
alias: platform:gpio_ich
license: GPL
description: GPIO interface for Intel ICH series
author: Peter Tyser <ptyser#xes-inc.com>
srcversion: 338BC4F9B47008C478E28F3
depends:
intree: Y
vermagic: 4.2.0-040200-generic SMP mod_unload modversions 686
parm: gpiobase:The GPIO number base. -1 means dynamic, which is the default. (int)
I have also dumped the configuration (following instructions from the first link):
root#wheezy7.8:~$ mount -t debugfs none /sys/kernel/debug
root#wheezy7.8:~$ cat /sys/kernel/debug/gpio
GPIOs 462-511, platform/gpio_ich.1.auto, gpio_ich:
This seems to suggest that the pins are 462 to 511, which is not the case:
root#wheezy7.8:/sys/class/gpio# GPIO=462
root#wheezy7.8:/sys/class/gpio# echo $GPIO > export
bash: echo: write error: No such device
root#wheezy7.8:/sys/class/gpio# GPIO=511
root#wheezy7.8:/sys/class/gpio# echo $GPIO > export
bash: echo: write error: No such device
I am trying short.c in examples of Linux Device Driver 3
My PC has Parallel Port and after the Ubuntu boots up, I can see these:
cat /proc/ioports
0378-037a : parport0
037b-037f : parport0
outp 0x378 1
(outp is another example in LDD3 which write data to ports)
the LED on the port is ON.
Then I run these commands to remove modules
rmmod lp
rmmod parport_pc
cat /proc/ioports
(There is no module on 0378-037f any more.)
I run this again but the LED is not ON this time.
outp 0x378 1
Then I install short.ko and request_region() succeeds.
cat /proc/ioports
0378-037f : short
cat /proc/devices
249 short
outp 0x378 1
the LED is not ON this time either.
I tried these too, but same result (LED is not ON)
mknod /dev/short0 c 249 0
echo -n "a" > /dev/short0
"a" is 0x61 so that the last bit is 1.
Why can I not write data out though I have got the I/O region?
Thanks for your answer.
Finally, I found the solution.
Make sure the “parport” module is not loaded or compiled into your kernel. It is not enough to simply unload the parport module, as it leaves the ports in an inconsistent state. You must reboot the machine and keep the parport and all related modules/code from loading in the first place.
One way to do this is to edit the /etc/modprobe.d/blacklist.conf file and add the following lines:
blacklist ppdev
blacklist lp
blacklist parport_pc
blacklist parport
It seems that partport has modify the mode of parallel port.
And if cups is installed, you should modify /etc/modules-load.d/cups-filters.conf:
#lp
#ppdev
#parport_pc
Within a bash script, I use the following:
$ stty -F /dev/ttyUSB0 921600 raw
$ echo -n "some test data" >/dev/ttyUSB0
and it works as expected.
Using a PL2303 USB to RS232 adapter:
$ lsusb
...
Bus 006 Device 010: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 006 Device 011: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Now I tried to do the same with 1 MBd, but got an error:
$ stty -F /dev/ttyUSB0 1000000 raw
stty: /dev/ttyUSB0: unable to perform all requested operations
Also the same message when I try with 500 kBd. Trying 250 kBd the error message is different:
$ stty -F /dev/ttyUSB0 250000 raw
stty: invalid argument `250000'
Try `stty --help' for more information.
As seen here, it's a problem in the PL2303 linux driver.
I'm working on Kubuntu 12.04, 32 Bit. Unfortunally, I don't know how to fix that driver on my system (getting driver source, patch em, compile, install … hmm, maybe I learn a bit and give it a try - advice is welcome).
But maybe there is an updated driver avaliable which is easy to install?
Or does someone know an alternate USB to RS232 adapter which works at 1 MBd (hardware flowcontrol via rts/cts is needed, which works pretty well with the PL2303)?
After the realization that »Prolific and FTDI are competitors«, I bought Ftdi US232R-10 which is a FT232R based device and specified for 1 MBd transfer rate.
With this adapter I'd successfully tested communication at 1 MBd by transfering some GiB data without any error (including usage of Rts/Cts hardware flow control).
Configuring this device using stty like:
$ stty -F /dev/ttyUSB0 1000000 raw
works successfully.