Could not connect to wpa_supplicant: wlan0 - re-trying - linux

I work on embedded device and I am configuring the WLAN module (QCA6174 - ath10k driver) with wpa_supplicant.
I load the driver modules (backports-20151120):
insmod /lib/modules/3.10.65-b2196-h301/wlan/compat.ko;
insmod lib/modules/3.10.65-b2196-h301/wlan/cfg80211.ko;
insmod /lib/modules/3.10.65-b2196-h301/wlan/mac80211.ko;
insmod /lib/modules/3.10.65-b2196-h301/wlan/ath.ko;
insmod /lib/modules/3.10.65-b2196-h301/wlan/ath10k_core.ko skip_otp=y;
insmod /lib/modules/3.10.65-b2196-h301/wlan/ath10k_pci.ko
I start the wpa_supplicant (default wpa_supplicant.conf):
wpa_supplicant -dd -Dwext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B
[ 182.257304] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
everything seems to work fine. I see the wlan0 interface,I can scan with iwlist, /var/run/wpa_supplicant/wlan0 exist.
But I can not use wpa_cli interface:
#wpa_cli
wpa_cli v2.4
Copyright (c) 2004-2015, Jouni Malinen <j#w1.fi> and contributors
Selected interface 'wlan0'
Interactive mode
Could not connect to wpa_supplicant: wlan0 - re-trying
Do you have any hints how can I track down the problem ?

After issuing
strace wpa_cli -i wlan0
the problem with /tmp folder was reported:
bind(3, {sa_family=AF_FILE, path="/tmp/wpa_ctrl_1095-5"}, 110) = -1 EROFS (Read-only file system)
After mounting tmpfs:
mount -t tmpfs -o size=12m tmpfs /tmp/
everything works fine.

I solved this by running sudo wpa_cli -i wlan0 in response to the "Read-only file system" permissions error.
In contrast to the accepted answer, this does not carry the side-effect of altering the permissions of the directory mounted at /tmp/.
Thank you #BartlomiejGrzeskowiak. I did not know about strace.

Related

RTNETLINK answers: Device or resource busy; ifup: failed to bring up wlxf4f26d13b2bd

I'm trying to configure the network via /etc/network/interfaces here's my file:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug usb0
iface usb0 inet dhcp
# The wifi network interface
iface wlxf4f26d13b2bd inet manual
hwaddress ether 2a:bf:x9:53:38:9d
wpa-driver nl80211
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
but when I try to activate the device with ifup wlxf4f26d13b2bd I get:
> RTNETLINK answers: Device or resource busy ifup: failed to bring up
> wlxf4f26d13b2bd
I'm not using NetworkManager.
This is the verbose output of ifup:
ifup -v wlxf4f26d13b2bd
ifup: configuring interface wlxf4f26d13b2bd=wlxf4f26d13b2bd (inet)
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/macchanger
run-parts: executing /etc/network/if-pre-up.d/wireless-tools
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
wpa_supplicant: terminating wpa_supplicant daemon via pidfile /run/wpa_supplicant.wlxf4f26d13b2bd.pid
Stopped /sbin/wpa_supplicant (pid 1568).
wpa_supplicant: removing /run/sendsigs.omit.d/wpasupplicant.wpa_supplicant.wlxf4f26d13b2bd.pid
wpa_supplicant: wait for wpa_cli to attach
wpa_supplicant: wpa-driver nl80211
wpa_supplicant: /sbin/wpa_supplicant -s -B -P /run/wpa_supplicant.wlxf4f26d13b2bd.pid -i wlxf4f26d13b2bd -W -D nl80211 -c /etc/wpa_supplicant/wpa_supplicant.conf -C /run/wpa_supplicant
Starting /sbin/wpa_supplicant...
wpa_supplicant: creating sendsigs omission pidfile: /run/sendsigs.omit.d/wpasupplicant.wpa_supplicant.wlxf4f26d13b2bd.pid
wpa_supplicant: ctrl_interface socket located at /run/wpa_supplicant/wlxf4f26d13b2bd
/sbin/ip link set dev wlxf4f26d13b2bd address 2a:bf:x9:53:38:9d
RTNETLINK answers: Device or resource busy
ifup: failed to bring up wlxf4f26d13b2bd
I solved the issue. The problem was that it was trying to change the MAC address after the wpa_supplicant configuration; The order of commands in the file is not respected. The simple solution is either to set the mac address with pre-up macchanger -m inside the iface stanza or to invoke macchanger before wpa-supplicant.
Thanks!

How to check if /init starts /etc/inittab

I have an embedded ARM system with processor AT91SAM9G45.
System consists of two components:
Linux kernel (4.14.79)
Busybox 1.29.3 as initramfs image.
I connect to the device using putty and connecting to serial port.
When kernel starts, everything goes fine. Kernel unpacks initramfs image, all files are found and listed (I see it by debug messages). But when it starts /init, log messages are:
Freeing unused kernel memory: 384K
This architecture does not have kernel memory protection.
run_init_process BEFORE /init
run_init_process AFTER /init, result = 0
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004
/init is symlink to /bin/busybox. I tried to replace /init with /sbin/init, /bin/busybox, /linuxrc, but results are the same.
/etc/inittab file:
# Begin /etc/inittab
id::initdefault:
si::sysinit:/etc/init.d/rc S
#l0::wait:/etc/rc.d/init.d/rc 0
#l1::wait:/etc/rc.d/init.d/rc 1
#l2::wait:/etc/rc.d/init.d/rc 2
#l3::wait:/etc/rc.d/init.d/rc 3
#l4::wait:/etc/rc.d/init.d/rc 4
#l5::wait:/etc/rc.d/init.d/rc 5
#l6::wait:/etc/rc.d/init.d/rc 6
ca::ctrlaltdel:/sbin/shutdown -t1 -a -r now
su::once:/sbin/sulogin
1::respawn:/sbin/getty ttyS1 115200
2::respawn:/sbin/getty ttyS2 115200
3::respawn:/sbin/getty ttyS3 115200
4::respawn:/sbin/getty ttyS4 115200
5::respawn:/sbin/getty ttyS5 115200
6::respawn:/sbin/getty ttyS6 115200
# End /etc/inittab
/etc/init.d/rcS file (this file is allowed to execute):
#!/bin/busybox sh
echo "Hello world!"
I don't know if even /init process starts parsing /etc/inittab or it falls before getting /etc/inittab by some reasons I cannot find out. Maybe there are
some mistakes in my /etc/inittab and /etc/init.d/rcS files. Maybe there are some errors with terminal (/etc/init.d/rcS cannot write to stdout cause it's blocked, suspended, being used by another process and so on).
How to definitely get sured, that /etc/inittab is started?
Welcome to StackOverflow.
I see there is space between rc and S
si::sysinit:/etc/init.d/rc S
change it to
si::sysinit:/etc/init.d/rcS
let me know if it works.
/init is symlink to /bin/busybox.
The typical /init file in an initramfs built by Buildroot that incorporates Busybox is a script of seven lines:
#!/bin/sh
# devtmpfs does not get automounted for initramfs
/bin/mount -t devtmpfs devtmpfs /dev
exec 0</dev/console
exec 1>/dev/console
exec 2>/dev/console
exec /sbin/init $*
Note the comment ("devtmpfs does not get automounted for initramfs") and the mount command for /dev.
It's /sbin/init (rather than /init) that is linked to /bin/busybox.
IOW without the proper setup of the /dev directory, userland has no I/O capabilty.
Only after devtmpfs has been mounted should the init program in Busybox be executed, which will then access /etc/inittab.
See Is there a way to get Linux to treat an initramfs as the final root filesystem?
and
Make CONFIG_DEVTMPFS_MOUNT apply to initramfs/initmpfs

Kernel Panic - Not Syncing. Segfault at Init

I recently tried to install php5-gd package on my debian vmware server and it failed at libc6 - i386.
Afterwards every command other than CD caused a Segmentation fault and the server would no long boot, showing the following error
[ 4.808086] init[1]: segfault at 0 ip (null) sp bff4645c error 14 in init[8048000+8000]
[ 4.808372] Kernel panic - not syncing: Attempted to kill init!
[ 4.808442] Pid: 1, comm: init Not tainted 3.2.0-4-686-pae #1 Debian 3.2.65-1
[ 4.808512] Call Trace:
(Trace continued in this image
)
I am at a complete loss on what to do at this moment. Any help or direction would be appreciated
Edit: I've since uploaded debian-live-8.3.0-i386-standard to the vmware store and booted the broken vm with the live cd.
Now I am in the live cd terminal but not sure what to do next. I did a lsblk and noted that the broken vm's boot partition is sda > sda2 and that's all I have done so far. Do I need to mount this somewhere now?
Edit2: I've now mounted the broken partition into the live cd, however when I tried to chroot, I get Segmentation Fault:
# mkdir -p /mnt/tcs1/boot
# mount /dev/tcs1/root /mnt/tcs1
# mount /dev/sda1 /mnt/tcs1/boot
# mount -t proc none /mnt/tcs1/proc
# mount -o bind /dev /mnt/tcs1/dev
# mount -o bind /run /mnt/tcs1/run
# mount -o bind /sys /mnt/tcs1/sys
# chroot /mnt/tcs1 /bin/bash
# Segmentation fault
Solved:
I relinked ld-linux.so.2 to /lib/i386-linux-gnu/ld-2.19.so from a rescue CD and managed to chroot in

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.

How to get bluetooth serial port status under linux?

Getting status of serial ports (ttyS*) via linux terminal is simple:
sudo cat /proc/tty/driver/serial
Then it shows serinfo with list of all uarts with info about status and buffers. When I call
sudo cat /proc/tty/drivers
then I can see that rfcomm drivers are available:
rfcomm /dev/rfcomm 216 0-255 serial
And, of course, reading data comming from paired bluetooth device is not a problem.
The question is: how to get status of rfcomm serial ports (e.g. Blueotooth SPP devices)? Is this information available somewhere in the /proc directory like for ttyS* or could I use totally different way?
It depends what status you are looking for. The "rfcomm" command that comes with bluez does have some status info. It depends if that is adequate for you.
% rfcomm -h
RFCOMM configuration utility ver 4.101
Usage:
rfcomm [options] <command> <dev>
Options:
-i [hciX|bdaddr] Local HCI device or BD Address
-h, --help Display help
-r, --raw Switch TTY into raw mode
-A, --auth Enable authentication
-E, --encrypt Enable encryption
-S, --secure Secure connection
-M, --master Become the master of a piconet
-f, --config [file] Specify alternate config file
-a Show all devices (default)
Commands:
bind <dev> <bdaddr> [channel] Bind device
release <dev> Release device
show <dev> Show device
connect <dev> <bdaddr> [channel] Connect device
listen <dev> [channel [cmd]] Listen
watch <dev> [channel [cmd]] Watch

Resources