lunes, 22 de abril de 2013

HTC Incredible S (???????????? - no permissions)

Unlike other popular devices (e.g. S2 i9100), some HTC phones require certain configuration in order to work properly under the context of Linux (e.g Ubuntu Quantal Quetzal).

#Android SDK is required to use "adb" 
$ adb devices
List of devices attached
???????????? no permissions 

In the case of HTC Incredible S, hardware definition is needed.


$ lsusb
Bus 001 Device 009: ID 0bb4:0cac HTC (High Tech Computer Corp.)

where

"obb4" is the vendor ID
"0cac" is the product ID

Create or edit the following file

$ sudo gedit /etc/udev/rules.d/51-android.rules

Add the following line and save it

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0cac", MODE="0666"

Restart the service

$ sudo restart udev
$ adb devices
List of devices attached
HT13WRD00413    device  

You may need to unplug the device from your computer before restarting the service. Restarting adb may be also needed ($adb kill-server/start server). More HTC configurations can be found in this link

martes, 12 de febrero de 2013

Arduino Mega ADK - Fundamentals


Requirements

Hardware
     1. Arduino Mega ADK
     2. Wifi-shield
     3. Mega Sensor shield
     4. Wifi Module

Tinker-kit also comes with several micro mechanical sensors such as accelerometer, photo-resistor, among others. Each sensor can be connected to the Mega sensor shield in order to sense environmental data.

Software

HTerm (for configuring Arduino WiFi)
Eclipse ( IDE for Android application development)

Assemble the follow structure (from top to bottom)
Wifi-Module -> Wifi-shield -> Micro controller


Configure Wifi Module and Establish Android Communication

/*
* author Huber Flores
*/
### Getting Arduino ready for HTerm
# 1- Set your Wifi Shield to USB (It’s a small switch on you WiFi Shield).
# 2- Upload BareMinimum sketch to your Arduino ((File->Examples->Basic->BareMinimum).
# 3- Open HTerm.
### Connect with following settings
# Port = Port, that you arduino is connected to
# Baud = 9600
# Data = 8
# Stop = 1
# Parity = None
# CTS Flow control = unchecked
### Set up new Baud rate, by typing in the following into Input control box
$ $$$ (Send or enter = None)
$ set u b 115200 (Send or enter = CF-LF from now on)
$ save
$ reboot
###Connecting Arduino to WiFi
# Connect as you did before, only set Baud to 115200
# Enter command mode(type $$$ (send on enter = None))
$ Set “Send or enter” to CF-LF
# Type “scan” (you should now see a list of WiFi networks available)
$ set wlan ssid <your wifi name>
$ set wlan pass <your wifi password>
$ save
$ reboot
# if configuration is successful then, Wifi Shield and led from Wifi module must be blinking
### Set up Arduino to communicate with Android
# Enter command mode
$ set ip remote 2000
$ set ip proto 1
$ comm times 1000
$ get ip
$ set ip host <your android ip address>
$ save
$ reboot
view raw arduino.as hosted with ❤ by GitHub


Once you established communication with Android, then you are ready to start developing Arduino sketches and your Android app.

Here some code to try

martes, 5 de febrero de 2013

Building Isolated Dalvik Machine

/*
* author Huber Flores
*/
#We also can provide you with Amazon image (AMI) public with Android x86
#Please contact to huber AT UT DOT ee for granting access
# CyanogendMod/Android environment must be set up first
# refer to CM7Guide (https://gist.github.com/huberflores/4687766)
$ cd ./android/system/
$ . build/envsetup.sh
$ lunch
.
.
103. cyanogen_espresso-eng
104. cyanogen_fascinatemtd-eng
105. cyanogen_galaxys2-eng (This one)
106. cyanogen_galaxys2att-eng
.
.
Which would you like? [full-eng] 105
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.7
TARGET_PRODUCT=cyanogen_galaxys2
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GINGERBREAD
============================================
# After environment is configured
$ make -j10 libdvm
or
$ make dalvikvm dalvik
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.3.7
TARGET_PRODUCT=cyanogen_galaxys2
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GINGERBREAD
============================================
.
.
.
Install: out/host/linux-x86/bin/apriori
Install: out/host/linux-x86/bin/soslim
Copy: out/host/linux-x86/usr/icu/icudt44l.dat
Copy: out/host/linux-x86/etc/security/cacerts.bks
Install: out/host/linux-x86/lib/libcrypto.so
Install: out/target/product/galaxys2/system/lib/libdl.so
Install: out/target/product/galaxys2/system/lib/libc.so
Install: out/target/product/galaxys2/system/lib/libstdc++.so
Install: out/target/product/galaxys2/system/lib/libm.so
Install: out/target/product/galaxys2/system/lib/liblog.so
Install: out/target/product/galaxys2/system/lib/libz.so
Install: out/target/product/galaxys2/system/lib/libicuuc.so
Install: out/target/product/galaxys2/system/lib/libexpat.so
Install: out/target/product/galaxys2/system/lib/libcutils.so
Install: out/target/product/galaxys2/system/lib/libcrypto.so
Install: out/target/product/galaxys2/system/lib/libicui18n.so
Install: out/target/product/galaxys2/system/lib/libssl.so
Install: out/target/product/galaxys2/system/lib/libutils.so
Install: out/host/linux-x86/lib/libssl.so
Install: out/target/product/galaxys2/system/lib/libsqlite.so
Install: out/target/product/galaxys2/system/lib/libnativehelper.so
Install: out/target/product/galaxys2/system/lib/libdvm.so ###Dalvik engine for Galaxy S2 i9100###
Install: out/host/linux-x86/lib/libicuuc.so
Install: out/host/linux-x86/lib/libicui18n.so
Install: out/host/linux-x86/lib/libdvm.so ###Dalvik engine for x_86###
<
(optional)
# Android x86
$ ./out/host/linux-x86/bin/dalvikvm
# Launch script for the Dalvik Virtual Machine in x86
# Here you actually could wrap .class files into .dex files and execute them within your computer :)
>
# Replace libdvm.so in your phone
# Plug galaxys2 (in my case :P) phone to your computer
$ adb root
adbd is already running as root
$ adb remount
remount succeeded
$ adb push ./android/system/out/target/product/galaxys2/system/lib/libdvm.so /system/lib/liddvm.so
3990 KB/s (671576 bytes in 0.164s)
$ adb reboot
Your phone will restart with the new Dalvik engine
view raw dalvik.as hosted with ❤ by GitHub

jueves, 31 de enero de 2013

Building CyanogenMod 7.2 from source for Samsung Galaxy S2 i9100

/*
* author Huber Flores
*/
### CyanogendMod7.2
### Builded in 64 bits Machine with Ubuntu quantal quetzal 12.10
# Install android SDK
# Download version x86_64
# Tutorial http://developer.android.com/sdk/index.html
### Install dependencies
$ sudo apt-get update
$ sudo apt-get install zip build-essential curl git-core \
python gcc patch flex bison gperf \
g++ squashfs-tools \
ia32-libs g++-multilib zlib1g-dev \
lib32z1-dev lib32ncurses5-dev \
gcc-multilib libwxgtk2.8-dev \
tofrodos texinfo mtools ccache \
gnupg libc6-dev x11proto-core-dev \
libx11-dev lib32readline-gplv2-dev \
libgl1-mesa-dev libxml2-utils
$ sudo apt-get install gnupg flex bison gperf build-essential squashfs-tools \
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386
$ sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev \
libwxgtk2.8-dev squashfs-tools zip pngcrush schedtool libxml2 xsltproc
# 64 bits dependecies
$ sudo apt-get install lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev \
gcc-4.7-multilib g++-4.5-multilib
# Install java
# Java SE 1.6 is required (other version, even greater is not accepted by the compiler)
# Download jdk-6u34-linux-x64.bin
$ chmod +x jdk-6u34-linux-x64.bin
$ sudo ./jdk-6u34-linux-x64.bin
$ sudo mv jdk1.6.0_34 /usr/lib/jvm/
$ sudo apt-get install update-java
$ sudo update-java (Choose your java version, if you have more installed)
### Set up environment (Follow the instructions to have similar environments)
$ mkdir CyanogenModBuild
$ cd CyanogenModBuild
$ mkdir environment
$ cd environment
$ mkdir ~/bin
$ mkdir ~/android/system
# Install repo command in /bin
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
# Open your bashrc file (in my case)
$ cd /homer/huber
$ nano .bashrc
# add the following line at the end
export PATH=$PATH:/home/huber/android-linux-x86_64/sdk/platform-tools:/home/huber/Desktop/CyanogenModBuild/environment/bin
export USE_CCACHE=1
# Now you can call $ repo and $ adb from any location
# Initialize repository
$ cd ./android/system
$ repo init -u git://github.com/CyanogenMod/android.git -b gb-release-7.2
# it will take time
# Once finished, then synchronize repositories (-j16 is for the number of concurrent threads)
$ repo sync -j16
# Copy proprietary files from the device
# Plug the device to your computer
$ cd ~/android/system/device/samsung/galaxys2/
$ ./extract-files.sh
# No missing files or errors should appear. If some files are missing, then you can try to find the missing file by downloading a stable CyanogenMod ROM (http://get.cm/?device=galaxys2&type=stable, cm-7.2.0-galaxys2.zip)
# Download the ROM Manager
$ cd ./android/system/vendor/cyanogen/
$ ./get-rommanager
# Synchronize again for updates
$ cd ~/android/system/
$ repo sync
# Build CyanogenMod7.2
$. build/envsetup.sh
$ brunch galaxys2
# Possible errors may appear
1)
Unknown parameter xmlns for tags/attrs...
make: *** [out/target/product/galaxys2/obj/STATIC_LIBRARIES/libwebcore_intermediates/WebCore/XMLNSNames.cpp] Error 255
# [SOLVED]: This is a bug from GCC 4.7, try to downgrade GCC to 4.5 or 4.6.2
# if you have 4.7 already installed, then install 4.5 or 4.6. Later, switch between compilers with the update-alternatives command, below procedure
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 47
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 46
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.5 45
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.7 47
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 46
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.5 45
$ sudo update-alternatives --config gcc
There are 3 choices for the alternative gcc (providing /usr/bin/gcc).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/gcc-4.7 47 auto mode
* 1 /usr/bin/gcc-4.5 45 manual mode
2 /usr/bin/gcc-4.6 46 manual mode
3 /usr/bin/gcc-4.7 47 manual mode
In short, both, GCC and G++ should have same version (e.g 4.5)
2)
# Missing prop files dependecies
# Extract them from the stable version as discussed before
3) Cloud issue (Amazon - Generic Ubuntu)
# The following packages have unmet dependencies:
# ia32-libs : Depends: ia32-libs-multiarch but it is not installable
# E: Unable to correct problems, you have held broken packages.
# [SOLVED]:
# Enable the installation of i386 packages on your 64 bits system:
$ dpkg --add-architecture i386
$ apt-get update
# Once the compilation process has finished, copy the ROM to your internal sdcard cm-7-20130131-UNOFFICIAL-galaxys2.zip (location:/android/system/out/target/product/galaxys2/)
### Flash the ROM in the device (Remember to have a backup)
# Open CWM
# Choose install zip from internal sdcard
# Install ROM cm-7-20130131-UNOFFICIAL-galaxys2.zip
# Wipe factory
# Wipe cache
# Restart device