Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    D1 用Xfel启动不了内核

    MR Series
    2
    4
    1640
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      geniusz LV 4 last edited by

      D1的sdk用pack 会打包出一个iMg文件,把他烧到flash可以直接启动,
      此时我根据大佬提供的xfel 工具,直接将ddr和串口初始化完成,此时将fw jump和uboot.bin都烧写到ddr 上,再将boot.img烧写到45000000上,直接运行fw jump,此时Opensbi和uboot 可以正常启动,但是后面运行bootm 450000000,只能启动到start kernel 这一步,后面的内核代码无法继续运行?
      是不是因为我缺少了很多文件还是啥,真的无法理解tina 的这个启动流程,求大佬解惑,跪求!

      A 1 Reply Last reply Reply Quote Share 0
      • A
        awwwwa LV 8 @geniusz last edited by awwwwa

        @geniusz 这与Tina没有什么关系,boot.img 是一个vfat格式的镜像,你需要载入镜像读取其中的 Image.gz 载入45000000,而不是一整个载入到内存中

        boot.img 是安卓格式的 Linux 内核文件,格式如下

        typedef struct boot_img_hdr boot_img_hdr;
        
        #define BOOT_MAGIC "Android!"
        #define BOOT_MAGIC_SIZE 8
        #define BOOT_NAME_SIZE 16
        #define BOOT_ARGS_SIZE 512
        
        struct boot_img_hdr
        {
            unsigned char magic[BOOT_MAGIC_SIZE];
        
            unsigned kernel_size;  /* size in bytes */
            unsigned kernel_addr;  /* physical load addr */
        
            unsigned ramdisk_size; /* size in bytes */
            unsigned ramdisk_addr; /* physical load addr */
        
            unsigned second_size;  /* size in bytes */
            unsigned second_addr;  /* physical load addr */
        
            unsigned tags_addr;    /* physical addr for kernel tags */
            unsigned page_size;    /* flash page size we assume */
            unsigned dt_size;      /* device tree in bytes */
            unsigned unused;       /* future expansion: should be 0 */
            unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */
        
            unsigned char cmdline[BOOT_ARGS_SIZE];
        
            unsigned id[8]; /* timestamp / checksum / sha1 / etc */
        };
        
        boot,img文件跳过2k的文件头之后,包括两个 gz包,一个是boot.img-kernel.gz:Linux内核,一个是boot.img-ramdisk.cpio.gz
        大概的组成结构如下:
        
        ** +-----------------+ 
        ** | boot header     | 1 page
        ** +-----------------+
        ** | kernel          | n pages  
        ** +-----------------+
        ** | ramdisk         | m pages  
        ** +-----------------+
        ** | second stage    | o pages
        ** +-----------------+
        ** | device tree     | p pages
        ** +-----------------+
        ** n = (kernel_size + page_size - 1) / page_size
        ** m = (ramdisk_size + page_size - 1) / page_size
        ** o = (second_size + page_size - 1) / page_size
        ** p = (dt_size + page_size - 1) / page_size
        

        boot.img包括boot.img header、kernel以及ramdisk文件系统,并不是单纯的 Kernel 文件。当然无法启动。

        你需要做的是将 kernel 编译目录下的 Image.gz/vmlinux这样类似的kernel载入才可启动。

        G 1 Reply Last reply Reply Quote Share 0
        • G
          geniusz LV 4 @awwwwa last edited by

          @awwwwa
          但是我使用flash中的自带程序启动uboot,然后用Xfel把boot.img 下载到45000000处,此时用自带的uboot 去运行命令bootm ,此时可以正常启动kernel ,但是用自己的方法去下载Opensbi 和uboot 就无法启动,我感觉我就少了一个boot0,以及一些board.dts ,我不太清楚这些东西为啥会影响我启动内核

          A 1 Reply Last reply Reply Quote Share 0
          • A
            awwwwa LV 8 @geniusz last edited by

            @geniusz 自带的uboot的bootm命令会自动解压,主线的需要自行配置

            1 Reply Last reply Reply Quote Share 0
            • 1 / 1
            • First post
              Last post

            Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

            行为准则 | 用户协议 | 隐私权政策