天天看点

移植 linux-5.8.5 到 iTOP-4412(二)boot from emmc一、bootm二、environment value三、booting sequence四、DEBUG

文章目录

  • 一、bootm
  • 二、environment value
  • 三、booting sequence
    • 1. u-boot
      • 1.1 boot_jump_linux()
    • 2. linux kernel
      • 2.1 secondary_startup()
      • 2.2 start()
  • 四、DEBUG
    • 1. invalid dtb
    • 2. unknown-block
    • 3. No working init found

一、bootm

   为了简单验证,首先使用 u-boot 的命令将 uImage 拷贝到 40008000 处,然后从此处 boot,能解析成功 uImage 的头信息。

xhr4412 # bootm 40008000
## Booting kernel from Legacy Image at 40008000 ...
   Image Name:   Linux-5.8.5
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    5222448 Bytes = 5 MiB
   Load Address: 40008000
   Entry Point:  40008000
   Verifying Checksum ... Bad Data CRC
ERROR: can't get kernel image!
           
  • Verifying Checksum ... Bad Data CRC

该问题是由于 kernel 分区太小,可能其中有坏块,导致文件读取不全,将 kernel 分区改大就可以解决该问题。

Verifying Checksum ... OK
   Loading Kernel Image

Starting kernel ...
           

当然,kernel 还并没有启动起来。

二、environment value

环境变量文件:

  • include/configs/xhr4412.h

三、booting sequence

1. u-boot

启动文件:

  • arch/arm/lib/bootm.c

1.1 boot_jump_linux()

   该函数前都执行成功,但是之后并没有成功执行 linux, 或者说没有串口输出,先从这个函数查起吧。

2. linux kernel

2.1 secondary_startup()

启动文件:

  • arch/arm/kernel/head.S

   secondary_startup() 该函数应该是 linux 解压后重新开始执行的地方。

   所以,先点个灯吧。好吧,没有成功。

2.2 start()

启动文件:

  • arch/arm/boot/compressed/head.S

   u-boot 会直接跳转到该地址开始执行 linux,相当于 u-boot 的 spl 部分,解压并再启动完整的 linux。

函数原型为:

  • void kernel_entry(void *fdt_addr, void *res0, void *res1, void *res2);

   在这里点灯,yes,可以成功,看来应该是 u-boot 传入的参数导致最后 boot 失败。

四、DEBUG

   打开 kernel 的 low-level debug 和 early_print 选项后,能够打印出 kernel 的信息,肯定是传入的参数不正确,看来 u-boot 还需要再做修改才行。

Starting kernel ...

Error: invalid dtb and unrecognized/unsupported machine ID
  r1=0x000022b8, r2=0x40000100
  r2[]=05 00 00 00 01 00 41 54 00 00 00 00 00 00 00 00
Available machine support:

ID (hex)        NAME
ffffffff        Generic DT based system
ffffffff        Samsung Exynos (Flattened Device Tree)
           

1. invalid dtb

报错文件:

  • arch/arm/kernel/setup.c:1085

   阅读源码可以看出,寄存器 r1 为 mach_id = 8888,是 u-boot 中在

arch/arm/include/asm/mach-types.h

定义的,实际上用处不大,现在都是用 dts 了;r2 = 40000100,是 u-boot 传的启动参数,dts 的信息也应该包含在内。

使用命令:

  1. mmc dev 0
  2. mmc read 40006FC0 460 5000
  3. mmc read 41000000 5460 C8
  4. bootm 40006FC0 - 41000000

将设备树文件拷贝到内存,就可以启动 kernel 了,不过传输的命令应该还有问题,kernel panic 了。

2. unknown-block

[    4.950425] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,50)
[    4.958983] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.8.5 #4
[    4.964772] Hardware name: Samsung Exynos (Flattened Device Tree)
           

   这是由于传入的参数不对,或是 emmc 没有分区导致的。传入参数在 dts 文件中修改,然后使用 u-boot 对 emmc 进行分区。

3. No working init found

[    3.666790] Waiting 1 sec before mounting root device...
[    4.767081] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null)
[    4.774179] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    4.781039] devtmpfs: error mounting -2
[    4.784859] Freeing unused kernel memory: 1024K
[    4.788846] Run /sbin/init as init process
[    4.792621] Run /etc/init as init process
[    4.796314] Run /bin/init as init process
[    4.800430] Run /bin/sh as init process
[    4.804063] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[    4.818243] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.8.5 #4
[    4.823985] Hardware name: Samsung Exynos (Flattened Device Tree)
           

   看起来似乎是因为没有找到根文件系统的问题,因为我本来也还没有移植嘛。

   所以应该是时候移植根文件系统的时候了。