<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.nathael.net/index.php?action=history&amp;feed=atom&amp;title=Dev%2FOPi%2FOPiZero2%2FFrom_Scratch</id>
	<title>Dev/OPi/OPiZero2/From Scratch - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.nathael.net/index.php?action=history&amp;feed=atom&amp;title=Dev%2FOPi%2FOPiZero2%2FFrom_Scratch"/>
	<link rel="alternate" type="text/html" href="http://wiki.nathael.net/index.php?title=Dev/OPi/OPiZero2/From_Scratch&amp;action=history"/>
	<updated>2026-05-07T02:45:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>http://wiki.nathael.net/index.php?title=Dev/OPi/OPiZero2/From_Scratch&amp;diff=152&amp;oldid=prev</id>
		<title>Drizzt: Created page with &quot;== ARM trusted firmware == You can generate it following the instructions from the file board/sunxi/README.sunxi64 from u-boot sources (see below)  git clone https://github.co...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.nathael.net/index.php?title=Dev/OPi/OPiZero2/From_Scratch&amp;diff=152&amp;oldid=prev"/>
		<updated>2023-03-06T18:41:42Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== ARM trusted firmware == You can generate it following the instructions from the file board/sunxi/README.sunxi64 from u-boot sources (see below)  git clone https://github.co...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== ARM trusted firmware ==&lt;br /&gt;
You can generate it following the instructions from the file board/sunxi/README.sunxi64 from u-boot sources (see below)&lt;br /&gt;
 git clone https://github.com/ARM-software/arm-trusted-firmware.git&lt;br /&gt;
 cd arm-trusted-firmware&lt;br /&gt;
 make CROSS_COMPILE=aarch64-linux-gnu- PLAT=sun50i_h616 DEBUG=1 bl31&lt;br /&gt;
Result is in build/sun50i_h616/debug/bl31.bin&lt;br /&gt;
&lt;br /&gt;
== U-boot ==&lt;br /&gt;
=== Grab the sources ===&lt;br /&gt;
Grab the sources from official uboot repository&lt;br /&gt;
 git clone https://source.denx.de/u-boot/u-boot.git&lt;br /&gt;
 cd u-boot/&lt;br /&gt;
&lt;br /&gt;
=== Compile ===&lt;br /&gt;
Note: fix the path (or use the right path) to your bl31.bin firmware&lt;br /&gt;
 make CROSS_COMPILE=aarch64-linux-gnu- orangepi_zero2_defconfig&lt;br /&gt;
 export BL31=/path/to/arm-trusted-firmware/bl31.bin  ##../arm-trusted-firmware/build/sun50i_h616/debug/bl31.bin&lt;br /&gt;
 make -j8 CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
Note: you can customize your u-boot configuration by using a make menuconfig&lt;br /&gt;
&lt;br /&gt;
=== Use ===&lt;br /&gt;
Erase the first Mo of the SD card while keeping the partition table:&lt;br /&gt;
 dd if=/dev/zero of=${card} bs=1k count=1023 seek=1&lt;br /&gt;
Copy uboot image (SPL + ATF + second stage) to the SD card:&lt;br /&gt;
 dd if=u-boot-sunxi-with-spl.bin of=${card} bs=1k seek=8&lt;br /&gt;
&lt;br /&gt;
== Linux Kernel ==&lt;br /&gt;
=== Grab the sources ===&lt;br /&gt;
* Kernel from kernel.org&lt;br /&gt;
 git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git&lt;br /&gt;
&lt;br /&gt;
=== Compile ===&lt;br /&gt;
 mkdir -p Build/{linux,results}&lt;br /&gt;
 cd linux&lt;br /&gt;
 cp ##Your_old_config_file## ../Build/linux/.config&lt;br /&gt;
 make ARCH=arm64 -j8 O=../Build/linux/ oldconfig&lt;br /&gt;
 cd ../Build/linux/ &lt;br /&gt;
 make ARCH=arm64 -j8 CROSS_COMPILE=aarch64-linux-gnu-&lt;br /&gt;
 make ARCH=arm64 -j8 CROSS_COMPILE=aarch64-linux-gnu- modules_install INSTALL_MOD_PATH=../results/Mods&lt;br /&gt;
&lt;br /&gt;
=== Use ===&lt;br /&gt;
* Linux Kernel&lt;br /&gt;
Compilation result is in arch/arm64/boot/Image&lt;br /&gt;
* Device tree&lt;br /&gt;
Use the sun50i-h616-orangepi-zero2.dtb (found in arch/arm64/boot/dts/allwinner/)&lt;br /&gt;
* Modules&lt;br /&gt;
If the compilation has been performed using the above command lines you should have a directory &amp;quot;Build/Mods/lib/modules/***&amp;quot; (*** = name of the kernel you just compiled)&amp;lt;br /&amp;gt;&lt;br /&gt;
You must copy the whole directory (not only the content) on the SD card, in the partition holding the root filesystem (rootfs), in the /lib/modules/ directory without changing the name.&lt;br /&gt;
&lt;br /&gt;
== SD Card creation ==&lt;br /&gt;
Original information from [http://linux-sunxi.org/Bootable_SD_card linux-sunxi wiki]&lt;br /&gt;
&lt;br /&gt;
=== SD card architecture ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
 ! start&lt;br /&gt;
 ! sector&lt;br /&gt;
 ! size&lt;br /&gt;
 ! usage&lt;br /&gt;
 |-&lt;br /&gt;
 | 0KB || 0 || 8KB || Unused, available for an MBR or (limited) GPT partition table&lt;br /&gt;
 |-&lt;br /&gt;
 | 8KB || 16 || 32KB || Initial SPL loader&lt;br /&gt;
 |-&lt;br /&gt;
 | 40KB || 80 || - || U-Boot&lt;br /&gt;
 |}&lt;br /&gt;
Typically partitions start at XXXMB (which is the default setting of most partitioning tools), but there is no hard requirement for this, so U-Boot can grow bigger than 984KB, if needed.&lt;br /&gt;
&lt;br /&gt;
=== Cleaning ===&lt;br /&gt;
Erase the first Mo of the SD card while keeping the partition table:&lt;br /&gt;
 dd if=/dev/zero of=${card} bs=1k count=1023 seek=1&lt;br /&gt;
(Use count=1024 and remove &amp;quot;seek&amp;quot; option to also erase the partition table)&lt;br /&gt;
&lt;br /&gt;
=== Bootloader ===&lt;br /&gt;
Copy (dd) uboot images (u-boot-sunxi-with-spl.bin) to the SD card. Refer to &amp;quot;U-boot/Use&amp;quot; section above.&lt;br /&gt;
&lt;br /&gt;
=== First partition ===&lt;br /&gt;
The first partition must start at +XXXMo, and be a few Mo (50 Mo should be OK) and be formated using ext2/3/4&amp;lt;br /&amp;gt;&lt;br /&gt;
Place the files &amp;quot;Image-5.19.0-ed3l&amp;quot;, &amp;quot;sun50i-h5-orangepi-zero-plus-ed3l.dtb&amp;quot; and &amp;quot;boot.scr&amp;quot; on the first partition.&lt;br /&gt;
* The file &amp;quot;boot.scr&amp;quot; is generated using mkimage from &amp;quot;boot.cmd&amp;quot; with the following command :&lt;br /&gt;
 mkimage -C none -A arm -T script -d boot.cmd boot.scr&lt;br /&gt;
An example &amp;quot;boot.cmd&amp;quot; file can be found in [http://data.nathael.net/Dev/Opi/OPiZeroPlus/ boot_devuan_ceres_***.tar.bz2]&lt;br /&gt;
&lt;br /&gt;
A short one can look like this :&lt;br /&gt;
 setenv kernel_image &amp;quot;Image&amp;quot;&lt;br /&gt;
 setenv fdtfile &amp;quot;sun50i-h616-orangepi-zero2.dtb&amp;quot;&lt;br /&gt;
 setenv bootargs &amp;quot;console=ttyS0,115200 root=/dev/mmcblk0p2 rw rootwait quiet&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 load ${devtype} ${devnum} ${fdt_addr_r} ${fdtfile}&lt;br /&gt;
 load ${devtype} ${devnum} ${kernel_addr_r} ${kernel_image}&lt;br /&gt;
 booti ${kernel_addr_r} - ${fdt_addr_r}&lt;br /&gt;
&lt;br /&gt;
=== Second partition ===&lt;br /&gt;
The second partition must be formated using ext4 and starts right after the first one. It can take all the remaining size unless you have other specific needs.&lt;br /&gt;
&lt;br /&gt;
This partition holds the root filesystem (rootfs).&lt;br /&gt;
&lt;br /&gt;
== Rootfs ==&lt;br /&gt;
This board uses an ARM64 processor, thus the root filesystem should be built using &amp;quot;aarch64-linux-gnu-&amp;quot; cross-toolchain or use the arm64 architecture for Devuan or other Debian based distribution.&lt;br /&gt;
&lt;br /&gt;
Refer to [[Dev/Embedded/Rootfs|the rootfs creation page]] for more information.&lt;/div&gt;</summary>
		<author><name>Drizzt</name></author>
	</entry>
</feed>