diff --git a/README.md b/README.md index 97669c2f9b34af6b64657c91c6a83c5b51dadc4e..ecaf598db6954cc1a0c1a993c2a2d877287d55a1 100644 --- a/README.md +++ b/README.md @@ -469,9 +469,9 @@ Issue the following command to boot the prebuilt kernel and rootfs on the defaul Login as `root` user without password(password is empty), just input `root` and press Enter: Welcome to Linux Lab - + linux-lab login: root - + # uname -a Linux linux-lab 5.1.0 #3 SMP Thu May 30 08:44:37 UTC 2019 armv7l GNU/Linux # @@ -658,7 +658,7 @@ Currently, such boards have the same name: LINUX ?= v5.1 ROOTDEV_LIST := /dev/vda /dev/ram0 /dev/nfs ROOTDEV ?= /dev/vda - + $ make list FILTER=/pc [ i386/pc ]: ARCH = x86 @@ -726,9 +726,9 @@ If want to upstream your local changes, please use `board-edit` and `board-confi v0.3+ version add target dependency by default, so, if want to compile a kernel, just run: $ make kernel-build - + Or - + $ make build kernel It will do everything required, of course, we still be able to run the targets explicitly. @@ -737,9 +737,9 @@ And futher, with the timestamping support, finished targets will not be run agai $ make cleanstamp kernel-build $ make kernel-build - + Or - + $ make force-kernel-build To clean all of the stamp files: @@ -766,9 +766,9 @@ Download one by one: $ make kernel-source $ make root-source $ make uboot-source - + Or - + $ make source bsp $ make source kernel $ make source root @@ -786,9 +786,9 @@ Checkout them one by one: $ make kernel-checkout $ make root-checkout - + Or - + $ make checkout kernel $ make checkout root @@ -796,9 +796,9 @@ If checkout not work due to local changes, save changes and run to get a clean e $ make kernel-cleanup $ make root-cleanup - + Or - + $ make cleanup kernel $ make cleanup root @@ -809,9 +809,9 @@ The same to qemu and uboot. Apply available patches in `boards//bsp/patch/linux` and `src/patch/linux/`: $ make kernel-patch - + Or - + $ make patch kernel ### 3.3.4 Configuration @@ -826,9 +826,9 @@ Configure one by one, by default, use the defconfig in `boards//bsp/`: $ make kernel-defconfig $ make root-defconfig - + Or - + $ make defconfig kernel $ make defconfig root @@ -844,9 +844,9 @@ If only defconfig name specified, search boards/ at first, and then the d $ make kernel-menuconfig $ make root-menuconfig - + Or - + $ make menuconfig kernel $ make menuconfig root @@ -855,9 +855,9 @@ If only defconfig name specified, search boards/ at first, and then the d $ make kernel-olddefconfig $ make root-olddefconfig $ make uboot-olddefconfig - + Or - + $ make olddefconfig kernel $ make olddefconfig root $ make olddefconfig uboot @@ -872,9 +872,9 @@ Build them one by one: $ make kernel-build # make kernel $ make root-build # make root - + Or - + $ make build kernel $ make build root @@ -893,9 +893,9 @@ Save configs and images to `boards//bsp/`: $ make root-saveconfig $ make root-save $ make kernel-save - + Or - + $ make saveconfig kernel $ make saveconfig root $ make save kernel @@ -998,16 +998,16 @@ Get state of a kernel module: $ make kernel-getconfig m=minix_fs Getting kernel config: MINIX_FS ... - + build/aarch64/linux-v5.1-virt/.config:CONFIG_MINIX_FS=m Enable a kernel module: $ make kernel-setconfig m=minix_fs Setting kernel config: m=minix_fs ... - + build/aarch64/linux-v5.1-virt/.config:CONFIG_MINIX_FS=m - + Enable new kernel config: minix_fs ... More control commands of `kernel-setconfig` including `y, n, c, o, s, v`: @@ -1051,14 +1051,14 @@ Enable one kernel module: $ make kernel-getconfig m=minix_fs Getting kernel config: MINIX_FS ... - + build/aarch64/linux-v5.1-virt/.config:CONFIG_MINIX_FS=m - + $ make kernel-setconfig m=minix_fs Setting kernel config: m=minix_fs ... - + build/aarch64/linux-v5.1-virt/.config:CONFIG_MINIX_FS=m - + Enable new kernel config: minix_fs ... Build one kernel module (e.g. minix.ko): @@ -1144,6 +1144,36 @@ Clear feature setting (reset feature saved in .labconfig): $ make feature feature= +#### using rust feature + +So far (2021.9.30), before using rust feature, we need to switch to rust branch. + +``` +$ cd /labs/linux-lab +$ git checkout -b rust +$ git pull +``` + +Compile board x86_64/pc: + +``` +make BOARD=x86_64/pc +``` + +Clone a kernel (v5.13) config, because the latest patchset can only be applied to v5.13. + +``` +make kernel-clone LINUX_NEW=v5.13 +``` + +Compile the kernel, and test it with one of the simplest module - rust_print: + +``` +make test f=rust m=rust_print FPL=0 +``` + +### + ### 4.1.4 Create new development branch If want to use a new development branch, please follow such steps: @@ -1241,7 +1271,7 @@ add external prebuilt qemu, this has been tested on vexpress-a9 and virt board. At first, build qemu-system-ARCH: $ make B=vexpress-a9 - + $ make qemu-download $ make qemu-checkout $ make qemu-patch @@ -1282,7 +1312,7 @@ Download, decompress and enable the external toolchain: Switch compiler version if exists, for example: $ make gcc-switch CCORI=internal GCC=4.7 - + $ make gcc-switch CCORI=linaro If not external toolchain there, the builtin will be used back. @@ -1588,18 +1618,18 @@ Docker host: Host: $ make BOARD=virt - + $ make root-install # Install mount/umount scripts, ref: src/system/etc/init.d/S50sharing $ make root-rebuild - + $ touch hostshare/test # Create a file in host - + $ make boot U=0 ROOTDEV=/dev/ram0 PBR=1 SHARE=1 - + $ make boot SHARE=1 SHARE_DIR=src/modules # for external modules development - + $ make boot SHARE=1 SHARE_DIR=build/aarch64/linux-v5.1-virt/ # for internal modules learning - + $ make boot SHARE=1 SHARE_DIR=src/examples # for c/assembly learning Qemu Board: @@ -1647,28 +1677,28 @@ Use hello as example: Use X32 (Code for x86-64, int/long/pointer to 32bits), ARM, MIPS, PPC and RISCV as example: $ sudo apt-get update -y - + $ sudo apt-get install -y libc6-x32 libc6-dev-x32 libx32gcc-8-dev $ gcc -mx32 -o hello hello.c $ ./hello Hello, World! - + $ sudo apt-get install -y libc6-dev-armel-cross libc6-armel-cross $ arm-linux-gnueabi-gcc -o hello hello.c $ qemu-arm -L /usr/arm-linux-gnueabi/ ./hello Hello, World! - + $ sudo apt-get install -y libc6-dev-mipsel-cross libc6-mipsel-cross $ mipsel-linux-gnu-gcc -o hello hello.c $ qemu-mipsel -L /usr/mipsel-linux-gnu/ ./hello Hello, World! - + $ sudo apt-get install -y libc6-dev-powerpc-cross libc6-powerpc-cross // Must use -static for Linux Lab v0.6, otherwise, there will be segmentation fault $ powerpc-linux-gnu-gcc -static -o hello hello.c $ qemu-ppc -L /usr/powerpc-linux-gnu/ ./hello Hello, World! - + $ sudo apt-get install -y libc6-riscv64-cross libc6-dev-riscv64-cross $ riscv64-linux-gnu-gcc -o hello hello.c $ qemu-riscv64 -L /usr/riscv64-linux-gnu/ ./hello @@ -1684,10 +1714,10 @@ Linux Lab allows to access Makefile goals easily via `-run`, for example: $ make kernel-run help $ make kernel-run menuconfig - + $ make root-run help $ make root-run busybox-menuconfig - + $ make uboot-run help $ make uboot-run menuconfig @@ -1760,7 +1790,7 @@ good helper to utilize existing configs: $ make kernel-clone LINUX=v5.1 LINUX_NEW=v5.4 $ make kernel-menuconfig $ make kernel-saveconfig - + $ make list root 2016.05 2019.02.2 $ make root-clone BUILDROOT=2019.02.2 BUILDROOT_NEW=2019.11 @@ -1811,9 +1841,9 @@ If want v5.1 kernel, just put a line "LINUX = v5.1" in `boards//Makefile` Or clone a kernel config from the old one or the official defconfig: $ make kernel-clone LINUX_NEW=v5.3 LINUX=v5.1 - + Or - + $ make B=i386/pc $ pushd linux-stable && git checkout v5.4 && popd $ make kernel-clone LINUX_NEW=v5.4 KCFG=i386_defconfig @@ -1873,7 +1903,7 @@ Use the backup as the build directory: $ make root-save $ make kernel-save $ make uboot-save - + $ make root-saveconfig $ make kernel-saveconfig $ make uboot-saveconfig @@ -1912,7 +1942,7 @@ We assume the docker network is `10.66.0.0/16`, if not, we'd better change it as $ sudo vim /etc/default/docker DOCKER_OPTS="$DOCKER_OPTS --bip=10.66.0.10/16" - + $ sudo vim /lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd -H fd:// --bip=10.66.0.10/16 @@ -2031,7 +2061,7 @@ If docker not work in Ubuntu 20.04, please use `doc/install/daemon.json` and cle [Service] ExecStart= ExecStart=/usr/bin/dockerd - + $ sudo cp /etc/docker/daemon.json /etc/docker/daemon.json.bak $ sudo cp doc/install/daemon.json /etc/docker/ $ sudo service docker restart @@ -2097,9 +2127,9 @@ That's because the docker image is not updated, just rerun the lab (please must $ tools/docker/pull linux-lab $ tools/docker/rerun linux-lab - + Or - + $ tools/docker/update linux-lab With `tools/docker/update`, every docker images and source code will be updated, it is preferred. @@ -2321,10 +2351,10 @@ Such information means the specified value is not supported currently: $ make boot ROOTDEV=/dev/vda ERR: /dev/vda not in supported ROOTDEV list: /dev/sda /dev/ram0 /dev/nfs, update may help: 'make bsp B=mips64el/ls3a7a'. Stop. - + $ make boot LINUX=v5.8 Makefile:594: *** ERR: v5.8 not in supported LINUX list: loongnix-release-1903 v5.7, clone one please: 'make kernel-clone KERNEL_NEW=v5.8'. Stop. - + $ make boot QEMU=loongson-v1.1 Makefile:606: *** ERR: loongson-v1.1 not in supported QEMU list: loongson-v1.0, clone one please: 'make qemu-clone QEMU_NEW=loongson-v1.1'. diff --git a/README_zh.md b/README_zh.md index bce2b98f3ae0051672aa2aec5432fc147d57ce7a..90336cc06bf766c04091eee77d8e3c53d8d99f71 100644 --- a/README_zh.md +++ b/README_zh.md @@ -598,9 +598,9 @@ Linux Lab 是一套完备的嵌入式 Linux 开发环境,需要预留足够的 使用 `root` 帐号登录,不需要输入密码(密码为空),只需要输入 `root` 然后输入回车即可: Welcome to Linux Lab - + linux-lab login: root - + # uname -a Linux linux-lab 5.1.0 #3 SMP Thu May 30 08:44:37 UTC 2019 armv7l GNU/Linux # @@ -790,7 +790,7 @@ Linux Lab 是一套完备的嵌入式 Linux 开发环境,需要预留足够的 LINUX ?= v5.1 ROOTDEV_LIST := /dev/vda /dev/ram0 /dev/nfs ROOTDEV ?= /dev/vda - + $ make list FILTER=/pc [ i386/pc ]: ARCH = x86 @@ -858,9 +858,9 @@ Linux Lab 支持 “插件” 功能,允许在独立的 git 仓库中添加和 v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想编译内核,直接: $ make kernel-build - + 或 - + $ make build kernel 它将自动完成所有需要的工作,当然,依然可以跟以前一样手动指定某个目标运行。 @@ -869,9 +869,9 @@ v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想 $ make cleanstamp kernel-build $ make kernel-build - + 或 - + $ make force-kernel-build 下面的命令则删掉所有内核目标的时间戳: @@ -898,9 +898,9 @@ v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想 $ make kernel-source $ make root-source $ make uboot-source - + 或 - + $ make source bsp $ make source kernel $ make source root @@ -918,9 +918,9 @@ v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想 $ make kernel-checkout $ make root-checkout - + 或 - + $ make checkout kernel $ make checkout root @@ -928,9 +928,9 @@ v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想 $ make kernel-cleanup $ make root-cleanup - + 或 - + $ make cleanup kernel $ make cleanup root @@ -941,9 +941,9 @@ v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想 给开发板打补丁,补丁包的来源是存放在 `boards//bsp/patch/linux` 和 `src/patch/linux/` 路径下: $ make kernel-patch - + 或 - + $ make patch kernel ### 3.3.4 配置 @@ -958,9 +958,9 @@ v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想 $ make kernel-defconfig $ make root-defconfig - + 或 - + $ make defconfig kernel $ make defconfig root @@ -976,9 +976,9 @@ v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想 $ make kernel-menuconfig $ make root-menuconfig - + 或 - + $ make menuconfig kernel $ make menuconfig root @@ -988,9 +988,9 @@ v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想 $ make root-olddefconfig $ make root-olddefconfig $ make uboot-olddefconfig - + 或 - + $ make olddefconfig kernel $ make olddefconfig root $ make olddefconfig uboot @@ -1005,9 +1005,9 @@ v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想 $ make kernel-build # make kernel $ make root-build # make root - + 或 - + $ make build kernel $ make build root @@ -1026,9 +1026,9 @@ v0.3 以及之后的版本默认增加了目标依赖支持,所以,如果想 $ make root-saveconfig $ make root-save $ make kernel-save - + 或 - + $ make saveconfig kernel $ make saveconfig root $ make save kernel @@ -1124,16 +1124,16 @@ Linux 内核提供了一个脚本 `scripts/config`,可用于非交互方式获 $ make kernel-getconfig m=minix_fs Getting kernel config: MINIX_FS ... - + build/aarch64/linux-v5.1-virt/.config:CONFIG_MINIX_FS=m 使能一个内核模块: $ make kernel-setconfig m=minix_fs Setting kernel config: m=minix_fs ... - + build/aarch64/linux-v5.1-virt/.config:CONFIG_MINIX_FS=m - + Enable new kernel config: minix_fs ... 更多 `kernel-setconfig` 命令的控制选项:`y, n, c, o, s, v`: @@ -1177,14 +1177,14 @@ Linux 内核提供了一个脚本 `scripts/config`,可用于非交互方式获 $ make kernel-getconfig m=minix_fs Getting kernel config: MINIX_FS ... - + build/aarch64/linux-v5.1-virt/.config:CONFIG_MINIX_FS=m - + $ make kernel-setconfig m=minix_fs Setting kernel config: m=minix_fs ... - + build/aarch64/linux-v5.1-virt/.config:CONFIG_MINIX_FS=m - + Enable new kernel config: minix_fs ... 编译一个内核模块(例如:minix.ko) @@ -1267,6 +1267,34 @@ Linux 内核提供了一个脚本 `scripts/config`,可用于非交互方式获 $ make feature feature= +#### 启用rust feature + +在Linux Lab中启用rust模块编译支持目前(截至2021.9.30)需要先切换到rust分支: + +``` +$ cd /labs/linux-lab +$ git checkout -b rust +$ git pull +``` + +编译开发板: + +``` +make BOARD=x86_64/pc +``` + +克隆内核配置到v5.13版本内核,因为最新的patchset只能打在v5.13内核上: + +``` +make kernel-clone LINUX_NEW=v5.13 +``` + +编译内核,并使用rust_print模块进行测试: + +``` +make test f=rust m=rust_print FPL=0 +``` + ### 4.1.4 新建开发分支 如果希望新建一个分支来做开发,那么可以参考如下步骤。 @@ -1291,7 +1319,7 @@ Linux 内核提供了一个脚本 `scripts/config`,可用于非交互方式获 $ cd src/linux-stable $ git checkout -b linux-v2.6.38-dev v2.6.38 - + $ make kernel-clone LINUX=v2.6.36 LINUX_NEW=linux-v2.6.38-dev 开发过程中,请及时 commit,另外,请慎重使用如下命令,避免清除重要变更: @@ -1366,7 +1394,7 @@ Linux 内核提供了一个脚本 `scripts/config`,可用于非交互方式获 首先,编译 qemu-system-ARCH: $ make B=vexpress-a9 - + $ make qemu-download $ make qemu-checkout $ make qemu-patch @@ -1399,7 +1427,7 @@ Linux 内核主线的升级非常迅速,内置的工具链可能无法与其 切换编译器版本,例子如下: $ make gcc-switch CCORI=internal GCC=4.7 - + $ make gcc-switch CCORI=linaro 如果未指定外部工具链,则缺省使用内置的工具链。 @@ -1708,18 +1736,18 @@ Docker 主机: 主机: $ make BOARD=virt - + $ make root-install # Install mount/umount scripts, ref: src/system/etc/init.d/S50sharing $ make root-rebuild - + $ touch hostshare/test # Create a file in host - + $ make boot U=0 ROOTDEV=/dev/ram0 PBR=1 SHARE=1 - + $ make boot SHARE=1 SHARE_DIR=src/modules # for external modules development - + $ make boot SHARE=1 SHARE_DIR=build/aarch64/linux-v5.1-virt/ # for internal modules learning - + $ make boot SHARE=1 SHARE_DIR=src/examples # for c/assembly learning Qemu 开发板: @@ -1767,28 +1795,28 @@ Linux Lab 在 `src/examples/assembly` 目录下有许多汇编代码的例子: 下面简单介绍如何在 Linux Lab 下交叉编译和并运行 C 程序,以 X32 (code for x86-64, int/long/pointer to 32bits), ARM, MIPS, PPC 和 RISCV 为例: $ sudo apt-get update -y - + $ sudo apt-get install -y libc6-x32 libc6-dev-x32 libx32gcc-8-dev $ gcc -mx32 -o hello hello.c $ ./hello Hello, World! - + $ sudo apt-get install -y libc6-dev-armel-cross libc6-armel-cross $ arm-linux-gnueabi-gcc -o hello hello.c $ qemu-arm -L /usr/arm-linux-gnueabi/ ./hello Hello, World! - + $ sudo apt-get install -y libc6-dev-mipsel-cross libc6-mipsel-cross $ mipsel-linux-gnu-gcc -o hello hello.c $ qemu-mipsel -L /usr/mipsel-linux-gnu/ ./hello Hello, World! - + $ sudo apt-get install -y libc6-dev-powerpc-cross libc6-powerpc-cross // Linux Lab v0.6 中,必须加 -static,否则运行时会有段错误 $ powerpc-linux-gnu-gcc -static -o hello hello.c $ qemu-ppc -L /usr/powerpc-linux-gnu/ ./hello Hello, World! - + $ sudo apt-get install -y libc6-riscv64-cross libc6-dev-riscv64-cross $ riscv64-linux-gnu-gcc -o hello hello.c $ qemu-riscv64 -L /usr/riscv64-linux-gnu/ ./hello @@ -1804,10 +1832,10 @@ Linux Lab 支持通过形如 `-run` 方式访问 Makefile 中定义的目 $ make kernel-run help $ make kernel-run menuconfig - + $ make root-run help $ make root-run busybox-menuconfig - + $ make uboot-run help $ make uboot-run menuconfig @@ -1879,7 +1907,7 @@ Linux Lab 也提供许多有效的配置,`xxx-clone` 命令有助于利用现 $ make kernel-clone LINUX=v5.1 LINUX_NEW=v5.4 $ make kernel-menuconfig $ make kernel-saveconfig - + $ make list root 2016.05 2019.02.2 $ make root-clone BUILDROOT=2019.02.2 BUILDROOT_NEW=2019.11 @@ -1928,9 +1956,9 @@ Linux Lab 也提供许多有效的配置,`xxx-clone` 命令有助于利用现 或者从旧的版本或者是官方的 defconfig 文件中复制一份内核的配置: $ make kernel-clone LINUX_NEW=v5.3 LINUX=v5.1 - + 或 - + $ make B=i386/pc $ pushd src/linux-stable && git checkout v5.4 && popd $ make kernel-clone LINUX_NEW=v5.4 KCFG=i386_defconfig @@ -1990,7 +2018,7 @@ Linux Lab 也提供许多有效的配置,`xxx-clone` 命令有助于利用现 $ make root-save $ make kernel-save $ make uboot-save - + $ make root-saveconfig $ make kernel-saveconfig $ make uboot-saveconfig @@ -2029,7 +2057,7 @@ Linux Lab 也提供许多有效的配置,`xxx-clone` 命令有助于利用现 $ sudo vim /etc/default/docker DOCKER_OPTS="$DOCKER_OPTS --bip=10.66.0.10/16" - + $ sudo vim /lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd -H fd:// --bip=10.66.0.10/16 @@ -2149,7 +2177,7 @@ Ubuntu 系统下,请根据不同版本情况选择下述**某一种**方法进 [Service] ExecStart= ExecStart=/usr/bin/dockerd - + $ sudo cp /etc/docker/daemon.json /etc/docker/daemon.json.bak $ sudo cp doc/install/daemon.json /etc/docker/ $ sudo service docker restart @@ -2216,9 +2244,9 @@ KVM 当前仅支持 `qemu-system-i386` 和 `qemu-system-x86_64`,并且还需 $ tools/docker/pull linux-lab $ tools/docker/rerun linux-lab - + 或 - + $ tools/docker/update linux-lab 使用 `tools/docker/update`,所有的 docker images 和源码都会被更新,这是推荐的做法。 @@ -2445,10 +2473,10 @@ Web 连接可能由于某些未知原因而挂起,导致 Linux Lab 有时可 $ make boot ROOTDEV=/dev/vda ERR: /dev/vda not in supported ROOTDEV list: /dev/sda /dev/ram0 /dev/nfs, update may help: 'make bsp B=mips64el/ls3a7a'. Stop. - + $ make boot LINUX=v5.8 Makefile:594: *** ERR: v5.8 not in supported LINUX list: loongnix-release-1903 v5.7, clone one please: 'make kernel-clone KERNEL_NEW=v5.8'. Stop. - + $ make boot QEMU=loongson-v1.1 Makefile:606: *** ERR: loongson-v1.1 not in supported QEMU list: loongson-v1.0, clone one please: 'make qemu-clone QEMU_NEW=loongson-v1.1'. diff --git a/tools/deps/rust.sh b/tools/deps/rust.sh index c56b7ff07c63c72ed04d820889f5226f31acfb5a..d113ba105dfe418877b62ad0bc860f746bd12f72 100755 --- a/tools/deps/rust.sh +++ b/tools/deps/rust.sh @@ -24,6 +24,10 @@ replace-with = 'ustc' [source.tuna] registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git" +# Beijing Foreign Studies University +[source.bfsu] +registry = "https://mirrors.bfsu.edu.cn/git/crates.io-index.git" + # University of science and technology of China [source.ustc] registry = "git://mirrors.ustc.edu.cn/crates.io-index"