uboot命令:

tftp 0x20008000 192.168.1.8:zImage.bin; tftp 0x20000100 192.168.1.8:perr.dtb; bootm 0x20008000 - 0x20000100

md.b 0x200061fc 100的输出:

200061fc: 62 6f 6f 74 61 72 67 73 00 63 73 69 73 30 00 66    bootargs.csis0.f
2000620c: 69 6d 63 30 00 66 69 6d 63 31 00 66 69 6d 63 32    imc0.fimc1.fimc2
2000621c: 00 69 32 63 30 00 69 32 63 31 00 69 32 63 32 00    .i2c0.i2c1.i2c2.
2000622c: 69 32 73 30 00 69 32 73 31 00 69 32 73 32 00 70    i2s0.i2s1.i2s2.p
...

fdt list /chosen的输出:
chosen {
        bootargs = "console=ttySAC0,115200n8 root=/dev/mmcblk0p1 rw rootwait ignore_loglevel earlyprintk";
};

内核打印:

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.17.0-rc4-00355-g1536340-dirty (perr@fedora) (gcc version 4.4.6 (crosstool-NG 1.19.0) ) #145 PREEMPT Thu Sep 25 1
8:12:21 CST 2014
[    0.000000] CPU: ARMv7 Processor [412fc082] revision 2 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] enter setup_machine_fdt(dt_phys=0x20000100)
[    0.000000] initial_boot_params=0xc0000100
[    0.000000] Machine model: (null)
[    0.000000] search "chosen", depth: 0, uname: 
[    0.000000] search "chosen", depth: 1, uname: chosen
[    0.000000] first prop[0xc00061fc]: <-----这个地方是空的,说明这个地方被清零了.
[    0.000000] BUG:     no bootargs found from dt

内核调用路径:

start_kernel()->
setup_arch()->
setup_machine_fdt()->
early_init_dt_scan_nodes()->
of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line)->
early_init_dt_scan_chosen()-> of_get_flat_dt_prop(node, "bootargs", &l)
    ...
    int i;
    struct fdt_property * property = NULL;
    i = fdt_first_property_offset(initial_boot_params, node);
    if(IS_ERR(i)) pr_debug("......i: %d\n", i);
    else{
            property = fdt_get_property_by_offset(initial_boot_params, i, NULL);
            p = fdt_string(initial_boot_params, fdt32_to_cpu(property->nameoff));
            pr_debug("first prop[0x%p]: %s\n", p,  p);
    }

    /* Retrieve command line */
    p = of_get_flat_dt_prop(node, "bootargs", &l);
    if(!p){
            pr_debug("BUG:     no bootargs found from dt\n");
    }
    if (p != NULL && l > 0){
            strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
            pr_debug("get bootargs from dt\n");
    }
    ...

问题:

由uboot部分知道: 0x200061fc的位置存储着"bootargs"字符串.

由内核初始化代码,dtb相关的函数可以分析到0xc00061fc应该放着这个bootargs属性名

这个地方不应该出现清零的情况才对.这导致不能进行内核初始化

我尝试过把dtb放到不同的位置,但结果都是bootargs字符串存放的地方被清零.这是肿么回事?

系统消息 若觉得内容不错,请点击左上角的"赞"图标,以优化网站的内容呈现。 另外,请及时验证注册邮箱,否则收不到21QA发出的红包。 官方Q群:250203055

asked 25 Sep '14, 19:21

perr's gravatar image

perr
406364151

编辑于 25 Sep '14, 19:22


原因:

arch/arm/boot/compressed/head.S------------------------------------
...
__setup_mmu:
        sub r3, r4, #16384      @ Page directory size 0x4000即16k
        bic r3, r3, #0xff       @ Align the pointer
        bic r3, r3, #0x3f00     @ r3为内核前方16k大小,16k对齐的区域,用作临时页表
/*
 * Initialise the page tables, turning on the cacheable and bufferable
 * bits for the RAM area only.
 */
        mov r0, r3
        mov r9, r0, lsr #18
        mov r9, r9, lsl #18     @ start of RAM
        add r10, r9, #0x10000000    @ a reasonable RAM size
        mov r1, #0x12       @ XN|U + section mapping
        orr r1, r1, #3 << 10    @ AP=11
        add r2, r3, #16384

1:      cmp r1, r9          @ if virt > start of RAM <--------------循环初始化页表
        cmphs   r10, r1         @   && end of RAM > virt
        bic r1, r1, #0x1c       @ clear XN|U + C + B
        orrlo   r1, r1, #0x10       @ Set XN|U for non-RAM
        orrhs   r1, r1, r6      @ set RAM section settings
        str r1, [r0], #4        @ 1:1 mapping
        add r1, r1, #1048576
        teq r0, r2
        bne 1b
...

内核解压前会建立16k大小16k对齐的临时页表

因为内核加载地址是0x20008000,所以r3=0x20008000-0x4000=0x20004000

而perr.dtb的大小是25k左右,在[0x20000100-0x20004000]这16k的区间里是放不过来的

故而,perr.dtb尾部被临时页表覆盖.因为dtb的字符串都放在尾部.从而导致dtb相关的代码找不到字符串.导致内核初始化失败.

解决方法:

arch/arm/Makefile中修改

textofs-y := 0x00018000

对应的uboot命令:

tftp 0x20018000 192.168.1.8:zImage.bin; tftp 0x20000100 192.168.1.8:perr.dtb; bootm 0x20018000 - 0x20000100
系统消息 若觉得内容不错,请点击左上角的"赞"图标,以优化网站的内容呈现。 另外,请及时验证注册邮箱,否则收不到21QA发出的红包。 官方Q群:250203055
permanent link

answered 26 Sep '14, 13:52

perr's gravatar image

perr
406364151

编辑于 26 Sep '14, 13:52

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link: [text](http://url.com/ "title")
  • image: ![alt](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×85
×1

question asked: 25 Sep '14, 19:21

question was seen: 4,882 times

last updated: 26 Sep '14, 13:52

powered by O*S*Q*A

粤ICP备14040061号-1