Skip to content

12. Frequently Asked Questions | 常见问题

ophub edited this page Dec 7, 2023 · 2 revisions

Here's a compilation of some common issues you may encounter while using Armbian.

12.1 dtb and u-boot Correspondence Table for Each Box

The supported TV box list is located in the /etc/model_database.conf configuration file in the Armbian system.

12.2 Instructions for LED Screen Display Control

Please refer to the instructions.

12.3 How to Restore the Original Android TV System

The Android TV system on the device is usually backed up and restored using armbian-ddbr.

In addition, the Android system can also be flashed into eMMC using the method of flashing via a cable. The download image of the Android system can be found in Tools.

12.3.1 Backup and Restore Using Armbian-ddbr

We recommend that before you install the Armbian system on a brand new box, you first backup the original Android TV system that came with the box. This is in case you need to restore the system later. Boot the Armbian system from TF/SD/USB, input the armbian-ddbr command, and then enter b when prompted to back up the system. The backup file is stored in /ddbr/BACKUP-arm-64-emmc.img.gz, please download and save it. To restore the Android TV system, upload the backup file to the same path on the TF/SD/USB device, enter the armbian-ddbr command, and then enter r when prompted to restore the system.

12.3.2 Recovering using Amlogic Flashing Tool

  • Generally, if you can boot from USB by reinserting the power supply, you can just reinstall. Try it multiple times if necessary.

  • If the screen is black after connecting to a monitor and you can't boot from USB, you'll need to short-circuit initialize the box. First, restore the box to the original Android system, and then reinstall the Armbian system. Download the amlogic_usb_burning_tool recovery tool and install it. Prepare a USB double male data cable and a paperclip.

  • Taking x96max+ as an example, confirm the location of the short-circuit point on the box's motherboard, and download the box's Android TV system package. Android TV systems and corresponding short-circuit point diagrams for other common devices can also be downloaded and viewed here.

Operating method:

1. Open USB Burning Tool:
   [ File → Import image ]: X96Max_Plus2_20191213-1457_ATV9_davietPDA_v1.5.img
   [ Select ]:Erase Flash
   [ Select ]:Erase bootloader
   Click on the [ Start ] button
2. Use the [ paperclip ] to short-circuit the [ two short-circuit points ] on the box's motherboard,
   and at the same time use the [ USB double male data cable ] to connect the [ box ] with the [ computer ].
3. When you see the [ progress bar starts moving ], remove the paperclip, no longer short-circuit.
4. When you see [ progress bar at 100% ], the flashing is complete, the box has been restored to the Android TV system.
   Click on the [ Stop ] button, unplug the [ USB double male data cable ] between the [ box ] and [ computer ].
5. If any of the above steps fail, try again until successful.
   If the progress bar does not move, you can try plugging in the power supply. Normally, you don't need power support for flashing, only the power supply from the USB double male can meet the requirements.

Once you've finished restoring factory settings, the box has been restored to the Android TV system, and the other steps to install the Armbian system are the same as when you first installed the system, just repeat them.

12.4 Setting the box to boot from USB/TF/SD

Based on the situation of your own device, there are two methods to use: initial installation and reinstallation of the Armbian system.

12.4.1 Initial Installation of Armbian System

  • Insert the USB/TF/SD with the installed system into the box.
  • Enable developer mode: Settings → About device → Version number (e.g., X96max plus...), rapidly click the left mouse button 5 times on the version number, until the system shows the prompt You are now a developer.
  • Enable USB debugging: System → Advanced options → Developer options (set USB debugging to enabled). Enable ADB debugging.
  • Install ADB tool: Download adb and extract it, copy the three files adb.exe, AdbWinApi.dll, AdbWinUsbApi.dll to the system32 and syswow64 folders under c://windows/, then open the cmd command panel, use the adb --version command, if it shows, it means it can be used.
  • Enter cmd command mode. Enter the adb connect 192.168.1.137 command (modify the IP according to your box, you can check it in the router device that the box is connected to), if the connection is successful, it will display connected to 192.168.1.137:5555
  • Enter the adb shell reboot update command, the box will reboot and boot from your inserted USB/TF/SD, you can enter the system by accessing the system's IP address from the browser, or via SSH.

12.4.2 Reinstallation of Armbian System

  • In normal situations, you can directly insert the USB flash drive with Armbian installed and boot from it. USB booting takes priority over eMMC.
  • In some cases, the device may not boot from the USB flash drive. In such cases, you can rename the boot.scr file in the /boot directory of the Armbian system on the eMMC. For example, you can rename it to boot.scr.bak. After that, you can insert the USB flash drive and boot from it. This way, you will be able to boot from the USB flash drive.

12.5 Disable Infrared Receiver

By default, support for the infrared receiver is enabled, but if you are using your TV box as a server, you might want to disable the IR kernel module to prevent it from mistakenly turning off your box. To completely disable IR, add the following line:

blacklist meson_ir

to /etc/modprobe.d/blacklist.conf and restart.

12.6 Boot file selection

  • Currently known devices, only T95(s905x) / T95Z-Plus(s912) / BesTV-R3300L(s905l-b) and a few other devices need to use the /bootfs/extlinux/extlinux.conf file, which has been added by default in the system. If other devices need it, you can write the system into USB, double-click to open the boot partition, and delete the .bak in the system's built-in /boot/extlinux/extlinux.conf.bak file name to use. When writing to eMMC, armbian-install will automatically check. If the extlinux.conf file exists, it will be created automatically.

  • Other devices only need /boot/uEnv.txt to boot, do not modify the extlinux.conf.bak file.

12.7 Network Configuration

12.7.1 Network Configuration Using Interfaces

The default content of the network configuration file /etc/network/interfaces is as follows:

source /etc/network/interfaces.d/*
# Network is managed by Network manager
auto lo
iface lo inet loopback
12.7.1.1 IP Address Assignment via DHCP
source /etc/network/interfaces.d/*

auto eth0
iface eth0 inet dhcp
12.7.1.2 Manual Setup of Static IP Address

Modify the IP, gateway, and DNS according to your network condition.

source /etc/network/interfaces.d/*

auto eth0
allow-hotplug eth0
iface eth0 inet static
hwaddress ether 12:34:56:78:9A:DA
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
12.7.1.3 Establish Interconnected Network Using OpenWrt in Docker

Modify the MAC address according to your needs.

source /etc/network/interfaces.d/*

allow-hotplug eth0
no-auto-down eth0
auto eth0
iface eth0 inet manual

auto macvlan
iface macvlan inet dhcp
        pre-up ip link add macvlan link eth0 type macvlan mode bridge
        post-down ip link del macvlan link eth0 type macvlan mode bridge

auto lo
iface lo inet loopback

12.7.2 Network Management Using NetworkManager

12.7.2.1 Create a New Network Connection

Preparation work before creating or modifying a network connection.

12.7.2.1.1 Get Network Interface Name

Check which network interfaces are available for establishing network connections.

nmcli device | grep -E "^[e].*|^[w].*|^[D].*|^[T].*" | awk '{printf "%-19s%-19s\n",$1,$2}'

The DEVICE column displays the network interface name, and the TYPE column displays the network interface type.

Where eth0 = the name of the first Ethernet card, eth1 = the name of the second Ethernet card, and so on. The same goes for wireless cards.

DEVICE             TYPE
eth0               ethernet
eth1               ethernet
eth2               ethernet
eth3               ethernet
wlan0              wifi
wlan1              wifi
12.7.2.1.2 Get Existing Network Connection Name

Check existing network connections on the device, including used and unused connections. When creating a new network connection, it is recommended not to use existing connection names.

nmcli connection show | grep -E ".*|^[N].*" | awk '{printf "%-19s%-19s\n", $1,$3}'

The NAME column displays the name of the existing network connection, and the TYPE column displays the network interface type.

Where ethernet = Ethernet card, wifi = wireless card, bridge = bridge

NAME               TYPE
cnc                ethernet
lan                ethernet
lte                ethernet
tel                ethernet
docker0            bridge
titanium           wifi
cpe                wifi
12.7.2.1.3 Create a Wired Network Connection

Create a new network connection on network interface eth0 and make it effective immediately (Dynamic IP Address - IPv4 / IPv6).

# Set ENV
MYCON=ether1                  # New network connection name
MYETH=eth0                    # Network interface name = eth0 / eth1 / eht2 / eth3
IPV6AGM=stable-privacy        # IPv6 address status mode = stable-privacy / eui64

# Add ETH
nmcli connection add \
con-name $MYCON \
type ethernet \
ifname $MYETH \
autoconnect yes \
ipv6.addr-gen-mode $IPV6AGM
nmcli connection up $MYCON
ip -c -br address

Create a new network connection on network interface eth0 and make it effective immediately (Static IP Address - IPv4).

# Set ENV
MYCON=ether1                  # Network connection name
MYETH=eth0                    # Network interface name = eth0 / eth1 / eht2 / eth3
IP=192.168.67.167/24          # HOST IP address, where 24 is the subnet mask corresponding to 255.255.255.0
GW=192.168.67.1               # Gateway
DNS=119.29.29.29,223.5.5.5    # DNS server address

# Chg CON
nmcli connection add \
con-name $MYCON \
type ethernet \
ifname $MYETH \
autoconnect yes \
ipv4.method manual \
ipv4.addresses $IP \
ipv4.gateway $GW \
ipv4.dns $DNS
nmcli connection up $MYCON
ip -c -br address
12.7.2.1.4 Creating a Wireless Network Connection

Create a network connection on the wlan0 network interface and take effect immediately (Dynamic IP address - IPv4 / IPv6).

# Set ENV
MYCON=ssid                    # Name of the new network connection, it is recommended to use WiFi SSID to specify the connection name
MYSSID=ssid                   # WiFi SSID, case sensitive
MYPSWD=passwd                 # WiFi password
MYWSKM=wpa-psk                # Security selection WPA-WPA2 = wpa-psk or WPA3 = sae (see which encryption method is in the wireless router or AP)
MYWLAN=wlan0                  # Network interface name = wlan0 / wlan1
IPV6AGM=stable-privacy        # IPv6 address status mode = stable-privacy / eui64

# Add WLAN
nmcli connection add \
con-name $MYCON \
type wifi \
ifname $MYWLAN \
autoconnect yes \
ipv6.addr-gen-mode $IPV6AGM \
wifi.ssid $MYSSID \
wifi-sec.key-mgmt $MYWSKM \
wifi-sec.psk $MYPSWD
nmcli connection up $MYCON
ip -c -br address
12.7.2.2 Modify WiFi SSID or PASSWD in Wireless Network Connection

Modify the WiFi SSID or PASSWD in the wireless network connection ssid and take effect immediately.

# Set ENV
MYCON=ssid                    # Wireless network connection name
MYSSID=ssid                   # WiFi SSID, case sensitive
MYPSWD=passwd                 # WiFi password
MYWSKM=wpa-psk                # Security selection WPA-WPA2 = wpa-psk or WPA3 = sae

# Add WLAN
nmcli connection modify $MYCON \
wifi.ssid $MYSSID \
wifi-sec.key-mgmt $MYWSKM \
wifi-sec.psk $MYPSWD
nmcli connection up $MYCON
ip -c -br address
12.7.2.3 Modify Network Address Allocation Method
12.7.2.3.1 Static IP address - IPv4

Modify the IP address allocation method to Static IP address on the network connection ether1 and take effect immediately.

*Applicable to wired connections / wireless connections

# Set ENV
MYCON=ether1                  # Network connection name
IP=192.168.67.167/24          # HOST IP address, where 24 is the subnet mask corresponding to 255.255.255.0
GW=192.168.67.1               # Gateway
DNS=119.29.29.29,223.5.5.5    # DNS server address

# Chg CON
nmcli connection modify $MYCON \
ipv4.method manual \
ipv4.addresses $IP \
ipv4.gateway $GW \
ipv4.dns $DNS
nmcli connection up $MYCON
ip -c -br address
12.7.2.3.2 DHCP Obtains Dynamic IP Address - IPv4 / IPv6

Modify the IP address allocation method to DHCP Obtains Dynamic IP Address on the network connection ether1 and take effect immediately.

*Applicable to wired connections / wireless connections

# Set ENV
MYCON=ether1                  # Network connection name

# Chg CON
nmcli connection modify $MYCON \
ipv4.method auto \
ipv6.method auto
nmcli connection up $MYCON
ip -c -br address
12.7.2.4 Modify Network Connection MAC Address

Modify (clone) the MAC Address on the network connection ether1 and take effect immediately to solve the problem of LAN MAC address conflict.

*Applicable to wired connections / wireless connections

# Set ENV
MYCON=ether1                  # Network connection name, note to match the network interface type
MYTYPE=ethernet               # Network interface type = Wired network card / Wireless network card = ethernet / wifi
MYMAC=12:34:56:78:9A:BC       # New MAC address

# Chg CON
nmcli connection modify ${MYCON} \
${MYTYPE}.cloned-mac-address ${MYMAC}
nmcli connection up ${MYETH}
ip -c -br address
  • When creating or modifying some network parameters, the network connection may be disconnected and reconnected to the network.
  • Due to different software and hardware environments (box, system, network equipment, etc.), it takes about 1-15 seconds to take effect. If it does not take effect for a longer time, it is recommended to check the software and hardware environment.
12.7.2.5 How to Disable IPv6

You can use the nmcli utility to disable the IPv6 protocol from the command line. Please refer to disable-ipv6 for the source.

Step 1, use the nmcli connection show command to view the network connection list, and the returned result is as follows:

NAME                 UUID                                   TYPE       DEVICE
Wired connection 1   8a7e0151-9c66-4e6f-89ee-65bb2d64d366   ethernet   eth0
...

Step 2, set the ipv6.method parameter of the connection to disabled:

nmcli connection modify "Wired connection 1" ipv6.method "disabled"

Step 3, reconnect to the network:

nmcli connection up "Wired connection 1"

Step 4, check the network connection status. If there is no inet6 entry displayed, IPv6 is disabled on the device:

ip address show eth0

Step 5, verify whether the /proc/sys/net/ipv6/conf/eth0/disable_ipv6 file now contains the value 1

# cat /proc/sys/net/ipv6/conf/eth0/disable_ipv6
1

12.7.3 How to Enable Wireless

Some devices support using wireless, the enablement method is as follows:

# Install management tool
sudo apt-get install network-manager

# Check network devices
sudo nmcli dev

# Enable wireless
sudo nmcli r wifi on

# Scan wireless
sudo nmcli dev wifi

# Connect to wireless
sudo nmcli dev wifi connect "wifi name" password "wifi password"

# Display the saved network connection list
sudo nmcli connection show

# Disconnect
sudo nmcli connection down "wifi name"

# Forget the connection and cancel automatic connection
sudo nmcli connection delete "wifi name"
image

12.7.4 How to Enable Bluetooth

Some devices support using Bluetooth, the enablement method is as follows:

# Install Bluetooth support
armbian-config >> Network >> BT: Install Bluetooth support

# Reboot the system
reboot

After the system reboots, check whether the Bluetooth driver is normal. The desktop system can connect Bluetooth devices from the menu. It can also be installed using the terminal graphical interface.

dmesg | grep Bluetooth
image
image
# Connect Bluetooth device
armbian-config >> Network >> BT: Discover and connect Bluetooth devices

You can also install it using commands in the terminal:

# Check the Bluetooth service running status
sudo systemctl status bluetooth

# If not started, start the Bluetooth service first
sudo systemctl enable bluetooth
sudo systemctl start bluetooth

# Scan nearby Bluetooth devices
bluetoothctl scan on

# Enable Bluetooth discovery
bluetoothctl discoverable on

# Pair the Bluetooth MAC address
bluetoothctl pair 12:34:56:78:90:AB

# Check the paired Bluetooth devices
blluetoothctl paired-devices

# Connect to the Bluetooth device
bluetoothctl connect 12:34:56:78:90:AB

# Trust the device for easy connection next time
bluetoothctl trust 12:34:56:78:90:AB

# Disconnect the Bluetooth device
bluetoothctl disconnect 12:34:56:78:90:AB

# Unpair the Bluetooth device
bluetoothctl remove 12:34:56:78:90:AB

# Block the connected device
bluetoothctl block 12:34:56:78:90:AB

12.8 How to Add Startup Tasks

A custom script for startup tasks has already been added to the system. In the Armbian system, the path is /etc/custom_service/start_service.sh. You can customize and add related tasks to this script according to your personal needs.

12.9 How to Update Service Scripts in the System

By using the armbian-sync command, you can update all service scripts in the local system to the latest version with one click.

12.10 How to Get Android System Partition Information on eMMC

When we write the Armbian system into the eMMC system, we need to first confirm the Android system partition table of the device to ensure that data is written to a safe area. Try not to damage the Android system partition table to avoid problems such as the system not being able to start. If you write to an unsafe area, it may fail to start or display an error similar to the one below:

image

12.10.1 Obtaining Partition Information

If you are using Armbian released in this repository after 2022.11, you can copy and paste the following command to obtain a URL that records the complete partition information (the device itself does not need to be connected to the internet):

ampart /dev/mmcblk2 --mode webreport 2>/dev/null

The webreport mode of ampart was introduced in the v1.2 version released on 2023.02.03. If there is no output when you use the above command, it may be an older version that does not support directly outputting URLs. You can instead use the following command:

echo "https://7ji.github.io/ampart-web-reporter/?dsnapshot=$(ampart /dev/mmcblk2 --mode dsnapshot 2>/dev/null | head -n 1)&esnapshot=$(ampart /dev/mmcblk2 --mode esnapshot 2>/dev/null | head -n 1)"

The URL you obtain will look similar to the one below:

https://7ji.github.io/ampart-web-reporter/?esnapshot=bootloader:0:4194304:0%20reserved:37748736:67108864:0%20cache:113246208:754974720:2%20env:876609536:8388608:0%20logo:893386752:33554432:1%20recovery:935329792:33554432:1%20rsv:977272832:8388608:1%20tee:994050048:8388608:1%20crypt:1010827264:33554432:1%20misc:1052770304:33554432:1%20instaboot:1094713344:536870912:1%20boot:1639972864:33554432:1%20system:1681915904:1073741824:1%20params:2764046336:67108864:2%20bootfiles:2839543808:754974720:2%20data:3602907136:4131389440:4&dsnapshot=logo::33554432:1%20recovery::33554432:1%20rsv::8388608:1%20tee::8388608:1%20crypt::33554432:1%20misc::33554432:1%20instaboot::536870912:1%20boot::33554432:1%20system::1073741824:1%20cache::536870912:2%20params::67108864:2%20data::-1:4

Copy and paste this URL into your browser to view the clear and concise DTB partition information and eMMC partition information:

image image

12.10.2 Sharing Partition Information

When you need to share partition information with others (for example, posting to this repository to report on a new device, or seeking help from others), try to share the URL itself rather than a screenshot. If you mind the URL being too long, you can use some free short URL tools.

  • On the one hand, the partition information on the webpage is dynamically generated each time you visit. The annotation of whether certain partitions can be written to and the format of the table may be updated.
  • On the other hand, others cannot conveniently copy partition parameters from screenshots for calculations, etc.

Also, you don't need to manually organize parameters into a table file. The layout of the table on the webpage has been specifically designed to be easily copied and pasted into Excel or LibreOffice Calc.

12.10.3 Interpreting Partition Information

The DTB table records the partition layout that every box's system hopes for in Android DTB. This layout usually ends with a data partition of automatically filled size, so boxes of the same system (and therefore, the same model) will necessarily have the same layout here. The actual partition layout on the box may vary due to different eMMC capacities, but it is always determined by the DTB partition layout (i.e., given the DTB partition layout and the exact size of eMMC, the eMMC partition situation can be deduced. Did you notice that the above DTB partition information and eMMC partition information do not come from the same box?).

The eMMC table is the actual eMMC partition layout on the box. Each row represents a storage area, which could be a partition or a gap between partitions (due to Amlogic's quirky decision, there is at least an 8M gap between each partition, which was intended to be used for other purposes, but hasn't been used even in the latest S905X4, wasting space). In the row corresponding to a partition, the font is black, and both the offset and mask columns have values. In the row corresponding to a gap, the font is grey, the offset and mask columns have no values, and the partition name is gap.

In the eMMC table, the last column of each storage area indicates whether it can be written to. Green and yes mean the area can be written to, red and no mean the area absolutely cannot be written to, and yellow with a label indicates it can be written to under certain prerequisites, or only part of it can be written to.

Using the above table as an example, the 0+4M (0M~4M) area corresponding to the bootloader partition absolutely cannot be written to, the 32M gap (4M~36M) after it can be written to, the 36M+64M (36M~100M) area corresponding to the reserved partition absolutely cannot be written to, the gap from there to the gap before env (100M~836M) can all be written to, the 1M after env (837M to the end) can be written to in case the Android boot logo is not needed, then the writable range on eMMC is:

  • 4M~36M
  • 100M~836M
  • 837M~end

If the Android boot logo is needed, additionally, the 852M + 32M (852M~884M) area corresponding to the logo partition cannot be written to, then the writable range on eMMC is:

  • 4M~36M
  • 100M~836M
  • 837M~852M
  • 884M~end

12.10.4 For eMMC Installation

If your device fails when using armbian-install and the -a parameter (use ampart to adjust the eMMC partition layout) is yes (default value), then your box cannot use the optimal layout (that is, adjust the DTB partition information to only have data, then generate eMMC partition information from this, and then move all remaining partitions forward. In this way, the space from 117M onwards can be used). You need to modify the corresponding partition information in armbian-install.

In this file, the key parameters for declaring the partition layout are three: BLANK1, BOOT, BLANK2. Among them, BLANK1 represents the unusable size starting from the beginning of eMMC; BOOT represents the size of the partition created after BLANK1 for storing the kernel, DTB, etc., preferably not less than 256M, BLANK2 represents the unusable size after BOOT. The space after this will be used to create the ROOT partition to store all the data outside the /boot mount point in the system. All three should be integers, and the unit is MiB (1 MiB = 1024 KiB = 1024^2 Byte)

In the case discussed in the previous paragraph where the logo partition is not needed, we naturally hope to use all the usable space, but the area of 4M~36M is too small to be used as BOOT, so it can only be counted in the unusable BLANK1. The area of 100M~836M is more than enough to be used as BOOT, so this 736M can be allocated to BOOT entirely. After this, there is an unusable area of 836M~837M, which is given to BLANK2, so the parameters to be used should be as follows (only s905x3 is used as an example in the following text, if your SoC is other, you need to modify other corresponding code blocks):

# Set partition size (Unit: MiB)
elif [[ "${AMLOGIC_SOC}" == "s905x3" ]]; then
    BLANK1="100"
    BOOT="736"
    BLANK2="1"

12.11 How to build the u-boot file

The u-boot file is a crucial component for the proper startup of the system. The process of obtaining source code and the compilation workflow varies slightly for Amlogic, Allwinner, and Rockchip devices.

12.11.1 How to build the u-boot file for Amlogic devices

Due to the fact that most manufacturers of Amlogic devices keep their source code closed, we need to extract u-boot related files from the device before proceeding with compilation. The method presented here is derived from the production tutorial shared by unifreq.

12.11.1.1 How to extract the bootloader and dtb files

Extraction requires the HxD software. You can get the installation from the official download link or the backup download link.

Execute the following commands one by one in the cmd panel to extract the relevant files and download them to your local computer.

# Use adb tool to enter the box
adb connect 192.168.1.111
adb shell

# Export bootloader command
dd if=/dev/block/bootloader of=/data/local/bootloader.bin

# Export dtb command
cat /dev/dtb >/data/local/mybox.dtb

# Export gpio command
cat /sys/kernel/debug/gpio >/data/local/mybox_gpio.txt

# Download the bootloader, dtb, and gpio files to the root directory of the C drive on your local computer in the mybox folder
adb pull /data/local/bootloader.bin C:\mybox
adb pull /data/local/mybox.dtb C:\mybox
adb pull /data/local/mybox_gpio.txt C:\mybox
12.11.1.2 How to create the acs.bin file

The most important part of the mainline u-boot is the acs.bin, which is used to initialize part of the memory. The original factory u-boot is located at the very front of the system, at a 4MB position. Use the bootloader.bin file obtained just now to extract the acs.bin file.

Open the HxD software, open the exported bootloader.bin file, Right click - Select range, start position F200, length 1000, select hexadecimal.

image

Copy the selected result, then create a new file, paste in insert mode, ignore the warning, and save it as the acs.bin file.

image image image

If the bootloader is locked, the code in this area is garbled and useless. Normally, there should be many 0s as in the picture above, cfg will appear several times in succession, and ddr related words will appear in the middle. This normal code can be used.

12.11.1.3 How to build the u-boot file

Creating u-boot requires source repositories https://github.com/unifreq/amlogic-boot-fip and https://github.com/unifreq/u-boot to compile two u-boot files for your device.

Within the amlogic-boot-fip source code, the only file that varies by device model is acs.bin, all other files are universal.

image

For instructions on creating u-boot, see the specific instructions in https://github.com/unifreq/u-boot/tree/master/doc/board/amlogic, and choose your device model for compiling and testing.

Creating u-boot according to unifreq's method requires the use of the device's acs.bin, dts, and config files. The dts exported from the Android system cannot be directly converted into the Armbian format, so you need to write a corresponding dts file yourself. Based on the specific differences in hardware on your device, such as switches, LEDs, power control, TF card, SDIO wifi module, etc., modify and create a dts file from the similar ones in the kernel source repository.

For example, creating a u-boot for X96Max Plus:

~/make-uboot
    ├── amlogic-boot-fip
    │   ├── x96max-plus                                     # Create directory yourself
    │   │   ├── asc.bin                                     # Self-made source file
    │   │   └── other-copy-files...                         # Copy files from other directories
    │   │
    │   ├── other-source-directories...
    │   └── other-source-files...
    │
    └── u-boot
        ├── configs
        │   └── x96max-plus_defconfig                       # Self-made source file
        ├── arch
        │   └── arm
        │       └── dts
        │           ├── meson-sm1-x96-max-plus-u-boot.dtsi  # Self-made source file
        │           ├── meson-sm1-x96-max-plus.dts          # Self-made source file
        │           └── Makefile                            # Edit
        ├── fip
        │   ├── u-boot.bin                                  # Generated file
        │   └── u-boot.bin.sd.bin                           # Generated file
        ├── u-boot.bin                                      # Generated file
        │
        ├── other-source-directories...
        └── other-source-files...

Two types of files are ultimately generated: the u-boot.bin file in the u-boot root directory is an incomplete version of u-boot used in the /boot directory (corresponds to the overload directory in the repository); the u-boot.bin and u-boot.bin.sd.bin in the fip directory are complete versions of u-boot files used in the /usr/lib/u-boot/ directory (corresponds to the bootloader directory in the repository). The complete versions of the two files differ by 512 bytes, the larger one has 512 bytes of 0 filled in front.

image image

💡 Tip: Before writing to eMMC for testing, please refer to section 12.3 for unbricking methods. Be sure to understand the short circuit point location, have the original .img format Android system file, and have performed short-circuit flashing tests. Ensure that you have mastered all the unbricking methods before proceeding with writing tests.

12.11.2 How to build the u-boot file for Rockchip devices

Since most manufacturers of Rockchip devices have opened up their u-boot source code, it's relatively easy to obtain the relevant u-boot source code from the manufacturer's source code repository and proceed with the compilation. Additionally, some open-source enthusiasts have also shared numerous user-friendly u-boot compilation scripts. Below, I'll provide a few examples to illustrate various compilation methods.

12.11.2.1 How to use Radxa's u-boot building script

Taking compiling Rock5b(rk3588) as an example.

# 01.Install the necessary build dependencies
sudo apt-get update
sudo apt-get install -y git device-tree-compiler libncurses5 libncurses5-dev build-essential libssl-dev mtools bc python dosfstools flex bison

# 02.Set up your workspace and get the source code from the Radxa Git repositories
mkdir ~/rk3588-sdk && cd ~/rk3588-sdk
git clone -b stable-5.10-rock5 https://github.com/radxa/u-boot.git
git clone -b master https://github.com/radxa/rkbin.git
git clone -b debian https://github.com/radxa/build.git

# Explanation of the source code:
# ~/rk3588-sdk/build/: Radxa helper script files and configuration files for building U-Boot, Linux kernel and rootfs.
# ~/rk3588-sdk/rkbin/: Pre-built Rockchip binaries, including first stage loader and ATF (Arm Trustzone Firmware)
# ~/rk3588-sdk/u-boot/: Second stage bootloader used to start the OS (e.g. Linux or Android)

# 03.Build u-boot (For ROCK 5B)
cd ~/rk3588-sdk
./build/mk-uboot.sh rk3588-rock-5b

# 04.After a successful build, the ~/rk3588-sdk/out/u-boot directory will be populated
~/rk3588-sdk/out/u-boot
├── idbloader.img
├── rk3588_spl_loader_v1.08.111.bin
├── spi
│   └── spi_image.img
└── u-boot.itb

By adding more options in the board_configs.sh and mk-uboot.sh within the radxa/build source code, it's possible to compile u-boot files for other devices as well. For instance, you can follow the instructions provided for compiling the Beelink-IPC-R(rk3588) device.

12.11.2.2 How to use cm9vdA's u-boot building script

cm9vdA provides scripts and usage instructions for compiling u-boot and the kernel in his open-source project cm9vdA/build-linux. I have utilized his project for u-boot compilation in various Rockchip devices and documented the processes for reference. Here are some excerpts:

  • Build u-boot for Lenovo-Leez-P710 (rk3399) device: Link
  • Build u-boot for DLFR100 (rk3399) device: Link
  • Build u-boot for ZYSJ (rk3399) device: Link

12.12 Error in Memory Size Recognition

If the memory size is recognized incorrectly (it is abnormal for 4G memory to be recognized as 1-2G, and it is normal to be recognized as 3.7G), you can try to manually copy a /boot/UBOOT_OVERLOAD file (please note it's "copy", "do not rename", as renaming it will make the system unable to boot after installation and updates). When used in USB, save it as /boot/u-boot.ext, and when used in eMMC, save it as /boot/u-boot.emmc.

Apart from trying to solve memory problems, do not manually copy the u-boot file. Incorrect addition will cause the system to fail to boot and various problems to occur.

12.13 How to Decompile dtb Files

Some new devices are not currently supported (or have variants), and you can try to adjust related parameters by decompiling.

# Install dependencies
sudo apt-get update
sudo apt-get install -y device-tree-compiler

# 1. Decompilation command (generate dts source code using dtb file)
dtc -I dtb -O dts -o xxx.dts xxx.dtb

# 2. Compilation command (generate dtb file using dts)
dtc -I dts -O dtb -o xxx.dtb xxx.dts

12.14 How to Modify cmdline Settings

In Amlogic devices, you can add/modify/delete settings in the /boot/uEnv.txt file. In Rockchip and Allwinner devices, you can set in the /boot/armbianEnv.txt file (add to extraargs or extraboardargs parameters). Devices using /boot/extlinux/extlinux.conf configure in this file. You need to restart after each change for it to take effect.

  • For instance, the Home Assistant Supervisor application only supports the docker cgroup v1 version, while the currently default installed version for Docker is the latest v2. If you need to switch to the v1 version, you can add the systemd.unified_cgroup_hierarchy=0 parameter setting in cmdline. After restarting, you can switch to the docker cgroup v1 version.

  • By adding max_loop=128 in cmdline, you can adjust the allowable amount of loop mounts.

  • By adding usbcore.usbfs_memory_mb=1024 in cmdline, you can permanently change the USBFS memory buffer from the default 16 mb to larger (cat /sys/module/usbcore/parameters/usbfs_memory_mb), improving the ability to transfer large files over USB.

  • By adding usbcore.usb3_disable=1 in cmdline, you can disable all USB 3.0 devices.

image
image

12.15 How to Add New Supported Devices

To build an Armbian system for a device, you need to use the device configuration file, system file, u-boot file, and process control file. The specific addition methods are introduced as follows:

12.15.1 Add Device Configuration File

In the configuration file /etc/model_database.conf, add the corresponding configuration information according to the device's test support status. The BUILD value is yes for some default build devices, the corresponding BOARD value must be unique, these boxes can use the default built Armbian system directly.

The default value is no without packaging, these devices need to download the same FAMILY Armbian system when using, after writing to USB, you can open USB's boot partition on your computer, modify the FDT dtb name in /boot/uEnv.txt file, adapt to other devices in the list.

12.15.2 Add System Files

Common files are placed in the build-armbian/armbian-files/common-files directory, universally applicable across platforms.

Platform files are respectively placed in build-armbian/armbian-files/platform-files/<platform> directory, Amlogic, Rockchip, and Allwinner share files of their respective platforms. The bootfs directory contains /boot partition files, and the rootfs directory contains Armbian system files.

If individual devices have special differential setting requirements, add an independent directory named after BOARD in the build-armbian/armbian-files/different-files directory, create bootfs directory as needed to add related files under system /boot partition, create rootfs directory as needed to add system files. All folder names are based on the actual path in the Armbian system. Used to add new files, or to override the same name files added from the common files and platform files.

12.15.3 Add u-boot Files

Amlogic series devices, share bootloader files and u-boot files. If there are new files, put them in the corresponding directory. The bootloader files will automatically be added to the Armbian system's /usr/lib/u-boot directory during system construction, and u-boot files will be automatically added to the /boot directory.

Rockchip and Allwinner series devices, add an independent u-boot file directory named after BOARD for each device, and the corresponding series files are placed in this directory.

During the Armbian image construction, these u-boot files will be written into the corresponding Armbian image files by the rebuild script according to the configuration in /etc/model_database.conf.

12.15.4 Add Process Control Files

Add the corresponding BOARD option to armbian_board in the yml workflow control file, which supports use in Actions on github.com.

12.16 How to Resolve the Issue of I/O Errors While Writing to eMMC

Some devices can normally boot Armbian from USB/SD/TF, but when writing to eMMC, an I/O write error is reported, such as the case in Issues, with the following error message:

[  284.338449] I/O error, dev mmcblk2, sector 0 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 2
[  284.341544] Buffer I/O error on dev mmcblk2, logical block 0, lost async page write
[  284.446972] I/O error, dev mmcblk2, sector 0 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 2
[  284.450074] Buffer I/O error on dev mmcblk2, logical block 0, lost async page write
[  284.497746] I/O error, dev mmcblk2, sector 0 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 2
[  284.500871] Buffer I/O error on dev mmcblk2, logical block 0, lost async page write

In such a situation, you can adjust the working mode speed and frequency of the dtb being used to stabilize the read and write support for storage. When using sdr mode, the frequency is twice the speed. When using ddr mode, the frequency equals the speed. For example:

sd-uhs-sdr12
sd-uhs-sdr25
sd-uhs-sdr50
sd-uhs-ddr50
sd-uhs-sdr104

max-frequency = <208000000>;

Take the code snippet in the dts file of the kernel source code as an example:

/* SD card */
&sd_emmc_b {
	status = "okay";

	bus-width = <4>;
	cap-sd-highspeed;
	sd-uhs-sdr12;
	sd-uhs-sdr25;
	sd-uhs-sdr50;
	max-frequency = <100000000>;
};

/* eMMC */
&sd_emmc_c {
	status = "okay";

	bus-width = <8>;
	cap-mmc-highspeed;
	max-frequency = <100000000>;
};

Generally, reducing the frequency of &sd_emmc_c from max-frequency = <200000000>; to max-frequency = <100000000>; can solve the problem. If it doesn't work, you can continue to reduce it to 50000000 for testing, and adjust &sd_emmc_b to set USB/SD/TF, you can also use sd-uhs-sdr to limit speed. You can modify the dts file and compile to get the test file, or you can use the method introduced in Section 12.13 to decompile and modify the existing dtb file to generate the test file. When modifying the decompiled dtb file, use hexadecimal values, where the decimal 200000000 corresponds to the hexadecimal 0xbebc200, the decimal 100000000 corresponds to the hexadecimal 0x5f5e100, the decimal 50000000 corresponds to the hexadecimal 0x2faf080, and the decimal 25000000 corresponds to the hexadecimal 0x17d7840.

In addition to solving this issue through the system software layer, it can also be resolved through money ability and hands-on ability.

12.17 How to Solve the Issue of No Sound in the Bullseye Version

Error log information for the sound issue:

Mar 29 15:47:18 armbian-ct2000 kernel:  fe.dai-link-0: ASoC: dpcm_fe_dai_prepare() failed (-22)
Mar 29 15:47:18 armbian-ct2000 kernel:  fe.dai-link-0: ASoC: no backend DAIs enabled for fe.dai-link-0

Please refer to the method in Bullseye NO Sound for settings.

wget https://github.com/ophub/kernel/releases/download/tools/bullseye_g12_sound-khadas-utils-4-2-any.tar.gz
tar -xzf bullseye_g12_sound-khadas-utils-4-2-any.tar.gz -C /

systemctl enable sound.service
systemctl restart sound.service

Restart Armbian for testing. If the sound still doesn't work, it may be because your box is using the old conf corresponding to the sound output route. You need to comment out the new configuration corresponding to L137-L142 in /usr/bin/g12_sound.sh (mainly for G12B, that is, S922X, before the old G12A/S905X2, and most of the SM1/S905X3 based on G12A can't be used), and then uncomment the old configuration corresponding to L130-L134.

12.18 How to build the boot.scr file

In the Armbian system, the boot.scr file in the /boot directory is used for booting the system. boot.scr is the compiled version of the boot.cmd file. boot.cmd is the source code file for boot.scr. You can modify the boot.cmd file to make changes to the boot.scr file and then compile it into a boot.scr file using the mkimage command.

Normally, these two files do not need to be modified. If adjustments are necessary, you can follow the methods below.

# Install dependencies
sudo apt-get update
sudo apt-get install -y u-boot-tools

# Edit the boot.cmd file
cd /boot
copy /boot/boot.cmd /boot/boot.cmd.bak
copy /boot/boot.scr /boot/boot.scr.bak
nano boot.cmd

# Compile the boot.scr file
mkimage -C none -A arm -T script -d boot.cmd boot.scr

# Restart to test
sync
reboot

# Additional Explanation
# For Amlogic devices, the file used in USB is /boot/boot.scr, while the file used for writing to eMMC is /boot/boot-emmc.scr.

在 Armbian 的使用中,一些可能遇到的常见问题汇总如下。

12.1 每个盒子的 dtb 和 u-boot 对应关系表

支持的电视盒子列表在 Armbian 系统中配置文件的位置为 /etc/model_database.conf

12.2 LED 屏显示控制说明

请查阅说明

12.3 如何恢复原安卓 TV 系统

通常使用 armbian-ddbr 对设备的安卓 TV 系统进行备份和恢复。

除此之外也可以通过线刷的方法,将安卓系统刷入 eMMC 中,安卓系统的下载镜像可在 Tools 中查找。

12.3.1 使用 armbian-ddbr 备份恢复

建议您在全新的盒子里安装 Armbian 系统前,先对当前盒子自带的原安卓 TV 系统进行备份,以便在需要恢复系统时使用。请从 TF/SD/USB 启动 Armbian 系统,输入 armbian-ddbr 命令,然后根据提示输入 b 进行系统备份,备份文件的存放路径为 /ddbr/BACKUP-arm-64-emmc.img.gz ,请下载保存。在需要恢复安卓 TV 系统时,将之前备份的文件上传至 TF/SD/USB 设备的相同路径下,输入 armbian-ddbr 命令,然后根据提示输入 r 进行系统恢复。

12.3.2 使用 Amlogic 刷机工具恢复

  • 一般情况下,重新插入电源,如果可以从 USB 中启动,只要重新安装即可,多试几次。

  • 如果接入显示器后,屏幕是黑屏状态,无法从 USB 启动,就需要进行盒子的短接初始化了。先将盒子恢复到原来的安卓系统,再重新刷入 Armbian 系统。首先下载 amlogic_usb_burning_tool 系统恢复工具并安装好。准备一条 USB 双公头数据线,准备一个 曲别针

  • 以 x96max+ 为例,在盒子的主板上确认 短接点 的位置,下载盒子的 Android TV 系统包。其他常见设备的安卓 TV 系统系统及对应的短接点示意图也可以在此下载查看

操作方法:

1. 打开刷机软件 USB Burning Tool:
   [ 文件 → 导入系统包 ]: X96Max_Plus2_20191213-1457_ATV9_davietPDA_v1.5.img
   [ 选择 ]:擦除 flash
   [ 选择 ]:擦除 bootloader
   点击 [ 开始 ] 按钮
2. 使用 [ 曲别针 ] 将盒子主板上的 [ 两个短接点进行短接连接 ],
   并同时使用 [ USB 双公头数据线 ] 将 [ 盒子 ] 与 [ 电脑 ] 进行连接。
3. 当看到 [ 进度条开始走动 ] 后,拿走曲别针,不再短接。
4. 当看到 [ 进度条 100% ], 则刷机完成,盒子已经恢复成 Android TV 系统。
   点击 [ 停止 ] 按钮, 拔掉 [ 盒子 ] 和 [ 电脑 ] 之间的 [ USB 双公头数据线] 。
5. 如果以上某个步骤失败,就再来一次,直至成功。
   如果进度条没有走动,可以尝试插入电源。通长情况下不用电源支持供电,只 USB 双公头的供电即可满足刷机要求。

当完成恢复出厂设置,盒子已经恢复成 Android TV 系统,其他安装 Armbian 系统的操作,就和你之前第一次安装系统时的要求一样了,再来一遍即可。

12.4 设置盒子从 USB/TF/SD 中启动

根据自己盒子的情况,分别使用初次安装和重新安装 Armbian 系统的两种方法。

12.4.1 初次安装 Armbian 系统

  • 把刷好系统的 USB/TF/SD 插入盒子。
  • 开启开发者模式: 设置 → 关于本机 → 版本号 (如: X96max plus...), 在版本号上快速连击 5 次鼠标左键, 看到系统显示 开启开发者模式 的提示。
  • 开启 USB 调试模式: 系统 → 高级选选 → 开发者选项 (设置 开启USB调试 为启用)。启用 ADB 调试。
  • 安装 ADB 工具:下载 adb 并解压,将 adb.exeAdbWinApi.dllAdbWinUsbApi.dll 三个文件拷⻉到 c://windows/ 目录下的 system32syswow64 两个文件夹内,然后打开 cmd 命令面板,使用 adb --version 命令,如果有显示就表示可以使用了。
  • 进入 cmd 命令模式。输入 adb connect 192.168.1.137 命令(其中的 ip 根据你的盒子修改,可以到盒子所接入的路由器设备里查看),如果链接成功会显示 connected to 192.168.1.137:5555
  • 输入 adb shell reboot update 命令,盒子将重启并从你插入的 USB/TF/SD 启动,从浏览器访问系统的 IP 地址,或者 SSH 访问即可进入系统。

12.4.2 重新安装 Armbian 系统

  • 正常情况下,直接把刷写好 Armbian 的 U 盘插入 USB 即可直接从 U 盘中启动。USB 启动比 eMMC 具有优先启动权。
  • 个别设备可能出现无法从 U 盘启动的现象,可以先把 eMMC 里 Armbian 系统 /boot 目录下的 boot.scr 文件改个名字,例如 boot.scr.bak,然后再插入 U 盘启动,这样就可以从 U 盘启动了。

12.5 禁用红外接收器

默认情况下启用对红外接收器的支持,但如果您将电视盒用作服务器,那么您可能希望禁用 IR 内核模块以防止错误地关闭您的盒子。 要完全禁用 IR,请添加以下行:

blacklist meson_ir

/etc/modprobe.d/blacklist.conf 并重启。

12.6 启动引导文件的选择

  • 目前已知的设备中,只有 T95(s905x) / T95Z-Plus(s912) / BesTV-R3300L(s905l-b) 等少数设备需要使用 /bootfs/extlinux/extlinux.conf 文件,已经在系统里默认添加了。其他设备如果需要,可以将系统写入 USB 后,双击打开 boot 分区,将系统自带的 /boot/extlinux/extlinux.conf.bak 文件名称中的 .bak 删除即可使用。当写入 eMMC 时 armbian-install 会自动检查,如果存在 extlinux.conf 文件,会自动创建。

  • 其他设备只需要 /boot/uEnv.txt 即可启动,不要修改 extlinux.conf.bak 文件。

12.7 网络设置

12.7.1 使用 interfaces 设置网络

网络配置文件 /etc/network/interfaces 的默认内容如下:

source /etc/network/interfaces.d/*
# Network is managed by Network manager
auto lo
iface lo inet loopback
12.7.1.1 由 DHCP 动态分配 IP 地址
source /etc/network/interfaces.d/*

auto eth0
iface eth0 inet dhcp
12.7.1.2 手动设置静态 IP 地址

其中的 IP 和网关和 DNS 根据自己的网络情况修改。

source /etc/network/interfaces.d/*

auto eth0
allow-hotplug eth0
iface eth0 inet static
hwaddress ether 12:34:56:78:9A:DA
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
12.7.1.3 在 docker 中使用 OpenWrt 建立互通网络

其中的 MAC 地址根据自己的需要修改。

source /etc/network/interfaces.d/*

allow-hotplug eth0
no-auto-down eth0
auto eth0
iface eth0 inet manual

auto macvlan
iface macvlan inet dhcp
        pre-up ip link add macvlan link eth0 type macvlan mode bridge
        post-down ip link del macvlan link eth0 type macvlan mode bridge

auto lo
iface lo inet loopback

12.7.2 使用 NetworkManager 管理网络

12.7.2.1 新建网络连接

新建或修改网络连接前的准备工作

12.7.2.1.1 获取网络接口名称

查看设备中有哪些网络接口可以用来建立网络连接。

nmcli device | grep -E "^[e].*|^[w].*|^[D].*|^[T].*" | awk '{printf "%-19s%-19s\n",$1,$2}'

执行命令后返回内容, DEVICE 列显示网络接口名称, TYPE 列显示网络接口类型。

其中 eth0 = 第1块有线网卡的名称, eth1 = 第2块有线网卡的名称, 以此类推, 无线网卡同理。

DEVICE             TYPE
eth0               ethernet
eth1               ethernet
eth2               ethernet
eth3               ethernet
wlan0              wifi
wlan1              wifi
12.7.2.1.2 获取现有网络连接名称

查看设备现有哪些网络连接, 包含使用中和未使用的连接。在新建网络连接时, 不建议使用已经存在的连接名称。

nmcli connection show | grep -E ".*|^[N].*" | awk '{printf "%-19s%-19s\n", $1,$3}'

执行命令后返回内容, NAME 列显示现有网络连接名称, TYPE 列显示网络接口类型。

其中 ethernet = 有线网卡, wifi = 无线网卡, bridge = 网桥

NAME               TYPE
cnc                ethernet
lan                ethernet
lte                ethernet
tel                ethernet
docker0            bridge
titanium           wifi
cpe                wifi
12.7.2.1.3 新建有线网络连接

在网络接口 eth0 上新建网络连接并立即生效 (动态 IP 地址 - IPv4 / IPv6)。

# Set ENV
MYCON=ether1                  # 新建网络连接名称
MYETH=eth0                    # 网络接口名称 = eth0 / eth1 / eht2 / eth3
IPV6AGM=stable-privacy        # IPv6 地址状态模式 = stable-privacy / eui64

# Add ETH
nmcli connection add \
con-name $MYCON \
type ethernet \
ifname $MYETH \
autoconnect yes \
ipv6.addr-gen-mode $IPV6AGM
nmcli connection up $MYCON
ip -c -br address

在网络接口 eth0 上新建网络连接并立即生效 (静态 IP 地址 - IPv4)。

# Set ENV
MYCON=ether1                  # 网络连接名称
MYETH=eth0                    # 网络接口名称 = eth0 / eth1 / eht2 / eth3
IP=192.168.67.167/24          # HOST IP 地址, 其中 24 是子网掩码 对应 255.255.255.0
GW=192.168.67.1               # 网关
DNS=119.29.29.29,223.5.5.5    # DNS 服务器地址

# Chg CON
nmcli connection add \
con-name $MYCON \
type ethernet \
ifname $MYETH \
autoconnect yes \
ipv4.method manual \
ipv4.addresses $IP \
ipv4.gateway $GW \
ipv4.dns $DNS
nmcli connection up $MYCON
ip -c -br address
12.7.2.1.4 新建无线网络连接

在网络接口 wlan0 上新建网络连接并立即生效 (动态 IP 地址 - IPv4 / IPv6)。

# Set ENV
MYCON=ssid                    # 新建网络连接名称, 建议使用 WiFi SSID 来指定连接名称
MYSSID=ssid                   # WiFi SSID 区分大小写
MYPSWD=passwd                 # WiFi 密码
MYWSKM=wpa-psk                # 安全性选择 WPA-WPA2 = wpa-psk or WPA3 = sae (无线路由器或 AP 中查看是哪一种加密方式)
MYWLAN=wlan0                  # 网络接口名称 = wlan0 / wlan1
IPV6AGM=stable-privacy        # IPv6 地址状态模式 = stable-privacy / eui64

# Add WLAN
nmcli connection add \
con-name $MYCON \
type wifi \
ifname $MYWLAN \
autoconnect yes \
ipv6.addr-gen-mode $IPV6AGM \
wifi.ssid $MYSSID \
wifi-sec.key-mgmt $MYWSKM \
wifi-sec.psk $MYPSWD
nmcli connection up $MYCON
ip -c -br address
12.7.2.2 修改无线网络连接中的 WiFi SSID or PASSWD

修改无线网络连接 ssid 中的 WiFi SSID or PASSWD 并立即生效。

# Set ENV
MYCON=ssid                    # 无线网络连接名称
MYSSID=ssid                   # WiFi SSID 区分大小写
MYPSWD=passwd                 # WiFi 密码
MYWSKM=wpa-psk                # 安全性选择 WPA-WPA2 = wpa-psk or WPA3 = sae

# Add WLAN
nmcli connection modify $MYCON \
wifi.ssid $MYSSID \
wifi-sec.key-mgmt $MYWSKM \
wifi-sec.psk $MYPSWD
nmcli connection up $MYCON
ip -c -br address
12.7.2.3 修改网络地址分配方式
12.7.2.3.1 静态 IP 地址 - IPv4

在网络连接 ether1 上修改 IP 地址分配方式为 静态 IP 地址 并立即生效。

*适用 有线连接 / 无线连接

# Set ENV
MYCON=ether1                  # 网络连接名称
IP=192.168.67.167/24          # HOST IP 地址, 其中 24 是子网掩码 对应 255.255.255.0
GW=192.168.67.1               # 网关
DNS=119.29.29.29,223.5.5.5    # DNS 服务器地址

# Chg CON
nmcli connection modify $MYCON \
ipv4.method manual \
ipv4.addresses $IP \
ipv4.gateway $GW \
ipv4.dns $DNS
nmcli connection up $MYCON
ip -c -br address
12.7.2.3.2 DHCP 获取动态 IP 地址 - IPv4 / IPv6

在网络连接 ether1 上修改 IP 地址分配方式为 DHCP 获取动态 IP 地址 并立即生效。

*适用 有线连接 / 无线连接

# Set ENV
MYCON=ether1                  # 网络连接名称

# Chg CON
nmcli connection modify $MYCON \
ipv4.method auto \
ipv6.method auto
nmcli connection up $MYCON
ip -c -br address
12.7.2.4 修改网络连接 MAC 地址

在网络连接 ether1 上修改(克隆) MAC 地址并立即生效, 以解决局域网 MAC 地址冲突问题。

*适用 有线连接 / 无线连接

# Set ENV
MYCON=ether1                  # 网络连接名称, 注意匹配网络接口类型
MYTYPE=ethernet               # 网络接口类型 = 有线网卡 / 无线网卡 = ethernet / wifi
MYMAC=12:34:56:78:9A:BC       # 新的 MAC 地址

# Chg CON
nmcli connection modify ${MYCON} \
${MYTYPE}.cloned-mac-address ${MYMAC}
nmcli connection up ${MYETH}
ip -c -br address
  • 新建或修改部分网络参数, 网络连接可能会被断开, 并重新连接网络。
  • 由于软硬件环境不同(盒子, 系统, 网络设备等), 生效所需时间 1-15 秒左右, 更长时间未生效的建议检查软硬件环境。
12.7.2.5 如何禁用 IPv6

您可以使用 nmcli 实用程序在命令行中禁用 IPv6 协议,参考来源 disable-ipv6

第一步,先使用 nmcli connection show 命令查看网络连接列表,返回结果如下:

NAME                 UUID                                   TYPE       DEVICE
Wired connection 1   8a7e0151-9c66-4e6f-89ee-65bb2d64d366   ethernet   eth0
...

第二步,将连接的 ipv6.method 参数设为 disabled :

nmcli connection modify "Wired connection 1" ipv6.method "disabled"

第三步,重新连接网络:

nmcli connection up "Wired connection 1"

第四步,查看网络连接状态,如果没有显示 inet6 条目,则 IPv6 在该设备上被禁用:

ip address show eth0

第五步,验证 /proc/sys/net/ipv6/conf/eth0/disable_ipv6 文件现在是否包含值 1

# cat /proc/sys/net/ipv6/conf/eth0/disable_ipv6
1

12.7.3 如何启用无线

有的设备支持使用无线,启用方法如下:

# 安装管理工具
sudo apt-get install network-manager

# 查看网络设备
sudo nmcli dev

# 启用无线
sudo nmcli r wifi on

# 扫描无线
sudo nmcli dev wifi

# 连接无线
sudo nmcli dev wifi connect "wifi名称" password "wifi密码"

# 显示已保存的网络连接列表
sudo nmcli connection show

# 断开连接
sudo nmcli connection down "wifi名称"

# 忘记连接并取消自动连接
sudo nmcli connection delete "wifi名称"
image

12.7.4 如何启用蓝牙

有的设备支持使用蓝牙,启用方法如下:

# 安装蓝牙支持
armbian-config >> Network >> BT: Install Bluetooth support

# 重启系统
reboot

系统重启后,查看蓝牙驱动是否正常。桌面系统的可以在菜单里连接蓝牙设备。也可以使用终端图形界面安装。

dmesg | grep Bluetooth
image
image
# 连接蓝牙设备
armbian-config >> Network >> BT: Discover and connect Bluetooth devices

也可以在终端中使用命令安装:

# 查看蓝牙服务运行状态
sudo systemctl status bluetooth

# 如果未启动,先开启蓝牙服务
sudo systemctl enable bluetooth
sudo systemctl start bluetooth

# 扫描附近的蓝牙设备
bluetoothctl scan on

# 启用蓝牙发现
bluetoothctl discoverable on

# 进行蓝牙 MAC 地址配对
bluetoothctl pair 12:34:56:78:90:AB

# 查看配对好的蓝牙设备
bluetoothctl paired-devices

# 连接蓝牙设备
bluetoothctl connect 12:34:56:78:90:AB

# 信任设备,方便以后直接连接
bluetoothctl trust 12:34:56:78:90:AB

# 断开蓝牙设备
bluetoothctl disconnect 12:34:56:78:90:AB

# 解除蓝牙配对
bluetoothctl remove 12:34:56:78:90:AB

# 阻止连接设备
bluetoothctl block 12:34:56:78:90:AB

12.8 如何添加开机启动任务

系统中已经添加了自定义开机启动任务脚本文件,在 Armbian 系统中的路径是 /etc/custom_service/start_service.sh 文件,可以根据个人需求在该脚本中自定义添加相关任务。

12.9 如何更新系统中的服务脚本

使用 armbian-sync 命令可以一键将本地系统中的全部服务脚本更新到最新版本。

12.10 如何获取 eMMC 上的安卓系统分区信息

我们将 Armbian 系统写入 eMMC 系统时,需要首先确认设备的安卓系统分区表,确保将数据写入至安全区域,尽量不要破坏安卓系统分区表,以免造成系统无法启动等问题。如果写入了不安全的区域,会无法启动,或出现类似下面的错误:

image

12.10.1 获取分区信息

如果你使用的是 2022.11 之后本仓库中发布的 Armbian,你可以复制粘贴以下命令来获得一个记录完整分区信息的网址(设备本身并不需要联网)

ampart /dev/mmcblk2 --mode webreport 2>/dev/null

ampart 的 webreport 模式为 2023.02.03 发布的 v1.2 版本引入的,如果你使用上面的命令无输出,则可能为不支持直接输出网址的旧版,你可以转而使用下面这条命令:

echo "https://7ji.github.io/ampart-web-reporter/?dsnapshot=$(ampart /dev/mmcblk2 --mode dsnapshot 2>/dev/null | head -n 1)&esnapshot=$(ampart /dev/mmcblk2 --mode esnapshot 2>/dev/null | head -n 1)"

得到的网址将会类似于下面这样:

https://7ji.github.io/ampart-web-reporter/?esnapshot=bootloader:0:4194304:0%20reserved:37748736:67108864:0%20cache:113246208:754974720:2%20env:876609536:8388608:0%20logo:893386752:33554432:1%20recovery:935329792:33554432:1%20rsv:977272832:8388608:1%20tee:994050048:8388608:1%20crypt:1010827264:33554432:1%20misc:1052770304:33554432:1%20instaboot:1094713344:536870912:1%20boot:1639972864:33554432:1%20system:1681915904:1073741824:1%20params:2764046336:67108864:2%20bootfiles:2839543808:754974720:2%20data:3602907136:4131389440:4&dsnapshot=logo::33554432:1%20recovery::33554432:1%20rsv::8388608:1%20tee::8388608:1%20crypt::33554432:1%20misc::33554432:1%20instaboot::536870912:1%20boot::33554432:1%20system::1073741824:1%20cache::536870912:2%20params::67108864:2%20data::-1:4

将这个网址复制到你的浏览器打开,即可看到格式清晰明了的 DTB 分区信息和 eMMC 分区信息:

image image

12.10.2 分区信息分享

当你需要分享分区信息给其他人时(比如,发布到本仓库以来汇报某一新设备的情况,或者寻求他人的帮助),尽量分享网址本身,而不是截图。如果介意网址太长,可以借用一些免费的短网址工具。

  • 一方面,网页上的分区信息在每次访问时都会动态生成,对于某些分区是否能写入的标注,以及表格的格式等都可能会更新。
  • 另一方面,从截图中其他人也不能方便地复制分区参数做计算等。

另外,也不需要额外地将参数整理到表格文件,网页上表格的布局已经特意设计为仅需复制粘贴就可以导入到 Excel 或者 LibreOffice Calc 中。

12.10.3 分区信息解读

DTB 表是安卓 DTB 中记录的每个盒子系统希望的分区布局,这一布局里一般会以一个大小为自动填充的 data 分区为结尾,所以同系统(也必然包括同型号)的盒子,这里的布局必然是相同的。盒子上实际的分区布局会因为 eMMC 的容量不同而各有差别,但总是由 DTB 的分区布局所决定的(即已知 DTB 分区布局 +eMMC 准确大小,必然可推知 eMMC 分区情况。 上面的 DTB 分区信息和 eMMC 分区信息并非来自同一个盒子,你看出来了吗?)。

eMMC 表是盒子上实际的 eMMC 分区布局。其中每一行表示一块存储区域,这一存储区域既可能是一个分区,也可能是分区间的空隙(因为晶晨的诡异决策,每个分区之间都至少有 8M 的空隙,计划留作他用,结果到最新的 S905X4 都没有用上,十分浪费空间)。对应分区的行中,字体为黑色,且偏移和掩码栏均有数值;对应空隙的行中,字体为灰色,偏移和掩码栏没有数值,且分区名为 gap

eMMC 表中,每一块存储区域的最后一栏为可写入的情况,绿色且 yes 表示这一区域可以写入,红色且 no 表示这一区域绝对不可以写入,黄色且有标注则表示某前提的下可以写入,或者只有部分可以写入。

以上表为例,bootloader 分区对应的 0+4M (0M~4M)绝对不可写入,其后的 32M 空隙(4M~36M)可以写入,reserved 分区对应的 36M+64M (36M~100M)绝对不可写入,其后的空隙一直到 env 前的空隙(100M~836M)都可以写入,env 的1M往后(837M一直到结尾)在不需要安卓启动 logo 的情况下都可以写入,则 eMMC 上所有可写入的范围为:

  • 4M~36M
  • 100M~836M
  • 837M~结尾

在需要安卓启动 logo 的情况下,额外的,logo分区对应的 852M + 32M (852M~884M)不能写入,则 eMMC 上所有的可写入范围为:

  • 4M~36M
  • 100M~836M
  • 837M~852M
  • 884M~结尾

12.10.4 用于 eMMC 安装

如果你的设备在使用 armbian-install-a 参数(使用 ampart 调整 eMMC 分区布局)为 yes(默认值)的情况下失败,则你的盒子不能使用最优化的布局(即把 DTB 分区信息调整为只有 data ,再由此生成 eMMC 分区信息,然后将所有还存在的分区均向前挪动,如此一来,117M 向后的空间便均可使用),你需要在 armbian-install 中修改对应的分区信息。

此文件中,声明分区布局的关键参数有三个:BLANK1, BOOT, BLANK2。其中 BLANK1 表示从 eMMC 开头算起的不能使用的大小;BOOT 表示在 BLANK1 以后创建的用来存放内核、DTB 等的分区的大小,最好不要小于 256M,BLANK2 表示 BOOT 以后不能使用的大小;在此之后的空间会全部用来创建 ROOT 分区,储存整个系统中 /boot 挂载点以外的数据。三者均应为整数,且单位为MiB (1 MiB = 1024 KiB = 1024^2 Byte)

讨论上一段中不需要 logo 分区的情况,我们自然希望将所有能使用的空间全部使用,但是 4M~36M 的区域由于太小,不能用作 BOOT,所以只能将它算在不能用的 BLANK1 里面。而 100M~836M 的区域,用作 BOOT 绰绰有余,则可以将这 736M 全部分配给 BOOT。此后再有 836M~837M 的不能使用区域,便算给 BLANK2 ,那么应该使用的参数就应该如下(下文仅以 s905x3 为例,若你的 SoC 为其他,需要修改其他的对应代码块):

# Set partition size (Unit: MiB)
elif [[ "${AMLOGIC_SOC}" == "s905x3" ]]; then
    BLANK1="100"
    BOOT="736"
    BLANK2="1"

12.11 如何制作 u-boot 文件

u-boot 文件是引导系统正常启动的重要文件。Amlogic,Allwinner 和 Rockchip 设备在获取源码和编译流程上略有不同。

12.11.1 如何制作 Amlogic 设备的 u-boot 文件

由于 Amlogic 系列的设备厂商大多数都是闭源的,所以我们需要从设备上提取 u-boot 相关文件,然后再进行编译。这里介绍的方法来自 unifreq 大佬分享的制作教程。

12.11.1.1 如何提取 bootloader 和 dtb 文件

提取需要使用 HxD 软件。可以从 官网下载链接备份下载链接 获取安装。

cmd 面板中依次执行以下命令提取相关文件,并下载到本地电脑。

# 使用 adb 工具进入盒子
adb connect 192.168.1.111
adb shell

# 导出 bootloader 命令
dd if=/dev/block/bootloader of=/data/local/bootloader.bin

# 导出 dtb 命令
cat /dev/dtb >/data/local/mybox.dtb

# 导出 gpio 命令
cat /sys/kernel/debug/gpio >/data/local/mybox_gpio.txt

# 依次把 bootloader、dtb 和 gpio 文件都下载到本地电脑C盘根目录下的 mybox 文件夹
adb pull /data/local/bootloader.bin C:\mybox
adb pull /data/local/mybox.dtb C:\mybox
adb pull /data/local/mybox_gpio.txt C:\mybox
12.11.1.2 如何制作 acs.bin 文件

主线 u-boot 最重要的是 acs.bin,用于初始化内存的部分,原厂 u-boot 位于系统最前面的 4MB 位置。使用刚才获得的 bootloader.bin 文件提取 acs.bin 文件。

打开 HxD 软件,打开上面导出的 bootloader.bin 文件,右键 - 选择范围,起始位置 F200,长度 1000,选十六进制

image

复制选择的结果,然后新建文件,插入式粘贴,警告忽略,另存为 acs.bin 文件。

image image image

如果是锁了 bootloader 的话这个区域的代码是是乱码就没用了。正常的应该像上图中这样有很多 0 ,有 cfg 会连续出现几次,中间会出现 ddr 相关的字样,这种正常代码就是可以使用的。

12.11.1.3 如何编译 u-boot 文件

制作 u-boot 需要 https://github.com/unifreq/amlogic-boot-fiphttps://github.com/unifreq/u-boot 这两个源码库,编译自己盒子的两个 u-boot 文件。

在 amlogic-boot-fip 源码里面每个机型只有 acs.bin 这个文件是不同的,其它的文件都可以通用。

image

制作 u-boot 的方法详见 https://github.com/unifreq/u-boot/tree/master/doc/board/amlogic 里的具体说明,选择自己设备的型号进行编译测试。

根据 unifreq 的方法制作 u-boot 需要用到盒子的 acs.bin,dts 和 config 文件。其中安卓系统导出来的 dts 不能直接转换成 Armbian 的格式,需要自己编写一个对应的 dts 文件。根据自己设备具体硬件上的区别部分,比如开关、led、电源控制、tf卡、sdio wifi模块等,使用内核源码库中相似的 dts 文件进行修改制作。

以制作 X96Max Plus 的 u-boot 为例:

~/make-uboot
    ├── amlogic-boot-fip
    │   ├── x96max-plus                                     # 自己创建目录
    │   │   ├── asc.bin                                     # 自己制作源文件
    │   │   └── other-copy-files...                         # 复制其他目录的文件
    │   │
    │   ├── other-source-directories...
    │   └── other-source-files...
    │
    └── u-boot
        ├── configs
        │   └── x96max-plus_defconfig                       # 自己制作源文件
        ├── arch
        │   └── arm
        │       └── dts
        │           ├── meson-sm1-x96-max-plus-u-boot.dtsi  # 自己制作源文件
        │           ├── meson-sm1-x96-max-plus.dts          # 自己制作源文件
        │           └── Makefile                            # 编辑
        ├── fip
        │   ├── u-boot.bin                                  # 生成文件
        │   └── u-boot.bin.sd.bin                           # 生成文件
        ├── u-boot.bin                                      # 生成文件
        │
        ├── other-source-directories...
        └── other-source-files...

最终生成的文件有两类:在 u-boot 根目录下的 u-boot.bin 文件是 /boot 目录下使用的不完整版 u-boot(对应仓库中的 overload 目录);在 fip 目录下的 u-boot.binu-boot.bin.sd.bin/usr/lib/u-boot/ 目录下使用的完整版 u-boot 文件(对应仓库中的 bootloader 目录),完整版的两个文件相差 512 字节,大的那个是填充了 512 字节的 0 在前面。

image image

💡提示:在写入 eMMC 进行测试前,请先查看 12.3 的救砖方法。务必掌握短接点位置,有原厂 .img 格式的安卓系统文件,并进行过短接刷机测试,确保救砖方法都已经掌握的情况下再进行写入测试。

12.11.2 如何制作 Rockchip 设备的 u-boot 文件

由于 Rockchip 设备的大部分厂商都开放了他们的 u-boot 源码,所以可以比较方便地从厂商的源码库中获取到相关的 u-boot 源码,然后进行编译。同时一些开源大佬们也分享了很多更易使用的 u-boot 编译脚本,下面以几个实例介绍几种编译方法。

12.11.2.1 如何使用 Radxa 的 u-boot 制作脚本

以编译 Rock5b(rk3588) 为例。

# 01.安装依赖
sudo apt-get update
sudo apt-get install -y git device-tree-compiler libncurses5 libncurses5-dev build-essential libssl-dev mtools bc python dosfstools flex bison

# 02.克隆源码
mkdir ~/rk3588-sdk && cd ~/rk3588-sdk
git clone -b stable-5.10-rock5 https://github.com/radxa/u-boot.git
git clone -b master https://github.com/radxa/rkbin.git
git clone -b debian https://github.com/radxa/build.git

# 源码说明:
# ~/rk3588-sdk/build/:Radxa 辅助脚本文件和用于构建 U-Boot、Linux 内核和根文件系统的配置文件。
# ~/rk3588-sdk/rkbin/:预构建的 Rockchip 二进制文件,包括第一阶段加载程序和 ATF(Arm Trustzone固件)。
# ~/rk3588-sdk/u-boot/:用于启动操作系统(如 Linux 或 Android)的第二阶段引导加载程序。

# 03.编译 u-boot (For ROCK 5B)
cd ~/rk3588-sdk
./build/mk-uboot.sh rk3588-rock-5b

# 04.构建成功后,将放置在 ~/rk3588-sdk/out/u-boot 目录
~/rk3588-sdk/out/u-boot
├── idbloader.img
├── rk3588_spl_loader_v1.08.111.bin
├── spi
│   └── spi_image.img
└── u-boot.itb

通过在 radxa/build 源码的 board_configs.shmk-uboot.sh 里添加更多选项,可以编译其他设备的 u-boot 文件,例如我编译 Beelink-IPC-R(rk3588) 设备的使用方法。

12.11.2.2 如何使用 cm9vdA 的 u-boot 制作脚本

cm9vdA 在他的 cm9vdA/build-linux 开源项目里提供了编译 u-boot 和 kernel 的脚本和使用方法,我在一些 Rockchip 设备的 u-boot 编译中使用了他的项目并进行了过程记录,摘录部分以供参考。

  • 编译 Lenovo-Leez-P710(rk3399) 设备的 u-boot:Link
  • 编译 DLFR100(rk3399) 设备的 u-boot:Link
  • 编译 ZYSJ(rk3399) 设备的 u-boot:Link

12.12 内存大小识别错误

如果内存大小识别不正确(4G内存识别为1-2G是不正常,识别为3.7G是正常),可以尝试手动复制一份 /boot/UBOOT_OVERLOAD 文件(注意是复制一份,不要改名,改名后安装与更新等操作后将无法启动),在 USB 中使用时另存为 /boot/u-boot.ext,在 eMMC 中使用时另存为 /boot/u-boot.emmc

除了想尝试解决内存的问题外,不要手动复制 u-boot 文件,添加不正确会导致无法启动以及出现各种问题。

12.13 如何反编译 dtb 文件

有些新设备不在目前的支持列表(或有变异体),可以通过反编译,调整相关参数进行尝试。

# 安装依赖
sudo apt-get update
sudo apt-get install -y device-tree-compiler

# 1. 反编译命令(使用 dtb 文件生成 dts 源码)
dtc -I dtb -O dts -o xxx.dts xxx.dtb

# 2. 编译命令(使用 dts 编译生成 dtb 文件)
dtc -I dts -O dtb -o xxx.dtb xxx.dts

12.14 如何修改 cmdline 设置

在 Amlogic 设备中,可以在 /boot/uEnv.txt 文件中进行添加/修改/删除等设置。在 Rockchip 和 Allwinner 设备中在 /boot/armbianEnv.txt 文件中进行设置(添加至 extraargsextraboardargs 参数里)。使用 /boot/extlinux/extlinux.conf 的设备在这个文件里配置。每次更改后要重启才能生效。

  • 比如 Home Assistant Supervisor 应用只支持 docker cgroup v1 版本,而目前 docker 默认安装的都是最新的 v2 版本。如需切换至 v1 版本,可以在 cmdline 中添加 systemd.unified_cgroup_hierarchy=0 参数设置,重启后就可以切换至 docker cgroup v1 版本。

  • 通过在 cmdline 中添加 max_loop=128 设置,可以调整允许的 loop 挂载数量。

  • 通过在 cmdline 中添加 usbcore.usbfs_memory_mb=1024 设置,可以永久将 USBFS 内存缓冲区从默认的 16 mb 改为更大(cat /sys/module/usbcore/parameters/usbfs_memory_mb),提升 USB 传输大文件的能力。

  • 通过在 cmdline 中添加 usbcore.usb3_disable=1 设置,可以禁用 USB 3.0 的所有设备。

image
image

12.15 如何添加新的支持设备

为一个设备构建 Armbian 系统,需要用到 设备配置文件系统文件u-boot 文件流程控制文件 共 4 部分,具体添加方法介绍如下:

12.15.1 添加设备配置文件

在配置文件 /etc/model_database.conf 里面,根据设备的测试支持情况,添加对应的配置信息。其中 BUILD 的值是 yes 的是默认构建的部分设备,对应的 BOARD必须唯一,这些盒子可以直接使用默认构建的 Armbian 系统。

默认值是 no 的没有打包,这些设备使用时需要下载相同 FAMILY 的 Armbian 系统,在写入 USB 后,可以在电脑上打开 USB 中的 boot 分区,修改 /boot/uEnv.txt 文件中 FDT 的 dtb 名称,适配列表中的其他设备。

12.15.2 添加系统文件

通用文件放在:build-armbian/armbian-files/common-files 目录下,各平台通用。

平台文件分别放在 build-armbian/armbian-files/platform-files/<platform> 目录下,AmlogicRockchipAllwinner 分别共用各自平台的文件,其中 bootfs 目录下是 /boot 分区的文件,rootfs 目录下的是 Armbian 系统文件。

如果个别设备有特殊差异化设置需求,在 build-armbian/armbian-files/different-files 目录下添加以 BOARD 命名的独立目录,根据需要建立 bootfs 目录添加系统 /boot 分区下的相关文件,根据需要建立 rootfs 目录添加系统文件。各文件夹命名以 Armbian 系统中的实际路径为准。用于添加新文件,或覆盖从通用文件和平台文件中添加的同名文件。

12.15.3 添加 u-boot 文件

Amlogic 系列的设备,共用 bootloader 文件和 u-boot 文件,如果有新增的文件,分别放入对应的目录。其中的 bootloader 文件在系统构建时会自动添加至 Armbian 系统的 /usr/lib/u-boot 目录,u-boot 文件会自动添加至 /boot 目录。

RockchipAllwinner 系列的设备,为每个设备添加以 BOARD 命名的独立 u-boot 文件目录,对应的系列文件放在此目录中。

构建 Armbian 镜像时,这些 u-boot 文件将根据 /etc/model_database.conf 中的配置,由 rebuild 脚本写入对应的 Armbian 镜像文件中。

12.15.4 添加流程控制文件

yml 工作流控制文件armbian_board 中添加对应的 BOARD 选项,支持在 github.com 的 Actions 中进行使用。

12.16 如何解决写入 eMMC 时 I/O 错误的问题

有些设备可以从 USB/SD/TF 正常启动 Armbian 使用,但是写入 eMMC 时会报 I/O 写入错误,例如 Issues 中的案例,报错内容如下:

[  284.338449] I/O error, dev mmcblk2, sector 0 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 2
[  284.341544] Buffer I/O error on dev mmcblk2, logical block 0, lost async page write
[  284.446972] I/O error, dev mmcblk2, sector 0 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 2
[  284.450074] Buffer I/O error on dev mmcblk2, logical block 0, lost async page write
[  284.497746] I/O error, dev mmcblk2, sector 0 op 0x1:(WRITE) flags 0x800 phys_seg 1 prio class 2
[  284.500871] Buffer I/O error on dev mmcblk2, logical block 0, lost async page write

这种情况下可以调整所使用的 dtb 的工作模式速度和频率,来稳定对存储的读写支持。使用 sdr 模式时,频率是速度的 2 倍,使用 ddr 模式时,频率等于速度。如下:

sd-uhs-sdr12
sd-uhs-sdr25
sd-uhs-sdr50
sd-uhs-ddr50
sd-uhs-sdr104

max-frequency = <208000000>;

以内核源码的 dts 文件中的代码片段举例:

/* SD card */
&sd_emmc_b {
	status = "okay";

	bus-width = <4>;
	cap-sd-highspeed;
	sd-uhs-sdr12;
	sd-uhs-sdr25;
	sd-uhs-sdr50;
	max-frequency = <100000000>;
};

/* eMMC */
&sd_emmc_c {
	status = "okay";

	bus-width = <8>;
	cap-mmc-highspeed;
	max-frequency = <100000000>;
};

一般情况下,把 &sd_emmc_c 的频率由 max-frequency = <200000000>; 下调为 max-frequency = <100000000>; 即可解决问题。如果不行可继续下调到 50000000 进行测试,并通过调整 &sd_emmc_b 来对 USB/SD/TF 进行设置,也可以使用 sd-uhs-sdr 进行限速。你可以通过修改 dts 文件并 编译 得到测试文件,也可以通过 12.13 节 中介绍的方法对已有的 dtb 文件进行反编译修改生成测试文件。反编译 dtb 文件修改时使用十六进制的值,其中十进制的 200000000 对应的十六进制为 0xbebc200,十进制的 100000000 对应的十六进制为 0x5f5e100,十进制的 50000000 对应的十六进制为 0x2faf080,十进制的 25000000 对应的十六进制为 0x17d7840

除了通过系统软件层来解决,还可以发挥 钞能力动手能力 解决。

12.17 如何解决 Bullseye 版本没有声音的问题

声音问题的错误日志信息:

Mar 29 15:47:18 armbian-ct2000 kernel:  fe.dai-link-0: ASoC: dpcm_fe_dai_prepare() failed (-22)
Mar 29 15:47:18 armbian-ct2000 kernel:  fe.dai-link-0: ASoC: no backend DAIs enabled for fe.dai-link-0

请参考 Bullseye NO Sound 中的方法进行设置。

wget https://github.com/ophub/kernel/releases/download/tools/bullseye_g12_sound-khadas-utils-4-2-any.tar.gz
tar -xzf bullseye_g12_sound-khadas-utils-4-2-any.tar.gz -C /

systemctl enable sound.service
systemctl restart sound.service

重启 Armbian 测试。如果声音仍然不工作,可能是因为你的盒子用的是旧的 conf 对应的声音输出路线,需要在 /usr/bin/g12_sound.sh 里面注释掉 L137-L142 对应的新配置(主要是给 G12B 用的,也就是 S922X,旧的 G12A/S905X2 之前,以及基于 G12A 的 SM1/S905X3 大部分用不来),然后取消 L130-L134 对应的旧配置的注释。

12.18 如何编译 boot.scr 文件

在 Armbian 系统中的 /boot 目录下,boot.scr 是用于引导系统的文件。boot.scrboot.cmd 的编译文件。boot.cmdboot.scr 的源码文件。可以通过修改 boot.cmd 文件来修改 boot.scr. 文件,然后通过 mkimage 命令编译成 boot.scr 文件。

这两个文件一般不需要修改,如果有调整需求,可以参考以下方法。

# 安装依赖
sudo apt-get update
sudo apt-get install -y u-boot-tools

# 编辑 boot.cmd 文件
cd /boot
copy /boot/boot.cmd /boot/boot.cmd.bak
copy /boot/boot.scr /boot/boot.scr.bak
nano boot.cmd

# 编译命令
mkimage -C none -A arm -T script -d boot.cmd boot.scr

# 重启测试
sync
reboot

# 补充说明
# 在 Amlogic 设备中,在 USB 中使用的是 /boot/boot.scr 文件,写入 eMMC 时使用的是 /boot/boot-emmc.scr 文件。
Clone this wiki locally