wpl_cli :not found with rooted android device? - android

i rooted my android device then i go to adb shell, then type su to enter wpa_cli. i surprise that this appeared : wpa_cli: not found although i get information when i type : wpa_supplicant?
i know that wpa_cli from same library wpa_supplicant?
from this link
android is linux based!! so why these commands can't be found in their kernel ?

Because wpa_supplicant is not a library, it's an executable. Brief introduction is here: http://en.wikipedia.org/wiki/Wpa_supplicant‎ and source code is here: https://github.com/android/platform_external_wpa_supplicant
Yes, wpa_cli is built from the same code base, but is not included on most phones. Android uses the wpa_crl.c/wpa_ctrl.h interface, not the command line utility wpa_cli.
The kernel doesn't contain commands and executables invoked through a shell.

Related

How to run a C program in adb shell?

So adb shell gives one a linux terminal into an android phone, when it is connected to a computer. One can run all the standard linux commands like ls and cat inside the android phone, and explore the android filesystem using the adb shell.
Now I wonder, is it possible to use a C/C++ compiler such as clang or gcc to compile and execute a C/C++ program in the android phone, as on linux? I am not talking about android app development here, I mean a linux command line C/C++ program for android. Also, can I use the C standard library and linux system calls such as fork(), exec(), kill(), and working with file descriptors, in the android adb shell, just as I would do it on linux?
Yes. You can . For that you need copy your compiler exe's to android file system. From there you can easily call. Same time make sure that all pre-builed libs in android PATH folder.

Wrapper library for avrdude

The problem:
Through an Android app, be able to programmatically verify arduino flash contents to ensure it has not been changed (maliciously)
I am able to do that with avrdude using the command as below in the android adb shell
avrdude -C/data/data/com.myapp.avrdude/local/etc/avrdude.conf -v -patmega2560 -cstk500v2 -P/dev/ttyACM0 -b115200 -D -Uflash:v:firmware.hex:i
This works well with arduino, but the problem comes in when I want to do the same with a board that uses an FTDI chip. When it's connected to the android device it does not show up in /dev/ location.
On a linux machine the arduino device appears as /dev/ttyACM0, and the FTDI device is /dev/ttyUSB0. The problem is the FTDI device does not appear on android therefore the avrdude command above becomes useless.
I do not want to build the kernel driver for FTDI as specified here
The approach I want to go with which I think is most viable is to find/build a simple java wrapper for avrdude that interacts with the usb device at a higher level, this way I can make use of the FTDI java library to execute a command to verify flash.
Is this approach viable? If not, what is the best way to approach this problem?
Looking at the FTDI site, it looks as though there may be a driver for some FTDI ICs: FTDI Android Driver
You may then well be building avrdude again in java ha.
I have used avrdude often when using arduino...mainly to remote re-format/upgrade firmware on a 3D printer from a raspberrypi...
I'd go
1) Look into the Arduino Driver...
2) if fail...Maybe try down the avenue of running C programs in java? So you can package avrdude with your app?
3) XY Problem -> Why not look at other avenues...The only way to really pop malicious firmware on is with physical access to the device and with a user that has the prior source code (you can set lock bits to prevent reading EEPROM). Even a timestamped and UUID 1024bit AES token/JWT like thing could be used on startup to verify the build?
https://en.wikipedia.org/wiki/Java_Native_Interface
building for JNI won't help while avrdude wasn't built with FTDI support.
I've downloaded avrdude-6.3.tar.gz and ran ./configure --enable-linuxgpio:
Configuration summary:
----------------------
...
DON'T HAVE libftdi1
DON'T HAVE libftdi
...
when looking for it:
$ sudo yum whatprovides */libftdi1
it gives me:
libftdi-devel-1.1-4.el7.x86_64 : Header files and static libraries for libftdi
Filename : /usr/include/libftdi1
sudo yum install libftdi-devel also installs libconfuse. it also needs flex and bison.
there are even drivers for D2XX and FT4222H.
see AN_357 Android D2XX Demo Application for FT4222H.
and there are builds for ARM libft4222-linux-1.4.1.231.tgz
... which would go into the jniLibs/armeabi directory.
it depends which chipset it is, but the TN 134 FTDI Android D2XX Driver states:
To accompany the native D2XX library, FTDI have provided a Java class and a JNI wrapper which can be
easily included in an application. The class provides access to all of the classic D2XX functions including
EEPROM functions.
it even comes with a video install guide.
also found the Arduino build-script for avrdude.

Android Device Driver make node

I have a course project that involves setting up a device driver on Android. I have previously worked with device drivers in the Linux kernel and we used two commands to initialize the device and make a node: insmod and mknod
Now when I launched the emulator shell using adb shell, I was able to use insmod but mknod did not work. I have tried to find alternatives but was not lucky.
From what I know, mknod in the Linux kernel lists the device under the /dev directory and allows user programs to read/write to it by using its file ops.
So what is its alternative for Android?
Perhaps, the android device you're using don't have mknod command. It need to be supported from rootfs, usually Android rootfs are built using busybox. Most probably, mknod was dropped from busybox config. Possible option could be, use custom Android image where you've mknod installed.

Android Systrace tool internally uses strace or ftrace?

Systrace Android tool calls internally a tool called atrace which is and extension of ftrace or strace (Linux tools).
If we connect via the emulator console (ADB shell) to Android Jelly Bean we can execute strace tool but we can not execute ftrace tool (command not installed).
Doing some reseach over the Internet I found that strace is a predecessor of ftrace:
http://crtags.blogspot.de/2012/04/dtrace-ftrace-ltrace-strace-so-many-to.html
Looking to Android Source Code, the most "internal" reference that I found is Trace.h file:
http://androidxref.com/4.1.1/xref/frameworks/native/include/utils/Trace.h
I think that this file is then resolved to a native Linux driver.
However, I'm still unable to know if this implementation driver belongs to strace or ftrace. "Normally", it should be ftrace because it is newer, but in that case I don't know why we can not run ftrace from the emulator. In contrast, strace is completely available from the emulator.
Then, does someone knows if Systrace Android tool uses at a very low level strace or ftrace?
Thank you!
I've follow the instructions found here, related to ftrace,:
http://www.linuxforu.com/2010/11/kernel-tracing-with-ftrace-part-1/
Everything works perfect. I wasn't able to execute ftrace before because interacting and retrieving data is done via logical paths.
To execute ftrace, after correctly configuration (many steps...), inside adb shell:
root#android:# cat /sys/kernel/debug/tracing/trace > mytracefile.txt
atrace makes configuration process easier, so we can access to trace information the following way:
root#android:# atrace -s -w -t 100 > mytracefile.txt
On the other hand, I've found information about executing strace here:
http://www.hokstad.com/5-simple-ways-to-troubleshoot-using-strace
All indicated examples were successfully executed in my environment using adb shell.
Interaction and access to results of both tools are very different.
Now I can say that systrace Android tool is based in atrace which in turn is based in ftrace.
strace is also supported but serves to another purposes and is not related to systrace.
Regards,

D2XX Sample for Android

Can anyone give me a step by step instruction on how to try the D2XX Sample on this one:
http://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_134_FTDI_Android_D2XX_Driver.pdf
im having troubles trying it on my device. as per requirement. my device is already rooted and i have also ndk-build the files but its showing force close when i ran the project.
Following are the steps you need to take in order to run the sample demo.
install the sample application on your android device.
connect your device via adb.
access your device using adb shell.
type cd /dev/bus/usb
then type ls
you should see directories such as 001 and 002.
go to each directory e.g., cd 001 .
then use the following command to give your application access to usb:
chmod 666 *
start your application and it should now detect your ftdi device and you would be able to transmit and receive data.
Install the application on your android box.

Categories

Resources