顯示具有 Android 標籤的文章。 顯示所有文章
顯示具有 Android 標籤的文章。 顯示所有文章

2022年9月27日 星期二

BlissRoms-x86 (Bliss 14, Android 11)

Repo
$ repo init -u https://github.com/BlissRoms-x86/manifest.git -b r11-r36

$ repo sync -c --force-sync --no-tags --no-clone-bundle -j$(nproc --all) --optimized-fetch --prune

build.sh
#!/bin/bash

  export BUILD_KERNEL_WITH_CLANG=true
  export BLISS_BUILD_VARIANT=foss
  export NO_KERNEL_CROSS_COMPILE=true

  source build/envsetup.sh
  lunch android_x86_64-userdebug


For more details, refer to build-bliss-os-14.x.md

2022年2月16日 星期三

A/B partition

how to make sure which partition you are using
Linux side:
$ adb shell

Target device:
$ getprop ro.boot.slot_suffix
_a  //use A partition

2021年12月15日 星期三

Set/Get volume for Android 11

dump all infomation
dumpsys audio

setting information
settings list system | grep volume

adjust volume
input keyevent 24


其它的keycode
keycodeMeaning
3 HOME key
4 Back key
5 Open the dial-up application
6 Hang up the call
24 Increase volume
25 Reduce the volume
26 Power button
27 Taking photos (need to be in the camera application)
64 Open the browser
82 Menu key
85 Play/Pause
86 Stop playing
87 Play the next song
88 Play the previous song
122 Move the cursor to the beginning of the line or the top of the list
123 Move the cursor to the end of the line or the bottom of the list
126 Resume playback
127 Pause playback
164 Mute (Speaker)
176 Open system settings
187 Switch application
207 Open contacts
208 Open the calendar
209 Open music
210 Open the calculator
220 Reduce screen brightness
221 Increase screen brightness
223 System hibernation
224 Light up the screen
231 Open the voice assistant
276 If there is no wakelock, let the system hibernate

ref: Most complete ADB command manual

2021年8月8日 星期日

Cross compile C code for Android

先用Android_studio下載NDK

init.sh
#!/bin/bash

NDK=/opt/android_studio/sdk/ndk/22.1.7171670
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64

export TARGET=aarch64-linux-android
#export TARGET=armv7a-linux-androideabi
#export TARGET=i686-linux-android
#export TARGET=x86_64-linux-android

export API=29

export AR=$TOOLCHAIN/bin/$TARGET-ar
export AS=$TOOLCHAIN/bin/$TARGET-as
export CC=$TOOLCHAIN/bin/$TARGET$API-clang
export CXX=$TOOLCHAIN/bin/$TARGET$API-clang++
export LD=$TOOLCHAIN/bin/$TARGET-ld
export RANLIB=$TOOLCHAIN/bin/$TARGET-ranlib
export STRIP=$TOOLCHAIN/bin/$TARGET-strip
export LD_LIBRARY_PATH=$TOOLCHAIN/sysroot/usr/lib/x86_64-linux-android/:$LD_LIBRARY_PATH

Useage:
$ source init.sh

$CC hello.c -o hello

cmake to compile Android


ref:Use the NDK with other build systems

2018年9月18日 星期二

Android_version_history

Code NameVersion NumberKernel Version
Gingerbread2.3 ~ 2.3.72.6.35
Honeycomb3.0 – 3.2.62.6.36
Ice Cream Sandwich4.0 – 4.0.43.0.1
Jelly Bean4.1 – 4.3.13.0.31 to 3.4.39
KitKat 4.4 – 4.4.43.10
Lollipop5.0 – 5.1.13.16
Marshmallow6.0 – 6.0.13.18
Nougat7.0 – 7.1.24.4
Oreo8.0 – 8.14.10
Pie9.04.4.107, 4.9.84, and 4.14.42 
ref: Android_version_history

2017年1月26日 星期四

usbmisc 自動產生usb device結點

環境:Upboard 6.0 + kernel 4.4.8

當usb driver是用usbmisc時,系統並不會長出對應的結點,
Driver=usb storage等看起來都正常,
所以看起來是必需手重加入:

system/core/init/devices.cpp
static void handle_generic_device_event(struct uevent *uevent)
{
    const char *base;
    const char *name;
    char devpath[DEVPATH_LEN] = {0};
    char **links = NULL;

    name = parse_device_name(uevent, 64);
    if (!name)
        return;

    struct ueventd_subsystem *subsystem =
            ueventd_subsystem_find_by_name(uevent->subsystem);

 //ERROR("TTest-%s, uevent->subsystem = %s\n", __FUNCTON__, uevent->subsystem);
 //ERROR("TTest-%s, uevent->device_name = %s\n", __FUNCTON__, uevent->device_name);

    if (subsystem) {
        const char *devname;

        switch (subsystem->devname_src) {
        case DEVNAME_UEVENT_DEVNAME:
            devname = uevent->device_name;
            break;

        case DEVNAME_UEVENT_DEVPATH:
            devname = name;
            break;

        default:
            ERROR("%s subsystem's devpath option is not set; ignoring event\n",
                    uevent->subsystem);
            return;
        }

        if (!assemble_devpath(devpath, subsystem->dirname, devname))
            return;
        mkdir_recursive_for_devpath(devpath);
    } else if (!strncmp(uevent->subsystem, "usb", 3)) {
         if (!strcmp(uevent->subsystem, "usb")) {
            if (uevent->device_name) {
                if (!assemble_devpath(devpath, "/dev", uevent->device_name))
                    return;
                mkdir_recursive_for_devpath(devpath);
             }
             else {
                 /* This imitates the file system that would be created
                  * if we were using devfs instead.
                  * Minors are broken up into groups of 128, starting at "001"
                  */
                 int bus_id = uevent->minor / 128 + 1;
                 int device_id = uevent->minor % 128 + 1;
                 /* build directories */
                 make_dir("/dev/bus", 0755);
                 make_dir("/dev/bus/usb", 0755);
                 snprintf(devpath, sizeof(devpath), "/dev/bus/usb/%03d", bus_id);
                 make_dir(devpath, 0755);
                 snprintf(devpath, sizeof(devpath), "/dev/bus/usb/%03d/%03d", bus_id, device_id);
             }
         } else {
   //add for usblp (thermal printer)
   if(!strncmp(uevent->subsystem, "usbmisc", 7))
   {
    if(!strncmp(uevent->device_name, "usb/lp", 6)){
     base = "/dev/usb/";
     make_dir(base, 0755);
    }
   }
   //end
   else
   /* ignore other USB events */
            return;
        }
     } else if (!strncmp(uevent->subsystem, "graphics", 8)) {
         base = "/dev/graphics/";
         make_dir(base, 0755);
     } else if (!strncmp(uevent->subsystem, "drm", 3)) {
         base = "/dev/dri/";
         make_dir(base, 0755);
     } else if (!strncmp(uevent->subsystem, "oncrpc", 6)) {
         base = "/dev/oncrpc/";
         make_dir(base, 0755);
     } else if (!strncmp(uevent->subsystem, "adsp", 4)) {
         base = "/dev/adsp/";
         make_dir(base, 0755);
     } else if (!strncmp(uevent->subsystem, "msm_camera", 10)) {
         base = "/dev/msm_camera/";
         make_dir(base, 0755);
     } else if(!strncmp(uevent->subsystem, "input", 5)) {
         base = "/dev/input/";
         make_dir(base, 0755);
     } else if(!strncmp(uevent->subsystem, "mtd", 3)) {
         base = "/dev/mtd/";
         make_dir(base, 0755);
     } else if(!strncmp(uevent->subsystem, "sound", 5)) {
         base = "/dev/snd/";
         make_dir(base, 0755);
     } else if(!strncmp(uevent->subsystem, "misc", 4) &&
                 !strncmp(name, "log_", 4)) {
         INFO("kernel logger is deprecated\n");
         base = "/dev/log/";
         make_dir(base, 0755);
         name += 4;
     } else
         base = "/dev/";
     links = get_character_device_symlinks(uevent);

     if (!devpath[0])
         snprintf(devpath, sizeof(devpath), "%s%s", base, name);

     handle_device(uevent->action, devpath, uevent->path, 0,
             uevent->major, uevent->minor, links);
}
ref : 程序園

2016年12月30日 星期五

取得android裝置內的apk

1. 需root權限
2. 按表施工
#pm list packages     列出所有安裝apk的package_name
#pm path package_name 查詢所在目錄
#cp package_name to USB storage
如果最後能用adb pull拿出來的話,也能透過adb取出apk ref : Here

Wifi + Ethernet workable at the same time on Android

Android 6.0 + kernel 4.4 on Upboard
(Thank Bruce and Solar for help)
Wifi + Ethernet can't workable at the same time on Android, even we use "ifconfig" to setting.

Upboard Setting:
ip :
eth0    inet addr:192.168.1.20  Bcast:192.168.1.255  Mask:255.255.255.0
wlan0   inet addr:172.20.10.5   Bcast:172.20.10.15   Mask:255.255.255.240
route :
待補

PC(linux) Setting:
ip :
eth0    inet addr:192.168.1.21  Bcast:192.168.1.255  Mask:255.255.255.0
We can use "$ping -I eth0 192.168.1.21" to get response from Upboard to PC, but if we use "$ping 192.168.1.21" it can't get any response.
According the above description here we come to the conclusion. We need to specify the interface so it can transmit the package successfully.

sample code: ref : stackoverflow
(sender.c and listener.c)
#include <netinet/in.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#define PORT  12345
#define SERVER_ADDR "192.168.1.20"

int main(int argc, char *argv[])
{
    int fd, nbytes;
    char message[16];
    struct sockaddr_in addr;

    if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
     perror("socket");
  return -1;
    }

    strncpy(message, argv[1], sizeof(message));

    memset(&addr, 0, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_addr.s_addr = inet_addr(SERVER_ADDR);
    addr.sin_port = htons(PORT);

    const char device[] = "eth0";
    if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, device, sizeof(device)) < 0) {
        perror("SO_BINDTODEVICE");
  return -1;
    }
    while (1) {
        if ((nbytes = sendto(fd, message, strlen(message), 0, 
                   (struct sockaddr *) &addr, sizeof(addr))) < 0) {
         perror("sendto");
   return -1;
     }
     usleep(1000*1000);
    }
}
Android/PC run the program, PC/Android run tcpdump, it should get packages. But...the program need root permission if you want to run Android App. = ="

Build wireless-tools in Android

Busybox下沒有iwconfig等cmd,只能動手編了
LOCAL_PATH:= $(call my-dir)
################## build iwlib ###################
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := debug
LOCAL_SRC_FILES := iwlib.c
LOCAL_CFLAGS += -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Winline -MMD -fPIC
LOCAL_MODULE:= libiw
LOCAL_WHOLE_STATIC_LIBRARIES := libm
LOCAL_STATIC_LIBRARIES := libcutils libc
include $(BUILD_STATIC_LIBRARY)
################## build iwconfig ###################
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := debug
LOCAL_SRC_FILES := iwconfig.c
LOCAL_CFLAGS += -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Winline -MMD -fPIC
LOCAL_MODULE:= iwconfig
LOCAL_STATIC_LIBRARIES := libcutils libc libm libiw
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) # install to system/xbin
#LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
#LOCAL_MODULE_TAGS := eng user
include $(BUILD_EXECUTABLE)
################## build iwlist ###################
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := debug
LOCAL_SRC_FILES := iwlist.c iwlib.h
LOCAL_CFLAGS += -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Winline -MMD -fPIC
LOCAL_MODULE:= iwlist
LOCAL_STATIC_LIBRARIES := libcutils libc libm libiw
LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) # install to system/xbin
#LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
#LOCAL_MODULE_TAGS := eng user
include $(BUILD_EXECUTABLE)
ref : Here

LOCAL_STATIC_LIBRARIES 
    These are the static libraries that you want to include in your module. Mostly, we use shared libraries, but there are a couple of places, like executables in sbin and host executables where we use static libraries instead.

LOCAL_WHOLE_STATIC_LIBRARIES
    These are the static libraries that you want to include in your module without allowing the linker to remove dead code from them. This is mostly useful if you want to add a static library to a shared library and have the static library's content exposed from the shared library.

 ref : Here

repo 續傳

repo斷線,再自動連線
#!/bin/bash  
echo "======start repo sync======"  
repo sync  
while [ $? = 1 ]; do  
echo “======sync failed, re-sync again======”  
sleep 3  
repo sync  
done  
循环判斷$? 是否為 1,為1則再次執行repo sync命令,直到$?=0, 完成退出。 $? 這個變數儲存的是上一次shell命令執行的返回值, 0表示成功,非零表示失敗。 ref : beter的博客

2016年12月3日 星期六

Cross compile C code for Android Lollipop

arm:
#!/bin/bash
export TOOLCHAIN=$PWD/android-toolchain
mkdir -p $TOOLCHAIN
$1/build/tools/make-standalone-toolchain.sh \
    --toolchain=arm-linux-androideabi-4.8 \
    --arch=arm \
    --install-dir=$TOOLCHAIN \
    --platform=android-19
export PATH=$TOOLCHAIN/bin:$PATH
export AR=$TOOLCHAIN/bin/arm-linux-androideabi-ar
export CC=$TOOLCHAIN/bin/arm-linux-androideabi-gcc
echo $CC
export CXX=$TOOLCHAIN/bin/arm-linux-androideabi-g++
export LINK=$TOOLCHAIN/bin/arm-linux-androideabi-g++
x86_64:
#!/bin/bash
export TOOLCHAIN=$PWD/android-toolchain
mkdir -p $TOOLCHAIN
$1/build/tools/make-standalone-toolchain.sh \
    --toolchain=x86_64-4.9 \
    --arch=x86_64 \
    --install-dir=$TOOLCHAIN \
export PATH=$TOOLCHAIN/bin:$PATH
export AR=$TOOLCHAIN/bin/x86_64-linux-android-ar
export CC=$TOOLCHAIN/bin/x86_64-linux-android-gcc
echo $CC
export CXX=$TOOLCHAIN/bin/x86_64-linux-android-g++
export LINK=$TOOLCHAIN/bin/x86_64-linux-android-g++
使用方式:
source android-configure.sh /opt/android-ndk-myVersion
$CC abc.c -o abc
Lollipop以上
$CC abc.c -pie -fPIE -o abc

2016年10月16日 星期日

Android 獲取USB OTG插入狀置的資訊

Android 獲取USB OTG插入狀置的資訊

android中想办法实现自动获得usb设备的操作权限
(看起來還是會彈出視窗,需要使用者同意才行 = =")

Android5.0如何监听USB插拔

keyword: allow the app to access the usb device

更改Android下的system檔案權限

環境: imx6 + kernel 3.0.35

./device/fsl/imx6/sabresd_6dq.mk
...
...
...
PRODUCT_COPY_FILES += \
    frameworks/native/data/etc/android.hardware.location.gps.xml:system/etc/permissions/android.hardware.location.gps.xml \
    frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml \
    frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml \
...
...
...
Android OS下/system/etc/permissions裡的一些xml
是從./frameworks/native/data/etc/下拷貝過去的,
而這些permissions應該是寫app時宣告時用到的,
但在 /system/ 下,通常都是 read-only,就算有root也沒變法改變權限,
所以在 build bsp 時就要先設定 ./system/core/include/private/android_filesystem_config.h
有root也沒變法改變權限
chown system system /system/etc/android.hardware.location.gps.xml
chmod 0555 /system/etc/android.hardware.location.gps.xml
改變/system/下的權限
...
...
...
static const struct fs_path_config android_dirs[] =  //設定dirs
{ 
    { 00770, AID_SYSTEM, AID_CACHE,  0, "cache" },
    { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app" },
    { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/app-private" },
    { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/dalvik-cache" },
    { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data/data" },
    { 00771, AID_SHELL,  AID_SHELL,  0, "data/local/tmp" },
    { 00771, AID_SHELL,  AID_SHELL,  0, "data/local" },
    { 01771, AID_SYSTEM, AID_MISC,   0, "data/misc" },
    { 00770, AID_DHCP,   AID_DHCP,   0, "data/misc/dhcp" },
    { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media" },
    { 00775, AID_MEDIA_RW, AID_MEDIA_RW, 0, "data/media/Music" },
    { 00771, AID_SYSTEM, AID_SYSTEM, 0, "data" },
    { 00750, AID_ROOT,   AID_SHELL,  0, "sbin" },
    { 00755, AID_ROOT,   AID_SHELL,  0, "system/bin" },
    { 00755, AID_ROOT,   AID_SHELL,  0, "system/vendor" },
    { 00755, AID_ROOT,   AID_SHELL,  0, "system/xbin" },
    { 00755, AID_ROOT,   AID_ROOT,   0, "system/etc/ppp" },
    { 00755, AID_ROOT,   AID_SHELL,  0, "vendor" },
    { 00777, AID_ROOT,   AID_ROOT,   0, "sdcard" },
    { 00755, AID_ROOT,   AID_ROOT,   0, 0 },
};
...
...
...
static const struct fs_path_config android_files[] = //設定files
{
...
...
...
    { 00755, AID_ROOT,      AID_ROOT,      0, "bin/*" },
    { 00750, AID_ROOT,      AID_SHELL,     0, "init*" },
    { 00750, AID_ROOT,      AID_SHELL,     0, "charger*" },
    { 00750, AID_ROOT,      AID_SHELL,     0, "sbin/fs_mgr" },
    { 00640, AID_ROOT,      AID_SHELL,     0, "fstab.*" },
    { 00777, AID_SYSTEM,    AID_SHELL,     0, "system/etc/permissions/android.hardware.usb.accessory.xml" },
    { 00777, AID_SYSTEM,    AID_SHELL,     0, "system/etc/permissions/android.hardware.usb.host.xml" },
    { 00644, AID_ROOT,      AID_ROOT,      0, 0 },
};
ref : 蝸牛慢慢

2016年10月3日 星期一

UpBoard

Android
  • rebuild kernel:
    rm -r out/target/product/x86_64/obj/kernel/vmlinux and vmlinux.o
    rm -r out/target/product/x86_64/kernel  (It's a file)
  • build image
    make efi_img
Ubuntu
  • 升級kernel為4.4  :
    sudo add-apt-repository ppa:ubilinux/up
    sudo apt update
    sudo apt install linux-upboard-lts-xenial
    sudo apt-get autoremove --purge 'linux-.*generic'
    ref : Here and Here

2016年9月27日 星期二

編譯android 4.2.2 / 4.4 (Jelly Bean or kitkat)交叉编译器

2016.09.27
最近換了顆硬碟,所以又重裝系統了(Mint 18)…
(話說…聽說2016的WD黑標是個雷,所以就買seagate - ST1000LM035)
由於google採用openjdk了,所以java就改裝…open-jdk-7 or open-jdk-6 (openjdk-8不能用)
openjdk-7-jdk
openjdk-7-jre
openjdk-7-jre-headless
碰到版本衝突時…
sudo apt install -f
然後再用dkpg安裝一次,
(可以用sudo update-alternatives --config java切換java版本)
最後,再安裝這個
libjpeg62-turbo
其它的,如下2014.08.26步驟
因為系統將gcc升級到5.3了,所以在compile hashtable_itr.c時會出現問題
(external/mtd-utils/mkfs.ubifs/hashtable/hashtable_itr.c)
/*****************************************************************************/
/* key      - return the key of the (key,value) pair at the current position */
/* value    - return the value of the (key,value) pair at the current position */

//marked for gcc 5.3
/*
void *
hashtable_iterator_key(struct hashtable_itr *i)
{ return i->e->k; }

void *
hashtable_iterator_value(struct hashtable_itr *i)
{ return i->e->v; }
*/
external/mtd-utils/mkfs.ubifs/hashtable/hashtable_itr.h
/*****************************************************************************/
/* hashtable_iterator_key
 * - return the value of the (key,value) pair at the current position */

//modified for gcc 5.3
//extern inline void *
static inline void *
hashtable_iterator_key(struct hashtable_itr *i)
{
    return i->e->k;
}

/*****************************************************************************/
/* value - return the value of the (key,value) pair at the current position */

//modified for gcc 5.3
//extern inline void *
static inline void *
hashtable_iterator_value(struct hashtable_itr *i)
{
    return i->e->v;
}
ref : Here
2014.08.26
最近重裝了台電腦,所以環境又要重設,
卡很久才弄好,超麻煩的...
環境: Ubuntu 12.04

1. 安裝java,目前1.6最新的是6u45 (先裝1.6的,反正官方寫說到kitkat都能用1.6)
2.
$sudo apt-get install git gnupg flex bison gperf build-essential \
     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
ref: Google android
先確認路徑有該檔案,沒有的話, 請裝 libgl1-mesa-glx:i386 libgl1-mesa-dev
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

以下是需要其它補裝的Q&A:
Q1. gcc: error trying to exec 'cc1plus': execvp: No such file or directory
A:1. 安裝 g++
  2. 確定 gcc -version 和 g++ -version 兩者版本是相同的
ref: Here
Q2. error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
A: 安裝 lib32z1
ref: Here
Q3. error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory  make:***
A: 安裝 libc6-dev-i386
ref: Here
Q4. OSError: [Errno 2] No such file or directory
A: 安裝 git (這跟git有關 = =?)
Q5. xmllint: command not found
A: 安裝 libxml2-utils
ref: Here
Q6. libssl.so.0.9.8: cannot open shared object file: No such file or directory
A: 安裝 libssl0.9.8:i386
ref: Here
Q7. libxml2.so.2: cannot open shared object file: No such file or directory
A: 安裝 libxml2:i386
Q8.  libQtGui.so.4: cannot open shared object file: No such file or directory
A: 安裝 libqtgui4:i386
ref: Here
Q9. xmllint: cannot open shared object file: No such file or directory
A: 安裝 libxml2-utils

Q10. “fatal error: uuid/uuid.h: No such file or directory”
A: 安裝 uuid-dev
ref: Here
Q11. mkimage command not found
A: 安裝 uboot-mkimage
ref: Here
Q12. zconf.h no such file or directory
A: 安裝 zlib1g-dev
ref: Here
Q13. “fatal error: lzo/lzo1x.h: No such file or directory”
A: 安裝 liblzo2-dev
ref: Here
Q14. Cross Compile tool chain
A: 1. 安裝 gcc-arm-linux-gnueabihf & gcc-arm-linux-gnueabi
   2. 手動安裝: 載點 (要 aach64 的)
ref: 交叉编译器 arm-linux-gnueabi 和 arm-linux-gnueabihf 的区别

#------------android BSP-------------------
CROSS_COMPILE=/opt/arm-eabi-4.6/bin/arm-eabi-
#------------jdk environment---------------
#JAVA_HOME=/opt/java/jdk1.8.0_91
#JRE_HOME=/opt/java/jdk1.8.0_91/jre
JAVA_HOME=/opt/java/jdk1.7.0_67
JRE_HOME=/opt/java/jdk1.7.0_67/jre
#JAVA_HOME=/opt/java/jdk1.6.0_45
#JRE_HOME=/opt/java/jdk1.6.0_45/jre
NDK_HOME=/opt/android-ndk-r10b/
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$NDK_HOME:$CROSS_COMPILE
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/jre/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH CROSS_COMPILE NDK_HOME

2016年5月30日 星期一

imx6 - fuse

有三個方法:
  1. Uboot
  2. 系統
  3. mfg-tool (emmc為例)

1. uboot
imxotp blow --force <index> <value>"

其中 index  = (Fuse Address - 0x400) / 0x10
ex: (Fusemap Descriptions)  
    Fuse Address  Fuses Name   Number of Fuses  Fuses Function
     0x660[31:0]       GP1[31:0]                  32             General Purpose
  
    index = (0x660 - 0x400) / 0x10 = 26

write :  imxopt blow --force 26 0x84267139
read  :  imxopt read 26

2. 系統
read
$ cat /sys/fsl_otp/HW_OCOTP_GP1

write 
$ echo 0x00006200 > /sys/fsl_otp/HW_OCOTP_GP1
3. mfg-tool (看here)
修改 ucl2.xml
<LIST name="Android-SabreSD-eMMC" desc="Choose eMMC android as media">
  <!-- Android Profile: -->
 <CMD state="BootStrap" type="boot" body="BootStrap" file ="u-boot-mx6q-sabresd.bin" >Loading U-boot</CMD>
 <CMD state="BootStrap" type="load" file="uImage" address="0x10800000"
        loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" >Loading Kernel.</CMD>
    <CMD state="BootStrap" type="load" file="initramfs.cpio.gz.uboot" address="0x10C00000"
        loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" >Loading Initramfs.</CMD>
    <CMD state="BootStrap" type="jump" > Jumping to OS image. </CMD>
 <CMD state="Updater" type="push" body="$ dd if=/dev/zero of=/dev/mmcblk0 bs=512 seek=1536 count=16">clean up u-boot parameter</CMD>
 <CMD state="Updater" type="push" body="$ echo 1 > /sys/devices/platform/sdhci-esdhc-imx.3/mmc_host/mmc0/mmc0:0001/boot_config">access boot partition 1</CMD>
 <CMD state="Updater" type="push" body="send" file="files/android/u-boot-6q.bin">Sending U-Boot</CMD>
 <CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk0 bs=512 seek=2 skip=2">write U-Boot to sd card</CMD>

 <CMD state="Updater" type="push" body="$ echo 8 > /sys/devices/platform/sdhci-esdhc-imx.3/mmc_host/mmc0/mmc0:0001/boot_config">access user partition and enable boot partion 1 to boot</CMD>
 <CMD state="Updater" type="push" body="send" file="mksdcard-android.sh.tar">Sending partition shell</CMD>
 <CMD state="Updater" type="push" body="$ tar xf $FILE "> Partitioning...</CMD>
 <CMD state="Updater" type="push" body="$ sh mksdcard-android.sh /dev/mmcblk0"> Partitioning...</CMD>

 <CMD state="Updater" type="push" body="$ ls -l /dev/mmc* ">Formatting sd partition</CMD>

 <CMD state="Updater" type="push" body="send" file="files/android/boot.img">Sending kernel uImage</CMD>
 <CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk0p1">write boot.img</CMD>
 <CMD state="Updater" type="push" body="frf">flush the memory.</CMD>

 <CMD state="Updater" type="push" body="$ mkfs.ext4 -b 4096 -m 0 /dev/mmcblk0p4">Formatting data partition</CMD>
 <CMD state="Updater" type="push" body="send" file="mk-encryptable-data-android.sh.tar">Sending data partition shell</CMD>
 <CMD state="Updater" type="push" body="$ tar xf $FILE ">Extracting data partition shell</CMD>
 <CMD state="Updater" type="push" body="$ sh mk-encryptable-data-android.sh /dev/mmcblk0 /dev/mmcblk0p4">Making data encryptable</CMD>

 <CMD state="Updater" type="push" body="$ mkfs.ext4 /dev/mmcblk0p5">Formatting system partition</CMD>
 <CMD state="Updater" type="push" body="$ mkfs.ext4 /dev/mmcblk0p6">Formatting cache partition</CMD>
 <CMD state="Updater" type="push" body="frf">flush the memory.</CMD>
 <CMD state="Updater" type="push" body="$ mkfs.ext4 /dev/mmcblk0p7">Formatting device partition</CMD>
 <CMD state="Updater" type="push" body="pipe dd of=/dev/mmcblk0p5 bs=512" file="files/android/system.img">Sending and writting system.img</CMD>
 <CMD state="Updater" type="push" body="frf">flush the memory.</CMD>
 <!-- Write userdata.img is optional, for some customer this is needed, but it's optional. -->
 <!-- Also, userdata.img will have android unit test, you can use this to do some auto test. -->
<!-- <CMD state="Updater" type="push" onError="ignore" body="pipe dd of=/dev/mmcblk0p7" file="file/android/userdate.img"> Sending userdata.img(optional) </CMD>
 <CMD state="Updater" type="push" body="frf">flush the memory.</CMD>  -->
 <CMD state="Updater" type="push" body="pipe dd of=/dev/mmcblk0p2 bs=512" file="files/android/recovery.img">Sending and writting recovery.img</CMD>

<!--Here strat add-->
    <CMD state="Updater" type="push" body="$ ls -la /sys/fsl_otp ">Showing HW_OCOTP fuse bank</CMD>
    <CMD state="Updater" type="push" body="$ echo 0x84267139 > /sys/fsl_otp/HW_OCOTP_GP1">write 0x84267139 to HW_OCOTP_GP1 fuse bank</CMD>
<!--Here end-->

 <CMD state="Updater" type="push" body="frf">Finishing rootfs write</CMD>

 <CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>
</LIST>
ref:
NXP community
NXP community
Boundary

2016年5月26日 星期四

rotation monitor from bsp

init.rc
setprop ro.sf.hwrotation 90

2016年4月20日 星期三

i2c-tools on Android

下載:
a. i2c-tools-3.1.2.tar.gz <- br="" broken="" is="" this="">b. Here

#  tools/external/i2c-tools/Android.mk

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include
LOCAL_SRC_FILES := tools/i2cbusses.c tools/util.c
LOCAL_MODULE := i2c-tools
include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES:=tools/i2cdetect.c
LOCAL_MODULE:=i2cdetect
LOCAL_CPPFLAGS += -DANDROID
LOCAL_SHARED_LIBRARIES:=libc
LOCAL_STATIC_LIBRARIES := i2c-tools
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include
include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES:=tools/i2cget.c
LOCAL_MODULE:=i2cget
LOCAL_CPPFLAGS += -DANDROID
LOCAL_SHARED_LIBRARIES:=libc
LOCAL_STATIC_LIBRARIES := i2c-tools
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include
include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES:=tools/i2cset.c
LOCAL_MODULE:=i2cset
LOCAL_CPPFLAGS += -DANDROID
LOCAL_SHARED_LIBRARIES:=libc
LOCAL_STATIC_LIBRARIES := i2c-tools
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include


include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := eng
LOCAL_SRC_FILES:=tools/i2cdump.c
LOCAL_MODULE:=i2cdump
LOCAL_CPPFLAGS += -DANDROID
LOCAL_SHARED_LIBRARIES:=libc
LOCAL_STATIC_LIBRARIES := i2c-tools
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/$(KERNEL_DIR)/include
include $(BUILD_EXECUTABLE)
ref : Here

2016年2月1日 星期一

PWM

環境:Freescale imx6
            (共有4組pwm可以使用)

PWM (兩邊都要改)
1. bootable/bootloader/uboot-imx/board/freescale/mx6q_sabresd/mx6q_sabresd.c
imx_pwm_config(pwm0, 250000, 500000);
imx_pwm_enable(pwm0);

2. kernel_imx/arch/arm/mach-mx6/board-mx6q_sabresd.c
static struct platform_pwm_backlight_data mx6_sabresd_pwm_backlight_data = {
 .pwm_id = 0,
 .max_brightness = 248,
 .dft_brightness = 128,
 //.pwm_period_ns = 50000,
 .pwm_period_ns = 500000,
};
/*nice*/