View Chinese description | 查看中文说明
The method of Use GitHub Actions to compile OpenWrt, as well as many contents in this document, come from many technical innovators and resource sharers such as P3TERX
, Flippy
, tuanqing
, etc. Because of the dedication of everyone, let us use OpenWrt in Amlogic S9xxx STB So Easy.
GitHub Actions
is a service launched by Microsoft
. It provides a virtual server environment with very good performance configuration. Based on it, projects can be built, tested, packaged, and deployed. The public repository can be used for free without time limit, and the single compilation time is up to 6 hours
, which is enough for compiling OpenWrt
(we can usually complete a compilation in about 3 hours
). Sharing is only for the exchange of experience. Please understand the deficiencies. Please do not initiate various bad attacks on the Internet, and do not maliciously use it.
- Register your own GitHub account
- Set the privacy variable GitHub_TOKEN
- Fork repository and set RELEASES_TOKEN
- Personalized OpenWrt firmware customization file description
- Compile the firmware
- Save the firmware
- Download the firmware
- Install the firmware
- Update firmware
- Personalized firmware customization update tutorial
- 10.1 Know the complete .config file
- 10.2 Know the workflow file
- 10.3 Custom banner information
- 10.4 Custom feeds configuration file
- 10.5 Custom software default configuration information
- 10.6 Opkg Package Manager
- 10.7 Manage packages using web interface
- 10.8 How to recover if the install fails and cannot be started
- 10.9 If you can’t startup after using the Mainline u-boot
- 10.10 Turn on the USB disk boot mode of the Amlogic S9xxx STB
Register your own account, so that you can continue to customize the firmware. Click the Sign up
button in the upper right corner of the giuhub.com
website and follow the prompts to register your account
.
Set the GitHub privacy variable GitHub_TOKEN
. After the firmware is compiled, we need to upload the firmware to GitHub Releases
. We set this variable according to the official requirements of GitHub. The method is as follows:
Personal center
: Settings
> Developer settings
> Personal access tokens
> Generate new token
( Name: GitHub_TOKEN
, Select: public_repo
). Other options
can be selected according to your needs. Submit and save, copy the Encrypted KEY Value
generated by the system, and save it
to your computer's notepad first. This value will be used in the next step. The icons are as follows:
Now you can Fork
the repository
, open the repository https://github.com/ophub/amlogic-s9xxx-openwrt, click the Fork
button on the upper right
, Will copy a copy of the repository code to your account, wait a few seconds
, and prompt the Fork to complete Later, go to your account to access amlogic-s9xxx-openwrt
in your repository
. In the upper right corner of Settings
> Secrets
> New repostiory secret
(Name: RELEASES_TOKEN
, Value: Fill in the value of GitHub_TOKEN
just now), save it
. The icons are as follows:
After the previous 3 steps of preparation, let's start personalized firmware customization now. Have some files in the router-config/lede-master directory. Except for the description files, the other three are files for customizing OpenWrt firmware. In this chapter, we only make the simplest instructions, so that you can experience the happiness of personalized customization with your hands. I put more complex customization operations in Section 10
, which requires you to have a little foundation.
The .config
file is the core file for personalized customization of the OpenWrt software package. It contains all the configuration information. Each line of code in the file represents a personalized configuration option. Although there are many projects, management is very simple. Let's get started.
in # National language packs, luci-i18n-base:
Take France as an example, if you enable French language support, just put
# CONFIG_PACKAGE_luci-i18n-base-fr is not set
change into
CONFIG_PACKAGE_luci-i18n-base-fr=y
All the personalized customization in the .config
file can be done in this way. For items you don't need, fill in #
at the beginning of the line, and change =y
to is not set
at the end of the line. For the items you need, remove the #
at the beginning of the line and change is not set
to =y
at the end
in #LuCI-app:
The practice of enabling and deleting the default software package is the same as above. This time we delete the luci-app-zerotier
plug-in in the default software package, just put
CONFIG_PACKAGE_luci-app-zerotier=y
change into
# CONFIG_PACKAGE_luci-app-zerotier is not set
I think you already know how to personalize the configuration. Each line of the .config
file represents a configuration item. You can use this method to enable or delete the default configuration in the firmware. The complete content of this file has several thousand lines, I provide This is only a simplified version. How to obtain a complete configuration file for more complex and personalized customization is introduced in Section 10
.
The scripts diy-part1.sh
and diy-part2.sh
are executed before and after
the update and installation
of feeds
respectively. When we introduce the OpenWrt source code library for personalized firmware compilation, sometimes we want to rewrite part of the code in the source code library, or add Some third-party software packages, delete or replace some software packages in the source code library, such as modifying the default IP, host name, theme, adding/deleting software packages
, etc., these modification instructions
to the source code library can be written to these two Script. Let's take the OpenWrt
source code library provided by coolsnowwolf
as the compilation object, to give a few examples.
Our following operations are based on this source code library: https://github.com/coolsnowwolf/lede
The first step is to add the following code to diy-part2.sh
:
git clone https://github.com/jerrykuku/luci-app-ttnode.git package/lean/luci-app-ttnode
The second step is to add the activation code of this third-party software package to the .config
file
CONFIG_PACKAGE_luci-app-ttnode=y
This completes the integration of third-party software packages and expands the software packages that are not in the current source code repository.
Replace the existing software package with the same name in the current source code library with a third-party software package. The first step is to add the following code to diy-part2.sh
:
First delete the original software package in the source code library, and Introduce a third-party package of the same name.
rm -rf package/lean/luci-theme-argon
git clone https://github.com/jerrykuku/luci-theme-argon.git package/lean/luci-theme-argon
The second step is to add third-party software packages to the .config
file.
CONFIG_PACKAGE_luci-theme-argon=y
This realizes the use of a third-party software package to replace the existing software package with the same name in the current source code library.
To achieve certain requirements by modifying the code in the source code library. We have added luci-app-cpufreq
support for aarch64
so that it can be used in our firmware (some modifications need to be cautious, you must know what you are doing).
Source file address: luci-app-cpufreq/Makefile
sed -i 's/LUCI_DEPENDS.*/LUCI_DEPENDS:=\@\(arm\|\|aarch64\)/g' package/lean/luci-app-cpufreq/Makefile
This realizes the modification of the source code.
Through diy-part1.sh
and diy-part2.sh
two scripts, we add operation commands to make more powerful functions.
The firmware compilation process is controlled in the .github/workflows/build-openwrt-lede.yml file. There are other yml files
in the workflows
directory to achieve other different functions. There are many ways to compile firmware, you can set timed compilation, manual compilation, or set some specific events to trigger compilation. Let's start with simple operations.
In the navigation bar of your repository
, click the Actions
button, and then click Build OpenWrt
> Run workflow
> Run workflow
to start the compilation, wait about 3 hours
, and complete the compilation after all the processes are over. The icons are as follows:
In the .github/workflows/build-openwrt-lede.yml file, use cron
to set the timing compilation. The 5 different positions represent min (0 - 59) / hour (0 - 23) / day of month (1 - 31) / month (1 - 12) / day of week (0 - 6)(Sunday - Saturday). Set the time by modifying the values of different positions. The system uses UTC standard time
by default, please convert it according to the time zone of your country.
schedule:
- cron: '0 17 * * *'
The settings saved by the firmware are also controlled in the .github/workflows/build-openwrt-lede.yml file. We will automatically upload the compiled firmware to the Actions
and Releases
officially provided by GitHub
through scripts, or upload it to a third party
(such as WeTransfer).
Now the longest storage period of Actions in GitHub is 90 days
, Releases is permanent
, and third parties such as WeTransfer are 7 days. First of all, we thank these service providers for their free support, but we also ask you to use it sparingly. We advocate the reasonable use of free services.
- name: Upload artifact to Actions
uses: kittaakos/upload-artifact-as-is@master
if: steps.build.outputs.status == 'success' && env.UPLOAD_FIRMWARE == 'true' && !cancelled()
with:
path: ${{ env.FILEPATH }}/
- name: Upload OpenWrt Firmware to Release
uses: ncipollo/release-action@v1
if: steps.build.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
tag: openwrt_s9xxx_${{ env.FILE_DATE }}
artifacts: ${{ env.FILEPATH }}/*
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
body: |
This is OpenWrt firmware for Amlogic S9xxx STB
* Firmware information
Default IP: 192.168.1.1
Default username: root
Default password: password
Default WIFI name: OpenWrt
Default WIFI password: none
Install to EMMC: Login to OpenWrt → System → Amlogic Service → Install OpenWrt
- name: Upload OpenWrt Firmware to WeTransfer
if: steps.build.outputs.status == 'success' && env.UPLOAD_WETRANSFER == 'true' && !cancelled()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer wet -s -p 16 --no-progress ${{ env.FILEPATH }}/{openwrt_s9xxx_*,openwrt_n1_*} 2>&1 | tee wetransfer.log
echo "WET_URL=$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_ENV
Download our compiled openwrt firmware.
Click the Actions
button in the repository navigation bar
. In the All workflows
list, click the compiled firmware list. In the firmware list inside, select the firmware corresponding to the model of your Amlogic S9xxx STB
. The icons are as follows:
Enter from the GitHub Releases
section at the bottom right corner of the repository homepage
, and select the firmware corresponding to the model of your Amlogic S9xxx STB
. The icons are as follows:
In the .github/workflows/build-openwrt-lede.yml file, upload to the third party is closed by default. If you need, change false
to true
, and upload to the third party when the compilation is completed next time. The third-party URL can be seen in the log
of the firmware compilation process, and can also be output to the compilation information.
UPLOAD_COWTRANSFER: false
UPLOAD_WETRANSFER: false
The support for uploading to a third party comes from Mikubill/transfer. If you need it, you can add more third-party support according to his instructions (control your creativity and don't waste too many free resources). The icons are as follows:
svn co https://github.com/ophub/luci-app-amlogic/trunk/luci-app-amlogic package/luci-app-amlogic
- Execute make
menuconfig
and selectluci-app-amlogic
underLuCI ---> 3. Applications ---> <*> luci-app-amlogic
For more instructions on the plug-in, see:https://github.com/ophub/luci-app-amlogic
Choose the corresponding firmware according to your STB. Then write the IMG file to the USB hard disk through software such as Rufus or balenaEtcher. Insert the USB hard disk into the STB.
Log in to the default IP: 192.168.1.1
→ Login in to openwrt
→ system menu
→ Amlogic Service
→ Install OpenWrt
Log in to the default IP: 192.168.1.1
→ Login in to openwrt
→ system menu
→ TTYD terminal
→ input command:
openwrt-install-amlogic
When writing into EMMC through openwrt-install-amlogic
, select the name
of the Amlogic S9xxx STB you own in the menu.
For more OpenWrt firmware .dtb files are in the amlogic-dtb directory. You can use the openwrt_s905x3_v*.img
firmware to install via USB hard disk. When writing into EMMC through openwrt-install-amlogic
, select 0: Enter the dtb file name of your box, and use the Amlogic S9xxx STB you own.
Log in to your OpenWrt system
, under the System
menu, select the Amlogic Service
, select the Update OpenWrt
to update. (You can update from a higher version such as 5.10.70 to a lower version such as 5.4.150, or from a lower version such as 5.4.150 to a higher version such as 5.10.70. The kernel version number does not affect the update, and you can freely update/downgrade
.)
Log in to your OpenWrt system
→ under the System
menu → Amlogic Service
→ upload openwrt*.img.gz (Support suffix: *.img.xz, *.img.gz, *.7z, *.zip)
to /mnt/mmcblk*p4/
, enter the system menu
→ TTYD terminal
→ input command:
openwrt-update-amlogic
💡Tips: You can also put the update file
in the /mnt/mmcblk*p4/
directory, the openwrt-update-amlogic
script will automatically find the update file
from the /mnt/mmcblk*p4/
directories.
If there is only one update file
in the /mnt/mmcblk*p4/
directory, you can just enter the openwrt-update-amlogic
command without specifying a specific update file
. The openwrt-update-amlogic
script will vaguely look for update file
from this directory and try to update. If there are multiple update file
in the /mnt/mmcblk*p4/
directory, please use the openwrt-update-amlogic openwrt_s905x3_v5.4.150_2021.03.17.0412.img.gz
command to specify the update file
.
- The
openwrt-update-amlogic
update file search order
Directory | /mnt/mmcblk*p4/ 1-6 |
---|---|
Oeder | specified_update_file → *.img → *.img.xz → *.img.gz → *.7z → *.zip → |
- Log in to the default IP: 192.168.1.1 →
Login in to openwrt
→system menu
→Amlogic Service
→ Upload kernel package(There are 3 files:boot-*,dtb-amlogic-*,modules-*)
to/mnt/mmcblk*p4/
, enter thesystem menu
→TTYD terminal
→ input the Kernel replacement command:
openwrt-kernel
💡Tips: You can also put the kernel files
in the /mnt/mmcblk*p4/
directory, the openwrt-kernel
script will automatically find the kernel file
from the /mnt/mmcblk*p4/
directories.
Replacing the OpenWrt kernel is only a kernel replacement, and the various personalized configurations of the firmware remain unchanged. It is the easiest way to update. Support replacement of kernel high/low version.
If you see this step in the tutorial, I believe you already know how to play happily. If you don’t continue to read what is said later, I believe you will not be at ease. But, but ah, if you continue to explore in depth, you will start an extraordinary journey of tossing. You will encounter a lot of problems. This requires you to be prepared for continuous exploration, and you must be good at using search engines
to solve problems. The time can go to various OpenWrt communities
to learn.
Use the official source code library of OpenWrt
or the source code library of other branches to perform a localized compilation
. For example, select the source code library of coolsnowwolf/lede, and install the Ubuntu system
locally and deploy the environment according to its compilation instructions. And complete a local compilation
. In the local compilation configuration interface, you can also see a lot of rich instructions, which will strengthen your understanding of the OpenWrt compilation process.
After you complete the OpenWrt personalized configuration
locally, save and exit
the configuration interface. You can find the .config
file in the root directory of the local OpenWrt source code library. You can upload this file directly to your repository on github.com
, Replace the router-config/lede-master/.config
file.
The official GitHub gave a detailed explanation. Regarding the use of GitHub Actions
, you can start to get to know it from here: Quickstart for GitHub Actions
Let’s make a few brief introductions based on the files being used in the repository: build-openwrt-lede.yml
#On Line 24: Source code library address
REPO_URL: https://github.com/coolsnowwolf/lede
#On Line 25: Branch name
REPO_BRANCH: master
You can modify it to other, such as official:
REPO_URL: https://github.com/openwrt/openwrt
REPO_BRANCH: openwrt-19.07
Near line 153, find Build OpenWrt firmware
, Code snippet like this:
- name: Build OpenWrt firmware
if: steps.compile.outputs.status == 'success' && env.UPLOAD_FIRMWARE == 'true' && !cancelled()
id: build
run: |
[ -d openwrt-armvirt ] || mkdir -p openwrt-armvirt
cp -f openwrt/bin/targets/*/*/*.tar.gz openwrt-armvirt/ && sync
sudo rm -rf openwrt && sync
sudo rm -rf /workdir && sync
sudo chmod +x make
sudo ./make -d -b s905x3_s905x2_s905x_s905d_s922x_s912 -k 5.10.70_5.4.150
cd out/ && sudo gzip *.img
cp -f ../openwrt-armvirt/*.tar.gz . && sync
echo "FILEPATH=$PWD" >> $GITHUB_ENV
echo "::set-output name=status::success"
Modify the -d parameter to the model of your STB, and modify the value after the -k parameter to the version number of the kernel you want to compile:
sudo ./make -d -b s905x -k 5.4.150
. Optional parameters and usage method see: Detailed make compile command
The default banner information is as follows, You can modify this file to customize your own personalized banner information. Put your finished banner file into the etc/banner directory and it will be automatically replaced during compilation.
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
%D %V, %C
-----------------------------------------------------
When you look at the feeds.conf.default
file in the source code repository
, do you find that there are a lot of package libraries introduced here? You understand that right, we can find the source code library officially provided by OpenWrt on GitHub, as well as the branches of OpenWrt shared by many people. If you know them, you can add them from here. For example, feeds.conf.default in the coolsnowwolf
source code library.
When we use OpenWrt
, we have already configured many software. Most of the configuration information
of these software is stored in your OpenWrt's /etc/config/
and other related directories. Copy the storage files of these configuration information to In the files
folder under the root directory of the repository in GitHub
, please keep the directory structure and files the same
. During OpenWrt compilation, the storage files of these configuration information will be compiled into your firmware. The specific method is in the .github/workflows/build-openwrt-lede.yml file. Let's take a look at this code together:
- name: Load custom configuration
run: |
[ -e files ] && mv files openwrt/files
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
chmod +x $DIY_P2_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P2_SH
Please do not copy the configuration information files that involve privacy
. If your repository is public
, then the files you put in the files
directory are also public
. Do not disclose the secrets. Some passwords and other information can be used using the private key settings
you just learned in Quickstart for GitHub Actions. You must understand what you are doing.
Like most Linux distributions (or mobile device operating systems like say Android or iOS), the functionality of the system can be upgraded rather significantly by downloading and installing pre-made packages from package repositories (local or on the Internet).
The opkg utility is the lightweight package manager used for this job. which is designed to add software to stock firmware of embedded devices. Opkg is a full package manager for the root file system, including kernel modules and drivers.
The package manager opkg attempts to resolve dependencies with packages in the repositories - if this fails, it will report an error and abort the installation of that package.
Missing dependencies with third-party packages are probably available from the source of the package.
To ignore dependency errors, pass the --force-depends
flag.
-
If you are using a snapshot / trunk / bleeding edge version, installing packages may fail if the package in the repository is for a newer kernel version than the kernel version you have. In this case, you will get the error message “Cannot satisfy the following dependencies for…”. For such usage of OpenWrt firmware,
it's warmly recommended to use the Image Builder to make a flashable image containing all packages you need
. -
Non-openwrt.org official plug-ins, such as
luci-app-uugamebooster
,luci-app-xlnetacc
, etc., need to be personalized during firmware compilation. These packages cannot be directly installed from the mirror server using opkg, But you can manuallyupload to openwrt and use opkg to install
. -
When on trunk/snapshot, kernel and kmod packages are flagged as hold, the
opkg upgrade
command won't attempt to update them.
Common commands:
opkg update #Update list of available packages
opkg upgrade <pkgs> #Upgrade packages
opkg install <pkgs> #Install package(s)
opkg install --force-reinstall <pkgs> #Force reinstall package(s)
opkg configure <pkgs> #Configure unpacked package(s)
opkg remove <pkgs | regexp> #Remove package(s)
opkg list #List available packages
opkg list-installed #List installed packages
opkg list-upgradable #List installed and upgradable packages
opkg list | grep <pkgs> #Find similar packages names
For more instructions please see: opkg
After you have flashed the OpenWrt firmware to your device, you can install additional software packages via WebUI.
- Navigate to LuCI → System → Software.
- Click Update lists button to fetch a list of available packages.
- Fill in Filter field and click Find package button to search for a specific package.
- Switch to Available packages tab to show and install available packages.
- Switch to Installed packages tab to show and remove installed packages.
Search and install luci-app-*
packages if you want to configure services using LuCI.
For more instructions please see: packages
-
Under normal circumstances, re-insert the USB hard disk and install it again.
-
If you cannot start the OpenWrt system from the USB hard disk again, connect the Amlogic S9xxx STB to the computer monitor. If the screen is completely black and there is nothing, you need to restore the Amlogic S9xxx STB to factory settings first, and then reinstall it.
Take x96max+ as an example.
Prepare materials:
1. [ A USB male-to-male data cable ]: https://www.ebay.com/itm/152516378334
2. [ A paper clip ]: https://www.ebay.com/itm/133577738858
3. Install the software and Download the Android TV firmware
[ Install the USB_Burning_Tool ]: https://androidmtk.com/download-amlogic-usb-burning-tool
[ Android TV firmware ]: https://xdafirmware.com/x96-max-plus-2
4. [ Find the two short-circuit points on the motherboard ]:
https://user-images.githubusercontent.com/68696949/110590933-67785300-81b3-11eb-9860-986ef35dca7d.jpg
Operation method:
1. Connect the [ Amlogic S9xxx STB ] to the [ computer ] with a [ USB male-to-male data cable ].
2. Open the USB Burning Tool:
[ File → Import image ]: X96Max_Plus2_20191213-1457_ATV9_davietPDA_v1.5.img
[ Check ]:Erase flash
[ Check ]:Erase bootloader
Click the [ Start ] button
3. Use a [ paper clip ] to [ connect the two short-circuit points ] on the motherboard at the same time.
If the progress bar does not respond after the short-circuit, plug in the [ power ] supply after the short-circuit.
Generally, there is no need to plug in the power supply.
4. Loosen the short contact after seeing the [ progress bar moving ].
5. After the [ progress bar is 100% ], the restoration of the original Android TV system is completed.
Click [ stop ], unplug the [ USB male-to-male data cable ] and [ power ].
6. If the progress bar is interrupted, repeat the above steps until it succeeds.
After restoring the factory settings, the operation method is the same as when you install openwrt on the Amlogic S9xxx STB for the first time:
- Make an openwrt mirrored usb hard disk and insert it into the USB port of the Amlogic S9xxx STB. Use a paper clip or other objects to press and hold the reset button in the AV hole, plug in the power, wait 5 seconds and then release the reset button, the system will boot from the USB hard disk, enter the openwrt system, enter The installation command can reinstall openwrt.
- Some Amlogic S905x3 STB sometimes fail to boot after use the
mainline u-boot
. The fault phenomenon is usually the=>
prompt of u-boot automatically. The reason is that TTL lacks a pull-up resistor or pull-down resistor and is easily interfered by surrounding electromagnetic signals. The solution is to solder a 5K-10K resistor (pull-down) between TTL RX and GND, or solder a resistor between RX and 3.3V. A resistance of 5K-10K (pull-up).
If you choose to use the mainline u-boot
during installation and it fails to start, please connect the Amlogic S905x3 STB to the monitor. If the screen shows the following prompt:
Net: eth0: ethernet0ff3f0000
Hit any key to stop autoboot: 0
=>
You need to install a resistor on the TTL: X96 Max Plus's V4.0 Motherboard
####################################################### #####################################################
# # # #
# Resistor (pull-down): between TTL's RX and GND # # Resistor (pull-up): between TTL's 3.3V and RX #
# # # #
# 3.3V RX TX GND # OR # 3.3V RX TX GND #
# ┖————█████████————┚ # # ┖————█████████————┚ #
# Resistor (5~10K) # # Resistor (5~10K) #
# # # #
####################################################### #####################################################
- Open the developer mode: Settings → About this machine → Version number (for example: X96max plus...), click on the version number for 7 times in quick succession, and you will see that the developer mode is turned on.
- Turn on USB debugging: After restarting, enter Settings → System → Advanced options → Developer options again (after entering, confirm that the status is on, and the USB debugging status in the list is also on)
- Boot from USB hard disk: Unplug the power → insert the USB hard disk → insert the thimble into the AV port (top reset button) → insert the power → release the thimble of the av port → the system will boot from the USB hard disk.
- Log in to the system: Connect the computer and the s9xxx box with a network interface → turn off the wireless wifi on the computer → enable the wired connection → manually set the computer ip to the same network segment ip as openwrt, ipaddr such as
192.168.1.2
. The netmask is255.255.255.0
, and others are not filled in. You can log in to the openwrt system from the browser, Enter OpwnWrt's IP Address:192.168.1.1
, Account:root
, Password:password
, and then log in OpenWrt system.