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? ####
###################################
############################################
#### How to pack files into APK? ####
############################################
#######################################
#### How to create keystore? ####
#######################################
###################################
#### How to sign an APK? ####
###################################
###################################
#### How to laing an APK? ####
###################################
relative to the start of the file, which reduces the amount of RAM consumed by an app.
#### 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.htmlzipalign ensures that all uncompressed data starts with a particular byte alignment
1. Run "zipalign -v 4 xxx-unaligned.apk xxx.apk"
relative to the start of the file, which reduces the amount of RAM consumed by an app.
2015年8月26日 星期三
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:
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
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:
3. Install gerrit"CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';" "CREATE DATABASE reviewdb;" "ALTER DATABASE reviewdb charset=latin1;" "GRANT ALL ON reviewdb.* TO 'gerrit2'@'localhost';" "FLUSH PRIVILEGES;"
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.so7. Create HTTP basic auth user/passwd file, later you won't need -c flag.(-c: create)
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>
sudo htpasswd -c /home/gerrit2/review_gerrit/etc/gerrit.htpasswd UserName8. My final gerrit.config is as following
[gerrit]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
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
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.
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
2014年8月4日 星期一
Update/Recover from Ubuntu 14.04 upgrade
1. First of all, the upgrade is simple. Follow the prompt and click next.
2. During the process, it says my xserver-xcore-video-all package has problem and my upgrade is canceled. In order to go on, I deleted that package
4. Download the latest NVIDIA driver from http://www.nvidia.com/Download/index.aspx and install.
p.s. The latest one is 340.24 and before this I tried the previously used the old one 331.20 and a random one not even double checked 331.67, both won't work and says "The system is running in low-graphis mode."
p.s. Please check /var/log/Xorg.0.log and kern.log for detail description. (words regarding nvidia driver problems)
5. Now we can log in but the resolution is very weired and shows only desktop. No unity icon, right botton does not work.
p.s. I thought it's unity/compiz/lightdm problem so I removed the previous settings by
but I think the above is unrelated.
6. Step 5 does not solve my problem and there is still not desktop with unity and I checked /var/log/lightdm/lightdm.log and found "Xlib: extension "GLX" missing on display ":0"."
7. "DISPLAY=:0 glxinfo" shows the same error
8. ldd /usr/bin/glxinfo and found libGL.so links to correct version(340.23) driver gl library.
9. Suddently I recalled that I removed xservice-xorg-video-all in the first place.
10. Trying to install this package and found the PPAs are different for 13.10 and 14.04. So I remove the the original ppa
11. Finally my Ubuntu upgrade finishes.
2. During the process, it says my xserver-xcore-video-all package has problem and my upgrade is canceled. In order to go on, I deleted that package
sudo apt-get remove xserver-xorg-video-all3. Things go well until the system reboots
4. Download the latest NVIDIA driver from http://www.nvidia.com/Download/index.aspx and install.
p.s. The latest one is 340.24 and before this I tried the previously used the old one 331.20 and a random one not even double checked 331.67, both won't work and says "The system is running in low-graphis mode."
p.s. Please check /var/log/Xorg.0.log and kern.log for detail description. (words regarding nvidia driver problems)
5. Now we can log in but the resolution is very weired and shows only desktop. No unity icon, right botton does not work.
p.s. I thought it's unity/compiz/lightdm problem so I removed the previous settings by
rm -rf /.config/*
rm -rf ~/.compiz/*
rm -rf ~/.cache/compizconfig-1/
but I think the above is unrelated.
6. Step 5 does not solve my problem and there is still not desktop with unity and I checked /var/log/lightdm/lightdm.log and found "Xlib: extension "GLX" missing on display ":0"."
7. "DISPLAY=:0 glxinfo" shows the same error
8. ldd /usr/bin/glxinfo and found libGL.so links to correct version(340.23) driver gl library.
9. Suddently I recalled that I removed xservice-xorg-video-all in the first place.
10. Trying to install this package and found the PPAs are different for 13.10 and 14.04. So I remove the the original ppa
sudo ppa-purge xorg-edgersand add it back
sudo apt-add-repository ppa:xorg-edgers
sudo apt-get updatesudo apt-get upgrade
11. Finally my Ubuntu upgrade finishes.
2014年7月31日 星期四
SOP to reinstall nvidia graphic card driver
From time to time, the display won't work correctly after my system upgrade or software upgrade. The following is the SOP to solve this problem:
a.
1. don't use Nvidia's graphic card
b.
1. ctrl + alt + F1 to change to another tty
2. sudo service lightdm stop to stop X
3. sudo ./XXXX-nvidia.xxx.run
4. sudo service lightdm start to activate X
a.
1. don't use Nvidia's graphic card
b.
1. ctrl + alt + F1 to change to another tty
2. sudo service lightdm stop to stop X
3. sudo ./XXXX-nvidia.xxx.run
4. sudo service lightdm start to activate X
2014年6月9日 星期一
LKD notes
1. types of exceptions: divided by 0; page fault; system call
2. Why interrupt can not sleep? Interrupt do not have task_info structure and therefore can not trace through the rbtree to find the next runnable process to run. Though current macro points to the interrupted process, but there is no way to find the interrupt handler that sleeps and to continue execution.
3. When do_IRQ() finished the isr, the entry code will then call ret_from_intr() and it checks is a reshcedule is pending(need_resched is set). If the reschedule is pending and the kernel is returning to user-space(that is, the interrupt interrupted a user process), schedule() is called. If the kernel is returning to kernel-space(that is, the interrupt interrupted the kernel itself), schedule() is called only if the preempt_count is zero. After schedule() returns, or if there is no work pending, the initial registers are restored and the kernel resumes whatever was interrupted. (do_IRQ() corresponds to handle_IRQ() under arch/arm/kernel/irq.c for ARM)
4. Sometimes we see spin_lock_irqsave()/spin_unlock_irqrestore() and mutex_lock()/mutex_unlock() pairs and the first is to provide protection against concurrent access from a possible interrupt handler and the later is to provide protection against concurrent access from another processor.
5. Interrupt handlers run asynchronously with at least the current interrupt line disabled.
2. Why interrupt can not sleep? Interrupt do not have task_info structure and therefore can not trace through the rbtree to find the next runnable process to run. Though current macro points to the interrupted process, but there is no way to find the interrupt handler that sleeps and to continue execution.
3. When do_IRQ() finished the isr, the entry code will then call ret_from_intr() and it checks is a reshcedule is pending(need_resched is set). If the reschedule is pending and the kernel is returning to user-space(that is, the interrupt interrupted a user process), schedule() is called. If the kernel is returning to kernel-space(that is, the interrupt interrupted the kernel itself), schedule() is called only if the preempt_count is zero. After schedule() returns, or if there is no work pending, the initial registers are restored and the kernel resumes whatever was interrupted. (do_IRQ() corresponds to handle_IRQ() under arch/arm/kernel/irq.c for ARM)
4. Sometimes we see spin_lock_irqsave()/spin_unlock_irqrestore() and mutex_lock()/mutex_unlock() pairs and the first is to provide protection against concurrent access from a possible interrupt handler and the later is to provide protection against concurrent access from another processor.
5. Interrupt handlers run asynchronously with at least the current interrupt line disabled.
2014年4月1日 星期二
Monitor dd progress
When we flash an image to a SD card through dd command,
we won't be able to know the progress by default.
If you need type sudo kill -USR1 $(pgrep ^dd)
and you will see the progress.
2014年1月20日 星期一
Steps to mount .img
Ok, you may have a image with multi-partitions(for example, boot and rootfs )and you may need to access the data under rootfs, and, you don't want to flash this image.
The concept is you mount the partition inside the image you want and the following are steps.
1. find partition information
mount -o loop /path/to/image won't work in this case since the start byte does not contain file system information in this image type
The concept is you mount the partition inside the image you want and the following are steps.
1. find partition information
fdisk -l xxx.img2. mount the partition as block device and have to specify the start address in bytes
sudo losetup /dev/loop0 xxx.img -o $((Start Sectors*512))3. mount it
sudo mount -t ext3 /dev/loop0 /mount/point
mount -o loop /path/to/image won't work in this case since the start byte does not contain file system information in this image type
2013年11月7日 星期四
Build OpenNI apk in Ubuntu shell
You should have AndroidManifest.xml in the APK root first and use the following command to generate build.xml
Easy~
~/ADT/android-sdk-linux/tools/android update project --target android-18 -p .Now you can build
ant debug/release -Dsdk.dir=/home/stevenchiu/ADT/android-sdk-linux/
Easy~
To run OpenNI Simple Viewer wth Kinect in BeagleBone Black Android
1. Build OpenNI
If you encountered cpu_set_t can not be recognized in NiSkeletonBenchmark.cpp, simply ignore this behaviour
-#if (XN_PLATFORM != XN_PLATFORM_MACOSX)
+#if (XN_PLATFORM != XN_PLATFORM_MACOSX && XN_PLATFORM != XN_PLATFORM_ANDROID_ARM) ^M
//we want out benchmark application will be running only on one CPU core
cpu_set_t mask;
2. Build SensorKinect
Now we have to upload the libraries located in Platform/Android/libs/armeabi-v7a/*.so to android /system/libs. We have to upload OpenNI libraries first and then SensorKinect since some libraries should be replaced according to the HW.
i.e. Kinect in this case.
Please remember to upload the Sample-SimpleRead binary to /system/bin/
4. Mount USBFS to grant USB device permission
mount -o devmode=0666 -t usbfs none /proc/bus/usb
5. Push xmls to /Data/ni
adb push SamplesConfig.xml /Data/ni
adb push modules /Data/ni
adb push GlobalDefaultskinect.ini /Data/ni
adb push License.xml /Data/ni
6. Run Sample-Read under /Data/ni
You should be able to see the middle point and frame rate
#Trouble shooting
USB open fail => sudo rmmod gpsca_kinect
git clone git://github.com/OpenNI/OpenNI
git checkout -b 1.5.4.0 Unstable-1.5.4.0checkout to tag 1.5.4.0, only this tag works for me
cd Platform/Android/jni
${NDK_ROOT}/ndk-buildYou have to define your NDK_ROOT of course. I use NDK r7
If you encountered cpu_set_t can not be recognized in NiSkeletonBenchmark.cpp, simply ignore this behaviour
-#if (XN_PLATFORM != XN_PLATFORM_MACOSX)
+#if (XN_PLATFORM != XN_PLATFORM_MACOSX && XN_PLATFORM != XN_PLATFORM_ANDROID_ARM) ^M
//we want out benchmark application will be running only on one CPU core
cpu_set_t mask;
2. Build SensorKinect
export NDK_MODULE_PATH=/path/to/openni/Platform/Android/jni
git clone git://github.com/avin2/SensorKinect.git
git checkout -b unstable origin/unstable
cd Platform/Android/jni
${NDK_ROOT}/ndk-build
3. Upload your libraries and binary to Android
Now we have to upload the libraries located in Platform/Android/libs/armeabi-v7a/*.so to android /system/libs. We have to upload OpenNI libraries first and then SensorKinect since some libraries should be replaced according to the HW.
i.e. Kinect in this case.
Please remember to upload the Sample-SimpleRead binary to /system/bin/
4. Mount USBFS to grant USB device permission
mount -o devmode=0666 -t usbfs none /proc/bus/usb
5. Push xmls to /Data/ni
adb push SamplesConfig.xml /Data/ni
adb push modules /Data/ni
adb push GlobalDefaultskinect.ini /Data/ni
adb push License.xml /Data/ni
6. Run Sample-Read under /Data/ni
You should be able to see the middle point and frame rate
#Trouble shooting
USB open fail => sudo rmmod gpsca_kinect
2013年10月30日 星期三
To run Nite samples in Ubuntu 13.10 (Nite + OpenNI + SensorKinect)
1. Build OpenNI
2. Build SensorKinect
now you can download NITE-Bin-Dev-Linux-x64-v1.5.2.21.tar.zip and run samples under Samples/Bin/x64-Release
git clone git://github.com/OpenNI/OpenNI
git checkout -b 1.5.4.0 Unstable-1.5.4.0checkout to tag 1.5.4.0, only this tag works for me
cd Platform/Linux/CreateRedist
./RedistMaker
cd ../Redist/$(Openni Version)/In my case, it's OpenNI-Bin-Dev-Linux-x64-v1.5.4.0
sudo install.sh
2. Build SensorKinect
git clone git://github.com/avin2/SensorKinect.git
git checkout -b unstable origin/unstable
cd Platform/Linux/CreateRedist
./RedistMaker
cd ../Redist/$(Sensor Kinect Version)/In my case, it's Sensor-Bin-Linux-x64-v5.1.2.1
sudo install.shIt's that simple.
now you can download NITE-Bin-Dev-Linux-x64-v1.5.2.21.tar.zip and run samples under Samples/Bin/x64-Release
2013年10月28日 星期一
[BBB] memo of configuring BeagleBone Black network
manually add a gateway
route add default gw 192.168.1.1 dev eth0 => add default gateway
The following configuration in /etc/network/interfaces does all above:
#iface eth0 inet dhcp iface eth0 inet static address 192.168.1.2 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1 dns-nameservers 192.168.1.1
Finally, add nameserver in /etc/resolf.conf
echo "nameserver 192.168.1.1" > /etc/resolv.conf
Restart network now: /etc/init.d/networking restart => restart network or
ifdown eth0; ifup eth0
toolchain for BBB is arm-linux-gnueabihf
Problem solved!
extract and cross compiled with CC=arm-linux-gnueabihf-gcc ./configue --target=arm-linux
2013年10月21日 星期一
Build OpenCV from souce
sudo apt-get install libgtk2.0-devI only encounter this problem. please google the error message you see to get the corresponding solutions
git clone https://github.com/Itseez/opencv.git
cd opencv
git checkout 2.4.6.2 -b 2.4.6.2default is master branch and I manually checkout to 2.4.6.2 tag.
mkdir build(whatever name you want)
cd build
cmake-gui ..(to generate the configurations you want and generate make file. sudo apt-get install cmake-gui if you don't have it.)
make; sudo mak install
2013年7月24日 星期三
Generate patches for specific user
To generate my own patches by the following command:
for commit in `git log --author=XXX --pretty=oneline | awk '{print $1}'`; do git format-patch -1 "$commit"; done
for commit in `git log --author=XXX --pretty=oneline | awk '{print $1}'`; do git format-patch -1 "$commit"; done
2012年12月18日 星期二
2012年3月22日 星期四
some string related tips
0. replace strings for all files in a folder
find ./ | xargs grep -l "$STRING_TO_BE_REPLACED" | xargs sed -i -e "s/$STRING_TO_BE_REPLACED/$STRING_TO_REPLACE/g"
0. find files and then grep som key word
find ./ -iname '$FILE_NAMES*' | xargs grep $SEARCH_KEY_WORDS
0. find files and then remove
find ./ -iname '$FILE_NAMES*' | xargs rm -rf
0. find and push multiple files from adb
find ./ -iname *.ko | xargs -t -i adb push {} /system/lib/modules/
0. Search multiple words in VIM
/\(kernel\|panic\); you will search both kernel and panic at the same time
0. Copy and rename multiple filse
for i in `find ./ -iname "*file_name*"`; do cp $i `echo $i | sed "s/$STRING_TO_BE_REPLACED/$STRING_TO_REPLACE/g"`; done
find ./ | xargs grep -l "$STRING_TO_BE_REPLACED" | xargs sed -i -e "s/$STRING_TO_BE_REPLACED/$STRING_TO_REPLACE/g"
0. find files and then grep som key word
find ./ -iname '$FILE_NAMES*' | xargs grep $SEARCH_KEY_WORDS
0. find files and then remove
find ./ -iname '$FILE_NAMES*' | xargs rm -rf
0. find and push multiple files from adb
find ./ -iname *.ko | xargs -t -i adb push {} /system/lib/modules/
0. Search multiple words in VIM
/\(kernel\|panic\); you will search both kernel and panic at the same time
0. Copy and rename multiple filse
for i in `find ./ -iname "*file_name*"`; do cp $i `echo $i | sed "s/$STRING_TO_BE_REPLACED/$STRING_TO_REPLACE/g"`; done
2011年12月26日 星期一
Note about kobjects, ksets, and ktypes.
kobject, quoted form kernek documentation: (example in samples/kobject/kobject-example.c)
1. A kobject must be initialized. for example
1. A kobject must be initialized. for example
void kobject_init(struct kobject *kobj, struct kobj_type *ktype);
The ktype is required for a kobject to be created properly, as every kobject
must have an associated kobj_type.
2. After calling kobject_init(), to regsiter the kobject with sysfs, kobject_add() must be called
int kobject_add(struct kobject *kobj, struct kobject *parent, const char *fmt, ...);
This setup the parrent of the kobject and the name for the kobject properly. If the kobject is to be associated with a specific kset, kobj->kset must be assigned before calling kobject_add(). If a kset is associated with a kobject, then the parent for the kobject can be set to NULL in the call to kobject_add() andthen the kobject's parent will be the kset itself.
or call int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
struct kobject *parent, const char *fmt, ...); to init and add kobject to the kernel at the same time.
3. To inform userspace that a kobj has been created, call
int kobject_uevent(struct kobject *kobj, enum kobject_action action);
4. To create a simple directory in the sysfs hierarchy and not to mess with the whole complication of ksets, show and store functions, call
struct kobject *kobject_create_and_add(char *name, struct kobject *parent);
It creates a kobject and place it in sysfs in the location underneath the specified parent kobject.
5. To release a kobject, don't do kfree() but kobject_put(). A good practice is to use kobject_put() as an error check after kobject_init() to avoid errors creeping in.
6. Every kobject must have a release() method and the release() method is not stored in the kobject itself but associated with the ktype. for example:
struct kobj_type {
void (*release)(struct kobject *);
const struct sysfs_ops *sysfs_ops;
struct attribute **default_attrs;
};
This structure must be referenced when you call kobject_init() or kobject_init_and_add()..
The ktype is required for a kobject to be created properly, as every kobject
must have an associated kobj_type.
2. After calling kobject_init(), to regsiter the kobject with sysfs, kobject_add() must be called
int kobject_add(struct kobject *kobj, struct kobject *parent, const char *fmt, ...);
This setup the parrent of the kobject and the name for the kobject properly. If the kobject is to be associated with a specific kset, kobj->kset must be assigned before calling kobject_add(). If a kset is associated with a kobject, then the parent for the kobject can be set to NULL in the call to kobject_add() andthen the kobject's parent will be the kset itself.
or call int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
struct kobject *parent, const char *fmt, ...); to init and add kobject to the kernel at the same time.
3. To inform userspace that a kobj has been created, call
int kobject_uevent(struct kobject *kobj, enum kobject_action action);
4. To create a simple directory in the sysfs hierarchy and not to mess with the whole complication of ksets, show and store functions, call
struct kobject *kobject_create_and_add(char *name, struct kobject *parent);
It creates a kobject and place it in sysfs in the location underneath the specified parent kobject.
5. To release a kobject, don't do kfree() but kobject_put(). A good practice is to use kobject_put() as an error check after kobject_init() to avoid errors creeping in.
6. Every kobject must have a release() method and the release() method is not stored in the kobject itself but associated with the ktype. for example:
struct kobj_type {
void (*release)(struct kobject *);
const struct sysfs_ops *sysfs_ops;
struct attribute **default_attrs;
};
This structure must be referenced when you call kobject_init() or kobject_init_and_add()..
訂閱:
文章 (Atom)
標籤
- 生活
- 閒聊
- android
- arm
- assembly
- beaglebone black
- bl
- business trip
- car rental
- coupon
- cross compile
- cygwin iphone toolchain install build
- dropbear
- embedded system
- find
- GDB
- gdbserver
- grep
- instruction
- io
- kinect
- life
- linux
- openni
- programming
- QT visual studio express 2008 install
- qualcomm
- qualcomm business trip
- replace
- rild
- san diego
- ssh
- substitute
- system realated
- toolchain
- ubuntu
- vim ^M 換行
- Windows CE VM

