From e81c6ddf84c7e6b76f6451c49d69d1357da84df9 Mon Sep 17 00:00:00 2001 From: Berkus Decker Date: Thu, 17 Jan 2019 19:38:05 +0200 Subject: [PATCH] [SQ] Replace runscript.sh with ninja file --- .cargo/config | 1 - .cargo/runscript.sh | 6 ------ Cargo.toml | 1 - README.md | 23 +++++++++-------------- build.ninja | 30 ++++++++++++++++++++++++++++++ hopper.sh | 2 ++ 6 files changed, 41 insertions(+), 22 deletions(-) delete mode 100755 .cargo/runscript.sh create mode 100644 build.ninja create mode 100755 hopper.sh diff --git a/.cargo/config b/.cargo/config index fbd2cda..1e51b34 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,2 +1 @@ [target.aarch64-vesper-metta] -runner=".cargo/runscript.sh" diff --git a/.cargo/runscript.sh b/.cargo/runscript.sh deleted file mode 100755 index a6e52bf..0000000 --- a/.cargo/runscript.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -aarch64-unknown-linux-musl-objcopy -O binary $1 $1.bin - -# -d in_asm,unimp,int -S -/usr/local/Cellar/qemu/HEAD-3365de01b5-custom/bin/qemu-system-aarch64 -M raspi3 -serial null -serial stdio -kernel $1.bin diff --git a/Cargo.toml b/Cargo.toml index 1ec80e8..89effe9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,4 +40,3 @@ memcpy = true [package.metadata.bootimage] default-target = "targets/aarch64-vesper-metta.json" -#run-command = ".cargo/runscript.sh" diff --git a/README.md b/README.md index 225423a..5d387b5 100644 --- a/README.md +++ b/README.md @@ -33,22 +33,17 @@ Vesper has been influenced by the kernels in L4 family, notably seL4. Fawn and N Use rustc nightly 2018-04-01 or later because of [bugs fixed](https://github.com/rust-lang/rust/issues/48884). ``` -cargo xbuild --target=targets/aarch64-vesper-metta.json --release - -# Post-command: -sh .cargo/runscript.sh -cp target/aarch64-vesper-metta/release/vesper.bin /Volumes/boot/vesper - -# config.txt on RPi3 -kernel=vesper -arm_64bit=1 - -# To run in qemu, `brew install qemu --HEAD --with-libusb` and -### This command is not supported by cargo-xbuild yet: xargo run --target=aarch64-vesper-metta -# Use this instead: -sh .cargo/runscript.sh +ninja qemu ``` +Will run `cargo xbuild` to create kernel and run it in qemu emulator. + +``` +ninja device +``` + +Will build kernel, and copy it to sdcard at /Volumes/BOOT/ + ## OSdev help Based on [Raspi3 tutorials by Andre Richter](https://github.com/rust-embedded/rust-raspi3-tutorial/blob/master/05_uart0/src/uart.rs), diff --git a/build.ninja b/build.ninja new file mode 100644 index 0000000..7afe1c7 --- /dev/null +++ b/build.ninja @@ -0,0 +1,30 @@ +TARGET = aarch64-vesper-metta +FEATURES = --features "noserial" + +UTILS_CONTAINER = andrerichter/raspi3-utils +DOCKER_CMD = docker run -it --rm -v ./:/work -w /work +QEMU_CMD = qemu-system-aarch64 -M raspi3 -kernel + +# -d in_asm,unimp,int -S +QEMU = /usr/local/Cellar/qemu/HEAD-3365de01b5-custom/bin/qemu-system-aarch64 -M raspi3 -d int -serial null -serial stdio -kernel + +rule cargo_build + command = cargo xbuild --target=targets/$TARGET.json --release $FEATURES + +rule strip + command = cargo objcopy -- --strip-all -O binary $in $out + +rule docker_qemulate + command = $DOCKER_CMD $UTILS_CONTAINER $QEMU_CMD $in + +rule qemulate + command = $QEMU $in + +build kernel: cargo_build + +build kernel8.img: strip target/${TARGET}/release/vesper | kernel + +build qemu: qemulate kernel8.img + +default kernel8.img + diff --git a/hopper.sh b/hopper.sh new file mode 100755 index 0000000..4f201c4 --- /dev/null +++ b/hopper.sh @@ -0,0 +1,2 @@ +#!/bin/sh +hopperv4 -e target/aarch64-vesper-metta/release/vesper.bin -R --base-address 0x80000 --entrypoint 0x80000 --file-offset 0 --aarch64