From 8dac3f107f33e445bff2a0133d897e0c1dac97f8 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Fri, 20 Sep 2019 01:38:52 +0800 Subject: [PATCH 1/7] travis: remove GCC toolchain, download prebuilt user image from github release --- .travis.yml | 19 ++----------------- kernel/Makefile | 4 ++-- user | 2 +- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index dda93734..ef9af965 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ sudo: false -dist: xenial +dist: bionic language: rust @@ -40,21 +40,6 @@ install: sudo apt update; sudo apt install device-tree-compiler -y; fi - - if [ 1 ]; then - [ $ARCH = riscv32 ] && export FILE="riscv32-linux-musl-cross"; - [ $ARCH = riscv64 ] && export FILE="riscv64-linux-musl-cross"; - [ $ARCH = mipsel ] && export FILE="mipsel-linux-musln32-cross"; - [ $ARCH = aarch64 ] && export FILE="aarch64-linux-musl-cross"; - [ $ARCH = x86_64 ] && export FILE="x86_64-linux-musl-cross"; - if [ $TRAVIS_OS_NAME = linux ]; then - wget https://musl.cc/$FILE.tgz; - elif [ $TRAVIS_OS_NAME = osx ]; then - wget https://mac.musl.cc/$FILE.tgz; - fi; - tar -xf $FILE.tgz; - export PATH=$PATH:$PWD/$FILE/bin; - fi - before_script: - rustup component add rust-src llvm-tools-preview @@ -62,7 +47,7 @@ before_script: - (test -x $HOME/.cargo/bin/cargo-xbuild || cargo install cargo-xbuild) script: - - cd user && make sfsimg arch=$ARCH && cd .. + - cd user && make sfsimg arch=$ARCH prebuilt=1 && cd .. - cd kernel && make build arch=$ARCH $OPTS && cd .. - if [ $ARCH = riscv32 ]; then cd tests && ./test.sh && cd ..; diff --git a/kernel/Makefile b/kernel/Makefile index 5b3f1fb3..131f38a7 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -257,10 +257,10 @@ runtest: build justruntest justrun: @qemu-system-$(arch) $(qemu_opts) -justrunnet: build +justrunnet: @sudo qemu-system-$(arch) $(qemu_opts) $(qemu_net_opts) -justruntest: build +justruntest: @qemu-system-$(arch) $(filter-out -serial mon:stdio, $(qemu_opts)) --append $(init) -serial file:../tests/stdout -monitor null debug: $(kernel) $(kernel_img) diff --git a/user b/user index 496a65e1..380ab63d 160000 --- a/user +++ b/user @@ -1 +1 @@ -Subproject commit 496a65e1d52c112c568f004144900d09e1d008c5 +Subproject commit 380ab63da9dba3ad2026828f212267123d98a253 From d6059f98c5d05f60821106ab37062f70355453e5 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Mon, 23 Sep 2019 01:08:39 +0800 Subject: [PATCH 2/7] travis: cache qemu, update brew on macOS --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ef9af965..deaeb760 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,10 +14,12 @@ cache: cargo: true directories: - $HOME/Library/Caches/Homebrew - - $TRAVIS_BUILD_DIR/qemu-4.1.0 + - $TRAVIS_BUILD_DIR/qemu-4.1.0/$ARCH-softmmu addons: homebrew: + update: true + brewfile: true packages: - qemu @@ -52,3 +54,6 @@ script: - if [ $ARCH = riscv32 ]; then cd tests && ./test.sh && cd ..; fi + +before_cache: + - if [ $TRAVIS_OS_NAME = osx ]; then brew cleanup; fi From badcd5330f7e9862ecf1008dc00368ab55076907 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Tue, 24 Sep 2019 01:19:31 +0800 Subject: [PATCH 3/7] travis: add missing package 'dtc' on macOS --- .travis.yml | 1 + user | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index deaeb760..c8c9ae0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ addons: brewfile: true packages: - qemu + - dtc env: matrix: diff --git a/user b/user index 380ab63d..10ac61f9 160000 --- a/user +++ b/user @@ -1 +1 @@ -Subproject commit 380ab63da9dba3ad2026828f212267123d98a253 +Subproject commit 10ac61f9ee5f64f2884b54719203be189ecb189d From 2722371d86f3517740abee266e01cd7fed393b75 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Tue, 24 Sep 2019 01:45:33 +0800 Subject: [PATCH 4/7] mips: fix build --- kernel/src/arch/mipsel/board/malta/mod.rs | 2 +- kernel/src/arch/mipsel/board/thinpad/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/src/arch/mipsel/board/malta/mod.rs b/kernel/src/arch/mipsel/board/malta/mod.rs index 9363e85a..94ca1bb5 100644 --- a/kernel/src/arch/mipsel/board/malta/mod.rs +++ b/kernel/src/arch/mipsel/board/malta/mod.rs @@ -36,7 +36,7 @@ pub fn init_driver() { yres_virtual: 600, xoffset: 0, yoffset: 0, - depth: fb::ColorDepth::try_from(8)?, + depth: fb::ColorDepth::ColorDepth8, format: fb::ColorFormat::VgaPalette, paddr: 0xb0000000, vaddr: 0xb0000000, diff --git a/kernel/src/arch/mipsel/board/thinpad/mod.rs b/kernel/src/arch/mipsel/board/thinpad/mod.rs index 6ff5101f..4c600185 100644 --- a/kernel/src/arch/mipsel/board/thinpad/mod.rs +++ b/kernel/src/arch/mipsel/board/thinpad/mod.rs @@ -25,7 +25,7 @@ pub fn init_driver() { yres_virtual: 600, xoffset: 0, yoffset: 0, - depth: fb::ColorDepth::try_from(8)?, + depth: fb::ColorDepth::ColorDepth8, format: fb::ColorFormat::RGB332, paddr: 0xa2000000, vaddr: 0xa2000000, From f1642ec547d8a52e0727a31ff06c5f3319bc46d7 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Tue, 24 Sep 2019 01:48:10 +0800 Subject: [PATCH 5/7] revert Rust toolchain to nightly-2019-07-15 to avoid LLVM bug on mips Related PR: https://github.com/rust-lang/rust/pull/62592 --- .travis.yml | 2 +- README.md | 2 +- rust-toolchain | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c8c9ae0b..ddabb080 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ dist: bionic language: rust -rust: nightly-2019-09-01 +rust: nightly-2019-07-15 os: - linux diff --git a/README.md b/README.md index 646dacb4..155fc08a 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Supported architectures and boards: ### Environment -* [Rust](https://www.rust-lang.org) toolchain at nightly-2019-09-01 +* [Rust](https://www.rust-lang.org) toolchain * Cargo tools: [cargo-xbuild](https://github.com/rust-osdev/cargo-xbuild) * [QEMU](https://www.qemu.org) >= 3.1.0 * [musl-based GCC toolchains](https://musl.cc/) diff --git a/rust-toolchain b/rust-toolchain index 7c5822d4..cd609032 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2019-09-01 +nightly-2019-07-15 From 3beddf12da37bcac11f4f39878e2a1706016a236 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Tue, 24 Sep 2019 14:26:18 +0800 Subject: [PATCH 6/7] build: remove filling symbols. prepare command 'make test'. --- .travis.yml | 4 +--- kernel/Makefile | 34 ++++++++++++++++------------------ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index ddabb080..bfcf4d82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,9 +52,7 @@ before_script: script: - cd user && make sfsimg arch=$ARCH prebuilt=1 && cd .. - cd kernel && make build arch=$ARCH $OPTS && cd .. - - if [ $ARCH = riscv32 ]; then - cd tests && ./test.sh && cd ..; - fi + - cd kernel && make test arch=$ARCH $OPTS && cd .. before_cache: - if [ $TRAVIS_OS_NAME = osx ]; then brew cleanup; fi diff --git a/kernel/Makefile b/kernel/Makefile index 131f38a7..998c94c4 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -2,10 +2,8 @@ # make build Build # make run Build and run in QEMU # make justrun Run the last build -# make runnet Build and run in QEMU with nic -# make justrunnet Run the last build with nic -# make runtest Build and run in QEMU with specified program -# make justruntest Run the last build with specified program +# make test Build and run in QEMU with specified program +# make justtest Run the last build with specified program # make doc Generate docs # make asm Open the deassemble file of the last build # make header Open 'objdump -h' of the last build @@ -26,6 +24,7 @@ # | k210 Only available on riscv64, run on K210, use Sv39 # | rocket_chip Only available on riscv64, run on Rocket Chip, use Sv39 # | raspi3 Only available on aarch64, run on Raspberry Pi 3 Model B/B+ +# net = on | off Only available on x86_64, enable NIC # pci_passthru = 0000:00:00.1 Only available on x86_64, passthrough the specified PCI device # init = /bin/ls Only available on riscv64, run specified program instead of user shell # extra_nic = on | off Only available on x86_64, add an additional e1000 nic @@ -41,6 +40,7 @@ pci_passthru ?= init ?= extra_nic ?= off +qemu := qemu-system-$(arch) target := $(arch) build_path := target/$(target)/$(mode) kernel := $(build_path)/rcore @@ -182,6 +182,11 @@ ifeq ($(graphic), off) qemu_opts += -nographic endif +ifeq ($(net), on) +qemu_opts += $(qemu_net_opts) +qemu := sudo $(qemu) +endif + ### build args ### ifeq ($(graphic), off) features += nographic @@ -238,7 +243,7 @@ strip := cargo strip -- dtc := dtc hostcc := gcc -.PHONY: all clean build asm doc debug kernel sfsimg install run justrun runnet justrunnet runtest justruntest +.PHONY: all clean build asm doc debug kernel sfsimg install run justrun test justtest all: kernel @@ -251,20 +256,17 @@ doc: @cargo rustdoc -- --document-private-items run: build justrun -runnet: build justrunnet -runtest: build justruntest +test: build justtest justrun: - @qemu-system-$(arch) $(qemu_opts) + @$(qemu) $(qemu_opts) -justrunnet: - @sudo qemu-system-$(arch) $(qemu_opts) $(qemu_net_opts) - -justruntest: - @qemu-system-$(arch) $(filter-out -serial mon:stdio, $(qemu_opts)) --append $(init) -serial file:../tests/stdout -monitor null +justtest: + # unavailable now + @#$(qemu) $(filter-out -serial mon:stdio, $(qemu_opts)) --append $(init) -serial file:../tests/stdout -monitor null debug: $(kernel) $(kernel_img) - @qemu-system-$(arch) $(qemu_opts) -s -S & + @$(qemu) $(qemu_opts) -s -S & @sleep 1 @$(gdb) $(kernel) -x ../tools/gdbinit @@ -293,8 +295,6 @@ ifeq ($(arch), x86_64) @cd ../rboot && make build endif ifeq ($(arch), aarch64) - @echo "Patching symbols into kernel." - @../tools/fill_symbols/aarch64.sh target/aarch64/$(mode)/rcore $(prefix) @echo Building $(arch) bootloader @$(strip) $(kernel) -o $(kernel)_stripped @cd $(bootloader_dir) && make arch=$(arch) mode=$(mode) payload=../kernel/$(kernel)_stripped @@ -320,8 +320,6 @@ kernel: $(dtb) @echo Building $(arch) kernel ifeq ($(arch), x86_64) @cargo xbuild $(build_args) - @echo "Now patching kernel symbols onto kernel." - @../tools/fill_symbols/x86_64.sh target/x86_64/$(mode)/rcore else ifeq ($(arch), $(filter $(arch), riscv32 riscv64)) ifeq ($(board), k210) @cp src/arch/riscv32/board/k210/linker.ld src/arch/riscv32/boot/linker64.ld From 3b1deac5d6c68a2d3c714f12c006f132cf6ae0a6 Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Tue, 24 Sep 2019 14:47:53 +0800 Subject: [PATCH 7/7] travis: fix caching qemu --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bfcf4d82..229a2059 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ cache: cargo: true directories: - $HOME/Library/Caches/Homebrew - - $TRAVIS_BUILD_DIR/qemu-4.1.0/$ARCH-softmmu + - $TRAVIS_BUILD_DIR/qemu-4.1.0 addons: homebrew: @@ -38,7 +38,7 @@ env: install: - if [ $TRAVIS_OS_NAME = linux ]; then - wget https://download.qemu.org/qemu-4.1.0.tar.xz && tar xJf qemu-4.1.0.tar.xz > /dev/null && cd qemu-4.1.0 && ./configure --target-list=$ARCH-softmmu && make && cd ..; + [ ! -d qemu-4.1.0/$ARCH-softmmu ] && wget https://download.qemu.org/qemu-4.1.0.tar.xz && tar xJf qemu-4.1.0.tar.xz > /dev/null && cd qemu-4.1.0 && ./configure --target-list=$ARCH-softmmu && make && cd ..; export PATH=$PATH:$PWD/qemu-4.1.0/$ARCH-softmmu:$PWD/qemu-4.1.0; sudo apt update; sudo apt install device-tree-compiler -y;