如何產生bootable kernel image "zImage":
1. 用以下指令產生ELF format kernel proper (.vmlinux.cmd):
cmd_vmlinux := /usr/local/arm/4.2.2-eabi/usr/bin/arm-unknown-linux-gnueabi-ld -EL -p --no-undefined -X -o vmlinux -T arch/arm/kernel/vmlinux.lds arch/arm/kernel/head.o arch/arm/kernel/init_task.o init/built-in.o --start-group usr/built-in.o arch/arm/kernel/built-in.o arch/arm/mm/built-in.o arch/arm/common/built-in.o arch/arm/mach-s5pc100/built-in.o arch/arm/plat-s5pc1xx/built-in.o arch/arm/plat-s3c/built-in.o arch/arm/nwfpe/built-in.o arch/arm/vfp/built-in.o kernel/built-in.o mm/built-in.o fs/built-in.o ipc/built-in.o security/built-in.o crypto/built-in.o block/built-in.o arch/arm/lib/lib.a lib/lib.a arch/arm/lib/built-in.o lib/built-in.o drivers/built-in.o sound/built-in.o firmware/built-in.o net/built-in.o --end-group .tmp_kallsyms2.o
2.用objcopy指令將kernel proper中的.note .comment ..note.gnu.build sections移除,並remove sections containing debugging information,而產生a raw binary file "arch/arm/boot/Image" (arch/arm/boot/.Image.cmd):
cmd_arch/arm/boot/Image := /usr/local/arm/4.2.2-eabi/usr/bin/arm-unknown-linux-gnueabi-objcopy -O binary -R .note -R .note.gnu.build-id -R .comment -S vmlinux arch/arm/boot/Image
3. 再將Image用以下指令做gzip 壓縮(kernel/arch/arm/boot/compressed/.piggy.gz.cmd):
cmd_arch/arm/boot/compressed/piggy.gz := gzip -f -9 <> arch/arm/boot/compressed/piggy.gz
4. 將piggy.gz include到"piggy.o"的".piggydata" section ( arch/arm/boot/compressed/piggy.S):
.section .piggydata,#alloc
.globl input_data
input_data:
.incbin "arch/arm/boot/compressed/piggy.gz"
.globl input_data_end
input_data_end:
5. 用以下的指令compile arch/arm/boot/compressed/piggy.S 產生piggy.o(arch/arm/boot/compressed/.piggy.o.cmd).
cmd_arch/arm/boot/compressed/piggy.o := /usr/local/arm/4.2.2-eabi/usr/bin/arm-unknown-linux-gnueabi-gcc -Wp,-MD,arch/arm/boot/compressed/.piggy.o.d -nostdinc -isystem /usr/local/arm/4.2.2-eabi/usr/bin-ccache/../lib/gcc/arm-unknown-linux-gnueabi/4.2.2/include -D__KERNEL__ -Iinclude -I/home/qustion/Samsung/s5pc100/03_bsp/Android/Beta_v0.3_090720/source/kernel/arch/arm/include -include include/linux/autoconf.h -mlittle-endian -Iarch/arm/mach-s5pc100/include -Iarch/arm/plat-s5pc1xx/include -Iarch/arm/plat-s3c/include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-interwork -D__LINUX_ARM_ARCH__=7 -march=armv5t -Wa,-march=armv7-a -msoft-float -gdwarf-2 -c -o arch/arm/boot/compressed/piggy.o arch/arm/boot/compressed/piggy.S
6. 再透過"arm-unknown-linux-gnueabi-ld"將arch/arm/boot/compressed/head.o, arch/arm/boot/compressed/piggy.o 和arch/arm/boot/compressed/misc.o整合成"arch/arm/boot/compressed/vmlinux" (arch/arm/boot/compressed/.vmlinux.cmd ):
./arch/arm/boot/compressed/.vmlinux.cmd:cmd_arch/arm/boot/compressed/vmlinux := /usr/local/arm/4.2.2-eabi/usr/bin/arm-unknown-linux-gnueabi-ld -EL --defsym zreladdr=0x20008000 --defsym initrd_phys=0x20800000 --defsym params_phys=0x20000100 -p --no-undefined -X /usr/local/arm/4.2.2-eabi/usr/bin-ccache/../lib/gcc/arm-unknown-linux-gnueabi/4.2.2/libgcc.a -T arch/arm/boot/compressed/vmlinux.lds arch/arm/boot/compressed/head.o arch/arm/boot/compressed/piggy.o arch/arm/boot/compressed/misc.o -o arch/arm/boot/compressed/vmlinux
7.用objcopy指令將arch/arm/boot/compressed/vmlinux中的.note .comment ..note.gnu.build sections移除,並remove sections containing debugging information,而產生a raw binary file "arch/arm/boot/zImage" (arch/arm/boot/.zImage.cmd),bootloader即可load 該composite kernel image 以執行linux :
cmd_arch/arm/boot/zImage := /usr/local/arm/4.2.2-eabi/usr/bin/arm-unknown-linux-gnueabi-objcopy -O binary -R .note -R .note.gnu.build-id -R .comment -S arch/arm/boot/compressed/vmlinux arch/arm/boot/zImage
reference:
1.
arch/arm/mach-s5pc100/Makefile.boot定義kernel loading memory address and kernel paramter address:
zreladdr-y := 0x20008000
params_phys-y := 0x20000100
initrd_phys=0x20800000
2.
http://book.opensourceproject.org.cn/embedded/embeddedprime/
3.
http://www.keil.com/support/man/docs/armasm/armasm_caccaghf.htm
4.
http://blog.linux.org.tw/~jserv/archives/001767.html
1 則留言:
Hmm is anyone else having problems with the pictures
on this blog loading? I'm trying to determine if its a problem on my end or if it's the blog.
Any feed-back would be greatly appreciated.
my webpage ... how to get followers on instagram
張貼留言