2014年4月13日 星期日

Using VirtualBox raw disk on Win7



  1. Offline the Physical Disk 0 and clear the read-only flag
    1. run diskpart.exe
    2. run "SELECT DISK 0" -- 0 is the physical disk I would like to use.
    3. run "OFFLINE DISK"
    4. run "ATTRIBUTES DISK CLEAR READONLY"
    5. run "ATTRIBUTES DISK" to check the readonly flag has been cleared.
  2. Create the raw disk in the Virtualbox Host - Ubuntu-Local
    1. Open up a command prompt.
    2. cd C:\Program Files\Oracle\VirtualBox
    3. VBoxManage internalcommands createrawvmdk -filename "G:\Ubuntu.vmdk" -rawdisk "\\.\PhysicalDrive0"
    4. VBoxManage storageattach "Ubuntu-Local" --storagectl "IDE" --port 0 --device 0 --type hdd --medium G:\Ubuntu.vmdk
      (Noted: You are able to create this by VirtualBox GUI, but be sure to run as an administrator when launching VirtualBox GUI)
  3.  Run VirtualBox as an administrator


2014年3月25日 星期二

Linux - data transfer between kernel/user space


  • put_user(x, ptr)
    - Write a simple value into user space
    • x - Value to copy to user space
    • ptr - Destination address in user space
  • get_user(x, ptr)
    - Get a simple variable from user space
    • x - Variable to store result
    • ptr - Source address in user space
  • copy_to_user(void __user *to, const void *from, unsigned long n);
    - Copy a block of data into user space
  • copy_from_user(void *to, const void __user *from, unsigned long n);
    - Copy a block of data from user space

2014年3月18日 星期二

Android build instruction


  1. build
    1. m - build all modules from the top of the tree
    2. mm - build all of the modules in current directory
    3. mmm - build all of the modules in the supplied directory
  2. make
    1. make systemimage - system.img
    2. make ramdisk - ramdisk.img
    3. make userdataimage - userdata.img
    4. make snod - build system.img quickly without checking the dependency
  3. misc
    1. croot - change directory to the top of the tree
    2. cgrep - grep on all local c/c++ files
    3. jgrep - grep on all local java files
    4. resgrep - grep on all local res/*.xml files
    5. godir - go to directory containing a file.
    6. printconfig - print the current build configuraiton

2014年3月17日 星期一

Linux init.rc (android)


Trigger sequence
   "early-init" -> "init" -> "early-fs" -> "fs" -> "post-fs" -> "early-boot" -> "boot"

At the end of "boot" trigger, start corresponding services
   class_start core
   class_start main




Android Zygote



  1. Linux kernel start the 1st process - init
  2. init fork a child process - ServiceManager 
  3. init fork a child process - Zygote
  4. Zygote 
    1. Fork an child process for SystemServer (register to ServiceManager)
    2. Main process is waiting to fork child processes of user applications from ActivityManagerService via socket



  • Linux - fork() function
    • return child pid in parent process
    • return 0 in child process

2014年3月16日 星期日

Process/Thread in each OS


  1. MS DOS
    1. Single-Process
    2. Single-Thread
  2. Java VM
    1. Single Process
    2. Multi-Thread
  3. Unix - traditional
    1. Multi-Process
    2. Single-Thread
  4. Linux, Windows, Solaris, ...
    1. Multi-Process
    2. Multi-Thread



2014年3月10日 星期一

Android App components

4 types of Android application components.

  • Activities - foreground UI handler
  • Services - background service routine
  • Content Providers - share app data, such as SQLite or data in filesystem.
  • Broadcast Receivers - response to system-wide broadcast