2016년 2월 25일 목요일

Google Play Store on ODROID-C2.






Visit http://dn.odroid.com/GAPPS and download GAppsInstaller_lollipop.apk

Install




Rebooted and log in google.

 Check Play store version.

If you Installed youtube app, You must update Google Play services too.


If you update Google Play service, You will go though this situation.
I do not have solution for that. You must reinstall android image.

Check Play store version like this. Play store will update automatically.


Fist Update Google Store and must update Google Play Services later.

2016년 2월 23일 화요일

Ctrl + Alt + Del doesn't reboot Android


















echo 0 > /proc/sys/kernel/ctrl-alt-del

Or edit init.xxx.rc

 write /proc/sys/kernel/ctrl-alt-del 0

2015년 12월 28일 월요일

overscan for ODROID-C1 Ubuntu


1. search overscan values.

Read default values
root@odroid:~# cat /sys/class/graphics/fb0/window_axis
window axis is [100 100 1919 1079]
root@odroid:~#

Try to set overscan values
root@odroid:~# echo 100 100 1919 1079 > /sys/class/graphics/fb0/window_axis
root@odroid:~# echo 0x10001 > /sys/class/graphics/fb0/free_scale


2. make script(overscan.sh)

root@odroid:~# cat overscan.sh
#!/bin/bash

echo 100 100 1919 1079 > /sys/class/graphics/fb0/window_axis
echo 0x10001 > /sys/class/graphics/fb0/free_scale 

root@odroid:~#

3. Auto-start overscan shell script on Ubuntu.

root@odroid:~# cp overscan.sh /etc/init.d/
root@odroid:~# sudo update-rc.d overscan.sh defaults 



left : 10
right : 1919
top : 10
bottom : 1070

2015년 10월 12일 월요일

안드로이드 repo 특정 날짜로 돌려서 빌드하기

급하게 아래 안드로이드 project를 build 해야 할 일이 생겼다.

https://github.com/voodik/android/tree/cm-12.1_5422

오래전에 받아 놓은 소스를 repo sync 후 빌드 하니 역시나 컴파일 에러가 난다.

git log를 보면 계속 작업을 진행하였지만 release한 버전에 tag가 없다. 그래서 원하는 버전으로 돌리기가 어렵다.

아래 포럼에 보면 마지막 7월 7일이 마지막 버전이다.
http://forum.odroid.com/viewtopic.php?f=94&t=9316

googling 하여 보니 git rev-list를 통해 특정 날짜로 돌릴 수 있다. 그래서 아래와 같이 모든 프로젝트를 7월 7일로 돌렸다.

우선 manifest를 7월 7일로 돌린다.
$ cd .repo/manifsets/
$ git rev-list -n 1 --before="2015-07-07 24:00:00" default | xargs -i git reset --hard {}

돌린 default.xml을 복사하여 둔다/
$ cp default.xml ../default_0707.xml

다시 마지막으로 원복시킨다.
$ git reset --hard origin/cm-12.1_5422

그리고 7월 7일 내용을 하나의 commit으로 올린다.
$ mv ../default_0707.xml default.xml
$ git add default.xml
$ git commit
$ repo sync

위와 같이 하지 않으면 repo sync시 다시 최신 소스로 돌아가 버린다.

마지막으로 모든 프로젝트도 동일하게 7월 7일로 reset 한다.

$ repo forall -c 'git rev-list -n 1 --before="2015-07-07 24:00:00" cm-12.1_5422 | xargs -i git reset --hard {}'

빌드를 진행한다.

2015년 9월 2일 수요일

Shell Scripting: Generate or Print Range of Numbers ( Sequence of Numbers for Loop )

seq를 이용하여 범위의 값을 아래와 같이 얻어 올 수 있다.

$ seq 1 10
1
2
3
4
5
6
7
8
9
10
$

seq man page
SEQ(1)                                                                                        User Commands                                                                                        SEQ(1)

NAME
       seq - print a sequence of numbers

SYNOPSIS
       seq [OPTION]... LAST
       seq [OPTION]... FIRST LAST
       seq [OPTION]... FIRST INCREMENT LAST

DESCRIPTION


seq를 통해 얻어온 값을 for loop에 넣어서 원하는 로직을 만들 수 있다.
$ for i in $(seq 1 10)
> do
> echo $i
> done
1
2
3
4
5
6
7
8
9
10

$ for i in $(seq 1 10)
> do
> echo $i > export
> done


2015년 8월 25일 화요일

Android File Chooser and URI to File Path.

파일을 Intent.ACTION_GET_CONTENT을 이용하여 선택하고 URIFile Path로 변환하기

Image 나 Video 같은 파일을 얻어오는 예제는 많지만 일반 파일을 선택하는 예제가 없어서 며칠 찾아 보다가 직접 external.db에서 값을 얻어와야 한다는 결론을 얻었습니다.

/data/data/com.android.providers.media/databases 경로에 가면 모든 파일을 DB로 관리합니다.

root@odroidc:/data/data/com.android.providers.media/databases # ls -l
-rw-rw---- u0_a4    u0_a4      163840 2015-08-25 03:23 external.db
-rw-rw---- u0_a4    u0_a4       32768 2015-08-25 03:21 external.db-shm
-rw-rw---- u0_a4    u0_a4       28872 2015-08-25 03:21 external.db-wal
-rw-rw---- u0_a4    u0_a4      212992 2015-08-20 06:22 internal.db
-rw------- u0_a4    u0_a4       32768 2015-08-25 03:21 internal.db-shm
-rw------- u0_a4    u0_a4      453232 2015-08-25 03:21 internal.db-wal
root@odroidc:/data/data/com.android.providers.media/databases #

external.db를 sqliteman 프로그램을 이용하여 열어 보시면 아래와 같이 되어 있습니다.
files 테이블에 '_data'란 column에 실제 file path가 들어 있습니다.



private static final int FILE_SELECT_CODE = 0;

private void showFileChooser() {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_GET_CONTENT);

아래와 같이 할 경우 mime-type에 해당하는 파일만 선택 가능해 집니다.
    intent.setType("application/zip");
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    try {
        startActivityForResult(
                Intent.createChooser(intent, "Select a File"),
                FILE_SELECT_CODE);
    } catch (android.content.ActivityNotFoundException ex) {
        // Potentially direct the user to the Market with a Dialog
        Toast.makeText(this, "Please install a File Manager.",
                Toast.LENGTH_SHORT).show();
    }
}

showFileChooser()를 실행하면 아래와 같은 file dialog가 실행 됩니다.


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case FILE_SELECT_CODE:
            if (resultCode == RESULT_OK) {
                // Get the Uri of the selected file
                Uri uri = data.getData();
URI -> real file path
                String file_path = getRealPathFromURI(uri);
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}


private String getRealPathFromURI(Uri uri) {
    String filePath = "";
    filePath = uri.getPath();
경로에 /storage가 들어가면 real file path로 판단
    if (filePath.startsWith("/storage"))
        return filePath;

    String wholeID = DocumentsContract.getDocumentId(uri);

wholeID는 파일명이 abc.zip이라면 /document/B5D7-1CE9:abc.zip와 같습니다.

    // Split at colon, use second item in the array
    String id = wholeID.split(":")[1];

    Log.e(TAG, "id = " + id);

    String[] column = { MediaStore.Files.FileColumns.DATA };

파일의 이름을 통해 where 조건식을 만듭니다.

    String sel = MediaStore.Files.FileColumns.DATA + " LIKE '%" + id + "%'";

External storage에 있는 파일의 DB를 접근하는 방법 입니다.
    Cursor cursor = getContentResolver().query(MediaStore.Files.getContentUri("external"),
            column, sel, null, null);

SQL문으로 표현하면 아래와 같이 되겠죠????
SELECT _dtat FROM files WHERE _data LIKE '%selected file name%'

    int columnIndex = cursor.getColumnIndex(column[0]);

    if (cursor.moveToFirst()) {
        filePath = cursor.getString(columnIndex);
    }
    cursor.close();
    return filePath;
}


2015년 7월 27일 월요일

How to write images without fastboot on ODROID-XU4(android)

You can not use fastboot on ODROID-XU4, because It doesn't have USB otg port.

How to write images?

First! setup adb connection or copy image to fat partition.


http://codewalkerster.blogspot.kr/2015/07/adb-connect-over-tcpip-when-multiple.html

Push image to fat partition.

$ adb push xxxx.img /storage/sdcard0/
$ adb reboot

Enter u-boot prompt.


U-Boot 2012.07-00029-g0e9204d-dirty (Jul 17 2015 - 15:38:42) for Exynos5422

CPU: Exynos5422 Rev0.1 [Samsung SOC on SMP Platform Base on ARM CortexA7]
APLL = 800MHz, KPLL = 800MHz
MPLL = 532MHz, BPLL = 825MHz

Board: HardKernel ODROID
DRAM:  2 GiB
WARNING: Caches not enabled

TrustZone Enabled BSP
BL1 version: �/� ⁁
VDD_KFC: 0x44
LDO19: 0xf2

Checking Boot Mode ... SDMMC
MMC:   S5P_MSHC2: 0, S5P_MSHC0: 1
MMC Device 0: 7.4 GiB
MMC Device 1: [ERROR] response timeout error : 00000104 cmd 1
Card did not respond to voltage select!
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
Double Press 'Enter' to stop autoboot:  0
Exynos5422 #


Example for zImage-dtb

Exynos5422 # fatload mmc 0:1 40008000 zImage-dtb
there are pending interrupts 0x00000001
reading zImage-dtb

4718814 bytes read
Exynos5422 # movi write kernel 0 40008000
writing kernel..device 0 Start 1263, Count 16384
MMC write: dev # 0, block # 1263, count 16384 ... 16384 blocks write: OK
completed
Exynos5422 #

Example for system.img

Exynos5422 # fatload mmc 0:1 40000000 system.img
there are pending interrupts 0x00000001
reading system.img

355139392 bytes read
Exynos5422 # fastboot flash system 40000000 0
[Partition table on MoviNAND]
ptn 0 name='fwbl1' start=0x0 len=N/A (use hard-coded info. (cmd: movi))
ptn 1 name='bl2' start=N/A len=N/A (use hard-coded info. (cmd: movi))
ptn 2 name='bootloader' start=N/A len=N/A (use hard-coded info. (cmd: movi))
ptn 3 name='tzsw' start=N/A len=N/A (use hard-coded info. (cmd: movi))
ptn 4 name='kernel' start=N/A len=N/A (use hard-coded info. (cmd: movi))
ptn 5 name='ramdisk' start=N/A len=0x800000(~8192KB) (use hard-coded info. (cmd)
ptn 6 name='system' start=0x42B5800 len=0x40648800(~1055010KB) 
ptn 7 name='userdata' start=0x448FE000 len=0x80527800(~2102430KB) 
ptn 8 name='cache' start=0xC4E25800 len=0x1036C800(~265650KB) 
ptn 9 name='fat' start=0xD5192000 len=0x1002E5800(~4197270KB) 
flashing 'system'
Compressed ext4 image
*** erase start block 0x215ac ***
*** erase block length 0x202ff0 ***
mmc erase user 0 21800 202c00

MMC erase: dev # 0, block # 137216, count 2108416 ... START: 137216 BLOCK: 21086
high_capacity: 1
Capacity: 2
byte_addressing
before_send_cmd
start_addr
end_addr
erase_addr

Erase
........................................
........................................
........................................
........................................
........................................
..........
 1.0 GB erase Done
2108416 blocks erase: OK

MMC write: dev # 0, block # 136620, count 8 ... 8 blocks write: OK

MMC write: dev # 0, block # 136628, count 8 ... 8 blocks write: OK

MMC write: dev # 0, block # 136636, count 504 ... 504 blocks write: OK
......
.....




You can find other command to write image in this boot.ini files.

boot.ini for eMMC

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#------------------------------------------------------------------------------------------------------
#
# EMMC to EMMC Recovery boot.ini text file
#
#------------------------------------------------------------------------------------------------------
ODROIDXU-UBOOT-CONFIG
#------------------------------------------------------------------------------------------------------
# BL1 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl1.bin
emmc open 0
movi w z f 0 40008000
emmc close 0
#------------------------------------------------------------------------------------------------------
# BL2 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl2.bin
emmc open 0
movi w z b 0 40008000
emmc close 0
#------------------------------------------------------------------------------------------------------
# Bootloader write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 u-boot.bin
emmc open 0
movi w z u 0 40008000
emmc close 0
#------------------------------------------------------------------------------------------------------
# Turst Zone Soft Ware write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 tzsw.bin
emmc open 0
movi w z t 0 40008000
emmc close 0
#------------------------------------------------------------------------------------------------------
# UBOOT ENV Erase
#------------------------------------------------------------------------------------------------------
mmc write 0 40008000 0x4CF 0x20
#------------------------------------------------------------------------------------------------------
# Kernel Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 zImage-dtb
movi write kernel 0 40008000

#------------------------------------------------------------------------------------------------------
# System Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40000000 system.img

#------------------------------------------------------------------------------------------------------
# Userdata Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 57000000 userdata.img

#------------------------------------------------------------------------------------------------------
# Cache Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 61000000 cache.img

#------------------------------------------------------------------------------------------------------
# Partition Create to eMMC
#------------------------------------------------------------------------------------------------------
fdisk -c 0

#------------------------------------------------------------------------------------------------------
fastboot flash system 40000000 0
fastboot flash userdata 57000000 0
fastboot flash cache 61000000 0

#------------------------------------------------------------------------------------------------------
# SD/eMMC FAT Format
#------------------------------------------------------------------------------------------------------
fatformat mmc 0:1

reset
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


boot.ini for SD

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#------------------------------------------------------------------------------------------------------
#
# SD to SD Recovery boot.ini text file
#
#------------------------------------------------------------------------------------------------------
ODROIDXU-UBOOT-CONFIG

#------------------------------------------------------------------------------------------------------
# BL1 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl1.bin
movi w f 0 40008000
#------------------------------------------------------------------------------------------------------
# BL2 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl2.bin
movi w b 0 40008000
#------------------------------------------------------------------------------------------------------
# Bootloader write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 u-boot.bin
movi w u 0 40008000
#------------------------------------------------------------------------------------------------------
# Turst Zone Soft Ware write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 tzsw.bin
movi w t 0 40008000
#------------------------------------------------------------------------------------------------------
# UBOOT ENV Erase
#------------------------------------------------------------------------------------------------------
mmc write 0 40008000 0x4CF 0x20
#------------------------------------------------------------------------------------------------------
# Kernel Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 zImage-dtb
movi write kernel 0 40008000

#------------------------------------------------------------------------------------------------------
# System Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40000000 system.img

#------------------------------------------------------------------------------------------------------
# Userdata Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 57000000 userdata.img

#------------------------------------------------------------------------------------------------------
# Cache Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 61000000 cache.img

#------------------------------------------------------------------------------------------------------
# Partition Create to eMMC
#------------------------------------------------------------------------------------------------------
fdisk -c 0

#------------------------------------------------------------------------------------------------------
fastboot flash system 40000000 0
fastboot flash userdata 57000000 0
fastboot flash cache 61000000 0

#------------------------------------------------------------------------------------------------------
# SD/eMMC FAT Format
#------------------------------------------------------------------------------------------------------
fatformat mmc 0:1

reset
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

boot.ini for SD to eMMC

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#------------------------------------------------------------------------------------------------------
#
# EMMC to EMMC Recovery boot.ini text file
#
#------------------------------------------------------------------------------------------------------
ODROIDXU-UBOOT-CONFIG
#------------------------------------------------------------------------------------------------------
# BL1 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl1.bin
emmc open 1
movi w z f 1 40008000
emmc close 1
#------------------------------------------------------------------------------------------------------
# BL2 write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 bl2.bin
emmc open 1
movi w z b 1 40008000
emmc close 1
#------------------------------------------------------------------------------------------------------
# Bootloader write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 u-boot.bin
emmc open 1
movi w z u 1 40008000
emmc close 1
#------------------------------------------------------------------------------------------------------
# Turst Zone Soft Ware write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 tzsw.bin
emmc open 1
movi w z t 1 40008000
emmc close 1
#------------------------------------------------------------------------------------------------------
# UBOOT ENV Erase
#------------------------------------------------------------------------------------------------------
mmc write 1 40008000 0x4CF 0x20
#------------------------------------------------------------------------------------------------------
# Kernel Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40008000 zImage-dtb
movi write kernel 1 40008000

#------------------------------------------------------------------------------------------------------
# System Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 40000000 system.img

#------------------------------------------------------------------------------------------------------
# Userdata Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 57000000 userdata.img

#------------------------------------------------------------------------------------------------------
# Cache Image write to eMMC
#------------------------------------------------------------------------------------------------------
fatload mmc 0:1 61000000 cache.img

#------------------------------------------------------------------------------------------------------
# Partition Create to eMMC
#------------------------------------------------------------------------------------------------------
fdisk -c 1

#------------------------------------------------------------------------------------------------------
fastboot flash system 40000000 1
fastboot flash userdata 57000000 1
fastboot flash cache 61000000 1

#------------------------------------------------------------------------------------------------------
# SD/eMMC FAT Format
#------------------------------------------------------------------------------------------------------
fatformat mmc 1:1

fastboot poweroff
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$



Build android.

$ adb connect 192.168.x.x
$ cd out/target/products/odroidxu3/
$ adb push update.zip /storage/sdcard0/
$ adb push update.zip.md5sum /storage/sdcard0/

Run ODROID Update.


Now enable 'Validate file' button.