2015年12月3日 星期四

Build OpenNI from Source for multiple targets

Linux x86
Under Platform/Linux/Build
make
Or under Platform/Linux/CreateRedist/
./RedistMaker
Linux Arm
export tool chain and staging
export ARM_CXX=arm-linux-gnueabihf-g++  
export ARM_STAGING=`pwd`/Staging
Under Platform/Linux/Build type
make Platform=Arm
Or under Platform/Linux/CreateRedist/
./RedistMaker Arm
Android Arm
Under Platform/Android/jni
PATH/TO/NDK/ndk-build

2015年11月22日 星期日

git tips

1. Push to review
    git push ssh://UserName@hostname:29418/repo_name HEAD:refs/for/master(branch name)

2. Push directly, need admin
    git push ssh://UserName@hostname:29418/repo_name HEAD:refs/heads/master

2015年11月12日 星期四

APK tools side note and how to sign a releaseed APK.

###################################
####     How to unpack APK?    ####
###################################
1. Put apktool, apktool.jar under the same folder.
2. Run "apktool d xxx.apk".


############################################
####     How to pack files into APK?    ####
############################################
1. Put apktool, aapt under the same folder.
2. Run "apktool b xxxx-folder-name".
3. The output will be under xxxx-folder-name/dist/ with name xxxx-folder-name.apk.


#######################################
####    How to create keystore?    ####
#######################################
Refer to http://developer.android.com/tools/publishing/app-signing.html
 1. Run "keytool -genkey -v -keystore steven.keystore -alias steven -keyalg RSA -keysize 2048 -validity 10000"
 2. Verity keystore with "keytool -list -v -keystore ./steven.keystore"


###################################
####    How to sign an APK?    ####
###################################
Refer to http://developer.android.com/tools/publishing/app-signing.html
1. Run "jarsigner -verbose -keystore  ./steven.keystore -signedjar xxxx-signed.apk xxxx.apk steven"
   or  "jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore steven.keystore ./xxxx.apk"
2. Verify the signed APK with "jarsigner -verify -verbose ./xxxx.apk"


###################################
####    How to laing an APK?   ####
###################################
Refer to http://developer.android.com/tools/publishing/app-signing.html
1. Run "zipalign -v 4 xxx-unaligned.apk xxx.apk"
zipalign ensures that all uncompressed data starts with a particular byte alignment
relative to the start of the file, which reduces the amount of RAM consumed by an app.

2015年8月26日 星期三

NDK build specific module

/PATH/TO/ndk-build APP_MODULES='name'

2015年8月5日 星期三

git & gerrit setup in Ubuntu

For gerrit install,
1. Download gerrit from http://gerrit-releases.storage.googleapis.com/index.html
    I choose gerrit-2.11.2.war
2. Create mySQL for gerrit
    a. mysql -u root -p PASSWD
    b.Create a Gerrit specific user within the database and assign it a password,  create a database, and give the user full rights:
"CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';"
"CREATE DATABASE reviewdb;"
"ALTER DATABASE reviewdb charset=latin1;"
"GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';"
"FLUSH PRIVILEGES;"
3. Install gerrit
 java -jar gerrit-2.11.2.war init -d /GERRIT/INSTALL/PATH

4. Choose HTTP as authentication method and set rest as default
5. Install apache2
6. Create a virtual host with the following httpd.conf under  /etc/apache2/sites-available and create a symlink to /etc/apache2/sites-enabled
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

<VirtualHost *:8082>
  ServerName localhost
  ProxyRequests Off
  ProxyVia Off
  ProxyPreserveHost On
  DocumentRoot /var/www/html

  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>

  <Location /login/>
    AuthType Basic
    AuthName "Gerrit Code Review"
    AuthBasicProvider file
    AuthUserFile /home/gerrit2/review_gerrit/etc/gerrit.htpasswd
    Require valid-user
    Order Deny,Allow
    Allow from all
  </Location>

  AllowEncodedSlashes On
  ProxyPass / http://SITESURL:6267/ nocanon
</VirtualHost>
 7. Create HTTP basic auth user/passwd file, later you won't need -c flag.(-c: create)
sudo htpasswd -c /home/gerrit2/review_gerrit/etc/gerrit.htpasswd UserName
8. My final gerrit.config is as following
[gerrit]
    basePath = git
    canonicalWebUrl = http://SITESURL:6267
[database]
    type = mysql
    hostname = localhost
    database = reviewdb
    username = gerrit2
[index]
    type = LUCENE
[auth]
    type = HTTP
    loginUrl = http://SITESURL:8082/login/
[sendemail]
    smtpServer = localhost
[container]
    user = gerrit2
    javaHome = /usr/lib/jvm/java-7-openjdk-amd64/jre
[sshd]
    listenAddress = *:29418
[httpd]
    listenUrl = http://SITESURL:6267/
[cache]
    directory = cache
[plugins]
    allowRemoteAdmin = true
9. Link to http://SITESURL:6267 and it will pop up a dialogue, fill in the username and passwd just create with htpasswd and change the settings in gerrit webUI. For example, paste your ssh public key and change your full name



2015年6月16日 星期二

kernel scheduler entry point

1. Upon returning to user-space or returning from an interrupt, the need_resched flag is checked. If it is set, the kernel invokes the scheduler before continuing.
2. Process preemption
3. Running out of time slice
4. Waiting for event
5. Waiting for IO
6. In idle loop cpu_idle_loop() (from code sched/idle.c)

In short, user preemption can occur
1. When returning to user-space from a system call
2. When returning to user-space from an interrupt handler

Kernel preemption:
So when is it safe to reschedule? The kernel can preempt a task running in the kernel
so long as it does not hold a lock.That is, locks are used as markers of regions of nonpre-
emptibility. Because the kernel is SMP-safe, if a lock is not held, the current code is reen-
trant and capable of being preempted.
The first change in supporting kernel preemption was the addition of a preemption
counter, preempt_count , to each process’s thread_info .This counter begins at zero and
increments once for each lock that is acquired and decrements once for each lock that is
released.When the counter is zero, the kernel is preemptible. Upon return from interrupt,
if returning to kernel-space, the kernel checks the values of need_resched and
preempt_count . If need_resched is set and preempt_count is zero, then a more impor-
tant task is runnable, and it is safe to preempt.Thus, the scheduler is invoked. If
preempt_count is nonzero, a lock is held, and it is unsafe to reschedule. In that case, the
interrupt returns as usual to the currently executing task.When all the locks that the cur-
rent task is holding are released, preempt_count returns to zero.At that time, the unlock
code checks whether need_resched is set. If so, the scheduler is invoked.

In short, Kernel preemption can occur

1. When an interrupt handler exits, before returning to kernel-space
2. When kernel code becomes preemptible again
3. If a task in the kernel explicitly calls schedule()
4. If a task in the kernel blocks (which results in a call to schedule() )


Unlike softirqs, however, two of the same tasklets never run concurrently—although two different tasklets can run at the same time on two different processors


Recall that two tasklets of the same type do not ever run simultaneously.Thus, there is no need to protect data used only within a single type of tasklet. If the data is shared between two different tasklets, however, you must obtain a normal spin lock before accessing the data in the bottom half.You do not need to disable bottom halves because a tasklet never preempts another running tasklet on the same processor.
With softirqs, regardless of whether it is the same softirq type, if data is shared bysoftirqs, it must be protected with a lock. Recall that softirqs, even two of the same type, might run simultaneously on multiple processors in the system. A softirq never preempts another softirq running on the same processor, however, so disabling bottom halves is not needed.


2014年8月5日 星期二

Install SCIM chewing on Ubuntu 14.04

sudo apt-get install scim scim-chewing
sudo im-config -s scim-bridge