Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I Change The Default Kernel? #52

Open
adibindrianto opened this issue Apr 20, 2024 · 20 comments
Open

Can I Change The Default Kernel? #52

adibindrianto opened this issue Apr 20, 2024 · 20 comments

Comments

@adibindrianto
Copy link

Can I change the default kernel from 5.4-6.6? for openwrt 21-23? what scripts need to be changed or added?

@friendlyarm
Copy link
Owner

If you want to use openwrt's built-in kernel, you can just compile openwrt directly,
If you just want to use an older version of the rockchip kernel, you can switch the script/sd-fuse branch to do so.

@adibindrianto
Copy link
Author

but how can change the kernel of existing rockchip in script/sd-fuse? please give me an example of the script to change

@lawrencetg
Copy link
Contributor

lawrencetg commented Apr 23, 2024

for example, switch to kernel 5.10 for rk3568/rk3588:

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bf5312f..1710052 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -185,6 +185,8 @@ jobs:
         repo sync -c scripts --no-clone-bundle
         repo sync -c scripts/sd-fuse  --no-clone-bundle
         repo sync -c toolchain  --no-clone-bundle
+        (cd kernel && git checkout nanopi5-v5.10.y_opt)
+        (cd scripts/sd-fuse && git checkout master)

     - name: Download friendlywrt rootfs (non-docker)
       if: matrix.SET == 'non-docker'

@adibindrianto
Copy link
Author

- name: Download source
  run: |
    mkdir project
    cd project
    repo init --depth=1 -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v${{ matrix.VERSION }} \
            -m rk3399.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle

    repo sync -c friendlywrt --no-clone-bundle
    repo sync -c configs --no-clone-bundle
    repo sync -c device/common --no-clone-bundle
    repo sync -c device/friendlyelec --no-clone-bundle
    repo sync -c scripts --no-clone-bundle
    repo sync -c scripts/sd-fuse  --no-clone-bundle
    repo sync -c toolchain  --no-clone-bundle
    (cd kernel && git checkout nanopi5-v5.15.y_opt)
    (cd scripts/sd-fuse && git checkout master)

like this for kernel 5.15?

@lawrencetg
Copy link
Contributor

- name: Download source
  run: |
    mkdir project
    cd project
    repo init --depth=1 -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v${{ matrix.VERSION }} \
            -m rk3399.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle

    repo sync -c friendlywrt --no-clone-bundle
    repo sync -c configs --no-clone-bundle
    repo sync -c device/common --no-clone-bundle
    repo sync -c device/friendlyelec --no-clone-bundle
    repo sync -c scripts --no-clone-bundle
    repo sync -c scripts/sd-fuse  --no-clone-bundle
    repo sync -c toolchain  --no-clone-bundle
    (cd kernel && git checkout nanopi5-v5.15.y_opt)
    (cd scripts/sd-fuse && git checkout master)

like this for kernel 5.15?

No, the rk3568/rk3588 platforms have never offered kernel 5.15, so it doesn't exist, and there are only two options at the moment: 5.10 and 6.1.

@adibindrianto
Copy link
Author

is it also for soc rk3288? only change 5.10 and 6.1?

@adibindrianto
Copy link
Author

i try your script not working for r2s

@lawrencetg
Copy link
Contributor

lawrencetg commented Apr 23, 2024

is it also for soc rk3288? only change 5.10 and 6.1?

rk3328 kernel 5.15:

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bf5312f..49fda10 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -185,6 +185,8 @@ jobs:
         repo sync -c scripts --no-clone-bundle
         repo sync -c scripts/sd-fuse  --no-clone-bundle
         repo sync -c toolchain  --no-clone-bundle
+        (cd kernel && git checkout nanopi-r2-v5.15.y)
+        (cd scripts/sd-fuse && git checkout kernel-5.15.y)

     - name: Download friendlywrt rootfs (non-docker)
       if: matrix.SET == 'non-docker'

@adibindrianto
Copy link
Author

- name: Download source
  run: |
    mkdir project
    cd project
    repo init --depth=1 -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v${{ matrix.VERSION }} \
            -m ${{ matrix.CPU }}.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle

    repo sync -c kernel --no-clone-bundle
    repo sync -c u-boot --no-clone-bundle
    repo sync -c rkbin --no-clone-bundle
    repo sync -c configs --no-clone-bundle
    repo sync -c device/common --no-clone-bundle
    repo sync -c device/friendlyelec --no-clone-bundle
    repo sync -c scripts --no-clone-bundle
    repo sync -c scripts/sd-fuse  --no-clone-bundle
    repo sync -c toolchain  --no-clone-bundle
    (cd kernel && git checkout nanopi-r2-v5.15.y)
    (cd scripts/sd-fuse && git checkout kernel-5.15.y)

Screenshot_20240423-150719_Chrome

@lawrencetg
Copy link
Contributor

lawrencetg commented Apr 23, 2024

i think it should work :)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bf5312f..ae97b2b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -142,7 +142,7 @@ jobs:
     strategy:
       matrix:
         VERSION: [21.02, 23.05]
-        CPU: [rk3328, rk3399, rk3568, rk3588]
+        CPU: [rk3328]
         SET: [docker, non-docker]
     steps:
     - name: Checkout
@@ -176,15 +176,15 @@ jobs:
         repo init --depth=1 -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v${{ matrix.VERSION }} \
                 -m ${{ matrix.CPU }}.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle

-        repo sync -c kernel --no-clone-bundle
         repo sync -c u-boot --no-clone-bundle
         repo sync -c rkbin --no-clone-bundle
         repo sync -c configs --no-clone-bundle
         repo sync -c device/common --no-clone-bundle
         repo sync -c device/friendlyelec --no-clone-bundle
         repo sync -c scripts --no-clone-bundle
-        repo sync -c scripts/sd-fuse  --no-clone-bundle
         repo sync -c toolchain  --no-clone-bundle
+        git clone https://github.com/friendlyarm/kernel-rockchip -b nanopi-r2-v5.15.y --depth 1 kernel
+        (cd scripts && git clone https://github.com/friendlyarm/sd-fuse_rk3328 -b kernel-5.15.y --depth 1 sd-fuse)
+        ln -s scripts/sd-fuse/out .

     - name: Download friendlywrt rootfs (non-docker)
       if: matrix.SET == 'non-docker'

@adibindrianto
Copy link
Author

- name: Download source
  run: |
    mkdir project
    cd project
    repo init --depth=1 -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v${{ matrix.VERSION }} \
            -m ${{ matrix.CPU }}.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle

    repo sync -c kernel --no-clone-bundle
    repo sync -c u-boot --no-clone-bundle
    repo sync -c rkbin --no-clone-bundle
    repo sync -c configs --no-clone-bundle
    repo sync -c device/common --no-clone-bundle
    repo sync -c device/friendlyelec --no-clone-bundle
    repo sync -c scripts --no-clone-bundle
    repo sync -c scripts/sd-fuse  --no-clone-bundle
    repo sync -c toolchain  --no-clone-bundle
    git clone https://github.com/friendlyarm/kernel-rockchip -b nanopi-r2-v5.15.y --depth 1 kernel
    cd scripts && git clone https://github.com/friendlyarm/sd-fuse_rk3328 -b kernel-5.15.y --depth 1 sd-fuse

Screenshot_20240423-174741_Chrome

i just copied your script, added bottom 2 lines but it doesn't work, check my image

@adibindrianto
Copy link
Author

friendlywrt official script that I changed a little, please how can I change the default kernel?

name: FriendlyWrt
on:
watch:
types: started
workflow_dispatch:
jobs:
prepare_release:
runs-on: ubuntu-20.04
if: github.event.repository.owner.id == github.event.sender.id
steps:
- name: Get release tag
id: release_tag
run: |
release_tag="FriendlyWrt-$(date +%Y-%m-%d)"
echo "##[set-output name=release_tag;]$release_tag"

- name: Create empty release
  id: release
  uses: softprops/action-gh-release@v1
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    tag_name: ${{ steps.release_tag.outputs.release_tag }}
    draft: false
    prerelease: false
outputs:
  release_tag: ${{ steps.release_tag.outputs.release_tag }}
  upload_url: ${{ steps.release.outputs.upload_url }}

build_friendlywrt:
needs: prepare_release
runs-on: ubuntu-20.04
if: github.event.repository.owner.id == github.event.sender.id
strategy:
matrix:
VERSION: [23.05]
SET: [docker]

steps:
- name: Checkout
  uses: actions/checkout@main

- name: Initialization environment
  env:
    DEBIAN_FRONTEND: noninteractive
  run: |
    sudo rm -rf /etc/apt/sources.list.d
    wget https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh
    sed -i -e 's/^apt-get -y install openjdk-8-jdk/# apt-get -y install openjdk-8-jdk/g' install.sh
    sed -i -e 's/^\[ -d fa-toolchain \]/# [ -d fa-toolchain ]/g' install.sh
    sed -i -e 's/^(cat fa-toolchain/# (cat fa-toolchain/g' install.sh
    sed -i -e 's/^(tar xf fa-toolchain/# (tar xf fa-toolchain/g' install.sh
    sudo -E bash ./install.sh
    sudo -E update-alternatives --install $(which python) python /usr/bin/python2.7 20
    sudo -E git config --global user.name 'GitHub Actions'
    sudo -E git config --global user.email '[email protected]'
    git clone https://github.com/friendlyarm/repo
    sudo -E cp repo/repo /usr/bin/
    mkdir -p ./artifact
    sudo swapoff -a
    sudo rm -rf /usr/share/dotnet /usr/local/lib/android/sdk /usr/local/share/boost /opt/ghc
    echo "cores: $(nproc)"

- name: Download source
  run: |
    mkdir project
    cd project
    repo init --depth=1 -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v${{ matrix.VERSION }} \
            -m rk3399.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle

    repo sync -c friendlywrt --no-clone-bundle
    repo sync -c configs --no-clone-bundle
    repo sync -c device/common --no-clone-bundle
    repo sync -c device/friendlyelec --no-clone-bundle
    repo sync -c scripts --no-clone-bundle
    repo sync -c scripts/sd-fuse  --no-clone-bundle
    repo sync -c toolchain  --no-clone-bundle
    git clone https://github.com/friendlyarm/kernel-rockchip -b nanopi-r2-v5.10.y --depth 1 kernel
    cd scripts && git clone https://github.com/friendlyarm/sd-fuse_rk3328 -b kernel-5.10.y --depth 1 sd-fuse

- name: Apply customizations
  run: |
    cd project
    source ../scripts/add_packages.sh
    source ../scripts/custome_config.sh
    sed -i 's/192.168.2.1/192.168.1.1/g' friendlywrt/target/linux/rockchip/armv8/base-files/etc/board.d/02_network

- name: Prepare dot config and feeds
  run: |
    cd project
    [ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker"
    DIRNAME=friendlywrt$(echo ${{ matrix.VERSION }}|awk -F . '{print $1}')${SUFFIX}
    CONFIG=rockchip${SUFFIX}
    cat > .current_config.mk <<EOL
    . device/friendlyelec/rk3399/base.mk
    TARGET_IMAGE_DIRNAME=${DIRNAME}
    TARGET_FRIENDLYWRT_CONFIG=${CONFIG}
    EOL
    DEBUG_DOT_CONFIG=1 ./build.sh friendlywrt

- name: Download package
  run: |
    cd project/friendlywrt
    make download -j8
    find dl -size -1024c -exec ls -l {} \;
    find dl -size -1024c -exec rm -f {} \;

- name: Compile friendlyWrt
  id: compile
  continue-on-error: true
  run: |
    cd project/friendlywrt
    make -j$(nproc) || make -j1 V=s
    echo $?

- name: Check the result and try again
  if: steps.compile.outcome == 'failure'
  run: |
    cd project/friendlywrt
    make -j1 V=s

- name: Create rootfs package
  id: create_rootfs_package
  run: |
    cd project
    source .current_config.mk
    [ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker"
    rootfs_filename="rootfs-friendlywrt-${{ matrix.VERSION }}${SUFFIX}.tgz"
    tar cvzf ../artifact/${rootfs_filename} ${FRIENDLYWRT_SRC}/${FRIENDLYWRT_ROOTFS} \
          ${FRIENDLYWRT_SRC}/${FRIENDLYWRT_PACKAGE_DIR}
    echo "##[set-output name=rootfs_filename;]$rootfs_filename"

- name: Upload rootfs package
  uses: svenstaro/upload-release-action@v2
  with:
    repo_token: ${{ secrets.GITHUB_TOKEN }}
    file: ./artifact/${{ steps.create_rootfs_package.outputs.rootfs_filename }}
    asset_name: ${{ steps.create_rootfs_package.outputs.rootfs_filename }}
    tag: ${{ needs.prepare_release.outputs.release_tag }}
    overwrite: true

build_img:
needs: [prepare_release,build_friendlywrt]
runs-on: ubuntu-20.04
if: github.event.repository.owner.id == github.event.sender.id

strategy:
  matrix:
    VERSION: [23.05]
    CPU: [rk3328]
    SET: [docker]
steps:
- name: Checkout
  uses: actions/checkout@main

- name: Initialization environment
  env:
    DEBIAN_FRONTEND: noninteractive
  run: |
    sudo rm -rf /etc/apt/sources.list.d
    wget https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh
    sed -i -e 's/^apt-get -y install openjdk-8-jdk/# apt-get -y install openjdk-8-jdk/g' install.sh
    sed -i -e 's/^\[ -d fa-toolchain \]/# [ -d fa-toolchain ]/g' install.sh
    sed -i -e 's/^(cat fa-toolchain/# (cat fa-toolchain/g' install.sh
    sed -i -e 's/^(tar xf fa-toolchain/# (tar xf fa-toolchain/g' install.sh
    sudo -E bash ./install.sh
    sudo -E update-alternatives --install $(which python) python /usr/bin/python2.7 20
    sudo -E git config --global user.name 'GitHub Actions'
    sudo -E git config --global user.email '[email protected]'
    git clone https://github.com/friendlyarm/repo
    sudo -E cp repo/repo /usr/bin/
    mkdir -p ./artifact
    sudo swapoff -a
    sudo rm -rf /usr/share/dotnet /usr/local/lib/android/sdk /usr/local/share/boost /opt/ghc
    echo "cores: $(nproc)"

- name: Download source
  run: |
    mkdir project
    cd project
    repo init --depth=1 -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v${{ matrix.VERSION }} \
            -m ${{ matrix.CPU }}.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle

    repo sync -c kernel --no-clone-bundle
    repo sync -c u-boot --no-clone-bundle
    repo sync -c rkbin --no-clone-bundle
    repo sync -c configs --no-clone-bundle
    repo sync -c device/common --no-clone-bundle
    repo sync -c device/friendlyelec --no-clone-bundle
    repo sync -c scripts --no-clone-bundle
    repo sync -c scripts/sd-fuse  --no-clone-bundle
    repo sync -c toolchain  --no-clone-bundle
    git clone https://github.com/friendlyarm/kernel-rockchip -b nanopi-r2-v5.10.y --depth 1 kernel
    cd scripts && git clone https://github.com/friendlyarm/sd-fuse_rk3328 -b kernel-5.10.y --depth 1 sd-fuse

- name: Download friendlywrt rootfs (non-docker)
  if: matrix.SET == 'non-docker'
  uses: robinraju/[email protected]
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    repository: ${{ github.repository }}
    tag: ${{ needs.prepare_release.outputs.release_tag }}
    fileName: "rootfs-friendlywrt-${{ matrix.VERSION }}.tgz"

- name: Download friendlywrt rootfs (docker)
  if: matrix.SET == 'docker'
  uses: robinraju/[email protected]
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    repository: ${{ github.repository }}
    tag: ${{ needs.prepare_release.outputs.release_tag }}
    fileName: "rootfs-friendlywrt-${{ matrix.VERSION }}-docker.tgz"

- name: Prepare config
  id: config
  run: |
    cd project
    case ${{ matrix.CPU }} in
    rk3328)
      MODEL=R2S-R2C-Series
      ;;
    rk3399)
      MODEL=R4S-Series
      ;;
    rk3568)
      MODEL=R5S-R5C-Series
      ;;
    rk3588)
      MODEL=T6-R6S-R6C-Series
      ;;
    *)
      echo "unknow cpu"
      exit 1
      ;;
    esac
    [ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker"
    FILENAME=${MODEL}-FriendlyWrt-${{ matrix.VERSION }}${SUFFIX}.img
    DIRNAME=friendlywrt$(echo ${{ matrix.VERSION }}|awk -F . '{print $1}')${SUFFIX}
    CONFIG=rockchip${SUFFIX}
    cat > .current_config.mk <<EOL
    . device/friendlyelec/${{ matrix.CPU }}/base.mk
    TARGET_IMAGE_DIRNAME=${DIRNAME}
    TARGET_FRIENDLYWRT_CONFIG=${CONFIG}
    TARGET_SD_RAW_FILENAME=${FILENAME}
    EOL
    echo "##[set-output name=img_filename;]$FILENAME"

- name: Unpack friendlywrt rootfs
  run: |
    cd project
    [ "${{ matrix.SET }}" == "docker" ] && SUFFIX="-docker"
    tar xvzf "../rootfs-friendlywrt-${{ matrix.VERSION }}${SUFFIX}.tgz"

- name: Compile uboot and kernel
  run: |
    cd project
    ./build.sh uboot
    ./build.sh kernel

- name: Build sd image
  id: build_sd_image
  run: |
    cd project
    ./build.sh sd-img
    mv out/${{ steps.config.outputs.img_filename }} ../artifact/
    cd ../artifact/
    gzip *.img

- name: Upload image to release
  uses: svenstaro/upload-release-action@v2
  with:
    repo_token: ${{ secrets.GITHUB_TOKEN }}
    file: ./artifact/${{ steps.config.outputs.img_filename }}.gz
    asset_name: ${{ steps.config.outputs.img_filename }}.gz
    tag: ${{ needs.prepare_release.outputs.release_tag }}
    overwrite: true

@friendlyarm
Copy link
Owner

Notice if there is a "-" in front of the line, you need to delete the following two lines

-        repo sync -c kernel --no-clone-bundle
-        repo sync -c scripts/sd-fuse  --no-clone-bundle

@adibindrianto
Copy link
Author

I'll trying, it's compiling now

@adibindrianto
Copy link
Author

not working, kernel 5.10 and 5.15

Screenshot_20240424-202229_Chrome

    repo sync -c u-boot --no-clone-bundle
    repo sync -c rkbin --no-clone-bundle
    repo sync -c configs --no-clone-bundle
    repo sync -c device/common --no-clone-bundle
    repo sync -c device/friendlyelec --no-clone-bundle
    repo sync -c scripts --no-clone-bundle
    repo sync -c toolchain  --no-clone-bundle
    git clone https://github.com/friendlyarm/kernel-rockchip -b nanopi-r2-v5.10.y --depth 1 kernel
    cd scripts && git clone https://github.com/friendlyarm/sd-fuse_rk3328 -b kernel-5.10.y --depth 1 sd-fuse

@lawrencetg
Copy link
Contributor

I found that I missed the symbolic link to the out directory, the last lines should be:

        git clone https://github.com/friendlyarm/kernel-rockchip -b nanopi-r2-v5.15.y --depth 1 kernel
        (cd scripts && git clone https://github.com/friendlyarm/sd-fuse_rk3328 -b kernel-5.15.y --depth 1 sd-fuse)
        ln -s scripts/sd-fuse/out .

I've tested it:
lawrencetg/Actions-FriendlyWrt-Test@0f18dd4

root@FriendlyWrt:~# cat /proc/version
Linux version 5.15.78 (runner@fv-az713-412) (aarch64-linux-gnu-gcc (ctng-1.25.0-119g-FA) 11.3.0, GNU l
d (GNU Binutils) 2.38) #1 SMP PREEMPT Thu Apr 25 05:13:35 UTC 2024
root@FriendlyWrt:~# ls /lib/modules/
5.15.78

@adibindrianto
Copy link
Author

I tried kernel 5.15 and it could compile but didn't get internet, didn't get ip dhcp, the wan and lan led indicators didn't light up then kernel 5.10 couldn't compile in the same way or changed from 5.15 to 5.10

@lawrencetg
Copy link
Contributor

I tried kernel 5.15 and it could compile but didn't get internet, didn't get ip dhcp, the wan and lan led indicators didn't light up then kernel 5.10 couldn't compile in the same way or changed from 5.15 to 5.10

What is your hardware model, older kernels usually lack support for newer model

@adibindrianto
Copy link
Author

my device is nanopi r2s but when I compile it using the latest 6.1 kernel it runs normally, I use a kernel other than 6.1 to use qos limit, does it work or not

@adibindrianto
Copy link
Author

any updates solution? how downgrade kernel from 6.x.x to 5.15 or 5.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants