Difference between revisions of "How to make your own SD-bootable ROM/zh"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
Line 34: Line 34:
 
|参数||说明
 
|参数||说明
 
|-
 
|-
|-c <filesystem type>  ||  用于指定做ROM前的准备方式,对于H3/H5系列的开发板,p1表示FriendlyCore/Ubuntu/Debian系列的ROM,p2表示制作Eflasher系列的ROM。
+
| -c <filesystem type>  ||  用于指定做ROM前的准备方式,对于H3/H5系列的开发板,p1表示FriendlyCore/Ubuntu/Debian系列的ROM,p2表示制作Eflasher系列的ROM。
 
|-
 
|-
|-m <partmap>  ||  用于指定制作ROM时需要的partmap文件,partmap文件用于指定ROM Image的布局方式和组成文件,不同的板子或者是同一板子不同版本的BSP使用的partmap文件是不一样的。
+
| -m <partmap>  ||  用于指定制作ROM时需要的partmap文件,partmap文件用于指定ROM Image的布局方式和组成文件,不同的板子或者是同一板子不同版本的BSP使用的partmap文件是不一样的。
 
|-
 
|-
|-d "<misc dir>;<partition1 dir>;<partition2 dir>;..."  ||对于H3/H5系列的开发板:<misc dir>: 用于指定bootloader所在的目录路径。<partition1 dir>: 对于H3/H5系列的开发板,用于指定boot分区的目录路径。<partition2 dir>: 对于H3/H5系列的开发板,用于指定rootfs分区的目录路径。
+
| -d "<misc dir>;<partition1 dir>;<partition2 dir>;..."  ||
 +
-d 用于指定系统文件所在的目录,对于H3/H5系列的开发板:
 +
<misc dir>: 用于指定bootloader所在的目录路径。
 +
<partition1 dir>: 对于H3/H5系列的开发板,用于指定boot分区的目录路径。
 +
<partition2 dir>: 对于H3/H5系列的开发板,用于指定rootfs分区的目录路径。
 
|-
 
|-
 
|}
 
|}

Revision as of 08:16, 30 January 2019

English

1 制作RK3399平台的系统映像

请参考这个git仓库: https://github.com/friendlyarm/sd-fuse_rk3399

2 制作S5P4418平台的系统映像

请参考这个git仓库: https://github.com/friendlyarm/sd-fuse_s5p4418

3 制作S5P6818平台的系统映像

请参考这个git仓库: https://github.com/friendlyarm/sd-fuse_s5p6818

4 制作H3 平台的系统映像

如果您定制了U-boot、Linux内核、文件系统,并且想基于自己定制的文件制作Linux系统映像文件 (以下简称为ROM文件),可以参考如下操作:
下载压缩包rom-maker-lite.tar.gz: 点击下载,然后在PC机 Ubuntu系统里解压得到如下目录:

$ rom-maker-lite

rom-maker-lite里最重要的脚本工具为mkimage.sh,执行该脚本可以制作出各种从SD启动的ROM(例如FriendlyCore系统、EFlasher系统)。

目前rom-maker-lite支持为 H3/H5 系列的开发板制作Linux平台的ROM文件,执行./mkimage.sh可以查看帮助信息:

$ ./mkimage.sh 
Usage:
    $ apt-get install tree exfat-utils dosfstools python3-ck
    $ ./mkimage.sh -c <filesystem type> -m <partmap> -d "<misc dir>;<partition1 dir>;<partition2 dir>;..."
        -c <filesystem type>: 
            1: misc(bootloader) + fat32 boot.img + ext4 rootfs.img
            2: misc(bootloader) + fat32 boot.img + ext4 rootfs.img + exfat friendlyarm.img
            3: misc(bootloader) + ext4 boot.img + ext4 rootfs.img
参数 说明
-c <filesystem type> 用于指定做ROM前的准备方式,对于H3/H5系列的开发板,p1表示FriendlyCore/Ubuntu/Debian系列的ROM,p2表示制作Eflasher系列的ROM。
-m <partmap> 用于指定制作ROM时需要的partmap文件,partmap文件用于指定ROM Image的布局方式和组成文件,不同的板子或者是同一板子不同版本的BSP使用的partmap文件是不一样的。
-d "<misc dir>;<partition1 dir>;<partition2 dir>;..."

-d 用于指定系统文件所在的目录,对于H3/H5系列的开发板: <misc dir>: 用于指定bootloader所在的目录路径。 <partition1 dir>: 对于H3/H5系列的开发板,用于指定boot分区的目录路径。 <partition2 dir>: 对于H3/H5系列的开发板,用于指定rootfs分区的目录路径。


  • 为H3 系列的板子制作基于Uboot-2017 + Linux-4.14 的ROM

所有H3 系列的板子是共用同一个基于Uboot-2017 + Linux-4.14 的ROM的,所以对于这个版本的BSP,所有H3 系列的板子的做ROM命令是一样的。
假设您有一张已经烧写FriendlyCore系统的SD卡,该SD卡的rootfs目录下已经包含了你的产品应用程序,请将SD卡插入PC机中,然后挂载SD卡的rootfs分区(假设挂载路径为/media/SD/rootfs, 请注意使用真实路径),然后通过以下命令就可以生成产品适用的ROM文件:

$ ./mkimage.sh p1 partmap/h3_linux-4.14/partmap.txt misc/uboot-2017_h3/ part1/boot_linux-4.14_h3/ /media/SD/rootfs
:

请将对应目录(misc/uboot-2017_h3、part1/boot_linux-4.14_h3)下的文件替换为您自己的定制文件,当然您也可以使用目录里预编译好的系统文件,我们会不定期更新预编译好的系统文件,通过tree命令可查看有哪些可替换的系统文件,例如:

$ tree misc/uboot-2017_h3/ part1/boot_linux-4.14_h3/
misc/uboot-2017_h3/
└── u-boot-sunxi-with-spl.bin
part1/boot_linux-4.14_h3/
├── boot.cmd
├── boot.scr
├── rootfs.cpio.gz
├── sun8i-h2-plus-nanopi-duo.dtb
├── sun8i-h3-nanopi-duo2.dtb
├── sun8i-h3-nanopi-m1.dtb
├── sun8i-h3-nanopi-m1-plus.dtb
├── sun8i-h3-nanopi-neo-air.dtb
├── sun8i-h3-nanopi-neo-core.dtb
├── sun8i-h3-nanopi-neo.dtb
└── zImage

对于所有使用Linux-4.14 BSP的H3板子,使用的都是同一个partmap文件partmap/h3_linux-4.14/partmap.txt。
mkimage.sh执行成功后,会生成一个out/SD-bootable-p1目录,其内容如下:

$ tree out/
out/
├── SD-bootable-p1
│   └── your_company
│       ├── boot.img
│       ├── info.conf
│       ├── partmap.txt
│       ├── rootfs.img
│       └── u-boot-sunxi-with-spl.bin
├── SD-bootable-p1.img

part1/boot_linux-4.14_h3/目录被制作成了boot.img,part2/rootfs_demo/被制作成了rootfs.img,而SD-bootable-p1.img则为最终的ROM文件。 你可以用win32diskimager或者dd命令将SD-bootable-p1.img烧写到SD卡中。


  • 为H3 系列的板子制作基于Uboot-2011 + Linux-3.4 的ROM

以NanoPi M1为例,执行命令:

$ ./mkimage.sh p1 partmap/h3_linux-3.4/partmap.txt misc/uboot-2011_m1/ part1/boot_linux-3.4_m1/ part2/rootfs_demo/

请将对应目录下的文件替换为您自己的定制文件。
对于所有使用Linux-3.4 BSP的H3板子,使用的都是同一个partmap文件partmap/h3_linux-3.4/partmap.txt。
以此类推,NanoPi M1 Plus 的做ROM 命令如下:

$ ./mkimage.sh p1 partmap/h3_linux-3.4/partmap.txt misc/uboot-2011_m1-plus/ part1/boot_linux-3.4_m1-plus/ part2/rootfs_demo/

NanoPi NEO / NanoPi NEO Air也是同样的道理,这样不再赘述。


  • 为H3 系列的板子制作基于Uboot-2017 + Linux-4.14 的Eflasher ROM

制作Eflasher ROM的前提条件是已经成功制作出了FriendlyCore系列的ROM,即已经有待烧写到eMMC的原材料文件,例如基于Uboot-2017 + Linux-4.14的FriendlyCore系统:

$ tree out/
out/
├── SD-bootable-p1
│   └── your_company
│       ├── boot.img
│       ├── info.conf
│       ├── partmap.txt
│       ├── rootfs.img
│       └── u-boot-sunxi-with-spl.bin

假设您有一张已经烧写Eflasher系统的SD卡,请将SD卡插入PC机中,然后挂载SD卡的rootfs分区(假设挂载路径为/media/SD/rootfs-eflasher, 请注意使用真实路径),然后通过以下命令就可以生成Eflasher ROM:

$ ./mkimage.sh p2 partmap/h3_eflasher-4.14/partmap.txt misc/uboot-2017_h3/ part1/boot_linux-4.14_h3/ /media/SD/rootfs-eflasher out/SD-bootable-p1/

mkimage.sh执行成功后,会生成一个out/SD-bootable-p2目录,其内容如下:

$ tree out/
out/
├── SD-bootable-p1
│   └── your_company
│       ├── boot.img
│       ├── info.conf
│       ├── partmap.txt
│       ├── rootfs.img
│       └── u-boot-sunxi-with-spl.bin
├── SD-bootable-p1.img
├── SD-bootable-p2
│   └── your_company
│       ├── boot.img
│       ├── friendlyarm.img
│       ├── info.conf
│       ├── partmap.txt
│       ├── rootfs.img
│       └── u-boot-sunxi-with-spl.bin
└── SD-bootable-p2.img

SD-bootable-p2.img为最终的Eflasher ROM文件,该Eflasher ROM能烧写什么系统到eMMC完全取决于out/SD-bootable-p1/里包含了什么系统文件。 你可以用win32diskimager或者dd命令将SD-bootable-p2.img烧写到SD卡中。

5 制作H5 平台的系统映像

如果您定制了U-boot、Linux内核、文件系统,并且想基于自己定制的文件制作Linux系统映像文件 (以下简称为ROM文件),可以参考如下操作:
下载压缩包rom-maker-lite.tar.gz: 点击下载,然后在PC机 Ubuntu系统里解压得到如下目录:

$ rom-maker-lite

rom-maker-lite里最重要的脚本工具为mkimage.sh,执行该脚本可以制作出各种从SD启动的ROM(例如FriendlyCore系统、EFlasher系统)。

目前rom-maker-lite支持为 H3/H5 系列的开发板制作Linux平台的ROM文件,执行./mkimage.sh可以查看帮助信息:

$ ./mkimage.sh 
Usage:
    $ apt-get install tree dosfstools
    $ ./mkimage.sh <prepare type> <partmap> <misc dir> <partition1 dir> <partition2 dir>
        prepare type: 
            p1: prepare misc(bootloader) + partition1.img(fat32 boot) + partition2.img(ext4 rootfs)
            p2: prepare misc(bootloader) + partition1.img(fat32 boot) + partition2.img(ext4 rootfs) + partition3.img(fat32 eflashed material)
            p3: prepare misc(bootloader) + partition1.img(ext4 boot) + partition2.img(ext4 rootfs)
参数 说明
<prepare type> 用于指定做ROM前的准备方式,对于H3/H5系列的开发板,p1表示FriendlyCore/Ubuntu/Debian系列的ROM,p2标志制作Eflasher系列的ROM。
<partmap> 用于指定制作ROM时需要的partmap文件,partmap文件用于指定ROM Image的布局方式和组成文件,不同的板子或者是同一板子不同版本的BSP使用的partmap文件是不一样的。
<misc dir> 对于H3/H5系列的开发板,用于指定bootloader所在的目录路径。
<partition1 dir> 对于H3/H5系列的开发板,用于指定boot分区的目录路径。
<partition2 dir> 对于H3/H5系列的开发板,用于指定rootfs分区的目录路径。


  • 为H5 系列的板子制作基于Uboot-2017 + Linux-4.14 的ROM

所有H5 系列的板子是共用同一个基于Uboot-2017 + Linux-4.14 的ROM的,所以对于这个版本的BSP,所有H5 系列的板子的做ROM命令是一样的。假设您有一张已经烧写FriendlyCore系统的SD卡,该SD卡的rootfs目录下已经包含了你的产品应用程序,请将SD卡插入PC机中,然后挂载SD卡的rootfs分区(假设挂载路径为/media/SD/rootfs, 请注意使用真实路径),然后通过以下命令可以生成产品适用的ROM文件:

$ ./mkimage.sh p1 partmap/h5_linux-4.14/partmap.txt misc/uboot-2017_h5/ part1/boot_linux-4.14_h5/ /media/SD/rootfs

请将对应目录(misc/uboot-2017_h5、part1/boot_linux-4.14_h5)下的文件替换为您自己的定制文件,当然您也可以使用目录里预编译好的系统文件,我们会不定期更新预编译好的系统文件,通过tree命令可查看有哪些可替换的系统文件,例如:

$ tree misc/uboot-2017_h5/ part1/boot_linux-4.14_h5/
misc/uboot-2017_h5/
├── sunxi-spl.bin
└── u-boot.itb
part1/boot_linux-4.14_h5/
├── boot.cmd
├── boot.scr
├── Image
├── overlays
│   └── sun50i-h5-gpio-dvfs-overlay.dtb
├── rootfs.cpio.gz
├── sun50i-h5-nanopi-k1-plus.dtb
├── sun50i-h5-nanopi-neo2.dtb
├── sun50i-h5-nanopi-neo-core2.dtb
└── sun50i-h5-nanopi-neo-plus2.dtb

对于所有使用Linux-4.14 BSP的H5板子,使用的都是同一个partmap文件partmap/h5_linux-4.14/partmap.txt。
mkimage.sh执行成功后,会生成一个out/SD-bootable-p1目录,其内容如下:

$ tree out/
out/
├── SD-bootable-p1
│   └── your_company
│       ├── boot.img
│       ├── info.conf
│       ├── partmap.txt
│       ├── rootfs.img
│       ├── sunxi-spl.bin
│       └── u-boot.itb
├── SD-bootable-p1.img

part1/boot_linux-4.14_h5/目录被制作成了boot.img,part2/rootfs_demo/被制作成了rootfs.img,而SD-bootable-p1.img则为最终的ROM文件。 你可以用win32diskimager或者dd命令将SD-bootable-p2.img烧写到SD卡中。


  • 为H5 系列的板子制作基于Uboot-2014 + Linux-3.10 的ROM

以NanoPi NEO2为例,执行命令:

$ ./mkimage.sh p1 partmap/h5_linux-3.10/partmap.txt misc/uboot-2014_neo2/ part1/boot_linux-3.10_neo2/ part2/rootfs_demo/

请将对应目录下的文件替换为您自己的定制文件。
对于所有使用Linux-3.10 BSP的H5板子,使用的都是同一个partmap文件partmap/h5_linux-3.10/partmap.txt。


  • 为H5 系列的板子制作基于Uboot-2017 + Linux-4.14 的Eflasher ROM

制作Eflasher ROM的前提条件是已经成功制作出了FriendlyCore系列的ROM,即已经有待烧写到eMMC的原材料文件,例如基于Uboot-2017 + Linux-4.14的FriendlyCore系统::

$ tree out/
out/
├── SD-bootable-p1
│   └── your_company
│       ├── boot.img
│       ├── info.conf
│       ├── partmap.txt
│       ├── rootfs.img
│       ├── sunxi-spl.bin
│       └── u-boot.itb

假设您有一张已经烧写Eflasher系统的SD卡,请将SD卡插入PC机中,然后挂载SD卡的rootfs分区(假设挂载路径为/media/SD/rootfs-eflasher, 请注意使用真实路径),然后通过以下命令就可以生成Eflasher ROM:

$ ./mkimage.sh p2 partmap/h5_eflasher-4.14/partmap.txt misc/uboot-2017_h5/ part1/boot_linux-4.14_h5/ /media/SD/rootfs-eflasher out/SD-bootable-p1/

mkimage.sh执行成功后,会生成一个out/SD-bootable-p2目录,其内容如下:

$ tree out/
out/
├── SD-bootable-p1
│   └── your_company
│       ├── boot.img
│       ├── info.conf
│       ├── partmap.txt
│       ├── rootfs.img
│       ├── sunxi-spl.bin
│       └── u-boot.itb
├── SD-bootable-p1.img
├── SD-bootable-p2
│   └── your_company
│       ├── boot.img
│       ├── friendlyarm.img
│       ├── info.conf
│       ├── partmap.txt
│       ├── rootfs.img
│       ├── sunxi-spl.bin
│       └── u-boot.itb
└── SD-bootable-p2.img

SD-bootable-p2.img为最终的Eflasher ROM文件,该Eflasher ROM能烧写什么系统到eMMC完全取决于out/SD-bootable-p1/里包含了什么系统文件。 你可以用win32diskimager或者dd命令将SD-bootable-p2.img烧写到SD卡中。