openwrt: patch-dtb

dts的概念是linux kernel中的,跟openwrt的关系不大。只是恰好在学习openwrt的时候碰到了这个东西,所以记录在openwrt名下。

patch-dtb

openwrt对arch/mips/kernel/head.S文件打了补丁,在其中加入了以下几行:

	.ascii  "OWRTDTB:"
	EXPORT(__image_dtb)
	.fill   0x4000
	__REF

在代码中预留了16KB的空间用于存放dtb数据,以"OWRTDTB:"为标志。

patch-dtb源码位于openwrt/tools/patch-image/src/patch-dtb.c,执行命令为:patch-dtb vmlinux-mt7620a MT7620A.dtb

patch-dtb在vmlinux的前16KB空间中中查找"OWRTDTB:"字符串,找到之后,把预留的16KB空间清0, 并把dtb数据复制到该处。

parse in kernel

start_kernel()
  -> setup_arch()
     -> arch_mem_init()
        -> plat_mem_setup()
           -> __dt_setup_arch(&__image_dtb);
              -> early_init_dt_scan()
        -> device_tree_init()

initial_boot_params = __image_dtb;
__image_dtb 定义于arch/mips/kernel/head.S中,是dtb区域的起始地址。

posted @ 2014-09-17 18:57  sammei  阅读(2238)  评论(0编辑  收藏  举报