diff --git a/.github/workflows/build_rpi3.yml b/.github/workflows/build_rpi3.yml index ea4285c0..506fd65a 100644 --- a/.github/workflows/build_rpi3.yml +++ b/.github/workflows/build_rpi3.yml @@ -32,9 +32,10 @@ jobs: - name: Set up Rust nightly run: | rustup self update - rustup toolchain install nightly --component rust-src llvm-tools-preview + rustup toolchain install nightly --component llvm-tools-preview rustup default nightly - cargo install cargo-xbuild cargo-binutils + rustup target add aarch64-unknown-none-softfloat + cargo install cargo-binutils - name: Set up Ruby run: | gem install bundler diff --git a/.github/workflows/build_rpi4.yml b/.github/workflows/build_rpi4.yml index 1d5ec090..810da145 100644 --- a/.github/workflows/build_rpi4.yml +++ b/.github/workflows/build_rpi4.yml @@ -32,9 +32,10 @@ jobs: - name: Set up Rust nightly run: | rustup self update - rustup toolchain install nightly --component rust-src llvm-tools-preview + rustup toolchain install nightly --component llvm-tools-preview rustup default nightly - cargo install cargo-xbuild cargo-binutils + rustup target add aarch64-unknown-none-softfloat + cargo install cargo-binutils - name: Set up Ruby run: | gem install bundler diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml index 44e935de..63102b4d 100644 --- a/.github/workflows/sanity.yml +++ b/.github/workflows/sanity.yml @@ -22,9 +22,9 @@ jobs: - name: Set up Rust nightly run: | rustup self update - rustup toolchain install nightly --component rustfmt clippy rust-src + rustup toolchain install nightly --component rustfmt clippy rustup default nightly - cargo install cargo-xbuild + rustup target add aarch64-unknown-none-softfloat - name: Set up Ruby run: | gem install bundler diff --git a/.github/workflows/test_integration.yml b/.github/workflows/test_integration.yml index 4d4e3f2c..b5555248 100644 --- a/.github/workflows/test_integration.yml +++ b/.github/workflows/test_integration.yml @@ -32,9 +32,10 @@ jobs: - name: Set up Rust nightly run: | rustup self update - rustup toolchain install nightly --component rust-src llvm-tools-preview + rustup toolchain install nightly --component llvm-tools-preview rustup default nightly - cargo install cargo-xbuild cargo-binutils + rustup target add aarch64-unknown-none-softfloat + cargo install cargo-binutils - name: Set up Ruby run: | gem install bundler diff --git a/.github/workflows/test_unit.yml b/.github/workflows/test_unit.yml index e50eda57..ef85071b 100644 --- a/.github/workflows/test_unit.yml +++ b/.github/workflows/test_unit.yml @@ -32,9 +32,10 @@ jobs: - name: Set up Rust nightly run: | rustup self update - rustup toolchain install nightly --component rust-src llvm-tools-preview + rustup toolchain install nightly --component llvm-tools-preview rustup default nightly - cargo install cargo-xbuild cargo-binutils + rustup target add aarch64-unknown-none-softfloat + cargo install cargo-binutils - name: Set up Ruby run: | gem install bundler @@ -42,4 +43,3 @@ jobs: - name: Make all run: | bundle exec ruby utils/devtool.rb test_unit - diff --git a/.gitignore b/.gitignore index c792d20b..91869c22 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ Gemfile.lock -xbuild_sysroot **/target/* **/.gdb_history diff --git a/01_wait_forever/Cargo.toml b/01_wait_forever/Cargo.toml index e11addd3..d20cb37f 100644 --- a/01_wait_forever/Cargo.toml +++ b/01_wait_forever/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/01_wait_forever/Makefile b/01_wait_forever/Makefile index 7b972f11..a82d5a35 100644 --- a/01_wait_forever/Makefile +++ b/01_wait_forever/Makefile @@ -26,16 +26,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -53,7 +55,7 @@ DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -73,7 +75,7 @@ qemu: all endif clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/01_wait_forever/README.CN.md b/01_wait_forever/README.CN.md index 87f1ab76..281a9290 100644 --- a/01_wait_forever/README.CN.md +++ b/01_wait_forever/README.CN.md @@ -4,7 +4,6 @@ 项目框架已经构建完成;目前代码做的仅仅是挂起CPU核心执行内核代码。 -- 工具链: `cargo xbuild` 工具 (包括 `xrustc`, `xclippy`) 以及用于构建 `AArch64` 裸机代码的 `aarch64-unknown-none-softfloat` 目标平台。 - `Makefile` 目标项: - `doc`: 生成文档。 - `qemu`: 在 QEMU 中运行 `kernel`。 diff --git a/01_wait_forever/README.md b/01_wait_forever/README.md index 489ad99a..a35c499b 100644 --- a/01_wait_forever/README.md +++ b/01_wait_forever/README.md @@ -7,8 +7,6 @@ executing the kernel code. ## Building -- Toolchain: `cargo xbuild` tools (`xrustc`, `xclippy`) and the `aarch64-unknown-none-softfloat` - target are used for building `AArch64` bare-metal code. - `Makefile` targets: - `doc`: Generate documentation. - `qemu`: Run the `kernel` in QEMU diff --git a/01_wait_forever/kernel b/01_wait_forever/kernel index 0bf53e84..db56de48 100755 Binary files a/01_wait_forever/kernel and b/01_wait_forever/kernel differ diff --git a/02_runtime_init/Cargo.toml b/02_runtime_init/Cargo.toml index e11addd3..d20cb37f 100644 --- a/02_runtime_init/Cargo.toml +++ b/02_runtime_init/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/02_runtime_init/Makefile b/02_runtime_init/Makefile index 7b972f11..a82d5a35 100644 --- a/02_runtime_init/Makefile +++ b/02_runtime_init/Makefile @@ -26,16 +26,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -53,7 +55,7 @@ DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -73,7 +75,7 @@ qemu: all endif clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/02_runtime_init/kernel b/02_runtime_init/kernel index 0b922fdb..6e495a44 100644 Binary files a/02_runtime_init/kernel and b/02_runtime_init/kernel differ diff --git a/02_runtime_init/kernel8.img b/02_runtime_init/kernel8.img index aae6b025..8cabfa90 100755 Binary files a/02_runtime_init/kernel8.img and b/02_runtime_init/kernel8.img differ diff --git a/03_hacky_hello_world/Cargo.toml b/03_hacky_hello_world/Cargo.toml index e11addd3..d20cb37f 100644 --- a/03_hacky_hello_world/Cargo.toml +++ b/03_hacky_hello_world/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/03_hacky_hello_world/Makefile b/03_hacky_hello_world/Makefile index 2fe12d45..587edb79 100644 --- a/03_hacky_hello_world/Makefile +++ b/03_hacky_hello_world/Makefile @@ -26,16 +26,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -53,7 +55,7 @@ DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -73,7 +75,7 @@ qemu: all endif clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/03_hacky_hello_world/kernel b/03_hacky_hello_world/kernel index 0b598fab..052f16a2 100755 Binary files a/03_hacky_hello_world/kernel and b/03_hacky_hello_world/kernel differ diff --git a/03_hacky_hello_world/kernel8.img b/03_hacky_hello_world/kernel8.img index 902da855..cf4eb0ad 100755 Binary files a/03_hacky_hello_world/kernel8.img and b/03_hacky_hello_world/kernel8.img differ diff --git a/04_zero_overhead_abstraction/Cargo.toml b/04_zero_overhead_abstraction/Cargo.toml index 0004a22a..6cb2c4f4 100644 --- a/04_zero_overhead_abstraction/Cargo.toml +++ b/04_zero_overhead_abstraction/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/04_zero_overhead_abstraction/Makefile b/04_zero_overhead_abstraction/Makefile index 2fe12d45..587edb79 100644 --- a/04_zero_overhead_abstraction/Makefile +++ b/04_zero_overhead_abstraction/Makefile @@ -26,16 +26,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -53,7 +55,7 @@ DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -73,7 +75,7 @@ qemu: all endif clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/04_zero_overhead_abstraction/README.md b/04_zero_overhead_abstraction/README.md index 6dded55e..0af2abed 100644 --- a/04_zero_overhead_abstraction/README.md +++ b/04_zero_overhead_abstraction/README.md @@ -13,7 +13,7 @@ zero-overhead abstractions and wraps the `unsafe` parts. diff -uNr 03_hacky_hello_world/Cargo.toml 04_zero_overhead_abstraction/Cargo.toml --- 03_hacky_hello_world/Cargo.toml +++ 04_zero_overhead_abstraction/Cargo.toml -@@ -10,7 +10,10 @@ +@@ -7,7 +7,10 @@ # The features section is used to select the target board. [features] default = [] diff --git a/04_zero_overhead_abstraction/kernel b/04_zero_overhead_abstraction/kernel index a83171b1..572ebfff 100755 Binary files a/04_zero_overhead_abstraction/kernel and b/04_zero_overhead_abstraction/kernel differ diff --git a/04_zero_overhead_abstraction/kernel8.img b/04_zero_overhead_abstraction/kernel8.img index 669ca35c..d43c762d 100755 Binary files a/04_zero_overhead_abstraction/kernel8.img and b/04_zero_overhead_abstraction/kernel8.img differ diff --git a/05_safe_globals/Cargo.toml b/05_safe_globals/Cargo.toml index 0004a22a..6cb2c4f4 100644 --- a/05_safe_globals/Cargo.toml +++ b/05_safe_globals/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/05_safe_globals/Makefile b/05_safe_globals/Makefile index 2fe12d45..587edb79 100644 --- a/05_safe_globals/Makefile +++ b/05_safe_globals/Makefile @@ -26,16 +26,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -53,7 +55,7 @@ DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -73,7 +75,7 @@ qemu: all endif clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/05_safe_globals/kernel b/05_safe_globals/kernel index f2aced0e..8eadb287 100755 Binary files a/05_safe_globals/kernel and b/05_safe_globals/kernel differ diff --git a/05_safe_globals/kernel8.img b/05_safe_globals/kernel8.img index c41f4520..76259b19 100755 Binary files a/05_safe_globals/kernel8.img and b/05_safe_globals/kernel8.img differ diff --git a/06_drivers_gpio_uart/Cargo.toml b/06_drivers_gpio_uart/Cargo.toml index 380f64d4..a98bd72a 100644 --- a/06_drivers_gpio_uart/Cargo.toml +++ b/06_drivers_gpio_uart/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/06_drivers_gpio_uart/Makefile b/06_drivers_gpio_uart/Makefile index 2fe12d45..587edb79 100644 --- a/06_drivers_gpio_uart/Makefile +++ b/06_drivers_gpio_uart/Makefile @@ -26,16 +26,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -53,7 +55,7 @@ DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -73,7 +75,7 @@ qemu: all endif clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/06_drivers_gpio_uart/README.md b/06_drivers_gpio_uart/README.md index d2b17e6f..d55106b6 100644 --- a/06_drivers_gpio_uart/README.md +++ b/06_drivers_gpio_uart/README.md @@ -90,7 +90,7 @@ sudo screen /dev/ttyUSB0 230400 diff -uNr 05_safe_globals/Cargo.toml 06_drivers_gpio_uart/Cargo.toml --- 05_safe_globals/Cargo.toml +++ 06_drivers_gpio_uart/Cargo.toml -@@ -10,10 +10,11 @@ +@@ -7,10 +7,11 @@ # The features section is used to select the target board. [features] default = [] diff --git a/06_drivers_gpio_uart/kernel b/06_drivers_gpio_uart/kernel index db11f1aa..f0c2ffaf 100755 Binary files a/06_drivers_gpio_uart/kernel and b/06_drivers_gpio_uart/kernel differ diff --git a/06_drivers_gpio_uart/kernel8.img b/06_drivers_gpio_uart/kernel8.img index e6ea1406..c4587299 100755 Binary files a/06_drivers_gpio_uart/kernel8.img and b/06_drivers_gpio_uart/kernel8.img differ diff --git a/07_uart_chainloader/Cargo.toml b/07_uart_chainloader/Cargo.toml index 380f64d4..a98bd72a 100644 --- a/07_uart_chainloader/Cargo.toml +++ b/07_uart_chainloader/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/07_uart_chainloader/Makefile b/07_uart_chainloader/Makefile index edc6ff0a..1e242283 100644 --- a/07_uart_chainloader/Makefile +++ b/07_uart_chainloader/Makefile @@ -33,16 +33,18 @@ else ifeq ($(BSP),rpi4) CHAINBOOT_DEMO_PAYLOAD = demo_payload_rpi4.img endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -63,7 +65,7 @@ DOCKER_EXEC_MINIPUSH = ruby /utils/minipush.rb all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -96,7 +98,7 @@ chainboot: $(CHAINBOOT_DEMO_PAYLOAD) clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/07_uart_chainloader/README.md b/07_uart_chainloader/README.md index 8a82381f..a924e290 100644 --- a/07_uart_chainloader/README.md +++ b/07_uart_chainloader/README.md @@ -118,8 +118,8 @@ diff -uNr 06_drivers_gpio_uart/Makefile 07_uart_chainloader/Makefile + CHAINBOOT_DEMO_PAYLOAD = demo_payload_rpi4.img endif - RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) -@@ -46,9 +53,12 @@ + SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) +@@ -48,9 +55,12 @@ DOCKER_IMAGE = rustembedded/osdev-utils DOCKER_CMD = docker run -it --rm DOCKER_ARG_DIR_TUT = -v $(shell pwd):/work -w /work @@ -133,7 +133,7 @@ diff -uNr 06_drivers_gpio_uart/Makefile 07_uart_chainloader/Makefile all: clean $(OUTPUT) -@@ -65,13 +75,26 @@ +@@ -67,13 +77,26 @@ ifeq ($(QEMU_MACHINE_TYPE),) qemu: @echo "This board is not yet supported for QEMU." @@ -158,7 +158,7 @@ diff -uNr 06_drivers_gpio_uart/Makefile 07_uart_chainloader/Makefile + $(CHAINBOOT_DEMO_PAYLOAD) + clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) diff -uNr 06_drivers_gpio_uart/src/_arch/aarch64/cpu.rs 07_uart_chainloader/src/_arch/aarch64/cpu.rs diff --git a/07_uart_chainloader/kernel b/07_uart_chainloader/kernel index e3474d8c..d3d0bb3d 100755 Binary files a/07_uart_chainloader/kernel and b/07_uart_chainloader/kernel differ diff --git a/07_uart_chainloader/kernel8.img b/07_uart_chainloader/kernel8.img index 44055b5c..b2904494 100755 Binary files a/07_uart_chainloader/kernel8.img and b/07_uart_chainloader/kernel8.img differ diff --git a/08_timestamps/Cargo.toml b/08_timestamps/Cargo.toml index 380f64d4..a98bd72a 100644 --- a/08_timestamps/Cargo.toml +++ b/08_timestamps/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/08_timestamps/Makefile b/08_timestamps/Makefile index 1cf7c716..55ad6597 100644 --- a/08_timestamps/Makefile +++ b/08_timestamps/Makefile @@ -31,16 +31,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -61,7 +63,7 @@ DOCKER_EXEC_MINIPUSH = ruby /utils/minipush.rb all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -86,7 +88,7 @@ chainboot: all $(OUTPUT) clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/08_timestamps/README.md b/08_timestamps/README.md index 19661a67..aa31d8fe 100644 --- a/08_timestamps/README.md +++ b/08_timestamps/README.md @@ -65,8 +65,8 @@ diff -uNr 07_uart_chainloader/Makefile 08_timestamps/Makefile + RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif - RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) -@@ -58,7 +56,7 @@ + SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) +@@ -60,7 +58,7 @@ DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) DOCKER_EXEC_MINIPUSH = ruby /utils/minipush.rb @@ -75,7 +75,7 @@ diff -uNr 07_uart_chainloader/Makefile 08_timestamps/Makefile all: clean $(OUTPUT) -@@ -75,25 +73,17 @@ +@@ -77,25 +75,17 @@ ifeq ($(QEMU_MACHINE_TYPE),) qemu: @echo "This board is not yet supported for QEMU." @@ -102,7 +102,7 @@ diff -uNr 07_uart_chainloader/Makefile 08_timestamps/Makefile + $(OUTPUT) clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) diff -uNr 07_uart_chainloader/src/_arch/aarch64/cpu.rs 08_timestamps/src/_arch/aarch64/cpu.rs --- 07_uart_chainloader/src/_arch/aarch64/cpu.rs diff --git a/08_timestamps/kernel b/08_timestamps/kernel index 364e14cd..2c75d18b 100755 Binary files a/08_timestamps/kernel and b/08_timestamps/kernel differ diff --git a/08_timestamps/kernel8.img b/08_timestamps/kernel8.img index e965e51a..bda292a0 100755 Binary files a/08_timestamps/kernel8.img and b/08_timestamps/kernel8.img differ diff --git a/09_hw_debug_JTAG/Cargo.toml b/09_hw_debug_JTAG/Cargo.toml index 380f64d4..a98bd72a 100644 --- a/09_hw_debug_JTAG/Cargo.toml +++ b/09_hw_debug_JTAG/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/09_hw_debug_JTAG/Makefile b/09_hw_debug_JTAG/Makefile index 39f77ce4..d8aa81a2 100644 --- a/09_hw_debug_JTAG/Makefile +++ b/09_hw_debug_JTAG/Makefile @@ -35,16 +35,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -67,7 +69,7 @@ DOCKER_EXEC_MINIPUSH = ruby /utils/minipush.rb all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -101,7 +103,7 @@ openocd: openocd $(OPENOCD_ARG) define gen_gdb - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(RUSTC_CMD) cp $(CARGO_OUTPUT) kernel_for_jtag @$(DOCKER_CMD) $(DOCKER_ARG_DIR_TUT) $(DOCKER_ARG_NET) $(DOCKER_IMAGE) \ gdb-multiarch -q kernel_for_jtag @@ -114,7 +116,7 @@ gdb-opt0: clean $(SOURCES) $(call gen_gdb,-C debuginfo=2 -C opt-level=0) clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/09_hw_debug_JTAG/README.md b/09_hw_debug_JTAG/README.md index 411e5827..202c0956 100644 --- a/09_hw_debug_JTAG/README.md +++ b/09_hw_debug_JTAG/README.md @@ -323,7 +323,7 @@ diff -uNr 08_timestamps/Makefile 09_hw_debug_JTAG/Makefile LINKER_FILE = src/bsp/raspberrypi/link.ld RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif -@@ -52,11 +56,13 @@ +@@ -54,11 +58,13 @@ DOCKER_CMD = docker run -it --rm DOCKER_ARG_DIR_TUT = -v $(shell pwd):/work -w /work DOCKER_ARG_DIR_UTILS = -v $(shell pwd)/../utils:/utils @@ -338,7 +338,7 @@ diff -uNr 08_timestamps/Makefile 09_hw_debug_JTAG/Makefile all: clean $(OUTPUT) -@@ -85,6 +91,28 @@ +@@ -87,6 +93,28 @@ $(DOCKER_IMAGE) $(DOCKER_EXEC_MINIPUSH) $(DEV_SERIAL) \ $(OUTPUT) @@ -352,7 +352,7 @@ diff -uNr 08_timestamps/Makefile 09_hw_debug_JTAG/Makefile + openocd $(OPENOCD_ARG) + +define gen_gdb -+ RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(XRUSTC_CMD) ++ RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(RUSTC_CMD) + cp $(CARGO_OUTPUT) kernel_for_jtag + @$(DOCKER_CMD) $(DOCKER_ARG_DIR_TUT) $(DOCKER_ARG_NET) $(DOCKER_IMAGE) \ + gdb-multiarch -q kernel_for_jtag @@ -365,6 +365,6 @@ diff -uNr 08_timestamps/Makefile 09_hw_debug_JTAG/Makefile + $(call gen_gdb,-C debuginfo=2 -C opt-level=0) + clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) ``` diff --git a/09_hw_debug_JTAG/kernel b/09_hw_debug_JTAG/kernel index 364e14cd..2c75d18b 100755 Binary files a/09_hw_debug_JTAG/kernel and b/09_hw_debug_JTAG/kernel differ diff --git a/09_hw_debug_JTAG/kernel8.img b/09_hw_debug_JTAG/kernel8.img index e965e51a..bda292a0 100755 Binary files a/09_hw_debug_JTAG/kernel8.img and b/09_hw_debug_JTAG/kernel8.img differ diff --git a/10_privilege_level/Cargo.toml b/10_privilege_level/Cargo.toml index 380f64d4..a98bd72a 100644 --- a/10_privilege_level/Cargo.toml +++ b/10_privilege_level/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/10_privilege_level/Makefile b/10_privilege_level/Makefile index 39f77ce4..d8aa81a2 100644 --- a/10_privilege_level/Makefile +++ b/10_privilege_level/Makefile @@ -35,16 +35,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -67,7 +69,7 @@ DOCKER_EXEC_MINIPUSH = ruby /utils/minipush.rb all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -101,7 +103,7 @@ openocd: openocd $(OPENOCD_ARG) define gen_gdb - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(RUSTC_CMD) cp $(CARGO_OUTPUT) kernel_for_jtag @$(DOCKER_CMD) $(DOCKER_ARG_DIR_TUT) $(DOCKER_ARG_NET) $(DOCKER_IMAGE) \ gdb-multiarch -q kernel_for_jtag @@ -114,7 +116,7 @@ gdb-opt0: clean $(SOURCES) $(call gen_gdb,-C debuginfo=2 -C opt-level=0) clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/10_privilege_level/kernel b/10_privilege_level/kernel index 8f9d4631..48a56066 100755 Binary files a/10_privilege_level/kernel and b/10_privilege_level/kernel differ diff --git a/10_privilege_level/kernel8.img b/10_privilege_level/kernel8.img index 0e59c88b..4a9aa64f 100755 Binary files a/10_privilege_level/kernel8.img and b/10_privilege_level/kernel8.img differ diff --git a/11_virtual_memory/Cargo.toml b/11_virtual_memory/Cargo.toml index 380f64d4..a98bd72a 100644 --- a/11_virtual_memory/Cargo.toml +++ b/11_virtual_memory/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/11_virtual_memory/Makefile b/11_virtual_memory/Makefile index 39f77ce4..d8aa81a2 100644 --- a/11_virtual_memory/Makefile +++ b/11_virtual_memory/Makefile @@ -35,16 +35,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -67,7 +69,7 @@ DOCKER_EXEC_MINIPUSH = ruby /utils/minipush.rb all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -101,7 +103,7 @@ openocd: openocd $(OPENOCD_ARG) define gen_gdb - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(RUSTC_CMD) cp $(CARGO_OUTPUT) kernel_for_jtag @$(DOCKER_CMD) $(DOCKER_ARG_DIR_TUT) $(DOCKER_ARG_NET) $(DOCKER_IMAGE) \ gdb-multiarch -q kernel_for_jtag @@ -114,7 +116,7 @@ gdb-opt0: clean $(SOURCES) $(call gen_gdb,-C debuginfo=2 -C opt-level=0) clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/11_virtual_memory/kernel b/11_virtual_memory/kernel index 0193f537..50c8e258 100755 Binary files a/11_virtual_memory/kernel and b/11_virtual_memory/kernel differ diff --git a/11_virtual_memory/kernel8.img b/11_virtual_memory/kernel8.img index 7779c6e9..9d7e6aa6 100755 Binary files a/11_virtual_memory/kernel8.img and b/11_virtual_memory/kernel8.img differ diff --git a/12_exceptions_part1_groundwork/Cargo.toml b/12_exceptions_part1_groundwork/Cargo.toml index 380f64d4..a98bd72a 100644 --- a/12_exceptions_part1_groundwork/Cargo.toml +++ b/12_exceptions_part1_groundwork/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/12_exceptions_part1_groundwork/Makefile b/12_exceptions_part1_groundwork/Makefile index 39f77ce4..d8aa81a2 100644 --- a/12_exceptions_part1_groundwork/Makefile +++ b/12_exceptions_part1_groundwork/Makefile @@ -35,16 +35,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -67,7 +69,7 @@ DOCKER_EXEC_MINIPUSH = ruby /utils/minipush.rb all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -101,7 +103,7 @@ openocd: openocd $(OPENOCD_ARG) define gen_gdb - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(RUSTC_CMD) cp $(CARGO_OUTPUT) kernel_for_jtag @$(DOCKER_CMD) $(DOCKER_ARG_DIR_TUT) $(DOCKER_ARG_NET) $(DOCKER_IMAGE) \ gdb-multiarch -q kernel_for_jtag @@ -114,7 +116,7 @@ gdb-opt0: clean $(SOURCES) $(call gen_gdb,-C debuginfo=2 -C opt-level=0) clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/12_exceptions_part1_groundwork/kernel b/12_exceptions_part1_groundwork/kernel index 945edfad..0b55799c 100755 Binary files a/12_exceptions_part1_groundwork/kernel and b/12_exceptions_part1_groundwork/kernel differ diff --git a/12_exceptions_part1_groundwork/kernel8.img b/12_exceptions_part1_groundwork/kernel8.img index 1a47d3c3..93b555cc 100755 Binary files a/12_exceptions_part1_groundwork/kernel8.img and b/12_exceptions_part1_groundwork/kernel8.img differ diff --git a/13_integrated_testing/Cargo.toml b/13_integrated_testing/Cargo.toml index f0049260..18df5acf 100644 --- a/13_integrated_testing/Cargo.toml +++ b/13_integrated_testing/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/13_integrated_testing/Makefile b/13_integrated_testing/Makefile index 46559a84..7015fdd9 100644 --- a/13_integrated_testing/Makefile +++ b/13_integrated_testing/Makefile @@ -48,16 +48,18 @@ endif QEMU_MISSING_STRING = "This board is not yet supported for QEMU." +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -X_CMD_ARGS = --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release -XRUSTC_CMD = cargo xrustc $(X_CMD_ARGS) -XTEST_CMD = cargo xtest $(X_CMD_ARGS) + +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) +TEST_CMD = cargo test $(COMPILER_ARGS) CARGO_OUTPUT = target/$(TARGET)/release/kernel @@ -82,7 +84,7 @@ DOCKER_EXEC_MINIPUSH = ruby /utils/minipush.rb all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -117,7 +119,7 @@ test: $(SOURCES) @mkdir -p target @echo "$$KERNEL_TEST_RUNNER" > target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XTEST_CMD) $(TEST_ARG) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) $(TEST_ARG) endif chainboot: all @@ -135,7 +137,7 @@ openocd: openocd $(OPENOCD_ARG) define gen_gdb - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(RUSTC_CMD) cp $(CARGO_OUTPUT) kernel_for_jtag @$(DOCKER_CMD_USER) $(DOCKER_ARG_DIR_TUT) $(DOCKER_ARG_NET) $(DOCKER_IMAGE) \ gdb-multiarch -q kernel_for_jtag @@ -148,7 +150,7 @@ gdb-opt0: clean $(SOURCES) $(call gen_gdb,-C debuginfo=2 -C opt-level=0) clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/13_integrated_testing/README.md b/13_integrated_testing/README.md index 66f0c67b..4cd1c403 100644 --- a/13_integrated_testing/README.md +++ b/13_integrated_testing/README.md @@ -54,8 +54,8 @@ testing facilities: Testing Rust `#![no_std]` code like our kernel is, at the point of writing this tutorial, not an easy endeavor. The short version is: We cannot use Rust's [native testing framework] straight away. -Utilizing the `#[test]` attribute macro and running `cargo test` (`xtest` in our case) would throw -compilation errors, because there are dependencies on the standard library. +Utilizing the `#[test]` attribute macro and running `cargo test` would throw compilation errors, +because there are dependencies on the standard library. [native testing framework]: https://doc.rust-lang.org/book/ch11-00-testing.html @@ -88,9 +88,9 @@ We introduce a new `Makefile` target: $ make test ``` -In essence, `make test` will execute `cargo xtest` instead of `cargo xrustc`. The details will be +In essence, `make test` will execute `cargo test` instead of `cargo rustc`. The details will be explained in due course. The rest of the tutorial will explain as chronologically as possible what -happens when `make test` aka `cargo xtest` runs. +happens when `make test` aka `cargo test` runs. ### Test Organization @@ -116,7 +116,7 @@ of the kernel code. The `main.rs` file is stripped down to the minimum. It only `use` statements. Since it is not possible to use `kernel` as the name for both the library and the binary part of the -crate, new entries in `Cargo.toml` are needed to differentiate the names. What's more, `cargo xtest` +crate, new entries in `Cargo.toml` are needed to differentiate the names. What's more, `cargo test` would try to compile and run `unit tests` for both. In our case, it will be sufficient to have all the unit test code in `lib.rs`, so test generation for `main.rs` can be disabled in `Cargo.toml` as well through the `test` flag: @@ -145,22 +145,22 @@ In `lib.rs`, we add the following headers to get started with `custom_test_frame Since this is a library now, we do not keep the `#![no_main]` inner attribute that `main.rs` has, because a library has no `main()` entry function, so the attribute does not apply. When compiling -for testing, though, it is still needed. The reason is that `cargo xtest` basically turns `lib.rs` +for testing, though, it is still needed. The reason is that `cargo test` basically turns `lib.rs` into a binary again by inserting a generated `main()` function (which is then calling a function that runs all the unit tests, but more about that in a second...). However, since our kernel code [overrides the compiler-inserted `main` shim] by way of using -`#![no_main]`, we need the same when `cargo xtest` is producing its test kernel binary. After all, +`#![no_main]`, we need the same when `cargo test` is producing its test kernel binary. After all, what we want is a minimal kernel that boots on the target and runs its own unit tests. Therefore, we conditionally set this attribute (`#![cfg_attr(test, no_main)]`) when the `test` flag is set, which -it is when `cargo xtest` runs. +it is when `cargo test` runs. [overrides the compiler-inserted `main` shim]: https://doc.rust-lang.org/unstable-book/language-features/lang-items.html?highlight=no_main#writing-an-executable-without-stdlib #### The Unit Test Runner The `#![test_runner(crate::test_runner)]` attribute declares the path of the test runner function -that we are supposed to provide. This is the one that will be called by the `cargo xtest` generated +that we are supposed to provide. This is the one that will be called by the `cargo test` generated `main()` function. Here is the implementation in `lib.rs`: ```rust @@ -221,12 +221,12 @@ call chain during kernel boot: | 4. | `kernel_init()` | `main.rs` | | 5. | `kernel_main()` | `main.rs` | -A function named `main` is never called. Hence, the `main()` function generated by `cargo xtest` +A function named `main` is never called. Hence, the `main()` function generated by `cargo test` would be silently dropped, and therefore the tests would never be executed. As you can see, `runtime_init()` is the last function residing in our carved-out `lib.rs`, and it calls into `kernel_init()`. So in order to get the tests to execute, we add a test-environment version of `kernel_init()` to `lib.rs` as well (conditional compilation ensures it is only present when the -test flag is set), and call the `cargo xtest` generated `main()` function from there. +test flag is set), and call the `cargo test` generated `main()` function from there. This is where `#![reexport_test_harness_main = "test_main"]` finally comes into picture. It declares the name of the generated main function so that we can manually call it. Here is the final @@ -359,7 +359,7 @@ test: $(SOURCES) @mkdir -p target @echo "$$KERNEL_TEST_RUNNER" > target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XTEST_CMD) $(TEST_ARG) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) $(TEST_ARG) ``` It first does the standard `objcopy` step to strip the `ELF` down to a raw binary. Just like in all @@ -404,7 +404,7 @@ def exec ### Writing Unit Tests Alright, that's a wrap for the whole chain from `make test` all the way to reporting the test exit -status back to `cargo xtest`. It is a lot to digest already, but we haven't even learned to write +status back to `cargo test`. It is a lot to digest already, but we haven't even learned to write `Unit Tests` yet. In essence, it is almost like in `std` environments, with the difference that `#[test]` can't be @@ -490,7 +490,7 @@ We are still not done with the tutorial, though :scream:. Integration tests need some special attention here and there too. As you already learned, they live in `$CRATE/tests/`. Each `.rs` file in there gets compiled into its own test kernel binary and -executed separately by `cargo xtest`. The code in the integration tests includes the library part of +executed separately by `cargo test`. The code in the integration tests includes the library part of our kernel (`libkernel`) through `use` statements. Also note that the entry point for each `integration test` must be the `kernel_init()` function @@ -498,7 +498,7 @@ again, just like in the `unit test` case. #### Test Harness -By default, `cargo xtest` will pull in the test harness (that's the official name for the generated +By default, `cargo test` will pull in the test harness (that's the official name for the generated `main()` function) into integration tests as well. This gives you a further means of partitioning your test code into individual chunks. For example, take a look at `tests/01_timer_sanity.rs`: @@ -701,7 +701,7 @@ Believe it or not, that is all. There are three ways you can run tests: ```console $ make test [...] -RUSTFLAGS="-C link-arg=-Tsrc/bsp/raspberrypi/link.ld -C target-cpu=cortex-a53 -D warnings -D missing_docs" cargo xtest --target=aarch64-unknown-none-softfloat --features bsp_rpi3 --release +RUSTFLAGS="-C link-arg=-Tsrc/bsp/raspberrypi/link.ld -C target-cpu=cortex-a53 -D warnings -D missing_docs" cargo test --target=aarch64-unknown-none-softfloat --features bsp_rpi3 --release Finished release [optimized] target(s) in 0.01s Running target/aarch64-unknown-none-softfloat/release/deps/libkernel-4cc6412ddf631982 ------------------------------------------------------------------- @@ -779,7 +779,7 @@ diff -uNr 12_exceptions_part1_groundwork/.cargo/config 13_integrated_testing/.ca diff -uNr 12_exceptions_part1_groundwork/Cargo.toml 13_integrated_testing/Cargo.toml --- 12_exceptions_part1_groundwork/Cargo.toml +++ 13_integrated_testing/Cargo.toml -@@ -14,7 +14,35 @@ +@@ -11,7 +11,35 @@ bsp_rpi4 = ["cortex-a", "register"] [dependencies] @@ -828,7 +828,7 @@ diff -uNr 12_exceptions_part1_groundwork/Makefile 13_integrated_testing/Makefile OPENOCD_ARG = -f /openocd/tcl/interface/ftdi/olimex-arm-usb-tiny-h.cfg -f /openocd/rpi3.cfg JTAG_BOOT_IMAGE = jtag_boot_rpi3.img LINKER_FILE = src/bsp/raspberrypi/link.ld -@@ -29,21 +30,34 @@ +@@ -29,12 +30,24 @@ # QEMU_BINARY = qemu-system-aarch64 # QEMU_MACHINE_TYPE = # QEMU_RELEASE_ARGS = -serial stdio -display none @@ -850,23 +850,18 @@ diff -uNr 12_exceptions_part1_groundwork/Makefile 13_integrated_testing/Makefile + +QEMU_MISSING_STRING = "This board is not yet supported for QEMU." + - RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) - RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs - SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) --XRUSTC_CMD = cargo xrustc \ -- --target=$(TARGET) \ -- --features bsp_$(BSP) \ -+X_CMD_ARGS = --target=$(TARGET) \ -+ --features bsp_$(BSP) \ - --release -+XRUSTC_CMD = cargo xrustc $(X_CMD_ARGS) -+XTEST_CMD = cargo xtest $(X_CMD_ARGS) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) +@@ -46,6 +59,7 @@ + + RUSTC_CMD = cargo rustc $(COMPILER_ARGS) + CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) ++TEST_CMD = cargo test $(COMPILER_ARGS) CARGO_OUTPUT = target/$(TARGET)/release/kernel -@@ -53,7 +67,8 @@ +@@ -55,7 +69,8 @@ -O binary DOCKER_IMAGE = rustembedded/osdev-utils @@ -876,7 +871,7 @@ diff -uNr 12_exceptions_part1_groundwork/Makefile 13_integrated_testing/Makefile DOCKER_ARG_DIR_TUT = -v $(shell pwd):/work -w /work DOCKER_ARG_DIR_UTILS = -v $(shell pwd)/../utils:/utils DOCKER_ARG_DIR_JTAG = -v $(shell pwd)/../X1_JTAG_boot:/jtag -@@ -62,7 +77,7 @@ +@@ -64,7 +79,7 @@ DOCKER_EXEC_QEMU = $(QEMU_BINARY) -M $(QEMU_MACHINE_TYPE) DOCKER_EXEC_MINIPUSH = ruby /utils/minipush.rb @@ -885,7 +880,7 @@ diff -uNr 12_exceptions_part1_groundwork/Makefile 13_integrated_testing/Makefile all: clean $(OUTPUT) -@@ -78,32 +93,51 @@ +@@ -80,32 +95,51 @@ ifeq ($(QEMU_MACHINE_TYPE),) qemu: @@ -916,7 +911,7 @@ diff -uNr 12_exceptions_part1_groundwork/Makefile 13_integrated_testing/Makefile + @mkdir -p target + @echo "$$KERNEL_TEST_RUNNER" > target/kernel_test_runner.sh + @chmod +x target/kernel_test_runner.sh -+ RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XTEST_CMD) $(TEST_ARG) ++ RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) $(TEST_ARG) endif chainboot: all @@ -939,7 +934,7 @@ diff -uNr 12_exceptions_part1_groundwork/Makefile 13_integrated_testing/Makefile openocd $(OPENOCD_ARG) define gen_gdb - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(RUSTC_CMD) cp $(CARGO_OUTPUT) kernel_for_jtag - @$(DOCKER_CMD) $(DOCKER_ARG_DIR_TUT) $(DOCKER_ARG_NET) $(DOCKER_IMAGE) \ + @$(DOCKER_CMD_USER) $(DOCKER_ARG_DIR_TUT) $(DOCKER_ARG_NET) $(DOCKER_IMAGE) \ diff --git a/13_integrated_testing/kernel b/13_integrated_testing/kernel index 04af9e60..36ae808b 100755 Binary files a/13_integrated_testing/kernel and b/13_integrated_testing/kernel differ diff --git a/13_integrated_testing/kernel8.img b/13_integrated_testing/kernel8.img index f7de2713..6fa7ec5f 100755 Binary files a/13_integrated_testing/kernel8.img and b/13_integrated_testing/kernel8.img differ diff --git a/14_exceptions_part2_peripheral_IRQs/Cargo.toml b/14_exceptions_part2_peripheral_IRQs/Cargo.toml index 93c4d204..e48f74b0 100644 --- a/14_exceptions_part2_peripheral_IRQs/Cargo.toml +++ b/14_exceptions_part2_peripheral_IRQs/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/14_exceptions_part2_peripheral_IRQs/Makefile b/14_exceptions_part2_peripheral_IRQs/Makefile index a006eb87..b9f23415 100644 --- a/14_exceptions_part2_peripheral_IRQs/Makefile +++ b/14_exceptions_part2_peripheral_IRQs/Makefile @@ -48,17 +48,19 @@ endif QEMU_MISSING_STRING = "This board is not yet supported for QEMU." +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs FEATURES = bsp_$(BSP) -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -X_CMD_ARGS = --target=$(TARGET) \ - --features $(FEATURES) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features $(FEATURES) \ --release -XRUSTC_CMD = cargo xrustc $(X_CMD_ARGS) -XTEST_CMD = cargo xtest $(X_CMD_ARGS) + +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) +TEST_CMD = cargo test $(COMPILER_ARGS) CARGO_OUTPUT = target/$(TARGET)/release/kernel @@ -83,7 +85,7 @@ DOCKER_EXEC_MINIPUSH = ruby /utils/minipush.rb all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -120,7 +122,7 @@ test: $(SOURCES) @mkdir -p target @echo "$$KERNEL_TEST_RUNNER" > target/kernel_test_runner.sh @chmod +x target/kernel_test_runner.sh - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XTEST_CMD) $(TEST_ARG) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(TEST_CMD) $(TEST_ARG) endif chainboot: all @@ -138,7 +140,7 @@ openocd: openocd $(OPENOCD_ARG) define gen_gdb - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC) $1" $(RUSTC_CMD) cp $(CARGO_OUTPUT) kernel_for_jtag @$(DOCKER_CMD_USER) $(DOCKER_ARG_DIR_TUT) $(DOCKER_ARG_NET) $(DOCKER_IMAGE) \ gdb-multiarch -q kernel_for_jtag @@ -151,7 +153,7 @@ gdb-opt0: clean $(SOURCES) $(call gen_gdb,-C debuginfo=2 -C opt-level=0) clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/14_exceptions_part2_peripheral_IRQs/README.md b/14_exceptions_part2_peripheral_IRQs/README.md index 03003fd3..2d9c0f90 100644 --- a/14_exceptions_part2_peripheral_IRQs/README.md +++ b/14_exceptions_part2_peripheral_IRQs/README.md @@ -750,7 +750,7 @@ Minipush 1.0 diff -uNr 13_integrated_testing/Cargo.toml 14_exceptions_part2_peripheral_IRQs/Cargo.toml --- 13_integrated_testing/Cargo.toml +++ 14_exceptions_part2_peripheral_IRQs/Cargo.toml -@@ -12,6 +12,7 @@ +@@ -9,6 +9,7 @@ default = [] bsp_rpi3 = ["cortex-a", "register"] bsp_rpi4 = ["cortex-a", "register"] @@ -762,21 +762,19 @@ diff -uNr 13_integrated_testing/Cargo.toml 14_exceptions_part2_peripheral_IRQs/C diff -uNr 13_integrated_testing/Makefile 14_exceptions_part2_peripheral_IRQs/Makefile --- 13_integrated_testing/Makefile +++ 14_exceptions_part2_peripheral_IRQs/Makefile -@@ -50,11 +50,12 @@ +@@ -52,9 +52,10 @@ RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs +FEATURES = bsp_$(BSP) - SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - - X_CMD_ARGS = --target=$(TARGET) \ -- --features bsp_$(BSP) \ -+ --features $(FEATURES) \ + COMPILER_ARGS = --target=$(TARGET) \ +- --features bsp_$(BSP) \ ++ --features $(FEATURES) \ --release - XRUSTC_CMD = cargo xrustc $(X_CMD_ARGS) - XTEST_CMD = cargo xtest $(X_CMD_ARGS) -@@ -91,6 +92,7 @@ + + RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +@@ -93,6 +94,7 @@ doc: cargo xdoc --target=$(TARGET) --features bsp_$(BSP) --document-private-items --open @@ -784,7 +782,7 @@ diff -uNr 13_integrated_testing/Makefile 14_exceptions_part2_peripheral_IRQs/Mak ifeq ($(QEMU_MACHINE_TYPE),) qemu: @echo $(QEMU_MISSING_STRING) -@@ -113,6 +115,7 @@ +@@ -115,6 +117,7 @@ endef export KERNEL_TEST_RUNNER diff --git a/14_exceptions_part2_peripheral_IRQs/kernel b/14_exceptions_part2_peripheral_IRQs/kernel index 14dcfa76..de22d5dd 100755 Binary files a/14_exceptions_part2_peripheral_IRQs/kernel and b/14_exceptions_part2_peripheral_IRQs/kernel differ diff --git a/14_exceptions_part2_peripheral_IRQs/kernel8.img b/14_exceptions_part2_peripheral_IRQs/kernel8.img index 9bc0ea3b..51af80c1 100755 Binary files a/14_exceptions_part2_peripheral_IRQs/kernel8.img and b/14_exceptions_part2_peripheral_IRQs/kernel8.img differ diff --git a/README.CN.md b/README.CN.md index 3cafd007..6d2e0552 100644 --- a/README.CN.md +++ b/README.CN.md @@ -58,11 +58,12 @@ _Cheers, curl https://sh.rustup.rs -sSf \ | \ sh -s -- \ - --default-toolchain nightly-2019-12-20 \ - --component rust-src llvm-tools-preview rustfmt + --default-toolchain nightly-2020-04-07 \ + --component llvm-tools-preview rustfmt source $HOME/.cargo/env -cargo install cargo-xbuild cargo-binutils +rustup target add aarch64-unknown-none-softfloat +cargo install cargo-binutils ``` 如果你使用 `Visual Studio Code`,我强烈推荐你安装[Rust Analyzer 扩展]。 diff --git a/README.md b/README.md index 248d7d07..eeb30b21 100644 --- a/README.md +++ b/README.md @@ -87,11 +87,12 @@ Before you can start, you must install a suitable Rust toolchain: curl https://sh.rustup.rs -sSf \ | \ sh -s -- \ - --default-toolchain nightly-2020-03-19 \ - --component rust-src llvm-tools-preview rustfmt + --default-toolchain nightly-2020-04-07 \ + --component llvm-tools-preview rustfmt source $HOME/.cargo/env -cargo install cargo-xbuild cargo-binutils +rustup target add aarch64-unknown-none-softfloat +cargo install cargo-binutils ``` In case you use `Visual Studio Code`, I strongly recommend installing the diff --git a/X1_JTAG_boot/Cargo.toml b/X1_JTAG_boot/Cargo.toml index 380f64d4..a98bd72a 100644 --- a/X1_JTAG_boot/Cargo.toml +++ b/X1_JTAG_boot/Cargo.toml @@ -4,9 +4,6 @@ version = "0.1.0" authors = ["Andre Richter "] edition = "2018" -[package.metadata.cargo-xbuild] -sysroot_path = "../xbuild_sysroot" - # The features section is used to select the target board. [features] default = [] diff --git a/X1_JTAG_boot/Makefile b/X1_JTAG_boot/Makefile index 1cf7c716..55ad6597 100644 --- a/X1_JTAG_boot/Makefile +++ b/X1_JTAG_boot/Makefile @@ -31,16 +31,18 @@ else ifeq ($(BSP),rpi4) RUSTC_MISC_ARGS = -C target-cpu=cortex-a72 endif +SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) + RUSTFLAGS = -C link-arg=-T$(LINKER_FILE) $(RUSTC_MISC_ARGS) RUSTFLAGS_PEDANTIC = $(RUSTFLAGS) -D warnings -D missing_docs -SOURCES = $(wildcard **/*.rs) $(wildcard **/*.S) $(wildcard **/*.ld) - -XRUSTC_CMD = cargo xrustc \ - --target=$(TARGET) \ - --features bsp_$(BSP) \ +COMPILER_ARGS = --target=$(TARGET) \ + --features bsp_$(BSP) \ --release +RUSTC_CMD = cargo rustc $(COMPILER_ARGS) +CLIPPY_CMD = cargo clippy $(COMPILER_ARGS) + CARGO_OUTPUT = target/$(TARGET)/release/kernel OBJCOPY_CMD = cargo objcopy \ @@ -61,7 +63,7 @@ DOCKER_EXEC_MINIPUSH = ruby /utils/minipush.rb all: clean $(OUTPUT) $(CARGO_OUTPUT): $(SOURCES) - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(XRUSTC_CMD) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(RUSTC_CMD) $(OUTPUT): $(CARGO_OUTPUT) cp $< . @@ -86,7 +88,7 @@ chainboot: all $(OUTPUT) clippy: - RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" cargo xclippy --target=$(TARGET) --features bsp_$(BSP) + RUSTFLAGS="$(RUSTFLAGS_PEDANTIC)" $(CLIPPY_CMD) clean: rm -rf target diff --git a/X1_JTAG_boot/jtag_boot_rpi3.img b/X1_JTAG_boot/jtag_boot_rpi3.img index 4bfda5ac..407ed26e 100755 Binary files a/X1_JTAG_boot/jtag_boot_rpi3.img and b/X1_JTAG_boot/jtag_boot_rpi3.img differ diff --git a/X1_JTAG_boot/jtag_boot_rpi4.img b/X1_JTAG_boot/jtag_boot_rpi4.img index 315e12a9..7de2d88f 100755 Binary files a/X1_JTAG_boot/jtag_boot_rpi4.img and b/X1_JTAG_boot/jtag_boot_rpi4.img differ diff --git a/utils/devtool.rb b/utils/devtool.rb index 927d55f7..e558f11f 100755 --- a/utils/devtool.rb +++ b/utils/devtool.rb @@ -88,7 +88,6 @@ class DevTool def clean @crates.each(&:clean) - FileUtils.rm_rf('xbuild_sysroot') end def clippy(bsp = nil)