blob: 779a02148ba5eb4599ad05da84c3615d6ff9e04c [file] [log] [blame]
Alistair Francis9f0b5ee2020-03-09 17:01:53 -07001# By default, let's print out some help
2.PHONY: usage
3usage:
4 @echo "$$(tput bold)Welcome to libtock-rs!$$(tput sgr0)"
5 @echo
6 @echo "First things first, if you haven't yet, check out Tocks's doc/Getting_Started."
7 @echo "After that read the README from libtock-rs"
8 @echo "You'll need to install a few requirements before we get going."
9 @echo
10 @echo "The next step is to choose a board to build Tock for. Mainline"
11 @echo "libtock-rs currently includes support for the following platforms:"
12 @echo " - hail"
13 @echo " - nrf52840"
Alexandru Radovicic0a7cc22020-06-06 17:40:36 +030014 @echo " - nucleo_f429zi"
15 @echo " - nucleo_f446re"
Alistair Francis9f0b5ee2020-03-09 17:01:53 -070016 @echo " - opentitan"
17 @echo " - hifive1"
18 @echo " - nrf52"
Vochescu Alexandrud5609772020-06-06 17:13:36 +030019 @echo " - imxrt1050"
Alistair Francis41218b42020-06-08 09:28:33 -070020 @echo " - apollo3"
l16250f187b2020-11-12 19:32:01 -050021 @echo " - stm32f3discovery"
Alistair Francis9f0b5ee2020-03-09 17:01:53 -070022 @echo
Alistair Francisc6fef952020-03-09 17:09:24 -070023 @echo "Run 'make setup' to setup Rust to build libtock-rs."
Alistair Francis9f0b5ee2020-03-09 17:01:53 -070024 @echo "Run 'make <board>' to build libtock-rs for that board"
Alistair Francisbb437f62020-03-10 14:07:36 -070025 @echo " Set the DEBUG flag to enable the debug build"
Alistair Francis55e3d6b2020-03-10 14:04:22 -070026 @echo " Set the FEATURES flag to enable features"
Alistair Franciscb3d5b82020-03-10 13:43:48 -070027 @echo "Run 'make flash-<board> EXAMPLE=<>' to flash EXAMPLE to that board"
Alistair Francis9f0b5ee2020-03-09 17:01:53 -070028 @echo "Run 'make test' to test any local changes you have made"
Johnathan Van Why74572d72020-06-16 16:46:50 -070029 @echo "Run 'make print-sizes' to print size data for the example binaries"
Alistair Francis9f0b5ee2020-03-09 17:01:53 -070030
Alistair Francis55e3d6b2020-03-10 14:04:22 -070031ifdef FEATURES
Alistair Francisab4d8b02020-03-25 09:00:20 -070032features=--features=$(FEATURES)
Alistair Francis55e3d6b2020-03-10 14:04:22 -070033endif
34
Alistair Francisbb437f62020-03-10 14:07:36 -070035ifndef DEBUG
Alistair Francisab4d8b02020-03-25 09:00:20 -070036release=--release
Alistair Francisbb437f62020-03-10 14:07:36 -070037endif
38
Alistair Francisc6fef952020-03-09 17:09:24 -070039.PHONY: setup
Johnathan Van Whyf07f8b22020-06-10 17:38:11 -070040setup: setup-qemu
Tobias Wölfelc355b472020-11-03 17:26:35 +010041 cargo install elf2tab --version 0.6.0
Alistair Franciseefde732020-03-24 10:58:42 -070042 cargo install stack-sizes
Johnathan Van Why988305c2020-07-08 15:50:45 -070043 cargo miri setup
Alistair Francisc6fef952020-03-09 17:09:24 -070044
Johnathan Van Whyc0d2b6f2020-06-15 15:29:54 -070045# Sets up QEMU in the tock/ directory. We use Tock's QEMU which may contain
46# patches to better support boards that Tock supports.
Johnathan Van Whyf07f8b22020-06-10 17:38:11 -070047.PHONY: setup-qemu
48setup-qemu:
Johnathan Van Whybd7dad22020-07-08 16:24:39 -070049 CI=true $(MAKE) -C tock ci-setup-qemu
Johnathan Van Whyf07f8b22020-06-10 17:38:11 -070050
Johnathan Van Why5a9606e2020-06-11 15:41:07 -070051# Builds a Tock kernel for the HiFive board for use by QEMU tests.
52.PHONY: kernel-hifive
53kernel-hifive:
54 $(MAKE) -C tock/boards/hifive1 \
55 $(CURDIR)/tock/target/riscv32imac-unknown-none-elf/release/hifive1.elf
56
Johnathan Van Why74572d72020-06-16 16:46:50 -070057# Prints out the sizes of the example binaries.
58.PHONY: print-sizes
59print-sizes: examples
Johnathan Van Whya6c5c9d2020-06-19 15:15:14 -070060 cargo run --release -p print_sizes
Johnathan Van Why74572d72020-06-16 16:46:50 -070061
Johnathan Van Why5a9606e2020-06-11 15:41:07 -070062# Runs the libtock_test tests in QEMU on a simulated HiFive board.
63.PHONY: test-qemu-hifive
Johnathan Van Whybd7dad22020-07-08 16:24:39 -070064test-qemu-hifive: kernel-hifive
Johnathan Van Why5a9606e2020-06-11 15:41:07 -070065 PLATFORM=hifive1 cargo rrv32imac --example libtock_test --features=alloc \
Johnathan Van Why3cbb1142020-08-03 16:24:51 -070066 --features=__internal_disable_gpio_in_integration_test \
67 --features=__internal_disable_timer_in_integration_test
Johnathan Van Whya6c5c9d2020-06-19 15:15:14 -070068 cargo run -p test_runner
Johnathan Van Why5a9606e2020-06-11 15:41:07 -070069
Alistair Francis9f0b5ee2020-03-09 17:01:53 -070070.PHONY: examples
71examples:
Johnathan Van Whya6c5c9d2020-06-19 15:15:14 -070072 PLATFORM=nrf52 cargo build --release --target=thumbv7em-none-eabi --examples -p libtock -p libtock_core
Alistair Francis9f0b5ee2020-03-09 17:01:53 -070073 PLATFORM=nrf52 cargo build --release --target=thumbv7em-none-eabi --examples --features=alloc
Woyten964bb722020-03-18 20:25:58 +010074 PLATFORM=nrf52 cargo build --release --target=thumbv7em-none-eabi --example panic --features=custom_panic_handler,custom_alloc_error_handler
75 PLATFORM=nrf52 cargo build --release --target=thumbv7em-none-eabi --example alloc_error --features=alloc,custom_alloc_error_handler
Johnathan Van Why74572d72020-06-16 16:46:50 -070076 # Important: This tests a platform without atomic instructions.
Johnathan Van Whya6c5c9d2020-06-19 15:15:14 -070077 PLATFORM=opentitan cargo build --release --target=riscv32imc-unknown-none-elf --examples -p libtock -p libtock_core
Alistair Francis9f0b5ee2020-03-09 17:01:53 -070078
79.PHONY: test
Johnathan Van Why5a9606e2020-06-11 15:41:07 -070080test: examples test-qemu-hifive
Alistair Francis9f0b5ee2020-03-09 17:01:53 -070081 PLATFORM=nrf52 cargo fmt --all -- --check
82 PLATFORM=nrf52 cargo clippy --workspace --all-targets
Johnathan Van Why988305c2020-07-08 15:50:45 -070083 PLATFORM=nrf52 cargo miri test --workspace
Johnathan Van Why5a9606e2020-06-11 15:41:07 -070084 echo '[ SUCCESS ] libtock-rs tests pass'
Alistair Francis9f0b5ee2020-03-09 17:01:53 -070085
Alistair Franciseefde732020-03-24 10:58:42 -070086.PHONY: analyse-stack-sizes
87analyse-stack-sizes:
88 cargo stack-sizes $(release) --example $(EXAMPLE) $(features) -- -Z emit-stack-sizes
89
Alistair Francis7ca0c452020-05-19 19:33:08 -070090.PHONY: apollo3
91apollo3:
92 PLATFORM=apollo3 cargo build $(release) --target=thumbv7em-none-eabi --examples $(features)
93
94.PHONY: flash-apollo3
95flash-apollo3:
96 PLATFORM=apollo3 cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features)
97
Alistair Francis9f0b5ee2020-03-09 17:01:53 -070098.PHONY: hail
99hail:
Alistair Francisbb437f62020-03-10 14:07:36 -0700100 PLATFORM=hail cargo build $(release) --target=thumbv7em-none-eabi --examples $(features)
Alistair Francis9f0b5ee2020-03-09 17:01:53 -0700101
Alistair Franciscb3d5b82020-03-10 13:43:48 -0700102.PHONY: flash-hail
103flash-hail:
Alistair Francisbb437f62020-03-10 14:07:36 -0700104 PLATFORM=hail cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features)
Alistair Franciscb3d5b82020-03-10 13:43:48 -0700105
Alexandru Radovicic0a7cc22020-06-06 17:40:36 +0300106.PHONY: nucleo_f429zi
107nucleo_f429zi:
108 PLATFORM=nucleo_f429zi cargo build $(release) --target=thumbv7em-none-eabi --examples $(features)
109
110.PHONY: flash-nucleo_f429zi
111flash-nucleo_f429zi:
112 PLATFORM=nucleo_f429zi cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features)
113
114.PHONY: nucleo_f446re
115nucleo_f446re:
116 PLATFORM=nucleo_f446re cargo build $(release) --target=thumbv7em-none-eabi --examples $(features)
117
118.PHONY: flash-nucleo_f446re
119flash-nucleo_f446re:
120 PLATFORM=nucleo_f446re cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features)
121
Alistair Francis9f0b5ee2020-03-09 17:01:53 -0700122.PHONY: nrf52840
123nrf52840:
Alistair Francisbb437f62020-03-10 14:07:36 -0700124 PLATFORM=nrf52840 cargo build $(release) --target=thumbv7em-none-eabi --examples $(features)
Alistair Francis9f0b5ee2020-03-09 17:01:53 -0700125
Alistair Franciscb3d5b82020-03-10 13:43:48 -0700126.PHONY: flash-nrf52840
127flash-nrf52840:
Alistair Francisbb437f62020-03-10 14:07:36 -0700128 PLATFORM=nrf52840 cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features)
Alistair Franciscb3d5b82020-03-10 13:43:48 -0700129
l16250f187b2020-11-12 19:32:01 -0500130.PHONY: stm32f3discovery
131stm32f3discovery:
132 PLATFORM=stm32f3discovery cargo build $(release) --target=thumbv7em-none-eabi --examples $(features)
133
134.PHONY: flash-stm32f3discovery
135flash-stm32f3discovery:
136 PLATFORM=stm32f3discovery cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features)
137
Alistair Francis9f0b5ee2020-03-09 17:01:53 -0700138.PHONY: opentitan
139opentitan:
Alistair Francisbb437f62020-03-10 14:07:36 -0700140 PLATFORM=opentitan cargo build $(release) --target=riscv32imc-unknown-none-elf --examples $(features)
Alistair Francis9f0b5ee2020-03-09 17:01:53 -0700141
Alistair Franciscb3d5b82020-03-10 13:43:48 -0700142.PHONY: flash-opentitan
143flash-opentitan:
Alistair Francis37bdcb02020-03-20 14:35:47 -0700144 PLATFORM=opentitan cargo run $(release) --target=riscv32imc-unknown-none-elf --example $(EXAMPLE) $(features)
Alistair Franciscb3d5b82020-03-10 13:43:48 -0700145
Alistair Francis9f0b5ee2020-03-09 17:01:53 -0700146.PHONY: hifive1
147hifive1:
Alistair Francisbb437f62020-03-10 14:07:36 -0700148 PLATFORM=hifive1 cargo build $(release) --target=riscv32imac-unknown-none-elf --examples $(features)
Alistair Francis9f0b5ee2020-03-09 17:01:53 -0700149
Alistair Franciscb3d5b82020-03-10 13:43:48 -0700150.PHONY: flash-hifive1
151flash-hifive1:
Alistair Francisbb437f62020-03-10 14:07:36 -0700152 PLATFORM=hifive1 cargo run $(release) --target=riscv32imac-unknown-none-elf --example $(EXAMPLE) $(features)
Alistair Franciscb3d5b82020-03-10 13:43:48 -0700153
Alistair Francis9f0b5ee2020-03-09 17:01:53 -0700154.PHONY: nrf52
155nrf52:
Alistair Francisbb437f62020-03-10 14:07:36 -0700156 PLATFORM=nrf52 cargo build $(release) --target=thumbv7em-none-eabi --examples $(features)
Alistair Francis9f0b5ee2020-03-09 17:01:53 -0700157
Alistair Franciscb3d5b82020-03-10 13:43:48 -0700158.PHONY: flash-nrf52
159flash-nrf52:
Alistair Francisbb437f62020-03-10 14:07:36 -0700160 PLATFORM=nrf52 cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features)
Alistair Franciscb3d5b82020-03-10 13:43:48 -0700161
Vochescu Alexandrud5609772020-06-06 17:13:36 +0300162.PHONY: imxrt1050
163imxrt1050:
164 PLATFORM=imxrt1050 cargo build $(release) --target=thumbv7em-none-eabi --examples $(features)
165
166.PHONY: flash-imxrt1050
167flash-imxrt1050:
168 PLATFORM=imxrt1050 cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features)
169
hotschif6cd66b2020-08-07 14:52:04 +0200170.PHONY: msp432
171msp432:
172 PLATFORM=msp432 cargo build $(release) --target=thumbv7em-none-eabi --examples $(features)
173
hotschie53bb532020-08-08 08:24:39 +0200174.PHONY: flash-msp432
hotschif6cd66b2020-08-07 14:52:04 +0200175flash-msp432:
176 PLATFORM=msp432 cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features)
Vochescu Alexandrud5609772020-06-06 17:13:36 +0300177
Alistair Francis9f0b5ee2020-03-09 17:01:53 -0700178.PHONY: clean
179clean:
Johnathan Van Whyc0d2b6f2020-06-15 15:29:54 -0700180 cargo clean
181 $(MAKE) -C tock clean