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

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
 
(7 intermediate revisions by 3 users not shown)
Line 5: Line 5:
  
 
==Make Image Files for S5P4418==
 
==Make Image Files for S5P4418==
Refer to this repo: https://github.com/friendlyarm/sd-fuse_s5p4418
+
Refer to this repo: https://github.com/friendlyarm/sd-fuse_s5p4418<br />
 +
<br />
 +
Example:  <br />
 +
<syntaxhighlight lang="bash">
 +
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/rootfs.img
 +
./mk-emmc-image.sh friendlycore
 +
dd if=out/s5p4418-eflasher-friendlycore-20190730.img of=/dev/sdX bs=32M
 +
</syntaxhighlight>
  
 
==Make Image Files for S5P6818==
 
==Make Image Files for S5P6818==
Line 11: Line 26:
  
 
==Make Image Files for H3==
 
==Make Image Files for H3==
{{ROM-Maker-lite_Introduce |h3}}
+
Refer to this repo: https://github.com/friendlyarm/sd-fuse_h3
 
+
===Make SD ROM===
+
====Linux-4.14====
+
For Linux-4.14 BSP all FriendlyElec's H3 platforms that have the same rootfs share the same SD ROM. Therefore the steps to make an sd ROM for all FriendlyElec's H3 platforms that support this BSP are the same.<br>
+
We take FriendlyCore's sd ROM as an example to show how to do it. The steps for making an sd ROM for Ubuntu,Debian,OpenWrt are the same.<br>
+
 
+
* <b>Get a Full FriendlyCore's rootfs Directory</b>
+
There are two ways to do it:<br>
+
1) Make an SD card with FriendlyCore and mount the SD card's rootfs partition on a PC host;<br>
+
2) Extract the /rootfs/rootfs_friendlycore_4.14_YYYYMMDD.tgz file<br>
+
 
+
<br>
+
* <b>Suppose rootfs' path is "./rom-maker-lite/part2/h3/4.14/friendlycore/rootfs/". After you run the following command you will be able to get an sd ROM:</b>
+
<syntaxhighlight lang="bash">
+
$ cd rom-maker-lite
+
$ ./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/"
+
</syntaxhighlight>
+
- All FriendlyElec's H3 platforms that run the Linux-4.14 BSP use the same partmap file: partmap/h3_linux-4.14/partmap.txt .<br>
+
- You can replace the files under "misc/uboot-2017_h3" and "part1/boot_linux-4.14_h3" with your application files. You can check the existing files by commanding "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>
+
 
+
<br>
+
After the mkimage.sh script is run successfully an "out/SD-bootable-1" directory ("1" corresponds to parameter "-c 1"). Here is what it will show:
+
<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>
+
- The "part1/boot_linux-4.14_h3/" directory will be converted to "boot.img";<br>
+
- The "part2/h3/4.14/friendlycore/rootfs/" directory will be converted to "rootfs.img";<br>
+
- The "SD-bootable-1.img" file will be an sd ROM which is composed of all files under the "SD-bootable-1" directory and is equivalent to a nanopi-[h3]_sd_friendlycore-xenial_4.14_armhf_YYYYMMDD.img file released by FriendlyElec;
+
 
+
<!--
+
下面的命令可以快速地将系统烧写到SD卡中:
+
<syntaxhighlight lang="bash">
+
$ ./tools/sd_update -d /dev/SD -p ./out/SD-bootable-1/your_company/partmap.txt
+
</syntaxhighlight>
+
注意: 请将/dev/sdX替换为实际的SD卡设备节点。
+
-->
+
 
+
 
+
====Linux-3.4====
+
- For Linux-3.4 BSP different FriendlyElec's H3 platforms use different sd ROMs although they may use the same rootfs.<br>
+
- We take FriendlyCore as an example to show how to make a Linux-3.4 sd ROM for the NanoPi M1. The steps for making an sd ROM for Ubuntu,Debian,OpenWrt are the same.<br><br>
+
 
+
* <b>Get a Full FriendlyCore's rootfs Directory</b>
+
Here is how to do it:<br>
+
1) Make an SD card with FriendlyCore and mount the SD card's rootfs partition on a PC host;<br>
+
 
+
<br>
+
* <b>Suppose rootfs' path is "./rom-maker-lite/part2/m1/3.4/friendlycore/rootfs/".After you run the following command you will be able to get an sd ROM:</b>
+
<syntaxhighlight lang="bash">
+
$ cd rom-maker-lite
+
$ ./mkimage.sh -c 1 -m partmap/h3_linux-3.4/partmap.txt -d "misc/uboot-2011_m1/;part1/boot_linux-3.4_m1/;part2/m1/3.4/friendlycore/rootfs"
+
</syntaxhighlight>
+
- All FriendlyElec's H3 platforms that run the Linux-3.4 BSP use the same partmap file: partmap/h3_linux-3.4/partmap.txt.<br>
+
- You can replace the files under "misc/uboot-2011_m1" and "part1/boot_linux-3.4_m1" with your application files. You can check the existing files by commanding "tree":
+
<syntaxhighlight lang="bash">
+
$ tree misc/uboot-2011_m1 part1/boot_linux-3.4_m1
+
misc/uboot-2011_m1
+
├── boot0_sdcard.fex
+
└── u-boot.fex
+
part1/boot_linux-3.4_m1
+
├── boot.img
+
└── bootlogo.bmp
+
</syntaxhighlight>
+
 
+
<br>
+
After the mkimage.sh script is run successfully an "out/SD-bootable-1" directory ("1" corresponds to parameter "-c 1"). Here is what it will show:
+
<syntaxhighlight lang="bash">
+
$ tree out/
+
out/
+
├── SD-bootable-1
+
│   └── your_company
+
│      ├── boot0_sdcard.fex
+
│      ├── boot.img
+
│      ├── info.conf
+
│      ├── partmap.txt
+
│      ├── rootfs.img
+
│      └── u-boot.fex
+
├── SD-bootable-1.img
+
</syntaxhighlight>
+
- The "part1/boot_linux-3.4_m1" directory will be converted to "boot.img";<br>
+
- The "part2/h3/3.4/friendlycore/rootfs/" directory will be converted to "rootfs.img";<br>
+
- The "SD-bootable-1.img" file will be an sd ROM which is composed of all files under the "SD-bootable-1" directory and is equivalent to a nanopi-m1_sd_friendlycore-xenial_3.4_armhf_YYYYMMDD.img file released by FriendlyElec;
+
<br>
+
* <b>Similarly the steps to make an sd ROM image for the NanoPi M1 Plus are as follows:</b>
+
<syntaxhighlight lang="bash">
+
$ ./mkimage.sh -c 1 -m partmap/h3_linux-3.4/partmap.txt -d "misc/uboot-2011_m1-plus/;part1/boot_linux-3.4_m1-plus/;part2/m1-plus/3.4/friendlycore/rootfs"
+
</syntaxhighlight>
+
The generated "SD-bootable-1.img" file is equivalent to the nanopi-m1-plus_sd_friendlycore-xenial_3.4_armhf_YYYYMMDD.img file released by FriendlyElec. This applies to both the NanoPi NEO and NanoPi NEO Air.
+
 
+
===Make eflasher ROM===
+
Before you make an eflasher ROM make sure you have already made a FriendlyCore/Debian/OpenWrt sd ROM.<br>
+
For example if you want to make a Linux-4.14 based FriendlyCore eflasher ROM you need to have a Linux-4.14 based FriendlyCore sd ROM. You can check the existing files by commanding "tree":
+
<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
+
</syntaxhighlight>
+
 
+
<br>
+
* <b>Get a Full eflasher rootfs Directory</b>
+
There are two ways to do it:<br>
+
1) Make an eflasher SD card and mount the SD card's rootfs partition on a PC host;<br>
+
2) Extract the /rootfs/rootfs_eflasher_4.14_YYYYMMDD.tgz file<br>
+
<br>
+
* <b>Suppose eflasher rootfs' path is "./rom-maker-lite/part2/h3/4.14/eflasher/rootfs/",After you run the following command you will be able to get an eflasher ROM:</b>
+
<syntaxhighlight lang="bash">
+
$ cd rom-maker-lite
+
$ ./mkimage.sh -c 2 -m partmap/h3_eflasher-4.14/partmap.txt -d "misc/uboot-2017_h3/;part1/boot_linux-4.14_h3/;part2/h3/4.14/eflasher/rootfs;out/SD-bootable-1/"
+
</syntaxhighlight>
+
After the mkimage.sh script is run successfully an "out/SD-bootable-2" directory. Here is what it will show:
+
<syntaxhighlight lang="bash">
+
$ tree out/
+
out/SD-bootable-2
+
├── SD-bootable-2
+
│   └── your_company
+
│      ├── boot.img
+
│      ├── friendlyarm.img
+
│      ├── info.conf
+
│      ├── partmap.txt
+
│      ├── rootfs.img
+
│      └── u-boot-sunxi-with-spl.bin
+
└── SD-bootable-2.img
+
</syntaxhighlight>
+
- The "part1/boot_linux-4.14_h3" directory will be converted to "boot.img";<br>
+
- The "part2/h3/4.14/eflasher/rootfs/" directory will be converted to "rootfs.img";<br>
+
- The "out/SD-bootable-1/" directory will be converted to "friendlyarm.img";<br>
+
- The "SD-bootable-2.img" file will be an eflasher ROM which is composed of all files under the "SD-bootable-2" directory and is equivalent to a nanopi-[h3]_eflasher_friendlycore-xenial_4.14_armhf_YYYYMMDD.img file released by FriendlyElec;<br>
+
Actually all FriendlyElec's H3 platforms use the same file "nanopi-[h3]_eflasher_friendlycore-xenial_4.14_armhf_YYYYMMDD.img".
+
 
+
===Make boot.img/rootfs.img===
+
{{ROM-Maker-lite_mk-fsimg |h3}}
+
 
+
====Linux-4.14====
+
You can run the following commands to generate a boot.img and rootfs.img for a Linux-4.14 based sd ROM:
+
<syntaxhighlight lang="bash">
+
$ cd rom-maker-lite
+
$ ./tools/mk_fsimg.sh vfat boot.img ./part1/boot_linux-4.14_h3/ 40 boot
+
$ ./tools/mk_fsimg.sh ext4 rootfs.img ./part2/h3/4.14/friendlycore/rootfs/ 2048 rootfs
+
</syntaxhighlight>
+
These commands apply to all FriendlyElec's H3 platforms.
+
 
+
====Linux-3.4====
+
You can run the following commands to generate a boot.img and rootfs.img for a Linux-3.4 based sd ROM for the NanoPi M1:
+
<syntaxhighlight lang="bash">
+
$ cd rom-maker-lite
+
$ ./tools/mk_fsimg.sh vfat boot.img ./part1/boot_linux-3.4_m1/ 40 boot
+
$ ./tools/mk_fsimg.sh ext4 rootfs.img ./part2/h3/3.4/friendlycore/rootfs/ 2048 rootfs
+
</syntaxhighlight>
+
These commands only apply to the NanoPi M1. But these commands with minors changes will work for other H3 platforms.
+
  
 
==Make Image File for H5==
 
==Make Image File for H5==
{{ROM-Maker-lite_Introduce |h5}}
+
Refer to this repo: https://github.com/friendlyarm/sd-fuse_h5
 
+
===Make sd ROM===
+
====Linux-4.14====
+
事实上,对于Linux-4.14 BSP,相同rootfs的所有H5 板子的sd ROM文件都是同一个,所以对于这个版本的BSP,所有H5 的板子的sd ROM 的制作命令是一样的。<br>
+
这里以制作FriendlyCore sd ROM为例进行讲解,Ubuntu、Debian、OpenWrt等sd ROM文件的制作方法是一样的。<br>
+
 
+
* <b>准备FriendlyCore的rootfs目录</b>
+
有2种方式可以准备FriendlyCore的rootfs目录:<br>
+
1) 制作一张带FriendlyCore系统的SD卡,然后基于该SD卡进行定制开发,当开发完毕后,在PC机上挂载该SD卡的rootfs分区; <br>
+
2) 解压网盘里的/rootfs/rootfs_friendlycore_4.14_YYYYMMDD.tgz<br>
+
 
+
<br>
+
* <b>假设rootfs目录的路径为./rom-maker-lite/part2/h5/4.14/friendlycore/rootfs/,执行下面的命令可生成sd ROM:</b>
+
<syntaxhighlight lang="bash">
+
$ cd rom-maker-lite
+
$ ./mkimage.sh -c 1 -m partmap/h5_linux-4.14/partmap.txt -d "misc/uboot-2017_h5/;part1/boot_linux-4.14_h5/;part2/h5/4.14/friendlycore/rootfs/"
+
</syntaxhighlight>
+
- 对于所有使用Linux-4.14 BSP的H5板子,使用的都是同一个partmap文件: partmap/h5_linux-4.14/partmap.txt。<br>
+
- 如果有需要,你可以将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>
+
 
+
<br>
+
mkimage.sh执行成功后,会生成out/SD-bootable-1目录(这里的"1"对应参数“-c 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;<br>
+
- part2/h5/4.14/friendlycore/rootfs/目录被制作成了rootfs.img;<br>
+
- SD-bootable-1.img则为最终的sd ROM文件,它是由SD-bootable-1目录下的所有文件组装而来的,等效于FriendlyElec 发布的nanopi-[h5]_sd_friendlycore-xenial_4.14_arm64_YYYYMMDD.img;
+
 
+
 
+
 
+
===制作eflasher ROM===
+
制作eflasher ROM的前提条件是已经成功制作出了FriendlyCore/Debian/OpenWrt等sd ROM,即已经有待烧写到eMMC的原材料文件。<br>
+
例如想制作用于烧写“Linux-4.14的FriendlyCore”的eflasher ROM,先要有"Linux-4.14的FriendlyCore"的sd ROM原材料,即:
+
<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>
+
 
+
* <b>准备eflasher的rootfs目录</b>
+
有2种方式可以准备eflasher的rootfs目录:<br>
+
1) 制作一张带eflasher 系统的SD卡,然后基于该SD卡进行定制开发,当开发完毕后,在PC机上挂载该SD卡的rootfs分区; <br>
+
2) 解压网盘里的/rootfs/rootfs_eflasher_4.14_YYYYMMDD.tgz<br>
+
 
+
* <b>假设eflasher rootfs目录的路径为./rom-maker-lite/part2/h5/4.14/eflasher/rootfs/,执行下面的命令可生成eflasher ROM:</b>
+
<syntaxhighlight lang="bash">
+
$ cd rom-maker-lite
+
$ ./mkimage.sh -c 2 -m partmap/h5_eflasher-4.14/partmap.txt -d "misc/uboot-2017_h5/;part1/boot_linux-4.14_h5/;part2/h5/4.14/eflasher/rootfs;out/SD-bootable-1"
+
</syntaxhighlight>
+
mkimage.sh执行成功后,会生成out/SD-bootable-2目录,其内容如下:
+
<syntaxhighlight lang="bash">
+
$ tree out/SD-bootable-2
+
out/SD-bootable-2
+
├── SD-bootable-2
+
│   └── your_company
+
│      ├── boot.img
+
│      ├── friendlyarm.img
+
│      ├── info.conf
+
│      ├── partmap.txt
+
│      ├── rootfs.img
+
│      ├── sunxi-spl.bin
+
│      └── u-boot.itb
+
└── SD-bootable-2.img
+
</syntaxhighlight>
+
- part1/boot_linux-4.14_h5/目录被制作成了boot.img;<br>
+
- part2/h5/4.14/eflasher/rootfs/目录被制作成了rootfs.img;<br>
+
- out/SD-bootable-1/目录被制作成了friendlyarm.img;<br>
+
- SD-bootable-2.img则为最终的eflasher ROM文件,它是由SD-bootable-2目录下的所有文件组装而来的,等效于FriendlyElec 发布的nanopi-[h5]_eflasher_friendlycore-xenial_4.14_arm64_YYYYMMDD.img;<br>
+
事实上,FriendlyElec发布的所有H5板子的nanopi-[h5]_eflasher_friendlycore-xenial_4.14_arm64_YYYYMMDD.img都是同一个文件。
+
 
+
 
+
===仅制作boot.img/rootfs.img===
+
{{ROM-Maker-lite_mk-fsimg |h5}}
+
 
+
====Linux-4.14====
+
为Linux-4.14 sd ROM生成boot.img和rootfs.img的命令如下:
+
<syntaxhighlight lang="bash">
+
$ cd rom-maker-lite
+
$ ./tools/mk_fsimg.sh vfat boot.img ./part1/boot_linux-4.14_h5/ 40 boot
+
$ ./tools/mk_fsimg.sh ext4 rootfs.img ./part2/h5/4.14/friendlycore/rootfs/ 2048 rootfs
+
</syntaxhighlight>
+
上述命令适用于所有H5的板子。
+

Latest revision as of 11:03, 29 October 2019

查看中文

1 Make Image Files for RK3399

Refer to this repo: https://github.com/friendlyarm/sd-fuse_rk3399

2 Make Image Files for S5P4418

Refer to this repo: 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/rootfs.img 
./mk-emmc-image.sh friendlycore
dd if=out/s5p4418-eflasher-friendlycore-20190730.img of=/dev/sdX bs=32M

3 Make Image Files for S5P6818

Refer to this repo: https://github.com/friendlyarm/sd-fuse_s5p6818

4 Make Image Files for H3

Refer to this repo: https://github.com/friendlyarm/sd-fuse_h3

5 Make Image File for H5

Refer to this repo: https://github.com/friendlyarm/sd-fuse_h5