2013년 12월 22일 일요일

USB vid/pid를 이용해서 장치 연결 상태 알아내기

USB 장치 중에 vid가 0bda이고 pid가 8176인 장치가 연결되어 있는지 알아 보는 방법입니다.

USB node는 /sys/bus/usb/devices/ 에 생성되고 idVendoridProuct를 읽어보면 됩니다.

{
    DIR *dir = opendir("/sys/bus/usb/devices/");
    struct dirent *dent;
    if (dir != NULL) {
        while ((dent = readdir(dir)) != NULL) {
            char node[50] = {'\0',};
            sprintf(node, "/sys/bus/usb/devices/%s/idVendor", dent->d_name);
            int vid_fd = open(node, O_RDONLY);
            char buf[5];
            if (vid_fd > 0) {
                read(vid_fd, buf, 4);
                ALOGE("node = %s, vid = %s", node, buf);
                if (strcmp(buf, "0bda") == 0) {
                    sprintf(node, "/sys/bus/usb/devices/%s/idProduct", dent->d_name);
                    int pid_fd = open(node, O_RDONLY);
                    read(pid_fd, buf, 4);
                    ALOGE("node = %s, pid = %s", node, buf);
                    if (pid_fd > 0) {
                        if (strcmp(buf, "8176") == 0) {
                            //pid가 8176인 장치가 연결되어 있음
                            break;
                        }
                        close(pid_fd);
                    }  
                }  
                close(vid_fd);
            }  
        }  
    }  
    close(dir);
}

2013년 12월 11일 수요일

AOSP build and run emulator(Android Virtual Device)

1. Download android source code.

http://source.android.com/source/downloading.html

$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.4_r1.2
$ repo sync

2. Build

$ source build/envsetup.sh
$ lunch
You're building on Linux

Lunch menu... pick a combo:
     1. aosp_arm-eng
     2. aosp_x86-eng
     3. aosp_mips-eng
     4. vbox_x86-eng
     5. mini_mips-userdebug
     6. mini_armv7a_neon-userdebug
     7. mini_x86-userdebug
     8. aosp_manta-userdebug
     9. aosp_grouper-userdebug
     10. aosp_flo-userdebug
     11. aosp_deb-userdebug
     12. aosp_tilapia-userdebug
     13. aosp_mako-userdebug
     14. aosp_hammerhead-userdebug

Which would you like? [aosp_arm-eng] 1

============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.4
TARGET_PRODUCT=aosp_arm
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
TARGET_CPU_VARIANT=generic
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-3.11.0-14-generic-x86_64-with-Ubuntu-13.10-saucy
HOST_BUILD_TYPE=release
BUILD_ID=KRT16S
OUT_DIR=out
============================================

[~/projects/android_kitkat]$ make -j8


....

k-r8e/:/opt/toolchains/arm-eabi-4.6/bin/:/opt/toolchains/arm-2010q1/bin:/usr/bin/:/usr/lib/ccache
+ ENABLE_SPARSE_IMAGE=
+ '[' out/target/product/generic/system = -s ']'
+ '[' 6 -ne 5 -a 6 -ne 6 ']'
+ SRC_DIR=out/target/product/generic/system
+ '[' '!' -d out/target/product/generic/system ']'
+ OUTPUT_FILE=out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img
+ EXT_VARIANT=ext4
+ MOUNT_POINT=system
+ SIZE=576716800
+ FC=out/target/product/generic/root/file_contexts
+ case $EXT_VARIANT in
+ '[' -z system ']'
+ '[' -z 576716800 ']'
+ '[' -n out/target/product/generic/root/file_contexts ']'
+ FCOPT='-S out/target/product/generic/root/file_contexts'
+ MAKE_EXT4FS_CMD='make_ext4fs  -S out/target/product/generic/root/file_contexts -l 576716800 -a system out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/generic/system'
+ echo make_ext4fs -S out/target/product/generic/root/file_contexts -l 576716800 -a system out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/generic/system
make_ext4fs -S out/target/product/generic/root/file_contexts -l 576716800 -a system out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/generic/system
+ make_ext4fs -S out/target/product/generic/root/file_contexts -l 576716800 -a system out/target/product/generic/obj/PACKAGING/systemimage_intermediates/system.img out/target/product/generic/system
Creating filesystem with parameters:
    Size: 576716800
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 7040
    Inode size: 256
    Journal blocks: 2200
    Label:
    Blocks: 140800
    Block groups: 5
    Reserved block group size: 39
Created filesystem with 1262/35200 inodes and 81852/140800 blocks
+ '[' 0 -ne 0 ']'
Install system fs image: out/target/product/generic/system.img
out/target/product/generic/system.img+ maxsize=588791808 blocksize=2112 total=576716800 reserve=5947392
[~/projects/android_kitkat]$

3. Install eclipse and adt
http://developer.android.com/sdk/installing/installing-adt.html

4. Install android sdk
https://developer.android.com/sdk/index.html

5. Android SDK Manager
update API 19

6. Change your output images.
$ [~/android-sdks/system-images/android-19]$ cd armeabi-v7a/
[~/android-sdks/system-images/android-19/armeabi-v7a]$ ls
build.prop   NOTICE.txt   source.properties  userdata.img
kernel-qemu  ramdisk.img  system.img

7. Make avd




8. Run AVD


2013년 12월 9일 월요일

Exynos4412 Android-4.1.2 (Beta 2.1.0) Release

29-Jun-2014
1. fix EDID
2. enable MTP
3. fix uboot to enable cm bootstrap.

Download for eMMC user.

https://www.dropbox.com/sh/vjplveim5ieq91e/jUSKWcmjw4

How to connect ODROID to Ubuntu using MTP
http://codewalkerster.blogspot.kr/2014/01/how-to-connect-odroid-to-ubuntu-using.html

19-Dec-2013
1. enable /dev/CEC node.
2. enable HDMI-EDID/CEC

https://www.dropbox.com/s/7nhmnnssuekk50n/odroidu-1.9.0.zip


http://dn.odroid.com/Android_Beta_1.9.0/

수정사항
1. Q/Q2 부팅 시 죽는 문제 수정
2. SD/eMMC 를 하나의 커널로 통합.
3. ODROID-U2를 ODROID-U로 변경

업그레이드 방법
1. X/X2/Q/Q2는 기존 방법처럼 아래와 같이 진행
http://codewalkerster.blogspot.kr/2013/05/odroid-update-and-install-gms.html

2. U2는 microSD일 경우 아래 이미지를 write하고 부팅
http://dn.odroid.com/Android_Beta_1.9.0/U/SD/
eMMC일 경우 아래 이미지를 write 하고 부팅 하면 자동 복구 후 부팅
http://dn.odroid.com/Android_Beta_1.9.0/U/eMMC_installer/

Google Mobile Service(GMS) 설치는 아래와 같이 One Click gapps installer에서 4.1.2를 선택.
http://codewalkerster.blogspot.kr/2013/11/universal-1-click-gapps-installer-for.html