odroidc2中可运行的fuchsia(zircon) kernel编译过程(基于2018年3月版本)

参考文献:https://forum.odroid.com/viewtopic.php?f=138&t=23370

zircon的启动

zircon内核由uboot加载,本次试验使用的uboot是odroid专门为fuchsia操作系统开发的,并没有源代码,zircon内核的启动目录内容为:

XXXXXXXX:~/work/zircon-topic-odroidc2/odroidc2-boot-files$ ls -l
总用量 8340
-rwxr-xr-x 1 suog suog    1098 8月   9 11:15 boot.scr
drwxr-xr-x 3 suog suog    4096 8月   9 11:15 dtbs
-rwxr-xr-x 1 suog suog 7402128 8月   9 11:15 odroidc2-bootdata.bin
-rwxr-xr-x 1 suog suog 1122376 8月   9 11:15 odroidc2-zircon.bin
XXXXXXXX:~/work/zircon-topic-odroidc2/odroidc2-boot-files$ find .
.
./odroidc2-zircon.bin
./dtbs
./dtbs/current
./dtbs/current/amlogic
./dtbs/current/amlogic/meson-gxbb-odroidc2.dtb
./boot.scr
./odroidc2-bootdata.bin

启动过程中依赖于无关文件

(1)u-boot.bin。u-boot.bin由odroid提供下载地址为:http://dn.odroid.com/S905/BootLoader/ODROID-C2/c2_boot_release_fuchsia.tar.gz。此uboot是fuchsia定制款,暂时没有源代码。

(2)boot.scr。boot.scr由boot.cmd生成,命令为:

 mkimage -A arm64 -T script -C none -d ./kernel/target/arm64/odroidc2/boot.cmd boot.scr

在本次试验中,boot.cmd内容如下:

XXXXXXXX:~/work/zircon-topic-odroidc2$ cat ./kernel/target/arm64/odroidc2/boot.cmd
setenv bootcmd ''

setenv fk_kvers current
setenv fdtpath /dtbs/${fk_kvers}/${fdtfile}

setenv fdt_addr_r 0x10200000
setenv kernel_addr_r 0x10280000

setenv ramdisk_addr_r 0x18000000

setenv bootargs 'TERM=uart'

# We don't have a great way to calculate the ramdisk_end
# on the odroidc2 since the default u-boot build did not
# enable the setexpr command.  In order to avoid requiring
# users to build/update the u-boot from the prebuilt available
# from hardkernel we will just declare a really large ramdisk.
# the arm generic platform will get the base address from the
# fdt, but will then pull the size from the ramdisk itself, so
# this will work around bootloader limitations without breaking
# compatibility on other targets.

setenv ramdisk_end 0x70000000

load mmc 0:1 ${fdt_addr_r} ${fdtpath}
fdt addr ${fdt_addr_r}
fdt resize
load mmc 0:1 ${ramdisk_addr_r} odroidc2-bootdata.bin
fdt chosen ${ramdisk_addr_r} ${ramdisk_end}
load mmc 0:1 ${kernel_addr_r} odroidc2-zircon.bin

booti ${kernel_addr_r} - ${fdt_addr_r}

(3)dtb文件。./dtbs/current/amlogic/meson-gxbb-odroidc2.dtb,设备树文件,Linux内核启动必须的,zircon在2018年3月份,也是需要有设备树文件的,2018年7月后从boot_shim启动,就不需要了。zircon改动很大,日新月异,跟不上步伐啊。。。。。。。。

(4)./odroidc2-zircon.bin。zircon的内核文件。

(5)./odroidc2-bootdata.bin。zircon的文件系统,相当于ramdisk。

 

odroidc2-zircon.bin的生成过程(倒叙)

1、odroidc2-zircon.bin

kernel/target/arm64/odroidc2/prepend-header.py --kernel ./build-arm64/zircon.bin --load_offset 0x10280000 --output ./build-arm64/odroidc2-zircon.bin

odroidc2-zircon.bin依赖于zircon.bin,在zircon.bin前面加上了64KB的文件头,添加文件头的脚本是kernel/target/arm64/odroidc2/prepend-header.py。文件头的前64字节内容如下:

4D 5A 00 91  FF 3F 00 14
//指令:0x91005a4d   含义# mrs   x19, mpidr_el1 ('MZ' magic)
//指令:0x14003fff   含义跳转到当前指令地址+4*0x3fff处执行,就是zircon内核的首地址  
00 00 28 10  00 00 00 00
//0x0000000010280000, 内核的加载地址load_offset  
48 20 10 00  00 00 00 00  
//0x0000000000102048,内核的大小kernel_size
00 00 00 00  00 00 00 00  //unused
00 00 00 00  00 00 00 00  //unused
00 00 00 00  00 00 00 00  //unused
00 00 00 00  00 00 00 00  //unused
41 52 4D 64  00 00 00 00  //41524D:ARM 64尾标志

2、zircon.bin

./prebuilt/downloads/gcc/bin/aarch64-elf-objcopy -O binary build-arm64/zircon.elf build-arm64/zircon.bin

3、zircon.elf。所有obj文件链接生成

./prebuilt/downloads/gcc/bin/aarch64-elf-ld -nostdlib --build-id -z max-page-size=4096 --gc-sections  -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/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/debugcommands/debugcommands.mod.o build-arm64/kernel/lib/debuglog/debuglog.mod.o build-arm64/kernel/lib/ktrace/ktrace.mod.o build-arm64/kernel/lib/mdi/mdi.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/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/third_party/lib/fdt/fdt.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/third_party/lib/safeint/safeint.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/lib/qrcodegen/qrcodegen.mod.o build-arm64/third_party/lib/uboringssl/uboringssl.mod.o -o build-arm64/zircon.elf

 

 

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