Navigation

    全志在线开发者论坛

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

    用buildroot自带的genimage把tina dragon的活干完,让dragon无活可干。

    D1系列-RISC-V
    phoenixsuit phoenixcard genimage buildroot
    5
    14
    1108
    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.
    • W
      whycan晕哥 LV 9 last edited by

      最终生成烧录的 img 文件是通过 scripts/pack_img.sh 的 do_finish()的 dragon命令:

      function do_finish()
      {
      ...
              if [ -f sys_partition_for_dragon.fex ]; then
                      do_dragon image.cfg sys_partition_for_dragon.fex
              else
                      do_dragon image.cfg
              fi
      ...
      }
      
      function do_dragon()
      {
              local partition_file_name="x$2"
              if [ $partition_file_name != "x" ]; then
                      echo "===================================="
                      echo "show \"$2\" message"
                      show_partition_message $2
              fi
              do_check_pack_file
              dragon $@
              if [ $? -eq 0 ]; then
                      if [ -e ${IMG_NAME} ]; then
                              mv ${IMG_NAME} ../${IMG_NAME}
                              echo "----------${image_instruction}----------"
                              echo '----------image is at----------'
                              echo -e '\033[0;31;1m'
                              echo ${ROOT_DIR}/${IMG_NAME}
                              echo -e '\033[0m'
                              if [ $PACK_HOOK ]
                              then
                                      $PACK_HOOK ${ROOT_DIR}/${IMG_NAME}
                              fi
                      fi
              fi
              # you can add scripts/.hooks/post-dragon to do something after dragon
              # for example, you can copy img to another dir, add post-dragon like this:
              #
              # echo "==========post-dragon========"
              # cp ${ROOT_DIR}/${IMG_NAME} ~/myimgs/
              # echo "==========post-dragon done========"
              #
              [ -e ${PACK_TOPDIR}/scripts/.hooks/post-dragon ] &&
                      source ${PACK_TOPDIR}/scripts/.hooks/post-dragon
      }
      

      以芒果派麻雀为例, pack 命令执行之后,最终生成了 out/d1-mangopi_mq_rgb800x480_gt9xx/tina_d1-mangopi_mq_rgb800x480_gt9xx_uart0.img 烧录文件。

      这个*.img文件可以通过 PhoenixSuit 在 Windows 通过USB线烧录,或者通过 LiveSuit 在 Linux 烧录。也可以在Windows用 PhoenixCard.exe 烧到卡上,但是Linux却没有对应的烧卡软件,尴尬了。。。

      1 Reply Last reply Reply Quote Share 0
      • W
        whycan晕哥 LV 9 last edited by whycan

        经过一番研究,加上学习韦老师的 buildroot 帖子, 研究出了一个genimage打包方法,可以打包成烧录二进制文件,用 dd 命令直接写TF卡即可。

        1 Reply Last reply Reply Quote Share 1
        • W
          whycan晕哥 LV 9 last edited by YuzukiTsuru

          假如tina 的分区文件是 sys_partition.fex:

          ;---------------------------------------------------------------------------------------------------
          ; 说明: 脚本中的字符串区分大小写,用户可以修改"="后面的数值,但是不要修改前面的字符串
          ;---------------------------------------------------------------------------------------------------
          
          
          ;---------------------------------------------------------------------------------------------------
          ;                                   固件下载参数配置
          ;---------------------------------------------------------------------------------------------------
          ;***************************************************************************************************
          ;    mbr的大小, 以Kbyte为单位
          ;***************************************************************************************************
          [mbr]
          size = 252
          
          ;***************************************************************************************************
          ;                                              分区配置
          ;
          ;
          ;  partition 定义范例:
          ;    [partition]                ;  //表示是一个分区
          ;    name        = USERFS2      ; //分区名称
          ;    size        = 16384        ; //分区大小 单位: 扇区.分区表示个数最多2^31 * 512 = 2T
          ;    downloadfile = "123.fex"   ; //下载文件的路径和名称,可以使用相对路径,相对是指相对于image.cfg文件所在分区。也可以使用绝对路径
          ;    keydata     = 1            ; //私有数据分区,重新量产数据将不丢失
          ;    encrypt     = 1            ; //采用加密方式烧录,将提供数据加密,但损失烧录速度
          ;    user_type   = ?            ; //私有用法
          ;    verify      = 1            ; //要求量产完成后校验是否正确
          ;
          ; 注:1、name唯一, 不允许同名
          ;     2、name最大12个字符
          ;     3、size = 0, 将创建一个无大小的空分区
          ;     4、align to logical block size(504 sectors), leb size = 2*(1 nand phy block size - 1 phy page size)
          ;***************************************************************************************************
          [partition_start]
          
          [partition]
              name         = boot-resource
              size         = 8064
              downloadfile = "boot-resource.fex"
              user_type    = 0x8000
          
          
          [partition]
              name         = env
              size         = 504
              downloadfile = "env.fex"
              user_type    = 0x8000
          
          [partition]
              name         = env-redund
              size         = 504
              downloadfile = "env.fex"
              user_type    = 0x8000
          
          [partition]
              name         = boot
              size         = 20664
              downloadfile = "boot.fex"
              user_type    = 0x8000
          
          [partition]
              name         = rootfs
          ;    size         = 40824
              size         = 131072
              downloadfile = "rootfs.fex"
              user_type    = 0x8000
          
          [partition]
              name         = dsp0
              size         = 1008
              downloadfile = "dsp0.fex"
              user_type    = 0x8000
          
          [partition]
              name         = recovery
              size         = 28224
              ;downloadfile = "recovery.fex"
              user_type    = 0x8000
          

          那么我们可以生成对应的 genimage.cfg 文件:

          image whycanpi0a_d1s_sdcard.img {
                  hdimage{
                          gpt = true
                          gpt-location = 1M
                  }
                  partition boot0 {
                          in-partition-table = "no"
                          image = "boot0_sdcard.fex"
                          offset = 8K
                  }
                  partition boot-packages {
                          in-partition-table = "no"
                          image = "boot_package.fex"
                          offset = 16400K
                  }
                  partition boot-resource {
                          partition-type = 0xC
                          image = "boot-resource.fex"
                          size = 4032K
                  }
                  partition env {
                          image = "env.fex"
                          size = 252K
                  }
                  partition env-redund {
                          image = "env.fex"
                          size = 252K
                  }
                  partition boot {
                          image = "boot.fex"
                          size = 10332K
                  }
                  partition rootfs {
                          image = "rootfs.fex"
                          size = 64M
                  }
                  partition dsp0 {
                          image = "dsp0.fex"
                          size = 504K
                  }
                  partition recovery {
                          image = "recovery.fex"
                          size = 14112K
                  }
          }
          

          此 genimage.cfg 可以放到 out/d1-mangopi_mq_rgb800x480_gt9xx/image/ 目录。

          然后执行:

          /opt/D1/buildroot-2021/output/host/bin/genimage --config genimage.cfg  --rootpath `mktemp -d` --tmppath `mktemp -d`  --inputpath $PWD --outputpath $PWD
          

          然后就可以生成: whycanpi0a_d1s_sdcard.img 文件了,直接把该文件 dd 到 TF卡即可以引导D1s Tina Linux 系统。

          1 Reply Last reply Reply Quote Share 0
          • W
            whycan晕哥 LV 9 last edited by

            有一个小问题, Ubuntu 没有 genimage 命令,需要自己编译,如果你编译过 buildroot 可以直接用,如果没有编译过,那么需要自己手动编译一个:

            https://github.com/pengutronix/genimage

            1 Reply Last reply Reply Quote Share 0
            • J
              Juggernaut LV 5 last edited by

              官方的哪吒板可以用吗?

              W 1 Reply Last reply Reply Quote Share 0
              • W
                whycan晕哥 LV 9 @Juggernaut last edited by

                @juggernaut
                可以,一样的使用。

                1 Reply Last reply Reply Quote Share 0
                • W
                  whycan晕哥 LV 9 last edited by

                  boot0:
                  image = "boot0_sdcard.fex"

                  uboot,opensbi等:
                  image = "boot_package.fex"

                  开机画面等:
                  image = "boot-resource.fex"

                  uboot的环境变量:
                  image = "env.fex"

                  uboot的环境变量备份:
                  image = "env.fex"

                  Linux kernel:
                  image = "boot.fex"

                  根文件系统:
                  image = "rootfs.fex"

                  这两个不知道干嘛的:
                  image = "dsp0.fex"
                  image = "recovery.fex"

                  T 1 Reply Last reply Reply Quote Share 0
                  • T
                    TEVET LV 6 @whycan last edited by whycan

                    @whycan
                    recovery.fex 是 用来做升级的镜像,是ramdisk的文件系统,make ota_menuconfig 可以配这个recovery
                    详见 D1_Tina_Linux_OTA_开发指南.pdf

                    W 1 Reply Last reply Reply Quote Share 0
                    • W
                      whycan晕哥 LV 9 @TEVET last edited by

                      @tevet
                      感谢大佬指点,顺便再请教 dsp0 是干嘛用的?

                      YuzukiTsuru 1 Reply Last reply Reply Quote Share 0
                      • YuzukiTsuru
                        柚木 鉉 LV 9 @whycan last edited by

                        @whycan DSP核用的,里面还能找到亮点呢
                        4ad62780-c054-42c6-a293-783336457e2d-image.png

                        C 1 Reply Last reply Reply Quote Share 1
                        • Referenced by  q1215200171 q1215200171 
                        • Referenced by  q1215200171 q1215200171 
                        • Referenced by  W whycan 
                        • Referenced by  W whycan 
                        • C
                          captain LV 5 @YuzukiTsuru last edited by

                          @yuzukitsuru
                          主控:t113-s3
                          SDK: longan_sdk
                          请教一下,
                          1.t113-s3 没有DSP核,是不是可以去掉dsp0.fex 这个文件?
                          2.如果不去掉dsp0.fex 这个文件,有没有好的办法对根文件系统扩容?因为我发现,根文件系统后面还有dsp0 分区的话,就不好进行自动扩容了。

                          1 Reply Last reply Reply Quote Share 0
                          • C
                            captain LV 5 last edited by

                            为了方便自动扩容,我把rootfs 分区和dsp0 进行了交换,然后修改了uboot里面的启动参数 mmc_root=/dev/mmcblk0p6 ,目前是可以使用的。
                            但是我还有两个疑问,大佬可以帮我解答一下吗?
                            1.没有在配置文件 env.cfg 里面找到环境变量 partitions,它是从哪里得来的呢?

                            partitions=boot-resource@mmcblk0p1:env@mmcblk0p2:env-redund@mmcblk0p3:boot@mmcblk0p4:dsp0@mmcblk0p5:@mmcblk0p6
                            

                            2.交换 rootfs 分区和dsp0 会有什么不良影响吗?

                            image T113_sdcard.img {
                                    hdimage{
                                            partition-table-type = hybrid
                                            gpt-location = 1M
                                    }
                                    partition boot0 {
                                            in-partition-table = "no"
                                            image = "boot0_sdcard.fex"
                                            offset = 8K
                                    }
                                    partition boot-packages {
                                            in-partition-table = "no"
                                            image = "boot_package.fex"
                                            offset = 16400K
                                    }
                                    partition boot-resource {
                                            partition-type = 0xC
                                            image = "boot-resource.fex"
                                            size = 14005K
                                    }
                                    partition env {
                                            image = "env.fex"
                                            size = 255K
                                    }
                                    partition env-redund {
                                            image = "env.fex"
                                            size = 255K
                                    }
                                    partition boot {
                                            image = "boot.fex"
                                            size = 35200K
                                    }
                                    partition dsp0 {
                                            image = "dsp0.fex"
                                            size = 504K
                                    }
                                    partition rootfs {
                                            image = "rootfs.ext4"
                                            size = 512M
                                    }
                            }
                            
                            image rootfs.ext4 {
                            	  name = "rootfs"
                            	  ext4 {}
                            	  size = 512M
                            	  mountpoint = "/"
                            }
                            
                            W 1 Reply Last reply Reply Quote Share 0
                            • W
                              whycan晕哥 LV 9 @captain last edited by

                              @captain 在 用buildroot自带的genimage把tina dragon的活干完,让dragon无活可干。 中说:

                              dsp0

                              你搜一下 dsp0 有没有用到,如果没有用到,我觉得这样改也没有多大问题.

                              C 1 Reply Last reply Reply Quote Share 0
                              • C
                                captain LV 5 @whycan last edited by

                                @whycan
                                我把dsp0 这个分区删除之后,发现不能正常启动了,可能还是使用了的。

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

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

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