Makefile: Add flash.sh support Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
diff --git a/.cargo/config b/.cargo/config index c34fe36..96fe275 100644 --- a/.cargo/config +++ b/.cargo/config
@@ -16,4 +16,4 @@ "-C", "relocation-model=static", "-C", "link-arg=-Tlayout.ld", ] -runner = "./flash.sh" +runner = "./tools/flash.sh"
diff --git a/.travis.yml b/.travis.yml index d088936..7b6bf87 100644 --- a/.travis.yml +++ b/.travis.yml
@@ -42,6 +42,6 @@ script: - make test # Run a QEMU instance of the HiFive1 app - - PLATFORM=hifive1 cargo rrv32imac --example hello_world + - make flash-hifive1 EXAMPLE=hello_world - timeout --foreground 10s qemu-system-riscv32 -M sifive_e -kernel ../tock/boards/hifive1/target/riscv32imac-unknown-none-elf/release/hifive1 -device loader,file=./target/riscv32imac-unknown-none-elf/tab/hifive1/hello_world/rv32imac.tbf,addr=0x20430000 -nographic | tee serial - grep "Hello Tock World" serial
diff --git a/Makefile b/Makefile index 263bfbf..feed19b 100644 --- a/Makefile +++ b/Makefile
@@ -18,15 +18,9 @@ @echo "Run 'make setup' to setup Rust to build libtock-rs." @echo "Run 'make <board>' to build libtock-rs for that board" @echo " Set the FEATURES flag to enable features" + @echo "Run 'make flash-<board> EXAMPLE=<>' to flash EXAMPLE to that board" @echo "Run 'make test' to test any local changes you have made" -check_defined = \ - $(strip $(foreach 1,$1, \ - $(call __check_defined,$1,$(strip $(value 2))))) -__check_defined = \ - $(if $(value $1),, \ - $(error Undefined $1$(if $2, $2))) - ifdef FEATURES features=--features=$(FEATURES) endif @@ -56,22 +50,42 @@ hail: PLATFORM=hail cargo build --release --target=thumbv7em-none-eabi --examples $(features) +.PHONY: flash-hail +flash-hail: + PLATFORM=hail cargo run --release --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) + .PHONY: nrf52840 nrf52840: PLATFORM=nrf52840 cargo build --release --target=thumbv7em-none-eabi --examples $(features) +.PHONY: flash-nrf52840 +flash-nrf52840: + PLATFORM=nrf52840 cargo run --release --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) + .PHONY: opentitan opentitan: PLATFORM=opentitan cargo build --release --target=riscv32imc-unknown-none-elf --examples $(features) +.PHONY: flash-opentitan +flash-opentitan: + PLATFORM=opentitan cargo run --release --target=riscv32imac-unknown-none-elf --example $(EXAMPLE) $(features) + .PHONY: hifive1 hifive1: PLATFORM=hifive1 cargo build --release --target=riscv32imac-unknown-none-elf --examples $(features) +.PHONY: flash-hifive1 +flash-hifive1: + PLATFORM=hifive1 cargo run --release --target=riscv32imac-unknown-none-elf --example $(EXAMPLE) $(features) + .PHONY: nrf52 nrf52: PLATFORM=nrf52 cargo build --release --target=thumbv7em-none-eabi --examples $(features) +.PHONY: flash-nrf52 +flash-nrf52: + PLATFORM=nrf52 cargo run --release --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) + .PHONY: clean clean: rm -rf target
diff --git a/README.md b/README.md index f5d2888..3f7e7f8 100644 --- a/README.md +++ b/README.md
@@ -63,7 +63,7 @@ make opentitan FEATURES=alloc # Builds all examples for the OpenTitan platform, with alloc feature enabled ``` - For an unknown platform, you may have to create your own memory layout definition. Place the layout definition file at `boards/layout_<platform>.ld` and do not forget to enhance the `tockloader_flags` dispatching section in `flash.sh`. You are welcome to create a PR, s.t. the number of supported platforms grows. + For an unknown platform, you may have to create your own memory layout definition. Place the layout definition file at `boards/layout_<platform>.ld` and do not forget to enhance the `tockloader_flags` dispatching section in `tools/flash.sh`. You are welcome to create a PR, s.t. the number of supported platforms grows. ## Using libtock-rs
diff --git a/flash.sh b/tools/flash.sh similarity index 100% rename from flash.sh rename to tools/flash.sh