Using GPIO pins on Intel Atom D525 - linux

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

Related

Setting GPIO using sysfs fails in i.MX6

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

Enable monitoring mode for RTL8188CUS via USB on Raspbian

I am trying to enable monitoring mode for a USB wifi dongle with the RTL8188CUS chipset on a raspberry pi model b+ (or any raspberry pi for that matter).
$ lsusb
Bus 001 Device 005: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
$ sudo iwconfig wlan0 mode monitor
Error for wireless request "Set Mode" (8B06) :
SET failed on device wlan0 ; Invalid argument.
According to github/raspberrypi/linux/issues/369, you need to enable the rtlwifi/rtl8192cu kernel module that is included with the kernel distribution but not compiled. This requires minor modifications to some files as diff'ed below in 'STEP 2'.
The USB issue mentioned in that thread has been resolved as of 4.1.6+, so the rtlwifi driver should work.
Steps to recreate on a fresh raspberry pi (model B+)...
STEP 0: Update existing modules and kernel to latest
$ sudo apt-get update
$ sudo rpi-update
$ uname -a
Linux raspberrypi 4.1.7+ #815 PREEMPT Thu Sep 17 17:59:24 BST 2015 armv6l GNU/Linux
STEP 1: Get the raspbian kernel source and add missing dependencies
$ git clone --depth=1 https://github.com/raspberrypi/linux
$ sudo apt-get install bc lshw
STEP 2: Enable the rtlwifi (kernel) drivers for RTL8188CUS (RTL8192)
edit linux/drivers/net/wireless/Kconfig
-#source "drivers/net/wireless/rtlwifi/Kconfig"
-source "drivers/net/wireless/rtl8192cu/Kconfig"
+source "drivers/net/wireless/rtlwifi/Kconfig"
+#source "drivers/net/wireless/rtl8192cu/Kconfig"
(Wheezy) edit linux/drivers/net/wireless/Makefile
-#obj-$(CONFIG_RTLWIFI) += rtlwifi/
+obj-$(CONFIG_RTLWIFI) += rtlwifi/
(Jessie) edit linux/drivers/net/wireless/realtek/Makefile
-#obj-$(CONFIG_RTLWIFI) += rtlwifi/
+obj-$(CONFIG_RTLWIFI) += rtlwifi/
STEP 3: Compile and install kernel (took many hours)
Summarized from kernel building documentation .
$ cd linux
$ KERNEL=kernel
$ make bcmrpi_defconfig
$ make zImage modules dtbs
$ sudo make modules_install
$ sudo cp arch/arm/boot/dts/*.dtb /boot/
$ sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
$ sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
$ sudo scripts/mkknlimg arch/arm/boot/zImage /boot/$KERNEL.img
STEP 4: Reboot
$ sudo reboot
STEP 5: Check that the rtlwifi/rtl8192cu module is loaded
$ lsmod | fgrep rtl8192cu
rtl8192cu 100806 0
rtl_usb 14781 1 rtl8192cu
rtl8192c_common 72091 1 rtl8192cu
rtlwifi 101122 3 rtl_usb,rtl8192c_common,rtl8192cu
mac80211 623281 3 rtl_usb,rtlwifi,rtl8192cu
$
$ lshw
*-network:0
description: Ethernet interface
physical id: 1
bus info: usb#1:1.3
logical name: wlan0
serial: 00:0b:81:94:e9:a3
capabilities: ethernet physical
configuration: broadcast=yes driver=rtl8192cu driverversion=4.1.7+ firmware=N/A link=no multicast=yes
STEP 6: Try to activate monitoring mode
$ sudo iwconfig wlan0 mode monitor
Error for wireless request "Set Mode" (8B06) :
SET failed on device wlan0 ; Operation not supported.
What did i miss?
Issue 369 seems to indicate that it can work with the rtlwifi driver?
Turns out the steps to recompile and load the rtlwifi module are correct. The problem is iwconfig not working to enable/determine monitoring mode in this situation.
Instead, I used iw as outlined by Steven Gordon - Capturing WiFi in Monitor mode with iw and it worked.
To summarize:
STEP 6b: List the physical network interfaces available
$ iw dev
STEP 7: Determine if the physical interface supports monitoring mode
$ iw phy phy0 info
... lots of stuff ...
Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* monitor
* mesh point
* P2P-client
* P2P-GO
... lots more stuff ...
STEP 8: Add a monitoring interface to that physical card
You need to explicitly add a 'monitoring' interface for the hardware you have.
$ sudo iw phy phy0 interface add mon0 type monitor
STEP 8: Start monitoring
In my case, I'm using tshark to facilitate monitoring, displaying a few useful fields rather than a lot of noise.
$ sudo apt-get install tshark
$ sudo tshark -i mon0 -f 'broadcast' -T fields -e frame.time_epoch -e wlan.sa -e radiotap.dbm_antsignal -e wlan.fc.type -e wlan.fc.subtype
Done.
For anyone still interested, the rtl8192cu is now compiled into the raspberry kernel by default. It can be activated by commenting out the blacklist in /etc/modprobe.d/blacklist-rtl8192cu.conf. Executing sudo iwconfig wlan0 mode monitor after a reboot will activate monitoring mode without any further problems.

alsa tool arecord not recognizing plughw:1,0 on Arch Linux

Edit: All of this was probably caused by a terribly configured microphone (or a faulty one, I changed laptops and now use Ubuntu instead of Arch Linux, so I actually don't have any idea). To record to a wav file, all I do now is run:
arecord -d $DURATION -f cd -t wav $OUTPUT_FILE_PATH
...replacing $DURATION with the duration of the recording in seconds, and $OUTPUT_FILE_PATH with the path to the desired file to write. I omitted the -D sysdefault argument as it caused problems for me (as with most things, your mileage may vary, so if the command doesn't work for you, try playing with several variables until it works).
Goes without saying, but all of this requires alsa-utils to be installed.
(The original question is left below, for those that still want to see it.)
Tl;dr version: arecord not recognizing plughw:1,0 , nor hw:1,0 , nor anything without the -D option
Whole story: I'm trying to make a simple voice assistant using a Bash script (I don't find Python/Perl easy for me to use, but that's just me). Dialogs are made in Zenity/KDialog. Voice recognition isn't included yet, so one has to type in the phrase/command. For now the program is represented in Spanish, but I plan to have an English version as well.
Doing my research, I found: http://blog.oscarliang.net/raspberry-pi-voice-recognition-works-like-siri/
But it doesn't work correctly on my machine.
[owner#arch-hp-2000-notebook-pc ~]$ ~/test-speech-input
“Recording… Press Ctrl+C to Stop.”
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM “plughw:1,0″
arecord: main:722: audio open error: No such file or directory
“Processing…”
^C
[owner#arch-hp-2000-notebook-pc ~]$
It apparently has to do with the arecord -D "plughw:1,0" -q -f cd -t wav part.
Output of arecord -l:
[owner#arch-hp-2000-notebook-pc ~]$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: Generic_1 [HD-Audio Generic], device 0: ALC269VC Analog [ALC269VC Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
Output of arecord -L:
[owner#arch-hp-2000-notebook-pc ~]$
null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
default
Default ALSA Output (currently PulseAudio Sound Server)
sysdefault:CARD=Generic_1
HD-Audio Generic, ALC269VC Analog
Default Audio Device
front:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
Front speakers
surround21:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Generic_1,DEV=0
HD-Audio Generic, ALC269VC Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
[owner#arch-hp-2000-notebook-pc ~]$
Following the first part of the answer by #CharlesDuffy (thanks for the help):
[owner#arch-hp-2000-notebook-pc ~]$ ~/test-speech-input
Recording… Press Ctrl+C to Stop.
Processing…
You Said: [owner#arch-hp-2000-notebook-pc ~]$
Following the new answer, also by #CharlesDuffy (although this system is all AMD I think, no intel):
[owner#arch-hp-2000-notebook-pc ~]$ test-speech-input
Recording… Press Ctrl+C to Stop.
ALSA lib pcm.c:2267:(snd_pcm_open_noupdate) Unknown PCM CARD=Generic_1
arecord: main:722: audio open error: No such file or directory
Processing…
You Said: [owner#arch-hp-2000-notebook-pc ~]$
Following the newest answer by #CharlesDuffy:
[owner#arch-hp-2000-notebook-pc ~]$
Recording… Press Ctrl+C to Stop.
ALSA lib pcm_dsnoop.c:614:(snd_pcm_dsnoop_open) unable to open slave
arecord: main:722: audio open error: No such file or directory
Processing…
^C
[owner#arch-hp-2000-notebook-pc ~]$
Double-checked the volume of the internal mic, and it seemed to have selected a non-existent mic. Switching to the real mic yielded the same results.
I'm lost right now. Any other ideas? Is there any other command-line voice recording tool that might work or that might be easier to use (at least for me)?
Machine: HP 2000 Notebook PC, Arch Linux, uname -a returns Linux HOST_NAME 4.1.2-2-ARCH #1 SMP PREEMPT Wed Jul 15 08:30:32 UTC 2015 x86_64 GNU/Linux
The plughw:1,0 suggestion is specific to Raspberry Pi hardware, and doesn't necessarily apply elsewhere.
The first thing I'd suggest is removing the -D DEVICE argument entirely.
If that doesn't work, I'd suggest trying:
-D sysdefault
...for your basic on-board audio, as listed by arecord -L.

alsa on embedded system CORE9G25

I have a CORE9G25-CON (256MBRAM) (http://armdevs.com/core9g25.html) device with embedded linux installed on it.
The version of linux is:
# uname -or
3.6.9 GNU/Linux
# cat /etc/os-release
NAME=Buildroot
VERSION=2012.11.1-dirty
ID=buildroot
VERSION_ID=2012.11.1
PRETTY_NAME="Buildroot 2012.11.1
The device is equipped with USB host connector in which I connected an USB-AUDIO interface
The USB interface is recognize by the system
# cat /proc/asound/cards
0 [Device ]: USB-Audio - USB PnP Sound Device
C-Media Electronics Inc. USB PnP Sound Device at usb-at91-1, full speed
# cat /proc/asound/devices
0: [ 0] : control
16: [ 0- 0]: digital audio playback
24: [ 0- 0]: digital audio capture
33: : timer
# ls /dev/snd
controlC0 pcmC0D0c pcmC0D0p timer
I would like to handle the AUDIO interface by using ALSA but this is the error shown on the console by using the simple command aplay -l
# aplay -l
**** List of PLAYBACK Hardware Devices ****
ALSA lib control.c:739:(snd_ctl_open_noupdate) Invalid CTL hw:0
aplay: device_list:226: control open (0): No such file or directory
aplay: conf.c:3095: snd_config_update_free: Assertion `update->count > 0 && update->finfo' failed.
Aborted
I googled for about a week trying to fix the problem but, up to now, i didn't find any solution.
Could you help me to fix the problem ?
Had you other similar experience about it ?
Thank you very much for your help and cooperation
best regards
What does your alsa.conf look like ? do this
locate alsa.conf
typically found at
/usr/share/alsa/alsa.conf
do a google on
audio sound alsa Invalid CTL hw:0
this might get you on the right path
#alsa.conf minimal configuration
ctl.hw {
#args [ CARD ]
#args.CARD {
type string
}
type hw
card $CARD #with 0 alsamixer work, with $CARD alsamixer lend to invalid argument
}

writing in /sys/bus/pci/... fails

Attempt to run the following command with root privilege on kernel 2.6.35 results in error:
% echo 0000:00:03.0 > /sys/bus/pci/drivers/foo/bind
-bash: echo: write error: No such device
UPDATE
The device does exist in /sys/bus/pci/devices/ the output of lspci is as follows:
% lspci -v -s 0000:00:03.0
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
Subsystem: Intel Corporation PRO/1000 MT Desktop Adapter
Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 10
Memory at f0000000 (32-bit, non-prefetchable) [size=128K]
I/O ports at d010 [size=8]
Capabilities: <access denied>
Kernel driver in use: e1000
I think I resolved the issue. It appears that the driver requires to unbind device at first.
It also appears that the shell processes redirection (echo .. > /sys/bus/..) with user permission, and 'sudo' handles only the command, i.e. 'echo' but not the whole command line that follows it, therefore it has to be executed this way:
% sudo sh -c "echo 0000:00:03.0 > /sys/bus/pci/drivers/foo/unbind"
% sudo sh -c "echo 0000:00:03.0 > /sys/bus/pci/drivers/foo_new/bind"

Resources