海思hikey960开发板的zircon启动映像

海思hikey960开发板的zircon启动映像:
1、在zircon目录下,执行./scripts/flash-hikey,生成boot.img
具体命令为:
/home/suog/work/zircon-20180724/scripts/../third_party/tools/android/mkbootimg --kernel build-arm64/zhikey960-zircon-bootimage.bin --kernel_offset 0x00080000 --base 0x00000000 --ramdisk_offset 0x07c00000 --ramdisk build-arm64/dummy-ramdisk.bin --tags_offset 0x07a00000 --cmdline  -o build-arm64/boot.img

2、boot.img依赖于build-arm64/zhikey960-zircon-bootimage.bin和build-arm64/dummy-ramdisk.bin,在当前版本中,dummy-ramdisk.bin的内容没有意义,只是因为mkbootimg工具需要输入ramdisk文件。

3、zhikey960-zircon-bootimage.bin依赖于hikey960-boot-shim.bin和zircon.zbi,hikey960-boot-shim.bin的功能是根据hikey960硬件传入的参数,计算得到dts,设置zircon.zbi执行所需要的环境和变量,然跳转到zircon.zbi执行。zircon.zbi是真正的内核映像。
cat ./build-arm64/hikey960-boot-shim.bin ./build-arm64/zircon.zbi > build-arm64/hikey960-zircon-bootimage.bin

4、hikey960-boot-shim.bin的生成过程为,先生成boot-shim.elf,在objcopy后得到hikey960-boot-shim.bin
./prebuilt/downloads/gcc/bin/aarch64-elf-ld -nostdlib --build-id -z noexecstack -z max-page-size=4096 --gc-sections  --emit-relocs --build-id=none ./build-arm64/boot-shim/hikey960/kernel/target/arm64/boot-shim/boot-shim.S.o ./build-arm64/boot-shim/hikey960/kernel/target/arm64/boot-shim/boot-shim.c.o ./build-arm64/boot-shim/hikey960/kernel/target/arm64/boot-shim/debug.c.o ./build-arm64/boot-shim/hikey960/kernel/target/arm64/boot-shim/devicetree.c.o ./build-arm64/boot-shim/hikey960/kernel/target/arm64/boot-shim/util.c.o ./build-arm64/boot-shim/hikey960/kernel/lib/libc/string/memcpy.c.o ./build-arm64/boot-shim/hikey960/kernel/lib/libc/string/memmove.c.o ./build-arm64/boot-shim/hikey960/kernel/lib/libc/string/memset.c.o ./build-arm64/boot-shim/hikey960/kernel/lib/libc/string/strcmp.c.o ./build-arm64/boot-shim/hikey960/kernel/lib/libc/string/strncmp.c.o ./build-arm64/boot-shim/hikey960/system/ulib/libzbi/zbi.c.o -defsym KERNEL_ALIGN=65536 -T kernel/target/arm64/boot-shim/boot-shim.ld -o build-arm64/boot-shim/hikey960/boot-shim.elf

./prebuilt/downloads/gcc/bin/aarch64-elf-objcopy -O binary build-arm64/boot-shim/hikey960/boot-shim.elf build-arm64/hikey960-boot-shim.bin

二者大小不同
suog@JiDe:~/work/zircon-20180724$ ls -l build-arm64/boot-shim/hikey960/boot-shim.elf
-rwxrwxr-x 1 suog suog 213152 8月   2 18:32 build-arm64/boot-shim/hikey960/boot-shim.elf
suog@JiDe:~/work/zircon-20180724$ ls -l build-arm64/hikey960-boot-shim.bin
-rwxrwxr-x 1 suog suog 65536 8月   2 18:32 build-arm64/hikey960-boot-shim.bin

5、./build-arm64/zircon.zbi依赖于kernel.zbi和文件系统,文件系统包含了sample和ddk-sample,文件列表为bootfs.manifest.
build-arm64/tools/zbi -o build-arm64/zircon.zbi --complete=arm64 ./build-arm64/kernel.zbi --groups=\!sample,ddk-sample ./build-arm64/bootfs.manifest

6、kernel.zbi由kernel-image.elf去除符号表得到
./prebuilt/downloads/gcc/bin/aarch64-elf-objcopy -O binary build-arm64/kernel-image.elf build-arm64/kernel.zbi

7 kernel-image.elf依赖于./build-arm64/kernel.image.o,./build-arm64/kernel-vars.ld,kernel/image.ld,./build-arm64/zircon.elf
./prebuilt/downloads/gcc/bin/aarch64-elf-ld -nostdlib --build-id -z noexecstack -z max-page-size=4096 --gc-sections --build-id=none -o build-arm64/kernel-image.elf -T kernel/image.ld --just-symbols ./build-arm64/zircon.elf ./build-arm64/kernel-vars.ld ./build-arm64/kernel.image.o

8、./build-arm64/kernel.image.o由kernel/arch/arm64/image.S编译得到

9、./build-arm64/zircon.elf由内核的.o文件链接而成
./prebuilt/downloads/gcc/bin/aarch64-elf-ld -nostdlib --build-id -z noexecstack -z max-page-size=4096 --gc-sections  --emit-relocs -T kernel/kernel.ld build-arm64/kernel-vars.ld build-arm64/kernel/platform/generic-arm/generic-arm.mod.o build-arm64/kernel/arch/arm64/arm64.mod.o build-arm64/kernel/top/top.mod.o build-arm64/kernel/dev/hdcp/amlogic_s912/amlogic_s912.mod.o build-arm64/kernel/dev/interrupt/arm_gic/common/common.mod.o build-arm64/kernel/dev/interrupt/arm_gic/v2/v2.mod.o build-arm64/kernel/dev/interrupt/arm_gic/v3/v3.mod.o build-arm64/kernel/dev/iommu/dummy/dummy.mod.o build-arm64/kernel/dev/pcie/pcie.mod.o build-arm64/kernel/dev/pdev/pdev.mod.o build-arm64/kernel/dev/pdev/power/power.mod.o build-arm64/kernel/dev/power/hisi/hisi.mod.o build-arm64/kernel/dev/psci/psci.mod.o build-arm64/kernel/dev/timer/arm_generic/arm_generic.mod.o build-arm64/kernel/dev/uart/amlogic_s905/amlogic_s905.mod.o build-arm64/kernel/dev/uart/nxp-imx/nxp-imx.mod.o build-arm64/kernel/dev/uart/pl011/pl011.mod.o build-arm64/kernel/kernel/kernel.mod.o build-arm64/kernel/lib/bitmap/bitmap.mod.o build-arm64/kernel/lib/cbuf/cbuf.mod.o build-arm64/kernel/lib/crashlog/crashlog.mod.o build-arm64/kernel/lib/debugcommands/debugcommands.mod.o build-arm64/kernel/lib/debuglog/debuglog.mod.o build-arm64/kernel/lib/ktrace/ktrace.mod.o build-arm64/kernel/lib/memory_limit/memory_limit.mod.o build-arm64/kernel/lib/mtrace/mtrace.mod.o build-arm64/kernel/lib/userboot/userboot.mod.o build-arm64/kernel/lib/version/version.mod.o build-arm64/kernel/lib/zbi/zbi.mod.o build-arm64/kernel/object/object.mod.o build-arm64/kernel/platform/platform.mod.o build-arm64/kernel/syscalls/syscalls.mod.o build-arm64/kernel/target/target.mod.o build-arm64/kernel/tests/tests.mod.o build-arm64/kernel/dev/interrupt/interrupt.mod.o build-arm64/kernel/dev/pdev/interrupt/interrupt.mod.o build-arm64/kernel/dev/pdev/uart/uart.mod.o build-arm64/kernel/dev/udisplay/udisplay.mod.o build-arm64/kernel/lib/console/console.mod.o build-arm64/kernel/lib/counters/counters.mod.o build-arm64/kernel/lib/crypto/crypto.mod.o build-arm64/kernel/lib/debug/debug.mod.o build-arm64/kernel/lib/explicit-memory/explicit-memory.mod.o build-arm64/kernel/lib/fbl/fbl.mod.o build-arm64/kernel/lib/fixed_point/fixed_point.mod.o build-arm64/kernel/lib/header_tests/header_tests.mod.o build-arm64/kernel/lib/heap/heap.mod.o build-arm64/kernel/lib/hypervisor/hypervisor.mod.o build-arm64/kernel/lib/libc/libc.mod.o build-arm64/kernel/lib/oom/oom.mod.o build-arm64/kernel/lib/pci/pci.mod.o build-arm64/kernel/lib/pow2_range_allocator/pow2_range_allocator.mod.o build-arm64/kernel/lib/region-alloc/region-alloc.mod.o build-arm64/kernel/lib/unittest/unittest.mod.o build-arm64/kernel/lib/user_copy/user_copy.mod.o build-arm64/kernel/lib/vdso/vdso.mod.o build-arm64/kernel/lib/zxcpp/zxcpp.mod.o build-arm64/kernel/vm/vm.mod.o build-arm64/kernel/arch/arm64/hypervisor/hypervisor.mod.o build-arm64/kernel/dev/hw_rng/hw_rng.mod.o build-arm64/kernel/lib/gfx/gfx.mod.o build-arm64/kernel/lib/gfxconsole/gfxconsole.mod.o build-arm64/kernel/lib/heap/cmpctmalloc/cmpctmalloc.mod.o build-arm64/kernel/lib/io/io.mod.o build-arm64/kernel/lib/pretty/pretty.mod.o build-arm64/third_party/lib/cryptolib/cryptolib.mod.o build-arm64/third_party/lib/jitterentropy/jitterentropy.mod.o build-arm64/third_party/li
b/uboringssl/uboringssl.mod.o -o build-arm64/zircon.elf

综上,海思960开发板的boot.img生成过程为:
1、zircon内核的源文件编译成的.o文件
2、.o文件链接得到zircon.elf
3、./build-arm64/kernel.image.o,./build-arm64/kernel-vars.ld,kernel/image.ld,./build-arm64/zircon.elf这四个文件链接得到./build-arm64/kernel.image.o
4、build-arm64/kernel-image.elf去除符号表得到kernel.zbi
5、使用zbi工具,kernel.zbi合并文件系统得到zircon.zbi
6、./build-arm64/hikey960-boot-shim.bin和./build-arm64/zircon.zbi合并生成build-arm64/hikey960-zircon-bootimage.bin
7、使用mkbootimg工具,由build-arm64/hikey960-zircon-bootimage.bin生成boot.img,此处文件系统没有含义。

Linux内核生成boot.img过程为
1、在linux目录编译,生成vmlinux文件
2、vmlinux去除符号表和某些段后,得到Image
aarch64-linux-android-objcopy -O binary -R .note -R .note.gnu.build-id -R .comment -S vmlinux  Image
suog@JiDe:~/hikey960-misc/hikey-linaro$ ls -l vmlinux
-rwxrwxr-x 1 suog suog 266217992 8月   2 23:03 vmlinux
suog@JiDe:~/hikey960-misc/hikey-linaro$ ls -l Image
-rw-rw-r-- 1 suog suog 21625344 8月   3 00:03 Image
   
3、Image压缩后得到Image.gz
   gzip -9 Image

4、(不确定是否存在这一步)加入自解压头。
5、mkbootimg工具,利用Image.gz和Ramdisk得到boot.img。

一个问题是:在hikey960平台上,由Linux系统生成boot.img中的kernel和ramdisk都是gz格式的,但是在zircon内核里面,zircon内核不是gzip格式的
有两种可能:(1)Linux的内核是自解压的;(2)hikey960系统的bootloader(解释boot.img的bootloader)可以识别压缩文件,从而解压。

根据文章https://blog.csdn.net/chenyu105/article/details/7393031  内核gzip压缩与解压缩介绍,Linux内核是自解压的。


 

你可能感兴趣的:(android,操作系统)