Skip to content

Commit

Permalink
Change the kernel repository
Browse files Browse the repository at this point in the history
  • Loading branch information
ophub committed Nov 12, 2021
1 parent bdc011f commit 0dbaab9
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 103 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-armbian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ jobs:
if: steps.build.outputs.status == 'success'
run: |
sudo chmod +x make
sudo ./make s922x_s922x-n2_s905x3_s905x2_s912_s905d 5.10.70_5.4.150
sudo ./make s905x_s905w 5.4.150
sudo ./make -d -b s922x_s922x-n2_s905x3_s905x2_s912_s905d -k 5.10.70_5.4.150
sudo ./make -d -b s905x_s905w -k 5.4.150
cd ./build/output/images && sudo gzip *.img && sync
echo "FILEPATH=$PWD" >> $GITHUB_ENV
echo "FILE_DATE=$(date +"%Y.%m.%d.%H%M")" >> $GITHUB_ENV
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/use-releases-file-to-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
[ -s DOWNLOAD_ARMBIAN ] && wget -q -P build/output/images https://github.com/${GITHUB_REPOSITORY}/releases/download/$(cat DOWNLOAD_ARMBIAN)
cd ./build/output/images && gzip -df *.img.gz && sync && cd ../../../
sudo chmod +x make
sudo ./make s922x_s922x-n2_s905x3_s905x2_s912_s905d 5.10.70_5.4.150
sudo ./make s905x_s905w 5.4.150
sudo ./make -d -b s922x_s922x-n2_s905x3_s905x2_s912_s905d -k 5.10.70_5.4.150
sudo ./make -d -b s905x_s905w -k 5.4.150
cd ./build/output/images && sudo gzip *.img && sync
echo "FILEPATH=$PWD" >> $GITHUB_ENV
echo "FILE_DATE=$(date +"%Y.%m.%d.%H%M")" >> $GITHUB_ENV
Expand Down
31 changes: 24 additions & 7 deletions README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ armbian-install
armbian-update 5.10.66
```

默认从 [stable](https://github.com/ophub/kernel/tree/main/pub/stable) 内核版本分支下载,如果下载其他 [版本分支](https://github.com/ophub/kernel/tree/main/pub) 的内核,请在第 `2` 个参数中根据分支文件夹名称指定,如 `armbian-update 5.7.2 beta`

默认自动安装主线 u-boot,可以更好的支持 5.10 及以上内核系列的使用。如果选择不安装,请在第 `3` 个输入参数中指定,如 `armbian-update 5.10.66 stable no`

- ### 安装 Docker 服务

登录 Armbian 系统 → 输入命令:
Expand Down Expand Up @@ -114,13 +118,26 @@ armbian-tf
```
</details>

## Armbian 固件制作方法

- 不同的 Amlogic armbian 固件,使用对应的 soc 代码生成。 请根据你的盒子的 soc 型号进行选择。支持 `s922x``s922x-n2``s905x3``s905x2``s912``s905d``s905x``s905w` 。说明:`s922x-n2``s922x-odroid-n2`

- 编译单个盒子的 Armbian 时,输入对应的 soc 型号,如 `sudo ./make s905x3`。 如果同时编译多个不同盒子时,将对应的 soc 型号使用 `_` 连接, 如 `sudo ./make s922x_s905x3`

- 可选项: 替换内核。如 `sudo ./make s905x 5.4.150`。当一次编译多个内核版本时,内核版本号使用 `_` 连接。如 `sudo ./make s922x_s905x3 5.10.70_5.4.150`。编译程序会自动到 [内核库](https://github.com/ophub/flippy-kernel/tree/main/library) 中查找你指定的内核系列是否有更新的版本,如果有则直接使用最新版。如果你想使用指定的固定版本,可以在版本号后使用 false 参数固定版本,如 `sudo ./make s905x 5.4.150 false`
## 打包命令的相关参数说明

- `sudo ./make -d -b s905x3 -k 5.4.150` : 推荐使用. 使用默认配置进行相关内核打包。
- `sudo ./make -d -b s905x3_s905d -k 5.10.70_5.4.150` : 使用默认配置,进行多个内核同时打包。使用 `_` 进行多内核参数连接。
- `sudo ./make -d` : 使用默认配置,使用内核库中的最新内核包,对全部型号的机顶盒进行打包。
- `sudo ./make -d -b s905x3 -k 5.4.150 -s 1024` : 使用默认配置,指定一个内核,一个型号进行打包,固件大小设定为1024M。
- `sudo ./make -d -b s905x3 -v beta -k 5.7.2` : 使用默认配置,指定型号,指定版本分支,指定内核进行打包。
- `sudo ./make -d -b s905x3_s905d` 使用默认配置,对多个型号的机顶盒进行全部内核打包, 使用 `_` 进行多型号连接。
- `sudo ./make -d -k 5.10.70_5.4.150` : 使用默认配置,指定多个内核,进行全部型号机顶盒进行打包, 内核包使用 `_` 进行连接。
- `sudo ./make -d -k 5.10.70_5.4.150 -a true` : 使用默认配置,指定多个内核,进行全部型号机顶盒进行打包, 内核包使用 `_` 进行连接。自动升级到同系列最新内核。
- `sudo ./make -d -s 1024 -k 5.4.150` : 使用默认配置,设置固件大小为 1024M, 并指定内核为 5.4.150 ,对全部型号机顶盒进行打包。

| 参数 | 含义 | 说明 |
| ---- | ---- | ---- |
| -d | Defaults | 使用默认配置 |
| -b | Build | 指定机顶盒型号,如 `-b s905x3` . 多个型号使用 `_` 进行连接,如 `-b s905x3_s905d` . 可以指定的型号有: `s905x3`, `s905x2`, `s905x`, `s905w`, `s905d`, `s922x`, `s922x-n2`, `s912`。说明:`s922x-n2``s922x-odroid-n2` |
| -v | Version | 指定内核 [版本分支](https://github.com/ophub/kernel/tree/main/pub) 名称,如 `-v stable` 。指定的名称须与分支目录名称相同。默认使用 `stable` 分支版本。 |
| -k | Kernel | 指定 [kernel](https://github.com/ophub/kernel/tree/main/pub/stable) 名称,如 `-k 5.4.150` . 多个内核使用 `_` 进行连接,如 `-k 5.10.70_5.4.150` |
| -a | AutoKernel | 设置是否自动采用同系列最新版本内核。当为 `true` 时,将自动在内核库中查找在 `-k` 中指定的内核如 5.4.150 的 5.4 同系列是否有更新的版本,如有 5.4.150 之后的最新版本时,将自动更换为最新版。设置为 `false` 时将编译指定版本内核。默认值:`true` |
| -s | Size | 对固件的大小进行设置,默认大小为 1024M, 固件大小必须大于 256M. 例如: `-s 1024` |

💡提示:当前 ***`s905x`******`s905w`*** 系列的盒子只支持使用 `5.4.*` 内核,不能使用 5.10.* 或更高版本,请在编译时指定替换内核。其他型号的盒子可任选内核版本使用。

Expand Down
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Query the available [kernel_version](https://github.com/ophub/flippy-kernel/tree
armbian-update 5.10.66
```

By default, download from [stable](https://github.com/ophub/kernel/tree/main/pub/stable) kernel version branch, if you download other [version branch](https://github.com/ophub/kernel/tree/main/pub), please specify according to the branch folder name in the `second` parameter, such as `armbian-update 5.7.2 beta`

The mainline u-boot is automatically installed by default, which can better support the use of kernel series 5.10 and above. If you choose not to install, please specify in the `third` input parameter, such as `armbian-update 5.10.66 stable no`

- ### Install Docker Service

Login in to armbian → input command:
Expand Down Expand Up @@ -114,13 +118,26 @@ Command: Enter [ vi /etc/fstab ]
```
</details>

## Armbian firmware make method

- Different amlogic armbian firmware, use the corresponding soc code to generate. Please choose according to your box soc model. Supported soc are `s922x`, `s922x-n2`, `s905x3`, `s905x2`, `s912`, `s905d`, `s905x`, `s905w`. Note: `s922x-n2` is `s922x-odroid-n2`.

- compile `a single soc` can be directly input `sudo ./make s905x3`. When `multiple soc` is compiled at the same time, please use `_` to connect multiple soc, such as `sudo ./make s922x_s905x3`

- Optionality: Replace the kernel. Run Eg: `sudo ./make s905x 5.4.150`. When multiple kernel versions are generated at one time, the kernel version number is connected with `_` . Run Eg: `sudo ./make s922x_s905x3 5.10.70_5.4.150`. When there is an latest version of the same series of the specified kernel version, the `latest version` will be download from [kernel library](https://github.com/ophub/flippy-kernel/tree/main/library) and used automatically. When you want to compile a `fixed kernel`, Run `sudo ./make s905x 5.4.150 false`.
## Detailed make compile command

- `sudo ./make -d -b s905x3 -k 5.4.150`: recommend. Use the default configuration, specify a kernel and a firmware for compilation.
- `sudo ./make -d -b s905x3_s905d -k 5.10.70_5.4.150`: Use the default configuration, specify multiple cores, and multiple firmware for compilation. use `_` to connect.
- `sudo ./make -d`: Compile latest kernel versions of openwrt for all SoC with the default configuration.
- `sudo ./make -d -b s905x3 -k 5.4.150 -s 1024`: Use the default configuration, specify a kernel, a firmware, and set the partition size for compilation.
- `sudo ./make -d -b s905x3 -v beta -k 5.7.2`: Use the default configuration, specify the model, specify the version branch, and specify the kernel for packaging.
- `sudo ./make -d -b s905x3_s905d`: Use the default configuration, specify multiple firmware, use `_` to connect. compile all kernels.
- `sudo ./make -d -k 5.10.70_5.4.150`: Use the default configuration. Specify multiple cores, use `_` to connect.
- `sudo ./make -d -k 5.10.70_5.4.150 -a true`: Use the default configuration. Specify multiple cores, use `_` to connect. Auto update to the latest kernel of the same series.
- `sudo ./make -d -s 1024 -k 5.4.150`: Use the default configuration and set the partition size to 1024m, and only compile the openwrt firmware with the kernel version 5.4.150.

| Parameter | Meaning | Description |
| ---- | ---- | ---- |
| -d | Defaults | Compile all cores and all firmware types. |
| -b | Build | Specify the Build firmware type. Write the build firmware name individually, such as `-b s905x3` . Multiple firmware use `_` connect such as `-b s905x3_s905d` . You can use these codes: `s905x3`, `s905x2`, `s905x`, `s905w`, `s905d`, `s922x`, `s922x-n2`, `s912`. Note: `s922x-n2` is `s922x-odroid-n2`. |
| -v | Version | Specify the name of the kernel [version branch](https://github.com/ophub/kernel/tree/main/pub), Such as `-v stable`. The specified name must be the same as the branch directory name. The `stable` branch version is used by default. |
| -k | Kernel | Specify the [kernel](https://github.com/ophub/kernel/tree/main/pub/stable) name. Write the kernel name individually such as `-k 5.4.150` . Multiple kernel use `_` connection such as `-k 5.10.70_5.4.150` |
| -a | AutoKernel | Set whether to automatically adopt the latest version of the kernel of the same series. When it is `true`, it will automatically find in the kernel library whether there is an updated version of the kernel specified in `-k` such as 5.4.150 version. If there is the latest version of 5.4 same series, it will automatically Replace with the latest version. When set to `false`, the specified version of the kernel will be compiled. Default value: `true` |
| -s | Size | Specify the size of the root partition in MB. The default is 1024, and the specified size must be greater than 256. Such as `-s 1024` |

💡Tips: The ***`s905x`*** and ***`s905w`*** boxs currently only support `5.4.*` kernels, Cannot use kernel version 5.10 and above. Please add kernel substitution variables when compiling these two models of devices. Other devices can be freely selected.

Expand Down
232 changes: 147 additions & 85 deletions make
Original file line number Diff line number Diff line change
Expand Up @@ -18,91 +18,18 @@ tmp_armbian=${make_path}/tmp_armbian
tmp_build=${make_path}/tmp_build
tmp_aml_image=${make_path}/tmp_aml_image

kernel_library="https://github.com/ophub/flippy-kernel/tree/main/library"
#kernel_library="https://github.com/ophub/flippy-kernel/trunk/library"
kernel_library="https://github.com/ophub/kernel/tree/main/pub"
#kernel_library="https://github.com/ophub/kernel/trunk/pub"
version_branch="stable"

build_armbian=("s922x" "s922x-n2" "s905x3" "s905x2" "s912" "s905d" "s905x" "s905w")
build_kernel=("default")
change_kernel="no"
#===== Do not modify the following parameter settings, End =======

# Specify Amlogic soc
if [ -n "${1}" ]; then
unset build_armbian
oldIFS=$IFS
IFS=_
build_armbian=(${1})
IFS=$oldIFS
fi

# Set whether to replace the kernel
if [ -n "${2}" ]; then
auto_kernel="${3}"
change_kernel="yes"
unset build_kernel
oldIFS=$IFS
IFS=_
build_kernel=(${2})
IFS=$oldIFS

# Convert kernel library address to svn format
if [[ ${kernel_library} == http* && $(echo ${kernel_library} | grep "tree/main") != "" ]]; then
kernel_library=${kernel_library//tree\/main/trunk}
fi

# Check the new version on the kernel library
if [[ -z "${auto_kernel}" || "${auto_kernel}" != "false" ]]; then

# Set empty array
TMP_ARR_KERNELS=()

# Convert kernel library address to API format
SERVER_KERNEL_URL=${kernel_library#*com\/}
SERVER_KERNEL_URL=${SERVER_KERNEL_URL//trunk/contents}
SERVER_KERNEL_URL="https://api.github.com/repos/${SERVER_KERNEL_URL}"

# Query the latest kernel in a loop
i=1
for KERNEL_VAR in ${build_kernel[*]}; do
echo -e "(${i}) Auto query the latest kernel version of the same series for [ ${KERNEL_VAR} ]"
MAIN_LINE_M=$(echo "${KERNEL_VAR}" | cut -d '.' -f1)
MAIN_LINE_V=$(echo "${KERNEL_VAR}" | cut -d '.' -f2)
MAIN_LINE_S=$(echo "${KERNEL_VAR}" | cut -d '.' -f3)
MAIN_LINE="${MAIN_LINE_M}.${MAIN_LINE_V}"
# Check the version on the server (e.g LATEST_VERSION="124")
LATEST_VERSION=$(curl -s "${SERVER_KERNEL_URL}" | grep "name" | grep -oE "${MAIN_LINE}.[0-9]+" | sed -e "s/${MAIN_LINE}.//g" | sort -n | sed -n '$p')
if [[ "$?" -eq "0" && ! -z "${LATEST_VERSION}" ]]; then
TMP_ARR_KERNELS[${i}]="${MAIN_LINE}.${LATEST_VERSION}"
else
TMP_ARR_KERNELS[${i}]="${KERNEL_VAR}"
fi
echo -e "(${i}) [ ${TMP_ARR_KERNELS[$i]} ] is latest kernel. \n"

let i++
done
auto_kernel="ture"

# Reset the kernel array to the latest kernel version
unset build_kernel
build_kernel=${TMP_ARR_KERNELS[*]}

fi

# Synchronization related kernel
i=1
for KERNEL_VAR in ${build_kernel[*]}; do
if [ ! -d "${kernel_path}/${KERNEL_VAR}" ]; then
echo -e "(${i}) [ ${KERNEL_VAR} ] Kernel loading from [ ${kernel_library}/${KERNEL_VAR} ]"
svn checkout ${kernel_library}/${KERNEL_VAR} ${kernel_path}/${KERNEL_VAR} >/dev/null
rm -rf ${kernel_path}/${KERNEL_VAR}/.svn >/dev/null && sync
else
echo -e "(${i}) [ ${KERNEL_VAR} ] Kernel is in the local directory."
fi

let i++
done

sync
fi
SKIP_MB=68
BOOT_MB=256
ROOT_MB=2748
#===== Do not modify the following parameter settings, End =======

die() {
echo -e " [\033[1;31m Error \033[0m] ${1}"
Expand All @@ -113,6 +40,64 @@ process() {
echo -e " [\033[1;32m ${build_soc}${out_kernel} \033[0m] ${1}"
}

download_kernel() {
cd ${make_path}

# Convert kernel library address to svn format
if [[ ${kernel_library} == http* && $(echo ${kernel_library} | grep "tree/main") != "" ]]; then
kernel_library="${kernel_library//tree\/main/trunk}"
fi
kernel_library="${kernel_library}/${version_branch}"

# Set empty array
TMP_ARR_KERNELS=()

# Convert kernel library address to API format
SERVER_KERNEL_URL=${kernel_library#*com\/}
SERVER_KERNEL_URL=${SERVER_KERNEL_URL//trunk/contents}
SERVER_KERNEL_URL="https://api.github.com/repos/${SERVER_KERNEL_URL}"

# Query the latest kernel in a loop
i=1
for KERNEL_VAR in ${build_kernel[*]}; do
echo -e "(${i}) Auto query the latest kernel version of the same series for [ ${KERNEL_VAR} ]"
MAIN_LINE_M=$(echo "${KERNEL_VAR}" | cut -d '.' -f1)
MAIN_LINE_V=$(echo "${KERNEL_VAR}" | cut -d '.' -f2)
MAIN_LINE_S=$(echo "${KERNEL_VAR}" | cut -d '.' -f3)
MAIN_LINE="${MAIN_LINE_M}.${MAIN_LINE_V}"
# Check the version on the server (e.g LATEST_VERSION="124")
LATEST_VERSION=$(curl -s "${SERVER_KERNEL_URL}" | grep "name" | grep -oE "${MAIN_LINE}.[0-9]+" | sed -e "s/${MAIN_LINE}.//g" | sort -n | sed -n '$p')
if [[ "$?" -eq "0" && ! -z "${LATEST_VERSION}" ]]; then
TMP_ARR_KERNELS[${i}]="${MAIN_LINE}.${LATEST_VERSION}"
else
TMP_ARR_KERNELS[${i}]="${KERNEL_VAR}"
fi
echo -e "(${i}) [ ${TMP_ARR_KERNELS[$i]} ] is latest kernel. \n"

let i++
done

# Reset the kernel array to the latest kernel version
unset build_kernel
build_kernel=${TMP_ARR_KERNELS[*]}

# Synchronization related kernel
i=1
for KERNEL_VAR in ${build_kernel[*]}; do
if [ ! -d "${kernel_path}/${KERNEL_VAR}" ]; then
echo -e "(${i}) [ ${KERNEL_VAR} ] Kernel loading from [ ${kernel_library}/${KERNEL_VAR} ]"
svn checkout ${kernel_library}/${KERNEL_VAR} ${kernel_path}/${KERNEL_VAR} >/dev/null
rm -rf ${kernel_path}/${KERNEL_VAR}/.svn >/dev/null && sync
else
echo -e "(${i}) [ ${KERNEL_VAR} ] Kernel is in the local directory."
fi

let i++
done

sync
}

make_image() {
cd ${make_path}

Expand All @@ -135,9 +120,6 @@ make_image() {
rm -f ${build_image_file}
sync

SKIP_MB=68
BOOT_MB=256
ROOT_MB=2748
IMG_SIZE=$((SKIP_MB + BOOT_MB + ROOT_MB))

dd if=/dev/zero of=${build_image_file} bs=1M count=${IMG_SIZE} conv=fsync >/dev/null 2>&1
Expand Down Expand Up @@ -179,7 +161,7 @@ extract_armbian() {

replace_kernel() {
# Replace if specified
if [[ "${change_kernel}" == "yes" ]]; then
if [[ "${auto_kernel}" == "ture" && ! "${build_kernel[*]}" =~ "default" ]]; then
cd ${make_path}

build_boot=$( ls ${kernel_path}/${new_kernel}/boot-${new_kernel}-*.tar.gz 2>/dev/null | head -n 1 )
Expand Down Expand Up @@ -421,9 +403,89 @@ clean_tmp() {
sync
}


[ $(id -u) = 0 ] || die "please run this script as root: [ sudo ./make ]"
echo -e "Welcome to build armbian for amlogic s9xxx STB! \n"
echo -e "Server space usage before starting to compile: \n$(df -hT ${PWD}) \n"

while [ "${1}" ]; do
case "${1}" in
-d | --default)
: ${version_branch:="${version_branch}"}
: ${build_armbian:="${build_armbian}"}
: ${build_kernel:="${build_kernel}"}
: ${ROOT_MB:="${ROOT_MB}"}
;;
-b | --build)
if [ -n "${2}" ]; then
unset build_armbian
oldIFS=$IFS
IFS=_
build_armbian=(${2})
IFS=$oldIFS
shift
else
die "Invalid build [ ${2} ]!"
fi
;;
-k)
if [ -n "${2}" ]; then
oldIFS=$IFS
IFS=_
build_kernel=(${2})
IFS=$oldIFS
shift
else
die "Invalid kernel [ ${2} ]!"
fi
;;
-a | --autokernel)
if [ -n "${2}" ]; then
oldIFS=$IFS
IFS=_
auto_kernel="${2}"
IFS=$oldIFS
shift
else
die "Invalid kernel [ ${2} ]!"
fi
;;
-v | --versionbranch)
if [ -n "${2}" ]; then
oldIFS=$IFS
IFS=_
version_branch="${2}"
IFS=$oldIFS
shift
else
die "Invalid kernel [ ${2} ]!"
fi
;;
-s | --size)
if [[ -n "${2}" && "${2}" -ge "256" ]]; then
oldIFS=$IFS
IFS=_
ROOT_MB="${2}"
IFS=$oldIFS
shift
else
die "Invalid size [ ${2} ]!"
fi
;;
*)
die "Invalid option [ ${1} ]!"
;;
esac
shift
done

# Set whether to replace the kernel
if [[ "${auto_kernel}" == "ture" && ! "${build_kernel[*]}" =~ "default" ]]; then
download_kernel
fi

echo -e "Armbian SoC List: [ ${build_armbian[*]} ]"
echo -e "Kernel List: [ ${build_kernel[*]} ]"
echo -e "Ready, start build armbian... \n"

# Start loop compilation
Expand Down

0 comments on commit 0dbaab9

Please sign in to comment.