<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pine64.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vitfen</id>
	<title>PINE64 - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pine64.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Vitfen"/>
	<link rel="alternate" type="text/html" href="https://wiki.pine64.org/wiki/Special:Contributions/Vitfen"/>
	<updated>2026-12-02T22:20:15Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Recovering_the_Bootloader_for_STAR64_JH7710_over_serial_using_screen&amp;diff=19864</id>
		<title>Recovering the Bootloader for STAR64 JH7710 over serial using screen</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Recovering_the_Bootloader_for_STAR64_JH7710_over_serial_using_screen&amp;diff=19864"/>
		<updated>2023-06-13T14:49:31Z</updated>

		<summary type="html">&lt;p&gt;Vitfen: Fix mdt number for data&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
== Recovering the Bootloader for STAR64 JH7710 over serial using screen ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
cd &amp;lt;path-to-directory-with-Tools&amp;gt;&lt;br /&gt;
screen -m -S star64 /dev/ttyUSB0 115200&lt;br /&gt;
# open a second shell&lt;br /&gt;
screen -S star64 -X exec \!\! sx Tools/recovery/jh7110-recovery-20230322.bin&lt;br /&gt;
# type 0 in the first shell&lt;br /&gt;
screen -S star64 -X exec \!\! sx u-boot/spl/u-boot-spl.bin.normal.out # file created with: ../Tools/spl_tool/spl_tool -c -f spl/u-boot-spl.bin&lt;br /&gt;
# type 2 in the first shell&lt;br /&gt;
screen -S star64 -X exec \!\! sx u-boot/u-boot.itb # file created with: tools/mkimage -f ../Tools/uboot_its/visionfive2-uboot-fit-image.its -A riscv -O u-boot -T firmware u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Backup current SPI ==&lt;br /&gt;
=== Using Linux ===&lt;br /&gt;
Execute the commands on the star64 (takes some time):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/mtd0 of=/tmp/star64-factory-spl.bin&lt;br /&gt;
dd if=/dev/mtd1 of=/tmp/star64-factory-uboot.bin&lt;br /&gt;
dd if=/dev/mtd2 of=/tmp/star64-factory-data.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute on you host:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
rsync ${MNAME}:&amp;#039;/tmp/star64-factory-*&amp;#039; .&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://github.com/starfive-tech/Tools/blob/master/README.md#recovery Tools README.md about recovery]&lt;br /&gt;
* [https://doc-en.rvspace.org/VisionFive2/PDF/VisionFive2_QSG.pdf#page=40 VisionFive 2 Single Board Computer Quick Start Guide: 4.4. Recovering the Bootloader p. 40]&lt;br /&gt;
* [https://doc-en.rvspace.org/VisionFive2/PDF/VisionFive2_SDK_QSG.pdf#page=19 VisionFive 2 SDK Quick Start Guide: 7.4. Recovering the Bootloader p. 19]&lt;br /&gt;
&lt;br /&gt;
[[Category:STAR64]]&lt;/div&gt;</summary>
		<author><name>Vitfen</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=User:RemDogKap/SandBox&amp;diff=19863</id>
		<title>User:RemDogKap/SandBox</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=User:RemDogKap/SandBox&amp;diff=19863"/>
		<updated>2023-06-13T14:33:04Z</updated>

		<summary type="html">&lt;p&gt;Vitfen: Add Link to Recovering the bootloader page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
Links to documentation pages I am currently working on for the Star64 SBC&lt;br /&gt;
&lt;br /&gt;
ToDo:&lt;br /&gt;
*Explain that SD Card does not work at full speed&lt;br /&gt;
*Tutorial for loading disk images onto eMMC&lt;br /&gt;
*How to update XSPI U-Boot&lt;br /&gt;
*How to use NVME drives&lt;br /&gt;
*working state of various USB ports &lt;br /&gt;
*list hardware bugs&lt;br /&gt;
**SD Card Voltage &lt;br /&gt;
**USB over current&lt;br /&gt;
*Armbian Install &lt;br /&gt;
*Memory DTB fix/recompile eeprom thing&lt;br /&gt;
*How to flash eMMC from SD card if possible&lt;br /&gt;
*Things needed to build you own working image&lt;br /&gt;
*How to connect over serial &lt;br /&gt;
&lt;br /&gt;
[[/First Setup]]&lt;br /&gt;
&lt;br /&gt;
[[/Status of Features]]&lt;br /&gt;
&lt;br /&gt;
[[/Build Your Own Image]]&lt;br /&gt;
&lt;br /&gt;
[[/Update XSPI Flash SPL and U-Boot]]&lt;br /&gt;
&lt;br /&gt;
[[Recovering the Bootloader for STAR64 JH7710 over serial using screen]]&lt;/div&gt;</summary>
		<author><name>Vitfen</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Recovering_the_Bootloader_for_STAR64_JH7710_over_serial_using_screen&amp;diff=19862</id>
		<title>Recovering the Bootloader for STAR64 JH7710 over serial using screen</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Recovering_the_Bootloader_for_STAR64_JH7710_over_serial_using_screen&amp;diff=19862"/>
		<updated>2023-06-13T14:30:14Z</updated>

		<summary type="html">&lt;p&gt;Vitfen: Initial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Under construction}}&lt;br /&gt;
&lt;br /&gt;
== Recovering the Bootloader for STAR64 JH7710 over serial using screen ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
cd &amp;lt;path-to-directory-with-Tools&amp;gt;&lt;br /&gt;
screen -m -S star64 /dev/ttyUSB0 115200&lt;br /&gt;
# open a second shell&lt;br /&gt;
screen -S star64 -X exec \!\! sx Tools/recovery/jh7110-recovery-20230322.bin&lt;br /&gt;
# type 0 in the first shell&lt;br /&gt;
screen -S star64 -X exec \!\! sx u-boot/spl/u-boot-spl.bin.normal.out # file created with: ../Tools/spl_tool/spl_tool -c -f spl/u-boot-spl.bin&lt;br /&gt;
# type 2 in the first shell&lt;br /&gt;
screen -S star64 -X exec \!\! sx u-boot/u-boot.itb # file created with: tools/mkimage -f ../Tools/uboot_its/visionfive2-uboot-fit-image.its -A riscv -O u-boot -T firmware u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Backup current SPI ==&lt;br /&gt;
=== Using Linux ===&lt;br /&gt;
Execute the commands on the star64 (takes some time):&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/mtd0 of=/tmp/star64-factory-spl.bin&lt;br /&gt;
dd if=/dev/mtd1 of=/tmp/star64-factory-uboot.bin&lt;br /&gt;
dd if=/dev/mtd1 of=/tmp/star64-factory-data.bin&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Execute on you host:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
rsync ${MNAME}:&amp;#039;/tmp/star64-factory-*&amp;#039; .&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
* [https://github.com/starfive-tech/Tools/blob/master/README.md#recovery Tools README.md about recovery]&lt;br /&gt;
* [https://doc-en.rvspace.org/VisionFive2/PDF/VisionFive2_QSG.pdf#page=40 VisionFive 2 Single Board Computer Quick Start Guide: 4.4. Recovering the Bootloader p. 40]&lt;br /&gt;
* [https://doc-en.rvspace.org/VisionFive2/PDF/VisionFive2_SDK_QSG.pdf#page=19 VisionFive 2 SDK Quick Start Guide: 7.4. Recovering the Bootloader p. 19]&lt;br /&gt;
&lt;br /&gt;
[[Category:STAR64]]&lt;/div&gt;</summary>
		<author><name>Vitfen</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=User:Vitali/Create_a_bootable_Debian/Linux_SDCard_for_the_Pine64/Star64_from_scratch&amp;diff=19861</id>
		<title>User:Vitali/Create a bootable Debian/Linux SDCard for the Pine64/Star64 from scratch</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=User:Vitali/Create_a_bootable_Debian/Linux_SDCard_for_the_Pine64/Star64_from_scratch&amp;diff=19861"/>
		<updated>2023-06-13T14:22:39Z</updated>

		<summary type="html">&lt;p&gt;Vitfen: Add category STAR64&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;introduction&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
This guide is for advance users only. In the process we will build every part necessary to boot the star64 until the kernel from &amp;#039;&amp;#039;&amp;#039;source&amp;#039;&amp;#039;&amp;#039;. For people interested to just get the star64 to boot I would recommend to search for [[#|a guide using a SDCard image]].&lt;br /&gt;
&lt;br /&gt;
This guide is a compilation of mostly already available information but this guide tries to glue all the parts together to make them work. All original sources are linked for reference.&lt;br /&gt;
&lt;br /&gt;
By following this guide you will compile &amp;lt;code&amp;gt;u-boot/spl&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;u-boot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;opensbi&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;linux kernel&amp;lt;/code&amp;gt; for the pine64/star64 and create a bootable SDCard by creating and populating the necessary partitions on the SDCard. Finally the precompiled official unstable &amp;lt;code&amp;gt;Debian&amp;lt;/code&amp;gt; riscv64 port will be installed to the rootfs partition on the SDCard. By using &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;systemd-nspawn&amp;lt;/code&amp;gt; we will be able to execute &amp;lt;code&amp;gt;debootstrap&amp;lt;/code&amp;gt; to install a foreign architecture (e.g. install &amp;lt;code&amp;gt;riscv64&amp;lt;/code&amp;gt; while running &amp;lt;code&amp;gt;debootstrap&amp;lt;/code&amp;gt; on a &amp;lt;code&amp;gt;amd64&amp;lt;/code&amp;gt; host). Also minimal configuration of the rootfs is done on the host computer. All commands are documented in a way to be easy repeatable and will produce a ready to boot and configured SDCard image. You can of course modify configurations done on the host to your preference.&lt;br /&gt;
&lt;br /&gt;
In contrast to methods using [[#|&amp;lt;code&amp;gt;buildroot&amp;lt;/code&amp;gt;]] or [[#|&amp;lt;code&amp;gt;yocto&amp;lt;/code&amp;gt;]] this guide is compiling each component separately. And the advantage of using &amp;lt;code&amp;gt;debian&amp;lt;/code&amp;gt; is that you will have access to thousands of precompiled &amp;lt;code&amp;gt;debian&amp;lt;/code&amp;gt; packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;preparation&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Preparation ==&lt;br /&gt;
&lt;br /&gt;
Install &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;systemd-nspawn&amp;lt;/code&amp;gt; and a &amp;lt;code&amp;gt;riscv compiler&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;sudo apt install gcc-riscv64-linux-gnu systemd-container qemu debootstrap pwgen&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Optional: Create .env file with your environment settings. Or Just set them directly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;nano .env&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;# cross compiler&lt;br /&gt;
CROSS_COMPILE=riscv64-linux-gnu-&lt;br /&gt;
# where to store apt cache, for faster installs&lt;br /&gt;
APT_CACHE_DIR=/tmp/apt/cache&lt;br /&gt;
# arbitrary path where the rootfs will be mounted at&lt;br /&gt;
ROOTFS=/tmp/star64/rootfs&lt;br /&gt;
# SDCard dev path&lt;br /&gt;
USBDEV=/dev/sdX&lt;br /&gt;
&lt;br /&gt;
# hostname of the target, can be left empty&lt;br /&gt;
MNAME=&lt;br /&gt;
&lt;br /&gt;
# username you are logged in your host system this name will be also used to create a new user on the newly created rootfs.&lt;br /&gt;
USER=$USER&lt;br /&gt;
test &amp;quot;$USER&amp;quot; = root &amp;amp;&amp;amp; { echo &amp;quot;USER can&amp;#039;t be root&amp;quot;; exit; }&lt;br /&gt;
&lt;br /&gt;
PASSWORD=$(pwgen -1)&lt;br /&gt;
&lt;br /&gt;
AUTHORIZED_KEY=$(ssh-keygen -f /home/$USER/.ssh/id_ed25519 -y)&lt;br /&gt;
&lt;br /&gt;
# define helper functions&lt;br /&gt;
function star64_mount() {&lt;br /&gt;
    mkdir -p ${ROOTFS?}/&lt;br /&gt;
    sudo -E mount ${USBDEV:?}4 ${ROOTFS?}/&lt;br /&gt;
    sudo mkdir -p ${ROOTFS?}/boot&lt;br /&gt;
    sudo -E mount -o umask=0000 ${USBDEV:?}3 ${ROOTFS?}/boot&lt;br /&gt;
}&lt;br /&gt;
function star64_unmount() {&lt;br /&gt;
    sudo umount ${ROOTFS?}/boot&lt;br /&gt;
    sudo umount ${ROOTFS?}/&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;source .env&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;connect-serial-cable&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
=== Connect Serial Cable ===&lt;br /&gt;
&lt;br /&gt;
It is a good idea to first make sure the serial connection is working. Make sure the boot switches are set to boot from UART.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PINE64 STAR64 BOOT UART&lt;br /&gt;
          ┌──┐&lt;br /&gt;
GOIO_0  1 │X │&lt;br /&gt;
GPIO_1  2 │X │&lt;br /&gt;
          └──┘&lt;br /&gt;
        H      L&amp;lt;/pre&amp;gt;&lt;br /&gt;
Connect and monitor the serial port as stated in the [[#serial-uart|Troubleshooting Section: Serial / UART]]. You should see repeatably printing of ‘C’. After making sure the serial works we can change it to SDCard boot mode.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PINE64 STAR64 BOOT SDCARD&lt;br /&gt;
          ┌──┐&lt;br /&gt;
GOIO_0  1 │ X│&lt;br /&gt;
GPIO_1  2 │X │&lt;br /&gt;
          └──┘&lt;br /&gt;
        H      L&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;build&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Build =&lt;br /&gt;
&lt;br /&gt;
Build each of the following projects. Make sure to navigate back into your base project directory (e.g. &amp;lt;code&amp;gt;/tmp/star64&amp;lt;/code&amp;gt;) if you proceed to build the next project. After completing this guide it should at least contain the directories: &amp;lt;code&amp;gt;linux opensbi Tools u-boot&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* [[#build-tools|Build tools]]&lt;br /&gt;
* [[#build-opensbi|Build OpenSBI]]&lt;br /&gt;
* [[#build-u-boot|Build U-Boot]]&lt;br /&gt;
* [[#partition-the-sdcard|Partition the SDCard]]&lt;br /&gt;
* [[#build-the-linux-kernel|Build the Linux kernel]]&lt;br /&gt;
* [[#debootstrap-the-debian-riscv64-rootfs|Debootstrap the Debian riscv64 rootfs]]&lt;br /&gt;
* [[#copy-the-linux-kernel-to-sdcard|Copy the Linux kernel to SDCard]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;build-tools&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Build tools =&lt;br /&gt;
&lt;br /&gt;
Build [https://github.com/starfive-tech/Tools/blob/master/spl_tool/README.md spl_tool].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;git clone --depth 1 https://github.com/starfive-tech/Tools.git&lt;br /&gt;
make -C Tools/spl_tool&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;build-opensbi&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Build OpenSBI =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;git clone --depth 1 https://github.com/riscv/opensbi.git&lt;br /&gt;
cd opensbi&lt;br /&gt;
make CROSS_COMPILE=${CROSS_COMPILE?} PLATFORM=generic FW_TEXT_START=0x40000000 FW_OPTIONS=0 -j&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more insight about the u-boot boot process you can find more useful information in the [https://github.com/u-boot/u-boot/blob/master/doc/board/starfive/visionfive2.rst u-boot visionfive2 docs].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;build-u-boot&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Build U-Boot =&lt;br /&gt;
&lt;br /&gt;
Make sure to [[#build-tools|build Tools]] and [[#build-opensbi|openSBI]] before proceeding.&lt;br /&gt;
&lt;br /&gt;
The upsteam u-boot builds the &amp;lt;code&amp;gt;u-boot.itb&amp;lt;/code&amp;gt; automatically by using openSBIs fw_dynamic.bin. But the upstream u-boot does not boot properly (Last checked: 26-05-23)… Therefore we use the fw_payload.bin method with the starfive/u-boot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;git clone --depth 1 -b Star64 https://github.com/Fishwaldo/u-boot.git&lt;br /&gt;
cd u-boot&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE=${CROSS_COMPILE?} make pine64_star64_defconfig&lt;br /&gt;
CROSS_COMPILE=${CROSS_COMPILE?} make OPENSBI=../opensbi/build/platform/generic/firmware/fw_dynamic.bin -j&lt;br /&gt;
&lt;br /&gt;
make -C ../opensbi CROSS_COMPILE=${CROSS_COMPILE?} PLATFORM=generic \&lt;br /&gt;
    FW_FDT_PATH=../u-boot/arch/riscv/dts/pine64_star64.dtb \&lt;br /&gt;
    FW_PAYLOAD_FDT_ADDR=0x40080000 \&lt;br /&gt;
    FW_PAYLOAD_OFFSET=0x00100000 \&lt;br /&gt;
    FW_PAYLOAD_PATH=../u-boot/u-boot.bin \&lt;br /&gt;
    FW_TEXT_START=0x40000000&lt;br /&gt;
&lt;br /&gt;
ln -s ../../opensbi/build/platform/generic/firmware/fw_payload.bin ../Tools/uboot_its/&lt;br /&gt;
tools/mkimage -f ../Tools/uboot_its/visionfive2-uboot-fit-image.its -A riscv -O u-boot -T firmware u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Create a SPL header as stated in [https://github.com/u-boot/u-boot/blob/master/doc/board/starfive/visionfive2.rst u-boot visionfive2 docs] and [https://github.com/starfive-tech/Tools/blob/master/spl_tool/README.md spl_tool]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;../Tools/spl_tool/spl_tool -c -f spl/u-boot-spl.bin&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;update-with-linux&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Update with Linux ==&lt;br /&gt;
&lt;br /&gt;
If you alreay have Linux running on the star64 and want to update &amp;lt;code&amp;gt;u-boot&amp;lt;/code&amp;gt; you can do that like that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;scp u-boot.itb ${MNAME?}:/tmp&lt;br /&gt;
ssh ${MNAME?} sudo dd if=/tmp/u-boot.itb of=/dev/mmcblk1p2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
More infos on the [https://u-boot.readthedocs.io/en/latest/build/gcc.html u-boot build process with gcc]. I strongly recommend to read [https://doc-en.rvspace.org/VisionFive2/Developer_Guide/JH7110_Boot_UG.pdf JH7110Boot User Guide] for more information on the boot process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;partition-the-sdcard&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Partition the SDCard =&lt;br /&gt;
&lt;br /&gt;
After build [[#build-opensbi|OpenSBI]] and [[#build-u-boot|U-Boot]] from above we can proceed to setup the partitions for the SDCard and write u-boot-spl into the &amp;lt;code&amp;gt;SPL&amp;lt;/code&amp;gt;-partition and u-boot into the &amp;lt;code&amp;gt;UBOOT&amp;lt;/code&amp;gt;-partition.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;# Set the SDCard dev path (content will be lost)&lt;br /&gt;
sudo su # continue with caution!&lt;br /&gt;
source .env&lt;br /&gt;
fdisk -l ${USBDEV:?} # make sure its in fact the right drive&lt;br /&gt;
&lt;br /&gt;
lsblk ${USBDEV:?} -n | grep -q part &amp;amp;&amp;amp; \&lt;br /&gt;
    { echo &amp;quot;delete partitions with &amp;#039;wipefs --all ${USBDEV:?}&amp;#039; first&amp;quot;; exit; }&lt;br /&gt;
&lt;br /&gt;
sfdisk ${USBDEV:?} &amp;lt;&amp;lt;EOF&lt;br /&gt;
label: gpt&lt;br /&gt;
: start=4096, size=2MiB, name=SPL, type=2E54B353-1271-4842-806F-E436D6AF6985&lt;br /&gt;
: size=4MiB, name=UBOOT, type=BC13C2FF-59E6-4262-A352-B275FD6F7172&lt;br /&gt;
: size=512MiB, name=BOOT, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7&lt;br /&gt;
: name=SYSTEM, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
mkfs.vfat -F 32 ${USBDEV:?}3&lt;br /&gt;
mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 ${USBDEV:?}4&lt;br /&gt;
&lt;br /&gt;
# if you install on eMMC: execute:&lt;br /&gt;
# Tools/spl_tool/spl_tool --fix-imghdr -f ${USBDEV:?}&lt;br /&gt;
&lt;br /&gt;
dd if=u-boot/spl/u-boot-spl.bin.normal.out of=${USBDEV:?}1&lt;br /&gt;
dd if=u-boot/u-boot.itb of=${USBDEV:?}2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can find more about the partition layout on [https://doc-en.rvspace.org/VisionFive2/Developer_Guide/JH7110_Boot_UG.pdf JH7110_Boot_UG] Page 8 Table1-3 SD/eMMC Boot Address Allocation and [https://github.com/u-boot/u-boot/blob/master/doc/board/starfive/visionfive2.rst#flashing u-boot/visionfive2: create bootable image: flashing]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;build-the-linux-kernel&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Build the Linux kernel =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;# alternative: https://github.com/starfive-tech/linux/tree/JH7110_VisionFive2_upstream&lt;br /&gt;
git clone --depth 1 -b Star64_devel https://github.com/Fishwaldo/Star64_linux.git linux&lt;br /&gt;
cd linux/&lt;br /&gt;
&lt;br /&gt;
ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} make pine64_star64_defconfig&lt;br /&gt;
&lt;br /&gt;
# if you need any extra symbols for your kernel&lt;br /&gt;
ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} make xconfig&lt;br /&gt;
&lt;br /&gt;
# or by command line&lt;br /&gt;
ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} scripts/config \&lt;br /&gt;
    -m ATA \&lt;br /&gt;
    -m SATA_AHCI \&lt;br /&gt;
    -m ATA_GENERIC&lt;br /&gt;
&lt;br /&gt;
# set new defaults if changed by command line&lt;br /&gt;
ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} make olddefconfig&lt;br /&gt;
&lt;br /&gt;
ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} make -j14&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;copy-the-linux-kernel-to-sdcard&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Copy the Linux kernel to SDCard =&lt;br /&gt;
&lt;br /&gt;
Make sure to [[#build-the-linux-kernel|build the Linux kernel]] and [[#partition-the-sdcard|Partition the SDCard]] before proceeding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
star64_mount&lt;br /&gt;
&lt;br /&gt;
cp -v linux/arch/riscv/boot/Image.gz ${ROOTFS?}/boot&lt;br /&gt;
# cp initramfs.cpio.gz ${ROOTFS?}/boot # don&amp;#039;t have one...&lt;br /&gt;
cp -v linux/arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dtb ${ROOTFS?}/boot&lt;br /&gt;
&lt;br /&gt;
sudo ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} \&lt;br /&gt;
    INSTALL_MOD_PATH=${ROOTFS?}/usr \&lt;br /&gt;
    INSTALL_PATH=${ROOTFS?}/boot \&lt;br /&gt;
    INSTALL_HDR_PATH=${ROOTFS?}/usr \&lt;br /&gt;
    make -C linux install modules_install headers_install&lt;br /&gt;
&lt;br /&gt;
star64_unmount&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;update-with-linux-1&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Update with Linux ==&lt;br /&gt;
&lt;br /&gt;
If you already have Linux running on the star64 and want to update the &amp;lt;code&amp;gt;linux&amp;lt;/code&amp;gt; kernel you can do that like that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;rsync --rsync-path=&amp;#039;sudo rsync&amp;#039; arch/riscv/boot/Image.gz ${MNAME?}:/boot&lt;br /&gt;
sudo ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} \&lt;br /&gt;
    INSTALL_MOD_PATH=/tmp/modules \&lt;br /&gt;
    make modules_install&lt;br /&gt;
rsync -rv --rsync-path=&amp;#039;sudo rsync&amp;#039; /tmp/modules/lib/modules/ ${MNAME?}:/lib/modules&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;debootstrap-the-debian-riscv64-rootfs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Debootstrap the Debian riscv64 rootfs =&lt;br /&gt;
&lt;br /&gt;
Make sure to setup [https://de.wikipedia.org/wiki/Binfmt_misc binfmt]. Check if it is available with &amp;lt;code&amp;gt;mount | grep binfmt_misc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cat /proc/sys/fs/binfmt_misc/qemu-riscv64&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Copy and past the &amp;lt;code&amp;gt;star64_install_debian&amp;lt;/code&amp;gt; function into bash and execute it or create a script file from that function. You can also execute them one by one if you prefer.&lt;br /&gt;
&lt;br /&gt;
You can also just run the &amp;lt;code&amp;gt;debootstrap&amp;lt;/code&amp;gt; command and setup Debian on your own. But at least set a root password so you can login over serial.&lt;br /&gt;
&lt;br /&gt;
For reference read [https://wiki.debian.org/RISC-V#debootstrap debootstrap].&lt;br /&gt;
&lt;br /&gt;
Alternatively if you dont want to use &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;systemd-nspawn&amp;lt;/code&amp;gt; you can just follow the [https://forum.pine64.org/showthread.php?tid=18276 Star64: Armbian Installation] guide instead of &amp;lt;code&amp;gt;debootsraping&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;Debian&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;#switch to root&lt;br /&gt;
sudo su&lt;br /&gt;
source .env&lt;br /&gt;
&lt;br /&gt;
function star64_install_debian() {&lt;br /&gt;
MNAME=${MNAME:-&amp;quot;star64-$(pwgen 4 -1 -A)&amp;quot;}&lt;br /&gt;
mkdir -p ${APT_CACHE_DIR:-/tmp/apt/cache}&lt;br /&gt;
&lt;br /&gt;
debootstrap --foreign --cache-dir=/mnt/data/tmp/apt-riscv --arch=riscv64 --no-check-gpg --include=debian-ports-archive-keyring,usrmerge,openssh-server,htop,vim,nano,tcpdump,sudo,curl,wget,iputils-ping,fdisk,gdisk,pciutils,usbutils,screen,rsync,firmware-linux-free unstable ${ROOTFS?} http://deb.debian.org/debian-ports&lt;br /&gt;
cp /usr/bin/qemu-riscv64 ${ROOTFS?}/usr/bin/&lt;br /&gt;
chroot ${ROOTFS?} /debootstrap/debootstrap --second-stage&lt;br /&gt;
&lt;br /&gt;
NSPAWN=&amp;quot;systemd-nspawn -M $MNAME -D ${ROOTFS?} --quiet --no-pager&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# ${NSPAWN?} sed -i &amp;#039;s/main/main non-free/g&amp;#039; /etc/apt/sources.list&lt;br /&gt;
# ${NSPAWN?} apt update&lt;br /&gt;
# ${NSPAWN?} apt install -y firmware-linux-nonfree&lt;br /&gt;
&lt;br /&gt;
PASSWORD=${PASSWORD:-$(pwgen 8 -1 -A)}&lt;br /&gt;
echo &amp;quot;Your root/$USER password is set to $PASSWORD&amp;quot;&lt;br /&gt;
${NSPAWN?} useradd --shell /bin/bash --create-home ${USER:-user}&lt;br /&gt;
${NSPAWN?} sh -c &amp;quot;echo root:$PASSWORD | chpasswd&amp;quot;&lt;br /&gt;
${NSPAWN?} sh -c &amp;quot;echo ${USER:-user}:$PASSWORD | chpasswd&amp;quot;&lt;br /&gt;
echo &amp;quot;$MNAME&amp;quot; &amp;gt; ${ROOTFS?}/etc/hostname&lt;br /&gt;
echo &amp;quot;127.0.0.1 $MNAME&amp;quot; &amp;gt;&amp;gt; ${ROOTFS?}/etc/hosts&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;${USER:-user} ALL=(ALL) NOPASSWD:ALL&amp;quot; &amp;gt; ${ROOTFS?}/etc/sudoers.d/${USER:-user}&lt;br /&gt;
install -o 1000 -g 1000 -d -m 0700 ${ROOTFS?}/home/${USER:-user}/.ssh/&lt;br /&gt;
install -o 1000 -g 1000 -m 0644 &amp;lt;(echo &amp;quot;$AUTHORIZED_KEY&amp;quot;) ${ROOTFS?}/home/${USER:-user}/.ssh/authorized_keys&lt;br /&gt;
&lt;br /&gt;
mkdir -p ${ROOTFS?}/boot&lt;br /&gt;
&lt;br /&gt;
test -b ${USBDEV:-&amp;#039;&amp;#039;} &amp;amp;&amp;amp; {&lt;br /&gt;
echo &amp;quot;PARTUUID=$(blkid ${USBDEV:?}4 --output value | tail -1)        /            ext4     defaults,noatime    0    0&amp;quot; &amp;gt;&amp;gt; ${ROOTFS?}/etc/fstab&lt;br /&gt;
echo &amp;quot;PARTUUID=$(blkid ${USBDEV:?}3 --output value | tail -1)        /boot        vfat     defaults,noatime    0    0&amp;quot; &amp;gt;&amp;gt; ${ROOTFS?}/etc/fstab&lt;br /&gt;
echo &amp;quot;none                                                 /tmp         tmpfs    defaults,noatime    0    0&amp;quot; &amp;gt;&amp;gt; ${ROOTFS?}/etc/fstab&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
${NSPAWN?} sh -c &amp;quot;&lt;br /&gt;
systemctl enable networking&lt;br /&gt;
systemctl enable systemd-networkd.service&lt;br /&gt;
systemctl enable ssh&lt;br /&gt;
&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; ${ROOTFS?}/etc/systemd/network/20-dhcp-all.network &amp;lt;&amp;lt;EOF&lt;br /&gt;
[Match]&lt;br /&gt;
Name=*&lt;br /&gt;
&lt;br /&gt;
[Network]&lt;br /&gt;
DHCP=yes&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;nameserver 1.1.1.1&amp;quot; &amp;gt; ${ROOTFS?}/etc/resolv.conf&lt;br /&gt;
echo &amp;quot;nameserver 8.8.8.8&amp;quot; &amp;gt;&amp;gt; ${ROOTFS?}/etc/resolv.conf&lt;br /&gt;
&lt;br /&gt;
test -d ssh_host &amp;amp;&amp;amp; {&lt;br /&gt;
sudo rsync --chown=root:root -vr ssh_host/etc/ssh/ ${ROOTFS?}/etc/ssh/&lt;br /&gt;
sudo chmod 600 ${ROOTFS?}/etc/ssh/ssh_host_*&lt;br /&gt;
sudo chmod +r ${ROOTFS?}/etc/ssh/ssh_host_*.pub&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
star64_mount&lt;br /&gt;
star64_install_debian&lt;br /&gt;
&lt;br /&gt;
tee ${ROOTFS?}/boot/vf2_uEnv.txt &amp;lt;&amp;lt;&amp;#039;EOF&amp;#039;&lt;br /&gt;
bootargs=console=ttyS0,115200 rootwait earlycon=sbi root=/dev/mmcblk1p4 rw&lt;br /&gt;
distro_bootcmd=fatload mmc 1:3 0x60200000 Image.gz; \&lt;br /&gt;
    fatload mmc 1:3 ${fdt_addr_r} jh7110-pine64-star64.dtb \&lt;br /&gt;
    unzip 0x60200000 ${kernel_addr_r}; \&lt;br /&gt;
    booti ${kernel_addr_r} - ${fdt_addr_r}&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
star64_unmount&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;troubleshooting&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;project-versions-used-last-git-commit-hash&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Project versions used (last git commit hash) ==&lt;br /&gt;
&lt;br /&gt;
* linux: 7943fd6427b0abd25e1af2756e061a112bde8711&lt;br /&gt;
* opensbi: d4c46e0ff1b0ead9d5a586e1a19a00a92160206d&lt;br /&gt;
* Tools: 693661d4ba314424f76c06da1bbb799e9b534c9f&lt;br /&gt;
* u-boot: 172b47f62039605d6806fa96bd403c21cda28996&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;serial-uart&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Serial / UART ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;       PINE64 STAR64 UART&lt;br /&gt;
&lt;br /&gt;
             ┌─────┐&lt;br /&gt;
       3.3V  │ 1  2│ 5V&lt;br /&gt;
       SDA1  │ 3  4│ 5V&lt;br /&gt;
       SCL1  │ 5  6│ GND&lt;br /&gt;
GPIO55       │ 7  8│ TXD&lt;br /&gt;
       GND   │ 9 10│ RXD&amp;lt;/pre&amp;gt;&lt;br /&gt;
Use &amp;lt;code&amp;gt;screen /dev/ttyUSB0 115200&amp;lt;/code&amp;gt; to monitor serial port.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;jtag&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== JTAG ==&lt;br /&gt;
&lt;br /&gt;
Connect a JTAG adapter to GPIO [https://files.pine64.org/doc/star64/Star64_Schematic_V1.1_20230504.pdf Star64 schematic] p. 18 J5 and Match it with the configuration as of in [https://github.com/starfive-tech/u-boot/blob/ac0ac696256abf412826d74ee918dd417e207d7b/board/starfive/visionfive2/starfive_visionfive2.c#L354 starfive-tech/u-boot: board: starfive_visionfive2.c#L354]. Also see: - [https://forum.rvspace.org/t/connecting-to-visionfive-s-jtag-port-a-short-guide/514 visionfive jtag port] - [https://doc-en.rvspace.org/JH7110/Datasheet/JH7110_DS/function_0.html JH7110 GPIO AF]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;      PINE64 STAR64 JTAG&lt;br /&gt;
&lt;br /&gt;
            │33 34│ GND&lt;br /&gt;
GPIO63 TMS  │35 36│ nTRST GPIO36&lt;br /&gt;
GPIO60 TCK  │37 38│ TDI   GPIO61&lt;br /&gt;
       GND  │39 40│ TDO   GPIO44&lt;br /&gt;
            └─────┘&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- RV_DEBUGGER:   TCK TDI TDO TMS --&amp;gt;&lt;br /&gt;
&amp;lt;!-- LOGICANALIZER: TCK TDI TDO TMS --&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;openocd&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
=== Openocd ===&lt;br /&gt;
&lt;br /&gt;
You can use the visionfive2 [https://forum.rvspace.org/t/openocd-config-for-visionfive-2/1452 openocd config].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;mkdir -p openocd/&lt;br /&gt;
nano openocd/starfive-visionfive2.cfg&lt;br /&gt;
openocd -f interface/ftdi/um232h.cfg -f openocd/starfive-visionfive2.cfg&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;boot-failerror-is-0xffffffff&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
=== BOOT fail,Error is 0xffffffff ===&lt;br /&gt;
&lt;br /&gt;
If you get the &amp;lt;code&amp;gt;BOOT fail,Error is 0xffffffff&amp;lt;/code&amp;gt; error just press the reset key again. This error keeps ocurring if powering the star64 on. But pressing reset will make the star64 boot normally.&lt;br /&gt;
&lt;br /&gt;
[[Category:STAR64]]&lt;/div&gt;</summary>
		<author><name>Vitfen</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=User:Vitali/Create_a_bootable_Debian/Linux_SDCard_for_the_Pine64/Star64_from_scratch&amp;diff=19854</id>
		<title>User:Vitali/Create a bootable Debian/Linux SDCard for the Pine64/Star64 from scratch</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=User:Vitali/Create_a_bootable_Debian/Linux_SDCard_for_the_Pine64/Star64_from_scratch&amp;diff=19854"/>
		<updated>2023-06-12T23:08:55Z</updated>

		<summary type="html">&lt;p&gt;Vitfen: Created page with &amp;quot;__TOC__  &amp;lt;span id=&amp;quot;introduction&amp;quot;&amp;gt;&amp;lt;/span&amp;gt; = Introduction =  This guide is for advance users only. In the process we will build every part necessary to boot the star64 until the kernel from &amp;#039;&amp;#039;&amp;#039;source&amp;#039;&amp;#039;&amp;#039;. For people interested to just get the star64 to boot I would recommend to search for a guide using a SDCard image.  This guide is a compilation of mostly already available information but this guide tries to glue all the parts together to make them work. All original...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__TOC__&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;introduction&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
This guide is for advance users only. In the process we will build every part necessary to boot the star64 until the kernel from &amp;#039;&amp;#039;&amp;#039;source&amp;#039;&amp;#039;&amp;#039;. For people interested to just get the star64 to boot I would recommend to search for [[#|a guide using a SDCard image]].&lt;br /&gt;
&lt;br /&gt;
This guide is a compilation of mostly already available information but this guide tries to glue all the parts together to make them work. All original sources are linked for reference.&lt;br /&gt;
&lt;br /&gt;
By following this guide you will compile &amp;lt;code&amp;gt;u-boot/spl&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;u-boot&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;opensbi&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;linux kernel&amp;lt;/code&amp;gt; for the pine64/star64 and create a bootable SDCard by creating and populating the necessary partitions on the SDCard. Finally the precompiled official unstable &amp;lt;code&amp;gt;Debian&amp;lt;/code&amp;gt; riscv64 port will be installed to the rootfs partition on the SDCard. By using &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;systemd-nspawn&amp;lt;/code&amp;gt; we will be able to execute &amp;lt;code&amp;gt;debootstrap&amp;lt;/code&amp;gt; to install a foreign architecture (e.g. install &amp;lt;code&amp;gt;riscv64&amp;lt;/code&amp;gt; while running &amp;lt;code&amp;gt;debootstrap&amp;lt;/code&amp;gt; on a &amp;lt;code&amp;gt;amd64&amp;lt;/code&amp;gt; host). Also minimal configuration of the rootfs is done on the host computer. All commands are documented in a way to be easy repeatable and will produce a ready to boot and configured SDCard image. You can of course modify configurations done on the host to your preference.&lt;br /&gt;
&lt;br /&gt;
In contrast to methods using [[#|&amp;lt;code&amp;gt;buildroot&amp;lt;/code&amp;gt;]] or [[#|&amp;lt;code&amp;gt;yocto&amp;lt;/code&amp;gt;]] this guide is compiling each component separately. And the advantage of using &amp;lt;code&amp;gt;debian&amp;lt;/code&amp;gt; is that you will have access to thousands of precompiled &amp;lt;code&amp;gt;debian&amp;lt;/code&amp;gt; packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;preparation&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Preparation ==&lt;br /&gt;
&lt;br /&gt;
Install &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;systemd-nspawn&amp;lt;/code&amp;gt; and a &amp;lt;code&amp;gt;riscv compiler&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;sudo apt install gcc-riscv64-linux-gnu systemd-container qemu debootstrap pwgen&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Optional: Create .env file with your environment settings. Or Just set them directly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;nano .env&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;# cross compiler&lt;br /&gt;
CROSS_COMPILE=riscv64-linux-gnu-&lt;br /&gt;
# where to store apt cache, for faster installs&lt;br /&gt;
APT_CACHE_DIR=/tmp/apt/cache&lt;br /&gt;
# arbitrary path where the rootfs will be mounted at&lt;br /&gt;
ROOTFS=/tmp/star64/rootfs&lt;br /&gt;
# SDCard dev path&lt;br /&gt;
USBDEV=/dev/sdX&lt;br /&gt;
&lt;br /&gt;
# hostname of the target, can be left empty&lt;br /&gt;
MNAME=&lt;br /&gt;
&lt;br /&gt;
# username you are logged in your host system this name will be also used to create a new user on the newly created rootfs.&lt;br /&gt;
USER=$USER&lt;br /&gt;
test &amp;quot;$USER&amp;quot; = root &amp;amp;&amp;amp; { echo &amp;quot;USER can&amp;#039;t be root&amp;quot;; exit; }&lt;br /&gt;
&lt;br /&gt;
PASSWORD=$(pwgen -1)&lt;br /&gt;
&lt;br /&gt;
AUTHORIZED_KEY=$(ssh-keygen -f /home/$USER/.ssh/id_ed25519 -y)&lt;br /&gt;
&lt;br /&gt;
# define helper functions&lt;br /&gt;
function star64_mount() {&lt;br /&gt;
    mkdir -p ${ROOTFS?}/&lt;br /&gt;
    sudo -E mount ${USBDEV:?}4 ${ROOTFS?}/&lt;br /&gt;
    sudo mkdir -p ${ROOTFS?}/boot&lt;br /&gt;
    sudo -E mount -o umask=0000 ${USBDEV:?}3 ${ROOTFS?}/boot&lt;br /&gt;
}&lt;br /&gt;
function star64_unmount() {&lt;br /&gt;
    sudo umount ${ROOTFS?}/boot&lt;br /&gt;
    sudo umount ${ROOTFS?}/&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;source .env&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;connect-serial-cable&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
=== Connect Serial Cable ===&lt;br /&gt;
&lt;br /&gt;
It is a good idea to first make sure the serial connection is working. Make sure the boot switches are set to boot from UART.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PINE64 STAR64 BOOT UART&lt;br /&gt;
          ┌──┐&lt;br /&gt;
GOIO_0  1 │X │&lt;br /&gt;
GPIO_1  2 │X │&lt;br /&gt;
          └──┘&lt;br /&gt;
        H      L&amp;lt;/pre&amp;gt;&lt;br /&gt;
Connect and monitor the serial port as stated in the [[#serial-uart|Troubleshooting Section: Serial / UART]]. You should see repeatably printing of ‘C’. After making sure the serial works we can change it to SDCard boot mode.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PINE64 STAR64 BOOT SDCARD&lt;br /&gt;
          ┌──┐&lt;br /&gt;
GOIO_0  1 │ X│&lt;br /&gt;
GPIO_1  2 │X │&lt;br /&gt;
          └──┘&lt;br /&gt;
        H      L&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;build&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Build =&lt;br /&gt;
&lt;br /&gt;
Build each of the following projects. Make sure to navigate back into your base project directory (e.g. &amp;lt;code&amp;gt;/tmp/star64&amp;lt;/code&amp;gt;) if you proceed to build the next project. After completing this guide it should at least contain the directories: &amp;lt;code&amp;gt;linux opensbi Tools u-boot&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* [[#build-tools|Build tools]]&lt;br /&gt;
* [[#build-opensbi|Build OpenSBI]]&lt;br /&gt;
* [[#build-u-boot|Build U-Boot]]&lt;br /&gt;
* [[#partition-the-sdcard|Partition the SDCard]]&lt;br /&gt;
* [[#build-the-linux-kernel|Build the Linux kernel]]&lt;br /&gt;
* [[#debootstrap-the-debian-riscv64-rootfs|Debootstrap the Debian riscv64 rootfs]]&lt;br /&gt;
* [[#copy-the-linux-kernel-to-sdcard|Copy the Linux kernel to SDCard]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;build-tools&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Build tools =&lt;br /&gt;
&lt;br /&gt;
Build [https://github.com/starfive-tech/Tools/blob/master/spl_tool/README.md spl_tool].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;git clone --depth 1 https://github.com/starfive-tech/Tools.git&lt;br /&gt;
make -C Tools/spl_tool&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;build-opensbi&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Build OpenSBI =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;git clone --depth 1 https://github.com/riscv/opensbi.git&lt;br /&gt;
cd opensbi&lt;br /&gt;
make CROSS_COMPILE=${CROSS_COMPILE?} PLATFORM=generic FW_TEXT_START=0x40000000 FW_OPTIONS=0 -j&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
For more insight about the u-boot boot process you can find more useful information in the [https://github.com/u-boot/u-boot/blob/master/doc/board/starfive/visionfive2.rst u-boot visionfive2 docs].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;build-u-boot&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Build U-Boot =&lt;br /&gt;
&lt;br /&gt;
Make sure to [[#build-tools|build Tools]] and [[#build-opensbi|openSBI]] before proceeding.&lt;br /&gt;
&lt;br /&gt;
The upsteam u-boot builds the &amp;lt;code&amp;gt;u-boot.itb&amp;lt;/code&amp;gt; automatically by using openSBIs fw_dynamic.bin. But the upstream u-boot does not boot properly (Last checked: 26-05-23)… Therefore we use the fw_payload.bin method with the starfive/u-boot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;git clone --depth 1 -b Star64 https://github.com/Fishwaldo/u-boot.git&lt;br /&gt;
cd u-boot&lt;br /&gt;
&lt;br /&gt;
CROSS_COMPILE=${CROSS_COMPILE?} make pine64_star64_defconfig&lt;br /&gt;
CROSS_COMPILE=${CROSS_COMPILE?} make OPENSBI=../opensbi/build/platform/generic/firmware/fw_dynamic.bin -j&lt;br /&gt;
&lt;br /&gt;
make -C ../opensbi CROSS_COMPILE=${CROSS_COMPILE?} PLATFORM=generic \&lt;br /&gt;
    FW_FDT_PATH=../u-boot/arch/riscv/dts/pine64_star64.dtb \&lt;br /&gt;
    FW_PAYLOAD_FDT_ADDR=0x40080000 \&lt;br /&gt;
    FW_PAYLOAD_OFFSET=0x00100000 \&lt;br /&gt;
    FW_PAYLOAD_PATH=../u-boot/u-boot.bin \&lt;br /&gt;
    FW_TEXT_START=0x40000000&lt;br /&gt;
&lt;br /&gt;
ln -s ../../opensbi/build/platform/generic/firmware/fw_payload.bin ../Tools/uboot_its/&lt;br /&gt;
tools/mkimage -f ../Tools/uboot_its/visionfive2-uboot-fit-image.its -A riscv -O u-boot -T firmware u-boot.itb&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Create a SPL header as stated in [https://github.com/u-boot/u-boot/blob/master/doc/board/starfive/visionfive2.rst u-boot visionfive2 docs] and [https://github.com/starfive-tech/Tools/blob/master/spl_tool/README.md spl_tool]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;../Tools/spl_tool/spl_tool -c -f spl/u-boot-spl.bin&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;update-with-linux&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Update with Linux ==&lt;br /&gt;
&lt;br /&gt;
If you alreay have Linux running on the star64 and want to update &amp;lt;code&amp;gt;u-boot&amp;lt;/code&amp;gt; you can do that like that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;scp u-boot.itb ${MNAME?}:/tmp&lt;br /&gt;
ssh ${MNAME?} sudo dd if=/tmp/u-boot.itb of=/dev/mmcblk1p2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
More infos on the [https://u-boot.readthedocs.io/en/latest/build/gcc.html u-boot build process with gcc]. I strongly recommend to read [https://doc-en.rvspace.org/VisionFive2/Developer_Guide/JH7110_Boot_UG.pdf JH7110Boot User Guide] for more information on the boot process.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;partition-the-sdcard&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Partition the SDCard =&lt;br /&gt;
&lt;br /&gt;
After build [[#build-opensbi|OpenSBI]] and [[#build-u-boot|U-Boot]] from above we can proceed to setup the partitions for the SDCard and write u-boot-spl into the &amp;lt;code&amp;gt;SPL&amp;lt;/code&amp;gt;-partition and u-boot into the &amp;lt;code&amp;gt;UBOOT&amp;lt;/code&amp;gt;-partition.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;# Set the SDCard dev path (content will be lost)&lt;br /&gt;
sudo su # continue with caution!&lt;br /&gt;
source .env&lt;br /&gt;
fdisk -l ${USBDEV:?} # make sure its in fact the right drive&lt;br /&gt;
&lt;br /&gt;
lsblk ${USBDEV:?} -n | grep -q part &amp;amp;&amp;amp; \&lt;br /&gt;
    { echo &amp;quot;delete partitions with &amp;#039;wipefs --all ${USBDEV:?}&amp;#039; first&amp;quot;; exit; }&lt;br /&gt;
&lt;br /&gt;
sfdisk ${USBDEV:?} &amp;lt;&amp;lt;EOF&lt;br /&gt;
label: gpt&lt;br /&gt;
: start=4096, size=2MiB, name=SPL, type=2E54B353-1271-4842-806F-E436D6AF6985&lt;br /&gt;
: size=4MiB, name=UBOOT, type=BC13C2FF-59E6-4262-A352-B275FD6F7172&lt;br /&gt;
: size=512MiB, name=BOOT, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7&lt;br /&gt;
: name=SYSTEM, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
mkfs.vfat -F 32 ${USBDEV:?}3&lt;br /&gt;
mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 ${USBDEV:?}4&lt;br /&gt;
&lt;br /&gt;
# if you install on eMMC: execute:&lt;br /&gt;
# Tools/spl_tool/spl_tool --fix-imghdr -f ${USBDEV:?}&lt;br /&gt;
&lt;br /&gt;
dd if=u-boot/spl/u-boot-spl.bin.normal.out of=${USBDEV:?}1&lt;br /&gt;
dd if=u-boot/u-boot.itb of=${USBDEV:?}2&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
You can find more about the partition layout on [https://doc-en.rvspace.org/VisionFive2/Developer_Guide/JH7110_Boot_UG.pdf JH7110_Boot_UG] Page 8 Table1-3 SD/eMMC Boot Address Allocation and [https://github.com/u-boot/u-boot/blob/master/doc/board/starfive/visionfive2.rst#flashing u-boot/visionfive2: create bootable image: flashing]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;build-the-linux-kernel&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Build the Linux kernel =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;# alternative: https://github.com/starfive-tech/linux/tree/JH7110_VisionFive2_upstream&lt;br /&gt;
git clone --depth 1 -b Star64_devel https://github.com/Fishwaldo/Star64_linux.git linux&lt;br /&gt;
cd linux/&lt;br /&gt;
&lt;br /&gt;
ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} make pine64_star64_defconfig&lt;br /&gt;
&lt;br /&gt;
# if you need any extra symbols for your kernel&lt;br /&gt;
ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} make xconfig&lt;br /&gt;
&lt;br /&gt;
# or by command line&lt;br /&gt;
ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} scripts/config \&lt;br /&gt;
    -m ATA \&lt;br /&gt;
    -m SATA_AHCI \&lt;br /&gt;
    -m ATA_GENERIC&lt;br /&gt;
&lt;br /&gt;
# set new defaults if changed by command line&lt;br /&gt;
ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} make olddefconfig&lt;br /&gt;
&lt;br /&gt;
ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} make -j14&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;copy-the-linux-kernel-to-sdcard&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Copy the Linux kernel to SDCard =&lt;br /&gt;
&lt;br /&gt;
Make sure to [[#build-the-linux-kernel|build the Linux kernel]] and [[#partition-the-sdcard|Partition the SDCard]] before proceeding.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;&lt;br /&gt;
star64_mount&lt;br /&gt;
&lt;br /&gt;
cp -v linux/arch/riscv/boot/Image.gz ${ROOTFS?}/boot&lt;br /&gt;
# cp initramfs.cpio.gz ${ROOTFS?}/boot # don&amp;#039;t have one...&lt;br /&gt;
cp -v linux/arch/riscv/boot/dts/starfive/jh7110-pine64-star64.dtb ${ROOTFS?}/boot&lt;br /&gt;
&lt;br /&gt;
sudo ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} \&lt;br /&gt;
    INSTALL_MOD_PATH=${ROOTFS?}/usr \&lt;br /&gt;
    INSTALL_PATH=${ROOTFS?}/boot \&lt;br /&gt;
    INSTALL_HDR_PATH=${ROOTFS?}/usr \&lt;br /&gt;
    make -C linux install modules_install headers_install&lt;br /&gt;
&lt;br /&gt;
star64_unmount&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;update-with-linux-1&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Update with Linux ==&lt;br /&gt;
&lt;br /&gt;
If you already have Linux running on the star64 and want to update the &amp;lt;code&amp;gt;linux&amp;lt;/code&amp;gt; kernel you can do that like that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;rsync --rsync-path=&amp;#039;sudo rsync&amp;#039; arch/riscv/boot/Image.gz ${MNAME?}:/boot&lt;br /&gt;
sudo ARCH=riscv CROSS_COMPILE=${CROSS_COMPILE?} \&lt;br /&gt;
    INSTALL_MOD_PATH=/tmp/modules \&lt;br /&gt;
    make modules_install&lt;br /&gt;
rsync -rv --rsync-path=&amp;#039;sudo rsync&amp;#039; /tmp/modules/lib/modules/ ${MNAME?}:/lib/modules&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;debootstrap-the-debian-riscv64-rootfs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Debootstrap the Debian riscv64 rootfs =&lt;br /&gt;
&lt;br /&gt;
Make sure to setup [https://de.wikipedia.org/wiki/Binfmt_misc binfmt]. Check if it is available with &amp;lt;code&amp;gt;mount | grep binfmt_misc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cat /proc/sys/fs/binfmt_misc/qemu-riscv64&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Copy and past the &amp;lt;code&amp;gt;star64_install_debian&amp;lt;/code&amp;gt; function into bash and execute it or create a script file from that function. You can also execute them one by one if you prefer.&lt;br /&gt;
&lt;br /&gt;
You can also just run the &amp;lt;code&amp;gt;debootstrap&amp;lt;/code&amp;gt; command and setup Debian on your own. But at least set a root password so you can login over serial.&lt;br /&gt;
&lt;br /&gt;
For reference read [https://wiki.debian.org/RISC-V#debootstrap debootstrap].&lt;br /&gt;
&lt;br /&gt;
Alternatively if you dont want to use &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;systemd-nspawn&amp;lt;/code&amp;gt; you can just follow the [https://forum.pine64.org/showthread.php?tid=18276 Star64: Armbian Installation] guide instead of &amp;lt;code&amp;gt;debootsraping&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;Debian&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;#switch to root&lt;br /&gt;
sudo su&lt;br /&gt;
source .env&lt;br /&gt;
&lt;br /&gt;
function star64_install_debian() {&lt;br /&gt;
MNAME=${MNAME:-&amp;quot;star64-$(pwgen 4 -1 -A)&amp;quot;}&lt;br /&gt;
mkdir -p ${APT_CACHE_DIR:-/tmp/apt/cache}&lt;br /&gt;
&lt;br /&gt;
debootstrap --foreign --cache-dir=/mnt/data/tmp/apt-riscv --arch=riscv64 --no-check-gpg --include=debian-ports-archive-keyring,usrmerge,openssh-server,htop,vim,nano,tcpdump,sudo,curl,wget,iputils-ping,fdisk,gdisk,pciutils,usbutils,screen,rsync,firmware-linux-free unstable ${ROOTFS?} http://deb.debian.org/debian-ports&lt;br /&gt;
cp /usr/bin/qemu-riscv64 ${ROOTFS?}/usr/bin/&lt;br /&gt;
chroot ${ROOTFS?} /debootstrap/debootstrap --second-stage&lt;br /&gt;
&lt;br /&gt;
NSPAWN=&amp;quot;systemd-nspawn -M $MNAME -D ${ROOTFS?} --quiet --no-pager&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# ${NSPAWN?} sed -i &amp;#039;s/main/main non-free/g&amp;#039; /etc/apt/sources.list&lt;br /&gt;
# ${NSPAWN?} apt update&lt;br /&gt;
# ${NSPAWN?} apt install -y firmware-linux-nonfree&lt;br /&gt;
&lt;br /&gt;
PASSWORD=${PASSWORD:-$(pwgen 8 -1 -A)}&lt;br /&gt;
echo &amp;quot;Your root/$USER password is set to $PASSWORD&amp;quot;&lt;br /&gt;
${NSPAWN?} useradd --shell /bin/bash --create-home ${USER:-user}&lt;br /&gt;
${NSPAWN?} sh -c &amp;quot;echo root:$PASSWORD | chpasswd&amp;quot;&lt;br /&gt;
${NSPAWN?} sh -c &amp;quot;echo ${USER:-user}:$PASSWORD | chpasswd&amp;quot;&lt;br /&gt;
echo &amp;quot;$MNAME&amp;quot; &amp;gt; ${ROOTFS?}/etc/hostname&lt;br /&gt;
echo &amp;quot;127.0.0.1 $MNAME&amp;quot; &amp;gt;&amp;gt; ${ROOTFS?}/etc/hosts&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;${USER:-user} ALL=(ALL) NOPASSWD:ALL&amp;quot; &amp;gt; ${ROOTFS?}/etc/sudoers.d/${USER:-user}&lt;br /&gt;
install -o 1000 -g 1000 -d -m 0700 ${ROOTFS?}/home/${USER:-user}/.ssh/&lt;br /&gt;
install -o 1000 -g 1000 -m 0644 &amp;lt;(echo &amp;quot;$AUTHORIZED_KEY&amp;quot;) ${ROOTFS?}/home/${USER:-user}/.ssh/authorized_keys&lt;br /&gt;
&lt;br /&gt;
mkdir -p ${ROOTFS?}/boot&lt;br /&gt;
&lt;br /&gt;
test -b ${USBDEV:-&amp;#039;&amp;#039;} &amp;amp;&amp;amp; {&lt;br /&gt;
echo &amp;quot;PARTUUID=$(blkid ${USBDEV:?}4 --output value | tail -1)        /            ext4     defaults,noatime    0    0&amp;quot; &amp;gt;&amp;gt; ${ROOTFS?}/etc/fstab&lt;br /&gt;
echo &amp;quot;PARTUUID=$(blkid ${USBDEV:?}3 --output value | tail -1)        /boot        vfat     defaults,noatime    0    0&amp;quot; &amp;gt;&amp;gt; ${ROOTFS?}/etc/fstab&lt;br /&gt;
echo &amp;quot;none                                                 /tmp         tmpfs    defaults,noatime    0    0&amp;quot; &amp;gt;&amp;gt; ${ROOTFS?}/etc/fstab&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
${NSPAWN?} sh -c &amp;quot;&lt;br /&gt;
systemctl enable networking&lt;br /&gt;
systemctl enable systemd-networkd.service&lt;br /&gt;
systemctl enable ssh&lt;br /&gt;
&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; ${ROOTFS?}/etc/systemd/network/20-dhcp-all.network &amp;lt;&amp;lt;EOF&lt;br /&gt;
[Match]&lt;br /&gt;
Name=*&lt;br /&gt;
&lt;br /&gt;
[Network]&lt;br /&gt;
DHCP=yes&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;nameserver 1.1.1.1&amp;quot; &amp;gt; ${ROOTFS?}/etc/resolv.conf&lt;br /&gt;
echo &amp;quot;nameserver 8.8.8.8&amp;quot; &amp;gt;&amp;gt; ${ROOTFS?}/etc/resolv.conf&lt;br /&gt;
&lt;br /&gt;
test -d ssh_host &amp;amp;&amp;amp; {&lt;br /&gt;
sudo rsync --chown=root:root -vr ssh_host/etc/ssh/ ${ROOTFS?}/etc/ssh/&lt;br /&gt;
sudo chmod 600 ${ROOTFS?}/etc/ssh/ssh_host_*&lt;br /&gt;
sudo chmod +r ${ROOTFS?}/etc/ssh/ssh_host_*.pub&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
star64_mount&lt;br /&gt;
star64_install_debian&lt;br /&gt;
&lt;br /&gt;
tee ${ROOTFS?}/boot/vf2_uEnv.txt &amp;lt;&amp;lt;&amp;#039;EOF&amp;#039;&lt;br /&gt;
bootargs=console=ttyS0,115200 rootwait earlycon=sbi root=/dev/mmcblk1p4 rw&lt;br /&gt;
distro_bootcmd=fatload mmc 1:3 0x60200000 Image.gz; \&lt;br /&gt;
    fatload mmc 1:3 ${fdt_addr_r} jh7110-pine64-star64.dtb \&lt;br /&gt;
    unzip 0x60200000 ${kernel_addr_r}; \&lt;br /&gt;
    booti ${kernel_addr_r} - ${fdt_addr_r}&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
star64_unmount&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;troubleshooting&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;project-versions-used-last-git-commit-hash&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Project versions used (last git commit hash) ==&lt;br /&gt;
&lt;br /&gt;
* linux: 7943fd6427b0abd25e1af2756e061a112bde8711&lt;br /&gt;
* opensbi: d4c46e0ff1b0ead9d5a586e1a19a00a92160206d&lt;br /&gt;
* Tools: 693661d4ba314424f76c06da1bbb799e9b534c9f&lt;br /&gt;
* u-boot: 172b47f62039605d6806fa96bd403c21cda28996&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;serial-uart&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== Serial / UART ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;       PINE64 STAR64 UART&lt;br /&gt;
&lt;br /&gt;
             ┌─────┐&lt;br /&gt;
       3.3V  │ 1  2│ 5V&lt;br /&gt;
       SDA1  │ 3  4│ 5V&lt;br /&gt;
       SCL1  │ 5  6│ GND&lt;br /&gt;
GPIO55       │ 7  8│ TXD&lt;br /&gt;
       GND   │ 9 10│ RXD&amp;lt;/pre&amp;gt;&lt;br /&gt;
Use &amp;lt;code&amp;gt;screen /dev/ttyUSB0 115200&amp;lt;/code&amp;gt; to monitor serial port.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;jtag&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
== JTAG ==&lt;br /&gt;
&lt;br /&gt;
Connect a JTAG adapter to GPIO [https://files.pine64.org/doc/star64/Star64_Schematic_V1.1_20230504.pdf Star64 schematic] p. 18 J5 and Match it with the configuration as of in [https://github.com/starfive-tech/u-boot/blob/ac0ac696256abf412826d74ee918dd417e207d7b/board/starfive/visionfive2/starfive_visionfive2.c#L354 starfive-tech/u-boot: board: starfive_visionfive2.c#L354]. Also see: - [https://forum.rvspace.org/t/connecting-to-visionfive-s-jtag-port-a-short-guide/514 visionfive jtag port] - [https://doc-en.rvspace.org/JH7110/Datasheet/JH7110_DS/function_0.html JH7110 GPIO AF]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;      PINE64 STAR64 JTAG&lt;br /&gt;
&lt;br /&gt;
            │33 34│ GND&lt;br /&gt;
GPIO63 TMS  │35 36│ nTRST GPIO36&lt;br /&gt;
GPIO60 TCK  │37 38│ TDI   GPIO61&lt;br /&gt;
       GND  │39 40│ TDO   GPIO44&lt;br /&gt;
            └─────┘&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;!-- RV_DEBUGGER:   TCK TDI TDO TMS --&amp;gt;&lt;br /&gt;
&amp;lt;!-- LOGICANALIZER: TCK TDI TDO TMS --&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;openocd&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
=== Openocd ===&lt;br /&gt;
&lt;br /&gt;
You can use the visionfive2 [https://forum.rvspace.org/t/openocd-config-for-visionfive-2/1452 openocd config].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;sh&amp;quot;&amp;gt;mkdir -p openocd/&lt;br /&gt;
nano openocd/starfive-visionfive2.cfg&lt;br /&gt;
openocd -f interface/ftdi/um232h.cfg -f openocd/starfive-visionfive2.cfg&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;span id=&amp;quot;boot-failerror-is-0xffffffff&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
=== BOOT fail,Error is 0xffffffff ===&lt;br /&gt;
&lt;br /&gt;
If you get the &amp;lt;code&amp;gt;BOOT fail,Error is 0xffffffff&amp;lt;/code&amp;gt; error just press the reset key again. This error keeps ocurring if powering the star64 on. But pressing reset will make the star64 boot normally.&lt;/div&gt;</summary>
		<author><name>Vitfen</name></author>
	</entry>
</feed>