2011年8月4日 星期四

android boot img

reference : http://huenlil.pixnet.net/blog/post/23862982

*boot.img = zImage + ramdisk.img
zImage = kernel image
ramdisk.img = out/target/product/blaze/root/
%./out/host/linux-x86/bin/mkbootimg
--kernel zImage
--ramdisk ramdisk.img
--base 0x80000000
--cmdline "console=ttyO2,115200n8 mem=456M@0x80000000 mem=512M@0xA0000000 init=/init androidboot.console=ttyO2"
--board xxxx
-o boot.img.new
Output: boot.img.new
**Note: bootarg is passed to kernel via --cmdline option above



How to unpack/pack ramdisk.img
unpack:
#gunzip -c ../your-ramdisk-file | cpio -i
pack:
#find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz


+-----------------+
| boot header | 1 page
+-----------------+
| kernel | n pages
+-----------------+
| ramdisk | m pages
+-----------------+
| second stage | o pages
+-----------------+

n = (kernel_size + page_size - 1) / page_size
m = (ramdisk_size + page_size - 1) / page_size
o = (second_size + page_size - 1) / page_size

0. all entities are page_size aligned in flash
1. kernel and ramdisk are required (size != 0)
2. second is optional (second_size == 0 -> no second)

usage: mkbootimg
--kernel
--ramdisk
[ --second <2ndbootloader-filename> ]
[ --cmdline ]
[ --board ]
[ --base
]
[ --pagesize ]
-o|--output


bootimg:
mkdir -p $(IMAGES_PATH)
cd $(IMAGES_PATH) && $(MKIMAGE) --kernel $(KDIR)/arch/arm/boot/zImage \
--ramdisk $(OUT_TARGET_DIR)/ramdisk.img \
--base 0x80000000 --cmdline "$(KERNEL_BOOTPARAMS)" \
--board omap4 -o boot.img && cd -

ex: mkbootimg --cmdline 'no_console_suspend=1 console=null' --kernel your-kernel-file --ramdisk newramdisk.cpio.gz -o mynewimage.img


==========================================================================================================================================
* system.img
#uncompress
%./out/host/linux-x86/bin/simg2img system.img system.img.raw
#mount to directory mnt-point/
%mkdir mnt-point
%sudo mount -t ext4 -o loop system.img.raw mnt-point/
#modify any .so or apk in the mnt-point/ directory
#rezip
%sudo out/host/linux-x86/bin/make_ext4fs -s -l 512M -a system system.img.new mnt-point/
%sudo umount mnt-point/
Output: system.img.new
=====================================================================================

2011年8月3日 星期三

Android Build Number

reference: http://blog.roodo.com/thinkingmore/archives/14594619.html
http://blog.csdn.net/yrj/article/details/5785894


I only setting : mydroid/build/core/build_id.mk
BUILD_NUMBER := test-2011

2011年8月2日 星期二

vim 整段註解

‧執行 vim 某個 文字檔,進入vim:

1. 先按 Esc 離開 insert mode
2. 再按 ctrl+v 將要註解的這幾行選取(使用上下左右鍵 or + shift )
3. 再按大寫的 I (指的是進入Insert mode)
4. 再輸入 #
5. 最後按 Esc 就會看到選取的這幾行都被 # 註解掉了

2011年6月29日 星期三

i2c command on uboot

#iprobe : probe to discover i2c chip address
#ibus [idx] [spd] : testing i2c bus speed ex: ibus 0 64
64(ST),0x190(FS),0xD480(HS)
#imd: display i2c memory
imd [chip address] [register address] .[show byte .0 .1 .2] [num of byte]
> imd 0x55 0x10.0 10
#imm: write data via i2c address
imm [chip address] [register address>.[show byte .0 .1 .2]

2011年6月28日 星期二

capture log into file from minicom

Ctrl+A+L --> open capture to which file? > input your file which store log
Ctrl+A+L --> close or pause

vim & cscope

reference:
http://blog.chhsu.org/2009/03/multi-projects-of-vim-using-cscope.html
http://rickey-nctu.blogspot.com/2009/02/vim-srcexpl.html

Installing:
sudo apt-get install cscope ctags

Build my environment:
step1: Put debug.sh into ~/bin/
#!/bin/bash
CSCOPE_FILE=cscope.out
if [ -n "$1" ]; then
echo "Source code directory: " $1
echo "Create file map : " $CSCOPE_FILE
find $1 -name "*.h" -o -name "*.c" -o -name "*.cpp" > $CSCOPE_FILE
cscope -bkq -i $CSCOPE_FILE
# cscope -Rbkq
ctags -R
else
echo "Please key-in path of project"
fi

step2: modify cscope_map.bin on /usr/share/vim/vim72/plugin/cscope-map.bin
let i = 1
while i < 20
if filereadable("cscope.out")
let db = getcwd() . "/cscope.out"
"echo db
let $CSCOPE_DB = db
cs add $CSCOPE_DB
let i = 20
else
cd ..
let i += 1
endif
endwhile

Debug:
step1:
go to project and type: #debug.sh

step2:
Open you want to trace code via vi
ex: vi /arch/arm/mach-xxx/board_xxxx.c

Trace code :
(Ctrl+\+c) : who call this function --> (Ctrl+\+t): return back
(Ctrl+\+g) : find this function defination --> (Ctrl+\+t) : return back
(Ctrl+\+s) : which function uses this function --> (Ctrl+\+t) : retunn back

2011年6月27日 星期一

view code by ctags

Exuberant Ctags
Installing :apt-get install exuberant-ctags

@setup taglist

Edit: /etc/vim/vimrc

"Tglist edit
set tags=tags;
set autochdir
nnoremap :TlistToggle

@ Create tags into root directory of project
# ctags -R *

@ Operation
step1 : Don't open screen
step2: Open Tlist via F9
step3: Open you want to see functino via Ctrl+]
If you want to open new window to see this function, you can type Ctrl+w+]
step4: Return your main window Ctrl+t
Or, you can close your new winodw which see this function, you can type Ctrl+w+q

@You can change your window size by Ctrl+w+"+" or Ctrl+w+"-"