Skip to content

更新手动构建内核相关文档 #36

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions docs/build/other/manual_build_kernel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 手动编译内核

支持架构:`x86_64` `riscv64`

`x86_64` 支持工具链:
* `6.6.0` Xuantie-900 Linux 6.6.0 (暂不能编译)
* `5.10.0` Xuantie-900 Linux 5.10.0 (暂不能编译)
* `13` 主线 RISC-V GCC 13交叉编译器
* `14` 主线 RISC-V GCC 14交叉编译器(默认)

`riscv64` 支持工具链:
* `rv` 主线 GCC 编译器

通过`TOOLCHAIN_VERSION`变量选择要使用的编译器

## 使用方法

```bash
git clone https://github.com/KamijoToma/xuantie-kernel-docker
cd xuantie-kernel-docker
docker build --build-arg TOOLCHAIN_VERSION=14 -t xuantie900:linux14 . # 根据支持架构确定 TOOLCHAIN_VERSION 参数
docker run -it --rm -v LOCAL_PATH:/output xuantie900:linux14 bash # LOCAL_PATH 为编译好的内核存放目录
./mkkernel_x64.sh # 根据 TOOLCHAIN_VERSION 配置选择 mkkernel_xuantie.sh 或 mkkernel_riscv64.sh
```

整个过程执行完成后,构建好的内核deb包将会被拷贝到`LOCAL_PATH`指定的目录中,然后使用`dpkg`安装即可。

```bash
sudo dpkg -i [PACKAGE]
```

编译过程会产生多个结果:
* linux-headers.deb(需要编译内核模块或内核开发时安装)
* linux-image-dbg.deb(调试符号,需要调试内核时安装)
* linux-image.deb(内核,必装)
* linux-libc-dev.deb(libc接口,一般不安装,使用通用版即可)

## 注意事项

1. 如需更改编译的版本,可在进入docker环境(输入`bash`)后自由修改
2. `x86_64`环境下交叉编译出的`linux-header`包可能包含`x86_64`的头文件。如需进行内核开发或使用如`zfs`之类的DKMS模块,请在RISC-V环境下使用`TOOLCHAIN_VERSION=rv`编译。
61 changes: 0 additions & 61 deletions docs/build/other/manuel_build_kernel.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Manual Kernel Compilation

Supported architectures: `x86_64` `riscv64`

`x86_64` supported toolchains:
* `6.6.0` Xuantie-900 Linux 6.6.0 (Currently not compilable)
* `5.10.0` Xuantie-900 Linux 5.10.0 (Currently not compilable)
* `13` Mainline RISC-V GCC 13 cross-compiler
* `14` Mainline RISC-V GCC 14 cross-compiler (Default)

`riscv64` supported toolchains:
* `rv` Mainline GCC compiler

Select the compiler to use through the `TOOLCHAIN_VERSION` variable.

## Usage

```bash
git clone https://github.com/KamijoToma/xuantie-kernel-docker
cd xuantie-kernel-docker
docker build --build-arg TOOLCHAIN_VERSION=14 -t xuantie900:linux14 . # Choose TOOLCHAIN_VERSION based on supported architecture
docker run -it --rm -v LOCAL_PATH:/output xuantie900:linux14 bash # LOCAL_PATH is the directory to store the compiled kernel
./mkkernel_x64.sh # Choose mkkernel_xuantie.sh or mkkernel_riscv64.sh based on TOOLCHAIN_VERSION configuration
```

After the entire process is completed, the built kernel deb packages will be copied to the directory specified by `LOCAL_PATH`, which can then be installed using `dpkg`.

```bash
sudo dpkg -i [DEB PACKAGE]
```

The compilation process will generate several results:
* linux-headers.deb (install when compiling kernel modules or for kernel development)
* linux-image-dbg.deb (debug symbols, install when debugging the kernel)
* linux-image.deb (kernel, required)
* linux-libc-dev.deb (libc interface, generally not installed, using the generic version is sufficient)

## Notes

1. If you need to change the version being compiled, you can freely modify it after entering the docker environment (by typing `bash`)
2. The `linux-header` package cross-compiled in an `x86_64` environment may contain `x86_64` header files. If you need to perform kernel development or use DKMS modules like `zfs`, please compile using `TOOLCHAIN_VERSION=rv` in a RISC-V environment.

This file was deleted.