Difference between revisions of "User:Nuess0r/SandBox/Install Debian"

From PINE64
Jump to navigation Jump to search
(Initial stub)
 
(Update installer download link)
 
(One intermediate revision by the same user not shown)
Line 52: Line 52:
Next in your home directory (<code>/home/user</code>) create a folder called <code>tftp_share</code>
Next in your home directory (<code>/home/user</code>) create a folder called <code>tftp_share</code>
  $ mkdir /home/user/tftp_share
  $ mkdir /home/user/tftp_share
In this folder, download  the <code>.bin.normal.out</code> SPL file and the <code>.img</code> U-Boot image using <code>wget</code>.  
In this folder, download  the <code>u-boot-spl.bin.normal.out</code> SPL file and the <code>u-boot.itb</code> U-Boot image using <code>wget</code>.  
  $ cd /srv/tftp
  $ cd /srv/tftp
  $ sudo wget <nowiki>https://freeshell.de/e/riscv64/u-boot-20241028-428921_429908_429906_ocloaderase.zip</nowiki>
  $ sudo wget <nowiki>https://freeshell.de/e/riscv64/u-boot-20241028-428921_429908_429906_ocloaderase.zip</nowiki>
  $ sudo unzip <nowiki>u-boot-20241028-428921_429908_429906_ocloaderase.zip</nowiki>
  $ sudo unzip <nowiki>u-boot-20241028-428921_429908_429906_ocloaderase.zip</nowiki>


Before connecting to the Star64 and updating the firmware install minicom, virtual console software, so it will be possible to communicate with the Star64.
Before connecting to the Star64 and updating the firmware install screen, virtual console software, so it will be possible to communicate with the Star64.
  $ sudo apt update && sudo apt install minicom
  $ sudo apt update && sudo apt install screen
Next connect your USB to TTL UART adapter to the computer and list the connected serial devices.  
Next connect your USB to TTL UART adapter to the computer and list the connected serial devices.  


Find the address of the TTL UART to USB adapter in the list (example: <code>ttyUSB0</code>) and connect to the serial device with a baud rate of 115200.  
Find the address of the TTL UART to USB adapter in the list (example: <code>ttyUSB0</code>) and connect to the serial device with a baud rate of 115200.  
  $ sudo minicom -D /dev/<Device Address> -b 115200
  $ screen /dev/<Device Address> 115200
Where <code><Device Address></code> is the address found in the step above. <span class="mw-customtoggle-device-address-toggle" style="text-decoration:underline;color:#0645ad">Example</span>
Where <code><Device Address></code> is the address found in the step above. <span class="mw-customtoggle-device-address-toggle" style="text-decoration:underline;color:#0645ad">Example</span>
<div class="mw-collapsible mw-collapsed" id="mw-customcollapsible-device-address-toggle">
<div class="mw-collapsible mw-collapsed" id="mw-customcollapsible-device-address-toggle">
  $ sudo minicom -D /dev/ttyUSB0 -b 115200
  $ screen /dev/ttyUSB0 115200
</div>
</div>


Line 112: Line 112:
First, initialize the flash with the <code>sf probe</code> command.
First, initialize the flash with the <code>sf probe</code> command.
  # sf probe
  # sf probe
The output should be something like:  
The output should be something like:  
<pre>
<pre>
Line 117: Line 118:
SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
</pre>
</pre>
Next copy the SPL <code>.bin.normal.out</code> file to memory address 0xa0000000 from our TFTP server.
Next copy the SPL <code>.bin.normal.out</code> file to memory address 0xa0000000 from our TFTP server.
  # tftpboot 0xa0000000 ${serverip}:[name of fishwaldo spl file]
  # tftpboot 0xa0000000 ${serverip}:u-boot-spl.bin.normal.out
 
Where ${serverip} is the environment variable we set earlier, no need to change it.  
Where ${serverip} is the environment variable we set earlier, no need to change it.  
Then use <code>sf update</code> to erase and update the SPI flash from memory. In this case we are copying from memory address 0xa0000000 which we wrote to earlier with an offset of 0x0.
Then use <code>sf update</code> to erase and update the SPI flash from memory. In this case we are copying from memory address 0xa0000000 which we wrote to earlier with an offset of 0x0.
Line 125: Line 128:


Next, copy the U-Boot <code>.img</code> binary to memory address 0xa0000000 from the TFTP server.  
Next, copy the U-Boot <code>.img</code> binary to memory address 0xa0000000 from the TFTP server.  
  # tftpboot 0xa0000000 ${serverip}:[name of fishwaldo uboot image]
  # tftpboot 0xa0000000 ${serverip}:u-boot.itb
Where ${serverip} is the environment variable we set earlier, no need to change it.  
Where ${serverip} is the environment variable we set earlier, no need to change it.  


Finally, write the new U-Boot binary using <code>sf update</code> from memory address 0xa0000000 with an offset of 0x100000.  
Finally, write the new U-Boot binary using <code>sf update</code> from memory address 0xa0000000 with an offset of 0x100000.  
  # sf update 0xa0000000 0x100000 $filesize
  # sf update 0xa0000000 0x100000 $filesize


Reboot the Star64 and the changes should have taken effect.
Reboot the Star64 and the changes should have taken effect.
Line 141: Line 143:
===Prepare Debian Installation Media===
===Prepare Debian Installation Media===


https://cdimage.debian.org/cdimage/daily-builds/daily/arch-latest/riscv64/iso-cd/
Download the latest Debian installer for Risc-V targets:
 
https://d-i.debian.org/daily-images/riscv64/daily/netboot/mini.iso


====Linux====
====Linux====
dd if=debian-testing-riscv64-netinst.iso of=/dev/sdX
 
Use [https://github.com/balena-io/etcher Balena Etcha] or <code>dd</code> to write the installer image to your SD card or eMMC drive.
 
$ sudo dd if=mini.iso of=/dev/sdX
 
Where <code>/dev/sdX</code> is the path of your SD card or eMMC drive. Warning: Double check the device name! Otherwise you could accidentally overwrite your system drive!


====Windows====
====Windows====
Use etcher
 
Use [https://github.com/balena-io/etcher Balena Etcha] to write the installer image to your SD card or eMMC drive.


===Boot into Debian Installer===
===Boot into Debian Installer===
[[File:Debian-Grub 20241117 144136.png|300px|thumb|right|Debian installer GRUB menu]]
Insert your SD card or eMMC drive into the Star64 and switch it on. After u-boot is finished you should see a GRUB menu where you can select ''install'' and other entries for more options.


Follow installation
Follow installation

Latest revision as of 21:31, 17 November 2024

Install Debian on Star64

This page or section is under construction

Please help to review and edit this page or section. Information are subject to change.

Warning: Attempting these instructions may permanently brick (make nonfunctional) your device. Do not attempt unless you know what you are doing.
Warning: These instructions have not been tested or verified. Use at your own risk.

This how-to guides you through the process to install Debian SID (unstable) on your Star64.

Prerequisites

Required:

  • Star64 SBC
  • Micro SDcard or Pine64 eMMC module
  • USB serial converter with TTL output (No RS232 converter)
  • Ability to network the Star64 to a computer over ethernet (Switch, Ethernet cables,...)
  • Ability to write Micro SDcards or if you have only the eMMC module you also need the Pine64 eMMC USB programmer
  • Computer running Linux


Update U-Boot and SPL

The Star64 ships with an integrated 128 megabit (16 megabyte) SPI NOR flash. Loaded on this flash from the factory is firmware called U-Boot and SPL but an old version designed for the StarFive VisionFive 2 SBC which is incompatible with the Star64 mainline Linux kernel (>= 6.11). The SPL (Secondary Program Loader) is the software that loads U-Boot, which in turn loads the Linux kernel. It performs similar functions to the BIOS on x86 platforms.

There are two main ways to update the SPI flash. The first uses the flashcp command which requires the Star64 to first boot into an OS. This method requires an OS able to boot from the old u-boot like Pinix from fishwaldo but unfortunately it doesn't ship with flashcp. The other method requires only the ability to load U-Boot and uses TFTP and the U-Boot tftpboot command.

Preparing The TFTP Server and UART Connection

Linux

First, on your computer (not the Star64) install a TFTP server and wget if you do not already have it.

$ sudo apt update && sudo apt install tftpd-hpa wget

Next, check that the TFPT server is running using systemctl.

$ sudo systemctl status tftpd-hpa

This should output somethng like

 tftpd-hpa.service - LSB: HPA's tftp server
     Loaded: loaded (/etc/init.d/tftpd-hpa; generated)
     Active: active (running) since Sat 2023-06-10 20:51:28 CDT; 17min ago
       Docs: man:systemd-sysv-generator(8)
    Process: 1016 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=0/SUCCESS)
      Tasks: 1 (limit: 2306)
     Memory: 588.0K
        CPU: 23ms
     CGroup: /system.slice/tftpd-hpa.service
            └─1023 /usr/sbin/in.tftpd --listen --user tftp --address :69 --secure /srv/tftp

Jun 10 20:51:28 debian-bookworm systemd[1]: Starting tftpd-hpa.service - LSB: HPA's tftp server...
Jun 10 20:51:28 debian-bookworm tftpd-hpa[1016]: Starting HPA's tftpd: in.tftpd.
Jun 10 20:51:28 debian-bookworm systemd[1]: Started tftpd-hpa.service - LSB: HPA's tftp server.           

If the service is not running, try

$ sudo systemctl start tftpd-hpa

and check the status again. If it is still not running please join the #star64 channel in the Pine64 IRC, Discord, or Matrix.


Next in your home directory (/home/user) create a folder called tftp_share

$ mkdir /home/user/tftp_share

In this folder, download the u-boot-spl.bin.normal.out SPL file and the u-boot.itb U-Boot image using wget.

$ cd /srv/tftp
$ sudo wget https://freeshell.de/e/riscv64/u-boot-20241028-428921_429908_429906_ocloaderase.zip
$ sudo unzip u-boot-20241028-428921_429908_429906_ocloaderase.zip

Before connecting to the Star64 and updating the firmware install screen, virtual console software, so it will be possible to communicate with the Star64.

$ sudo apt update && sudo apt install screen 

Next connect your USB to TTL UART adapter to the computer and list the connected serial devices.

Find the address of the TTL UART to USB adapter in the list (example: ttyUSB0) and connect to the serial device with a baud rate of 115200.

$ screen /dev/<Device Address> 115200

Where <Device Address> is the address found in the step above. Example

$ screen /dev/ttyUSB0 115200

Windows

First, install two pieces of software, tftpd64, a TFTP server for windows, and Tera Term, a virtual console for interacting with the Star64 in U-Boot. Next on your desktop, create a folder called tftp_share In this folder, place the the u-boot-spl.bin.normal.out SPL file and the u-boot.itb U-Boot image from [u-boot-20241028-428921_429908_429906_ocloaderase.zip this Zip file].

Next, load tftpd64 and configure the settings to have the "Current Directory" as the tftp_share folder on the desktop and "Server interfaces" is set to 127.0.0.1 Software Loopback Interface 1. The path should look something like C:\Users\${Username}\Desktop\tftp_share where ${Username} is your username on Windows.

Star64 tftpd64 settings.png

TODO: Short intro how to use Putty.

Updating the SPI Flash

Serial pins on the STAR64 I/O connector

Next, connect a TTL UART to USB cable to to the Star64 with the GND cable on pin 6 of the GPIO header, TXD on pin 8, and RXD on pin 10 as well as Ethernet. Note that depending on your UART adapter you may have to switch TXD and RXD. Now power on the Star64 and enter U-Boot. You will need to press a key to prevent it from autobooting and instead enter the U-Boot command prompt. Once you are in the U-Boot shell set some environment variables. First, set the IP address of the Star64 and connect it to the network using the dhcp command.

# dhcp 

Set an environment variable of the TFTP server to make future command easier. If you don't what the IP address of your TFTP server is you can see connected devices in your router's configuration which can usually be accessed by typing in the IP address found on the router itself.

# setenv serverip <server IP>

Where server IP is the IP address of the TFTP server. Example

# setenv serverip 192.168.1.199

Ping the TFTP server from the Star64 to make sure the connection works where <Server IP> refers to the IP address of your TFTP server. Note that if you are hosting the TFTP server on Windows, you may need to configure Windows firewall to allow ‘File and Printer Sharing (Echo Request – ICMPv4 – In)’. This is only needed to test the network connection with ping and not for the actual tftpboot command so if ping fails tftpboot may still succeed.

# ping <server IP>

Example

# ping 192.168.1.199

The result should look something like this:

Star64 # ping 192.168.1.199
Using ethernet@16030000 device
host 192.168.1.199 is alive

If ping fails, please try again or please join the #star64 channel in the Pine64 IRC, Discord, or Matrix for help.

Finally, it is time to update the xSPI flash.

First, initialize the flash with the sf probe command.

# sf probe

The output should be something like:

Star64 # sf probe
SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB

Next copy the SPL .bin.normal.out file to memory address 0xa0000000 from our TFTP server.

# tftpboot 0xa0000000 ${serverip}:u-boot-spl.bin.normal.out

Where ${serverip} is the environment variable we set earlier, no need to change it. Then use sf update to erase and update the SPI flash from memory. In this case we are copying from memory address 0xa0000000 which we wrote to earlier with an offset of 0x0.

# sf update 0xa0000000 0x0 $filesize

Next, copy the U-Boot .img binary to memory address 0xa0000000 from the TFTP server.

# tftpboot 0xa0000000 ${serverip}:u-boot.itb

Where ${serverip} is the environment variable we set earlier, no need to change it.

Finally, write the new U-Boot binary using sf update from memory address 0xa0000000 with an offset of 0x100000.

# sf update 0xa0000000 0x100000 $filesize

Reboot the Star64 and the changes should have taken effect.

On your Linux host, disable the TFTP server again, when you don't need it anymore:

$ sudo systemctl disable tftpd-hpa

Install Debian

Prepare Debian Installation Media

Download the latest Debian installer for Risc-V targets:

https://d-i.debian.org/daily-images/riscv64/daily/netboot/mini.iso

Linux

Use Balena Etcha or dd to write the installer image to your SD card or eMMC drive.

$ sudo dd if=mini.iso of=/dev/sdX

Where /dev/sdX is the path of your SD card or eMMC drive. Warning: Double check the device name! Otherwise you could accidentally overwrite your system drive!

Windows

Use Balena Etcha to write the installer image to your SD card or eMMC drive.

Boot into Debian Installer

Debian installer GRUB menu

Insert your SD card or eMMC drive into the Star64 and switch it on. After u-boot is finished you should see a GRUB menu where you can select install and other entries for more options.


Follow installation

In the tasks selection, enable SSH server

TODO: Notes on partitioning, how to use eMMC when installer is on eMMC.

Final Steps

Finish the installation" step of installer to ^a^n change 'screen' window over to command prompt in debian-installer and

$ cp -rT /target/lib/linux-image-*-riscv64 /target/boot/efi/dtb