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)
 
(74 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[How to make your own SD-bootable ROM|English]]
 
[[How to make your own SD-bootable ROM|English]]
  
==制作RK3399平台的系统映像==
+
==制作量产用的文件系统 (以s5p4418为例)==
请参考这个git仓库: https://github.com/friendlyarm/sd-fuse_rk3399
+
===烧写系统到emmc,按你的项目要求定制系统===
 +
* 用 s5p4418-eflasher-friendlycore-xxx.img 的固件 制做一张 tf 卡<br />
 +
* 用 tf 卡启动,进入烧写预览界面,选中 Disable overlay filesystem,  然后正常烧写系统到 emmc,如果没有看到 Disable overlay filesystem 选项,说明你的固件不是新版本,先去下载新固件:dl.friendlyelec.com <br />
 +
* 拨出 tf 卡,用 emmc 启动到 friendlycore<br />
 +
* 用 mount 命令查看根目录,确定根目录的挂载类型不是 overlay<br />
 +
* 正常安装你想要的软件,配置系统<br />
  
==制作S5P4418平台的系统映像==
+
===从emmc中把文件系统备份出来===
请参考这个git仓库: https://github.com/friendlyarm/sd-fuse_s5p4418
+
* 准备一个 u盘,格式化分区为 ext4 格式<br />
 
+
* 再次用 tf 卡启动系统,并拨入u盘<br />
==制作S5P6818平台的系统映像==
+
* 用电脑上用 ssh 登录: ssh root@192.168.1.231,密码是 fa<br />
请参考这个git仓库: https://github.com/friendlyarm/sd-fuse_s5p6818
+
* 用以下命令挂载 emmc 的 rootfs 分区到 /mnt/rootfs目录:
 
+
==制作H3 平台的系统映像==
+
如果您定制了U-boot、Linux内核、文件系统,并且想基于自己定制的文件制作Linux系统映像文件 (以下简称为ROM文件),可以使用FriendlyElec提供的[https://pan.baidu.com/s/1DSd4XYXr1yGyQTdRNQNoOw rom-maker-lite]工具。<br>
+
rom-maker-lite是一套通用的制作映像文件的脚本工具,目前支持为 H3/H5 系列的开发板制作Linux平台的sd/eflasher ROM文件(尚未支持Android),解压后执行./mkimage.sh可以查看帮助信息:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ ./mkimage.sh
+
mkdir /mnt/rootfs
Usage:
+
mount /dev/mmcblk1p2 /mnt/rootfs
    $ apt-get install tree exfat-utils dosfstools python3-tk
+
    $ ./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
+
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
* 挂载 u盘下到 /mnt/udisk (如何没有挂载), 然后创建 /mnt/udisk/rootfs 目录
::{| class="wikitable"
+
|-
+
|参数||说明
+
|-
+
| -c <filesystem type>  ||
+
-c 用于指定ROM文件内各分区的文件系统格式,对于H3/H5系列的开发板:<br>
+
-c 1适用于FriendlyCore/Ubuntu/Debian/OpenWrt等sd ROM; <br>
+
-c 2适用于eflasher ROM。
+
|-
+
| -m <partmap>  ||  用于指定制作ROM时需要的partmap文件,partmap文件用于指定ROM Image的布局方式和组成文件,不同的板子或者是同一板子不同版本的BSP使用的partmap文件是不一样的。
+
|-
+
| -d "<misc dir>;<partition1 dir>;<partition2 dir>;..."  ||
+
-d 用于指定系统文件所在的目录,每个路径之间用“;”分割,对于H3/H5系列的开发板:<br>
+
<misc dir>: 用于指定bootloader所在的目录路径;<br>
+
<partition1 dir>: 用于指定boot分区的目录路径;<br>
+
<partition2 dir>: 用于指定rootfs分区的目录路径;<br>
+
最后的...表示就还可以接收更多的目录路径。当制作eflasher ROM时,就需要添加friendlyarm分区的目录路径;
+
|-
+
|}
+
 
+
* <b>准备工作</b>
+
经测试过PC机 Ubuntu版本包括:<br>
+
1) ubuntu-16.04.5-desktop-amd64.iso <br>
+
2) ubuntu-18.04.1-desktop-amd64.iso <br>
+
如果您当前PC机使用的Ubuntu系统无法成功执行出系统映像,请尝试切换到上面这两个版本的Ubuntu系统。<br>
+
 
+
在开始制作系统映像前,必须先安装下列软件包:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ apt-get install tree exfat-utils dosfstools python3-tk
+
mount /dev/sdb1 /mnt/udisk
 +
mkdir /mnt/udisk/rootfs
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
注:有时 u盘的设备名是 /dev/sda1已经自动挂载到 /mnt/udisk 目录<br />
由于制作系统映像需要root权限,请先切换到root用户:
+
<br />
 +
* 安装 rsync 工具
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ su root
+
wget http://112.124.9.243/cn-apt-source.sh
 +
chmod 755 cn-apt-source.sh
 +
./cn-apt-source.sh
 +
apt-get update
 +
apt-get -y install rsync
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
* 将 emmc 的 rootfs 分区文件拷贝到 u盘,忽略掉特殊文件:
 
+
* <b>为H3 系列的板子制作基于Uboot-2017 + Linux-4.14 的sd ROM(包括FriendlyCore/Debian/OpenWrt)</b>
+
事实上,对于Uboot-2017 + Linux-4.14版本的BSP,所有H3 系列的板子的sd ROM文件都是同一个。所以对于这个版本的BSP,所有H3 系列的板子的sd ROM 的制作命令是一样的。<br>
+
这里以制作FriendlyCore sd ROM为例进行讲解,Debian、OpenWrt等sd ROM文件的制作方法是类似的。<br>
+
假设您已经有一张带有riendlyCore系统的SD卡,该SD卡的rootfs目录下已经包含了您自己的应用程序和设置。请将该SD卡插入PC机中,然后挂载SD卡的rootfs分区(假设挂载路径为rom-maker-lite/part2/h3/4.14/friendlycore/rootfs/, 请注意使用真实路径),使用下面的命令可以生成您自己定制的ROM文件:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ ./mkimage.sh -c 1 -m partmap/h3_linux-4.14/partmap.txt -d "misc/uboot-2017_h3/;part1/boot_linux-4.14_h3/;part2/h3/4.14/friendlycore/rootfs/"
+
rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/swapfile"} /mnt/rootfs/* /mnt/udisk/rootfs
 
</syntaxhighlight>
 
</syntaxhighlight>
请将misc/uboot-2017_h3、part1/boot_linux-4.14_h3目录下的文件替换为您自己的定制文件,当然您也可以使用目录里预编译好的系统文件,我们会不定期更新预编译好的系统文件,通过tree命令可查看有哪些可替换的系统文件,例如:
 
<syntaxhighlight lang="bash">
 
$ 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
 
</syntaxhighlight>
 
对于所有使用Linux-4.14 BSP的H3板子,使用的都是同一个partmap文件partmap/h3_linux-4.14/partmap.txt。<br>
 
mkimage.sh执行成功后,会生成一个out/SD-bootable-1目录,其内容如下:
 
<syntaxhighlight lang="bash">
 
$ tree out/
 
out/
 
├── SD-bootable-1
 
│   └── your_company
 
│      ├── boot.img
 
│      ├── info.conf
 
│      ├── partmap.txt
 
│      ├── rootfs.img
 
│      └── u-boot-sunxi-with-spl.bin
 
├── SD-bootable-1.img
 
  
</syntaxhighlight>
+
===用备份出来的文件系统,重新制作用于量产的固件===
part1/boot_linux-4.14_h3/目录被制作成了boot.img,part2/h3/4.14/friendlycore/rootfs/被制作成了rootfs.img,而SD-bootable-1.img则为最终的ROM文件。
+
* 将 u盘拷到ubuntu电脑上,挂载u盘到 /media/udisk<br />
<!--
+
* 用 sd-fuse_s5p4418 重新制作 rootfs.img:
您可以通过如下命令迅速将其烧写到SD卡中以进行测试:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ ./tools/sd_update -d /dev/SD -p ./out/SD-bootable-1/your_company/partmap.txt
+
git clone https://github.com/friendlyarm/sd-fuse_s5p4418.git
 +
cd sd-fuse_s5p4418
 +
./build-rootfs-img.sh /media/udisk/rootfs friendlycore
 +
./mk-emmc-image.sh friendlycore
 
</syntaxhighlight>
 
</syntaxhighlight>
注意: 请将/dev/sdX替换为实际的SD卡设备节点。
+
现在,你可以将生成的 out/s5p4418-eflasher-friendlycore-xenial-4.4-YYYYMMDD.img 固件用于量产了。
-->
+
你可以用win32diskimager或者dd命令将SD-bootable-1.img烧写到SD卡中。
+
  
<br>
+
==制作RK3399平台的系统映像==
* <b>为H3 系列的板子制作基于Uboot-2011 + Linux-3.4 的ROM </b>
+
请参考这个git仓库: https://github.com/friendlyarm/sd-fuse_rk3399
以NanoPi M1为例,执行命令:
+
<syntaxhighlight lang="bash">
+
$ ./mkimage.sh p1 partmap/h3_linux-3.4/partmap.txt misc/uboot-2011_m1/ part1/boot_linux-3.4_m1/ part2/rootfs_demo/
+
</syntaxhighlight>
+
请将对应目录下的文件替换为您自己的定制文件。<br>
+
对于所有使用Linux-3.4 BSP的H3板子,使用的都是同一个partmap文件partmap/h3_linux-3.4/partmap.txt。<br>
+
以此类推,NanoPi M1 Plus 的做ROM 命令如下:
+
<syntaxhighlight lang="bash">
+
$ ./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/
+
</syntaxhighlight>
+
NanoPi NEO / NanoPi NEO Air也是同样的道理,这样不再赘述。
+
  
<br>
+
==制作S5P4418平台的系统映像==
* <b>为H3 系列的板子制作基于Uboot-2017 + Linux-4.14 的Eflasher ROM</b>
+
请参考这个git仓库: https://github.com/friendlyarm/sd-fuse_s5p4418<br />
制作Eflasher ROM的前提条件是已经成功制作出了FriendlyCore系列的ROM,即已经有待烧写到eMMC的原材料文件,例如基于Uboot-2017 + Linux-4.14的FriendlyCore系统:
+
<br />
 +
Example: <br />
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
$ tree out/
+
mkdir test
out/
+
cd test
├── SD-bootable-1
+
git clone https://github.com/friendlyarm/sd-fuse_s5p4418
│   └── your_company
+
cd sd-fuse_s5p4418/
│      ├── boot.img
+
tar xzf /mnt/dvd/S5P4418/images-for-eflasher/friendlycore-images.tgz
│      ├── info.conf
+
tar xzf  /mnt/dvd/S5P4418/images-for-eflasher/emmc-flasher-images.tgz
│      ├── partmap.txt
+
tar xzf /mnt/dvd/S5P4418/rootfs/rootfs-friendlycore-20190718.tgz
│      ├── rootfs.img
+
sed "s/\${BOARD}/XXYYZZ/g" friendlycore/rootfs/etc/rc.local -i
│      └── u-boot-sunxi-with-spl.bin
+
./build-rootfs-img.sh friendlycore/rootfs friendlycore
 +
./mk-emmc-image.sh friendlycore
 +
dd if=out/s5p4418-eflasher-friendlycore-20190730.img of=/dev/sdX bs=32M
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
<br />
 +
上例中两个关键的命令:<br />
 +
./build-rootfs-img.sh friendlycore/rootfs friendlycore<br />
 +
将 friendlycore/rootfs 目录制作成 rootfs.img <br />
 +
<br />
 +
./mk-emmc-image.sh friendlycore<br />
 +
将friendlycore目录下的系统制作为  eflaher固件,会生成 out/s5p4418-eflasher-friendlycore-20190730.img,直接 dd 到卡里即可<br />
  
假设您有一张已经烧写Eflasher系统的SD卡,请将SD卡插入PC机中,然后挂载SD卡的rootfs分区(假设挂载路径为/media/SD/rootfs-eflasher, 请注意使用真实路径),然后通过以下命令就可以生成Eflasher ROM:
+
==制作S5P6818平台的系统映像==
<syntaxhighlight lang="bash">
+
请参考这个git仓库: https://github.com/friendlyarm/sd-fuse_s5p6818
$ ./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-1/
+
 
</syntaxhighlight>
+
==制作H3 平台的系统映像==
mkimage.sh执行成功后,会生成一个out/SD-bootable-p2目录,其内容如下:
+
请参考这个git仓库: https://github.com/friendlyarm/sd-fuse_h3
<syntaxhighlight lang="bash">
+
$ tree out/
+
out/
+
├── SD-bootable-1
+
│   └── your_company
+
│      ├── boot.img
+
│      ├── info.conf
+
│      ├── partmap.txt
+
│      ├── rootfs.img
+
│      └── u-boot-sunxi-with-spl.bin
+
├── SD-bootable-1.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
+
</syntaxhighlight>
+
SD-bootable-p2.img为最终的Eflasher ROM文件,该Eflasher ROM能烧写什么系统到eMMC完全取决于out/SD-bootable-1/里包含了什么系统文件。
+
<!--
+
通过如下命令迅速将其烧写到SD卡中以进行测试:
+
<syntaxhighlight lang="bash">
+
$ ./tools/sd_update -d /dev/SD -p ./out/SD-bootable-p2/your_company/partmap.txt
+
</syntaxhighlight>
+
注意: 请将/dev/sdX替换为实际的SD卡设备节点。
+
-->
+
你可以用win32diskimager或者dd命令将SD-bootable-p2.img烧写到SD卡中。
+
  
 
==制作H5 平台的系统映像==
 
==制作H5 平台的系统映像==
如果您定制了U-boot、Linux内核、文件系统,并且想基于自己定制的文件制作Linux系统映像文件 (以下简称为ROM文件),可以参考如下操作:<br>
+
请参考这个git仓库: https://github.com/friendlyarm/sd-fuse_h5
下载压缩包rom-maker-lite.tar.gz: [https://pan.baidu.com/s/1DSd4XYXr1yGyQTdRNQNoOw 点击下载],然后在PC机 Ubuntu系统里解压得到如下目录:
+
<syntaxhighlight lang="bash">
+
$ rom-maker-lite
+
</syntaxhighlight>
+
rom-maker-lite里最重要的脚本工具为mkimage.sh,执行该脚本可以制作出各种从SD启动的ROM(例如FriendlyCore系统、EFlasher系统)。<br><br>
+
 
+
目前rom-maker-lite支持为 H3/H5 系列的开发板制作Linux平台的ROM文件,执行./mkimage.sh可以查看帮助信息:
+
<syntaxhighlight lang="bash">
+
$ ./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)
+
</syntaxhighlight>
+
 
+
::{| class="wikitable"
+
|-
+
|参数||说明
+
|-
+
|<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分区的目录路径。
+
|-
+
|}
+
 
+
<br>
+
* <b>为H5 系列的板子制作基于Uboot-2017 + Linux-4.14 的ROM</b>
+
所有H5 系列的板子是共用同一个基于Uboot-2017 + Linux-4.14 的ROM的,所以对于这个版本的BSP,所有H5 系列的板子的做ROM命令是一样的。假设您有一张已经烧写FriendlyCore系统的SD卡,该SD卡的rootfs目录下已经包含了你的产品应用程序,请将SD卡插入PC机中,然后挂载SD卡的rootfs分区(假设挂载路径为/media/SD/rootfs, 请注意使用真实路径),然后通过以下命令可以生成产品适用的ROM文件:
+
<syntaxhighlight lang="bash">
+
$ ./mkimage.sh p1 partmap/h5_linux-4.14/partmap.txt misc/uboot-2017_h5/ part1/boot_linux-4.14_h5/ /media/SD/rootfs
+
</syntaxhighlight>
+
请将对应目录(misc/uboot-2017_h5、part1/boot_linux-4.14_h5)下的文件替换为您自己的定制文件,当然您也可以使用目录里预编译好的系统文件,我们会不定期更新预编译好的系统文件,通过tree命令可查看有哪些可替换的系统文件,例如:
+
<syntaxhighlight lang="bash">
+
$ 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
+
</syntaxhighlight>
+
 
+
对于所有使用Linux-4.14 BSP的H5板子,使用的都是同一个partmap文件partmap/h5_linux-4.14/partmap.txt。<br>
+
mkimage.sh执行成功后,会生成一个out/SD-bootable-1目录,其内容如下:
+
<syntaxhighlight lang="bash">
+
$ tree out/
+
out/
+
├── SD-bootable-1
+
│   └── your_company
+
│      ├── boot.img
+
│      ├── info.conf
+
│      ├── partmap.txt
+
│      ├── rootfs.img
+
│      ├── sunxi-spl.bin
+
│      └── u-boot.itb
+
├── SD-bootable-1.img
+
 
+
</syntaxhighlight>
+
part1/boot_linux-4.14_h5/目录被制作成了boot.img,part2/rootfs_demo/被制作成了rootfs.img,而SD-bootable-1.img则为最终的ROM文件。
+
<!--
+
您可以通过如下命令迅速将其烧写到SD卡中以进行测试:
+
<syntaxhighlight lang="bash">
+
$ ./tools/sd_update -d /dev/SD -p ./out/SD-bootable-1/your_company/partmap.txt
+
</syntaxhighlight>
+
注意: 请将/dev/sdX替换为实际的SD卡设备节点。
+
-->
+
你可以用win32diskimager或者dd命令将SD-bootable-p2.img烧写到SD卡中。
+
 
+
<br>
+
* <b>为H5 系列的板子制作基于Uboot-2014 + Linux-3.10 的ROM </b>
+
以NanoPi NEO2为例,执行命令:
+
<syntaxhighlight lang="bash">
+
$ ./mkimage.sh p1 partmap/h5_linux-3.10/partmap.txt misc/uboot-2014_neo2/ part1/boot_linux-3.10_neo2/ part2/rootfs_demo/
+
</syntaxhighlight>
+
请将对应目录下的文件替换为您自己的定制文件。<br>
+
对于所有使用Linux-3.10 BSP的H5板子,使用的都是同一个partmap文件partmap/h5_linux-3.10/partmap.txt。<br>
+
 
+
<br>
+
* <b>为H5 系列的板子制作基于Uboot-2017 + Linux-4.14 的Eflasher ROM</b>
+
制作Eflasher ROM的前提条件是已经成功制作出了FriendlyCore系列的ROM,即已经有待烧写到eMMC的原材料文件,例如基于Uboot-2017 + Linux-4.14的FriendlyCore系统::
+
<syntaxhighlight lang="bash">
+
$ tree out/
+
out/
+
├── SD-bootable-1
+
│   └── your_company
+
│      ├── boot.img
+
│      ├── info.conf
+
│      ├── partmap.txt
+
│      ├── rootfs.img
+
│      ├── sunxi-spl.bin
+
│      └── u-boot.itb
+
</syntaxhighlight>
+
 
+
假设您有一张已经烧写Eflasher系统的SD卡,请将SD卡插入PC机中,然后挂载SD卡的rootfs分区(假设挂载路径为/media/SD/rootfs-eflasher, 请注意使用真实路径),然后通过以下命令就可以生成Eflasher ROM:
+
<syntaxhighlight lang="bash">
+
$ ./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-1/
+
</syntaxhighlight>
+
mkimage.sh执行成功后,会生成一个out/SD-bootable-p2目录,其内容如下:
+
<syntaxhighlight lang="bash">
+
$ tree out/
+
out/
+
├── SD-bootable-1
+
│   └── your_company
+
│      ├── boot.img
+
│      ├── info.conf
+
│      ├── partmap.txt
+
│      ├── rootfs.img
+
│      ├── sunxi-spl.bin
+
│      └── u-boot.itb
+
├── SD-bootable-1.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
+
</syntaxhighlight>
+
SD-bootable-p2.img为最终的Eflasher ROM文件,该Eflasher ROM能烧写什么系统到eMMC完全取决于out/SD-bootable-1/里包含了什么系统文件。
+
<!--
+
通过如下命令迅速将其烧写到SD卡中以进行测试:
+
<syntaxhighlight lang="bash">
+
$ ./tools/sd_update -d /dev/SD -p ./out/SD-bootable-p2/your_company/partmap.txt
+
</syntaxhighlight>
+
注意: 请将/dev/sdX替换为实际的SD卡设备节点。
+
-->
+
你可以用win32diskimager或者dd命令将SD-bootable-p2.img烧写到SD卡中。
+

Latest revision as of 07:17, 21 February 2022

English

1 制作量产用的文件系统 (以s5p4418为例)

1.1 烧写系统到emmc,按你的项目要求定制系统

  • 用 s5p4418-eflasher-friendlycore-xxx.img 的固件 制做一张 tf 卡
  • 用 tf 卡启动,进入烧写预览界面,选中 Disable overlay filesystem, 然后正常烧写系统到 emmc,如果没有看到 Disable overlay filesystem 选项,说明你的固件不是新版本,先去下载新固件:dl.friendlyelec.com
  • 拨出 tf 卡,用 emmc 启动到 friendlycore
  • 用 mount 命令查看根目录,确定根目录的挂载类型不是 overlay
  • 正常安装你想要的软件,配置系统

1.2 从emmc中把文件系统备份出来

  • 准备一个 u盘,格式化分区为 ext4 格式
  • 再次用 tf 卡启动系统,并拨入u盘
  • 用电脑上用 ssh 登录: ssh root@192.168.1.231,密码是 fa
  • 用以下命令挂载 emmc 的 rootfs 分区到 /mnt/rootfs目录:
mkdir /mnt/rootfs
mount /dev/mmcblk1p2 /mnt/rootfs
  • 挂载 u盘下到 /mnt/udisk (如何没有挂载), 然后创建 /mnt/udisk/rootfs 目录
mount /dev/sdb1 /mnt/udisk
mkdir /mnt/udisk/rootfs

注:有时 u盘的设备名是 /dev/sda1已经自动挂载到 /mnt/udisk 目录

  • 安装 rsync 工具
wget http://112.124.9.243/cn-apt-source.sh
chmod 755 cn-apt-source.sh
./cn-apt-source.sh
apt-get update
apt-get -y install rsync
  • 将 emmc 的 rootfs 分区文件拷贝到 u盘,忽略掉特殊文件:
rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/swapfile"} /mnt/rootfs/* /mnt/udisk/rootfs

1.3 用备份出来的文件系统,重新制作用于量产的固件

  • 将 u盘拷到ubuntu电脑上,挂载u盘到 /media/udisk
  • 用 sd-fuse_s5p4418 重新制作 rootfs.img:
git clone https://github.com/friendlyarm/sd-fuse_s5p4418.git
cd sd-fuse_s5p4418
./build-rootfs-img.sh /media/udisk/rootfs friendlycore
./mk-emmc-image.sh friendlycore

现在,你可以将生成的 out/s5p4418-eflasher-friendlycore-xenial-4.4-YYYYMMDD.img 固件用于量产了。

2 制作RK3399平台的系统映像

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

3 制作S5P4418平台的系统映像

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

Example:

mkdir test
cd test
git clone https://github.com/friendlyarm/sd-fuse_s5p4418
cd sd-fuse_s5p4418/
tar xzf /mnt/dvd/S5P4418/images-for-eflasher/friendlycore-images.tgz
tar xzf  /mnt/dvd/S5P4418/images-for-eflasher/emmc-flasher-images.tgz
tar xzf /mnt/dvd/S5P4418/rootfs/rootfs-friendlycore-20190718.tgz 
sed "s/\${BOARD}/XXYYZZ/g" friendlycore/rootfs/etc/rc.local -i
./build-rootfs-img.sh friendlycore/rootfs friendlycore
./mk-emmc-image.sh friendlycore
dd if=out/s5p4418-eflasher-friendlycore-20190730.img of=/dev/sdX bs=32M


上例中两个关键的命令:
./build-rootfs-img.sh friendlycore/rootfs friendlycore
将 friendlycore/rootfs 目录制作成 rootfs.img

./mk-emmc-image.sh friendlycore
将friendlycore目录下的系统制作为 eflaher固件,会生成 out/s5p4418-eflasher-friendlycore-20190730.img,直接 dd 到卡里即可

4 制作S5P6818平台的系统映像

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

5 制作H3 平台的系统映像

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

6 制作H5 平台的系统映像

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