Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 1 | # By default, let's print out some help |
| 2 | .PHONY: usage |
| 3 | usage: |
| 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 Radovici | c0a7cc2 | 2020-06-06 17:40:36 +0300 | [diff] [blame] | 14 | @echo " - nucleo_f429zi" |
| 15 | @echo " - nucleo_f446re" |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 16 | @echo " - opentitan" |
| 17 | @echo " - hifive1" |
| 18 | @echo " - nrf52" |
Vochescu Alexandru | d560977 | 2020-06-06 17:13:36 +0300 | [diff] [blame] | 19 | @echo " - imxrt1050" |
Alistair Francis | 41218b4 | 2020-06-08 09:28:33 -0700 | [diff] [blame] | 20 | @echo " - apollo3" |
l162 | 50f187b | 2020-11-12 19:32:01 -0500 | [diff] [blame] | 21 | @echo " - stm32f3discovery" |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 22 | @echo |
Alistair Francis | c6fef95 | 2020-03-09 17:09:24 -0700 | [diff] [blame] | 23 | @echo "Run 'make setup' to setup Rust to build libtock-rs." |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 24 | @echo "Run 'make <board>' to build libtock-rs for that board" |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 25 | @echo " Set the DEBUG flag to enable the debug build" |
Alistair Francis | 55e3d6b | 2020-03-10 14:04:22 -0700 | [diff] [blame] | 26 | @echo " Set the FEATURES flag to enable features" |
Alistair Francis | cb3d5b8 | 2020-03-10 13:43:48 -0700 | [diff] [blame] | 27 | @echo "Run 'make flash-<board> EXAMPLE=<>' to flash EXAMPLE to that board" |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 28 | @echo "Run 'make test' to test any local changes you have made" |
Johnathan Van Why | 74572d7 | 2020-06-16 16:46:50 -0700 | [diff] [blame] | 29 | @echo "Run 'make print-sizes' to print size data for the example binaries" |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 30 | |
Alistair Francis | 55e3d6b | 2020-03-10 14:04:22 -0700 | [diff] [blame] | 31 | ifdef FEATURES |
Alistair Francis | ab4d8b0 | 2020-03-25 09:00:20 -0700 | [diff] [blame] | 32 | features=--features=$(FEATURES) |
Alistair Francis | 55e3d6b | 2020-03-10 14:04:22 -0700 | [diff] [blame] | 33 | endif |
| 34 | |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 35 | ifndef DEBUG |
Alistair Francis | ab4d8b0 | 2020-03-25 09:00:20 -0700 | [diff] [blame] | 36 | release=--release |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 37 | endif |
| 38 | |
Alistair Francis | c6fef95 | 2020-03-09 17:09:24 -0700 | [diff] [blame] | 39 | .PHONY: setup |
Johnathan Van Why | f07f8b2 | 2020-06-10 17:38:11 -0700 | [diff] [blame] | 40 | setup: setup-qemu |
Tobias Wölfel | c355b47 | 2020-11-03 17:26:35 +0100 | [diff] [blame] | 41 | cargo install elf2tab --version 0.6.0 |
Alistair Francis | eefde73 | 2020-03-24 10:58:42 -0700 | [diff] [blame] | 42 | cargo install stack-sizes |
Johnathan Van Why | 988305c | 2020-07-08 15:50:45 -0700 | [diff] [blame] | 43 | cargo miri setup |
Alistair Francis | c6fef95 | 2020-03-09 17:09:24 -0700 | [diff] [blame] | 44 | |
Johnathan Van Why | c0d2b6f | 2020-06-15 15:29:54 -0700 | [diff] [blame] | 45 | # 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 Why | f07f8b2 | 2020-06-10 17:38:11 -0700 | [diff] [blame] | 47 | .PHONY: setup-qemu |
| 48 | setup-qemu: |
Johnathan Van Why | bd7dad2 | 2020-07-08 16:24:39 -0700 | [diff] [blame] | 49 | CI=true $(MAKE) -C tock ci-setup-qemu |
Johnathan Van Why | f07f8b2 | 2020-06-10 17:38:11 -0700 | [diff] [blame] | 50 | |
Johnathan Van Why | 5a9606e | 2020-06-11 15:41:07 -0700 | [diff] [blame] | 51 | # Builds a Tock kernel for the HiFive board for use by QEMU tests. |
| 52 | .PHONY: kernel-hifive |
| 53 | kernel-hifive: |
| 54 | $(MAKE) -C tock/boards/hifive1 \ |
| 55 | $(CURDIR)/tock/target/riscv32imac-unknown-none-elf/release/hifive1.elf |
| 56 | |
Johnathan Van Why | 74572d7 | 2020-06-16 16:46:50 -0700 | [diff] [blame] | 57 | # Prints out the sizes of the example binaries. |
| 58 | .PHONY: print-sizes |
| 59 | print-sizes: examples |
Johnathan Van Why | a6c5c9d | 2020-06-19 15:15:14 -0700 | [diff] [blame] | 60 | cargo run --release -p print_sizes |
Johnathan Van Why | 74572d7 | 2020-06-16 16:46:50 -0700 | [diff] [blame] | 61 | |
Johnathan Van Why | 5a9606e | 2020-06-11 15:41:07 -0700 | [diff] [blame] | 62 | # Runs the libtock_test tests in QEMU on a simulated HiFive board. |
| 63 | .PHONY: test-qemu-hifive |
Johnathan Van Why | bd7dad2 | 2020-07-08 16:24:39 -0700 | [diff] [blame] | 64 | test-qemu-hifive: kernel-hifive |
Johnathan Van Why | 5a9606e | 2020-06-11 15:41:07 -0700 | [diff] [blame] | 65 | PLATFORM=hifive1 cargo rrv32imac --example libtock_test --features=alloc \ |
Johnathan Van Why | 3cbb114 | 2020-08-03 16:24:51 -0700 | [diff] [blame] | 66 | --features=__internal_disable_gpio_in_integration_test \ |
| 67 | --features=__internal_disable_timer_in_integration_test |
Johnathan Van Why | a6c5c9d | 2020-06-19 15:15:14 -0700 | [diff] [blame] | 68 | cargo run -p test_runner |
Johnathan Van Why | 5a9606e | 2020-06-11 15:41:07 -0700 | [diff] [blame] | 69 | |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 70 | .PHONY: examples |
| 71 | examples: |
Johnathan Van Why | a6c5c9d | 2020-06-19 15:15:14 -0700 | [diff] [blame] | 72 | PLATFORM=nrf52 cargo build --release --target=thumbv7em-none-eabi --examples -p libtock -p libtock_core |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 73 | PLATFORM=nrf52 cargo build --release --target=thumbv7em-none-eabi --examples --features=alloc |
Woyten | 964bb72 | 2020-03-18 20:25:58 +0100 | [diff] [blame] | 74 | 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 Why | 74572d7 | 2020-06-16 16:46:50 -0700 | [diff] [blame] | 76 | # Important: This tests a platform without atomic instructions. |
Johnathan Van Why | a6c5c9d | 2020-06-19 15:15:14 -0700 | [diff] [blame] | 77 | PLATFORM=opentitan cargo build --release --target=riscv32imc-unknown-none-elf --examples -p libtock -p libtock_core |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 78 | |
| 79 | .PHONY: test |
Johnathan Van Why | 5a9606e | 2020-06-11 15:41:07 -0700 | [diff] [blame] | 80 | test: examples test-qemu-hifive |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 81 | PLATFORM=nrf52 cargo fmt --all -- --check |
| 82 | PLATFORM=nrf52 cargo clippy --workspace --all-targets |
Johnathan Van Why | 988305c | 2020-07-08 15:50:45 -0700 | [diff] [blame] | 83 | PLATFORM=nrf52 cargo miri test --workspace |
Johnathan Van Why | 5a9606e | 2020-06-11 15:41:07 -0700 | [diff] [blame] | 84 | echo '[ SUCCESS ] libtock-rs tests pass' |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 85 | |
Alistair Francis | eefde73 | 2020-03-24 10:58:42 -0700 | [diff] [blame] | 86 | .PHONY: analyse-stack-sizes |
| 87 | analyse-stack-sizes: |
| 88 | cargo stack-sizes $(release) --example $(EXAMPLE) $(features) -- -Z emit-stack-sizes |
| 89 | |
Alistair Francis | 7ca0c45 | 2020-05-19 19:33:08 -0700 | [diff] [blame] | 90 | .PHONY: apollo3 |
| 91 | apollo3: |
| 92 | PLATFORM=apollo3 cargo build $(release) --target=thumbv7em-none-eabi --examples $(features) |
| 93 | |
| 94 | .PHONY: flash-apollo3 |
| 95 | flash-apollo3: |
| 96 | PLATFORM=apollo3 cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) |
| 97 | |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 98 | .PHONY: hail |
| 99 | hail: |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 100 | PLATFORM=hail cargo build $(release) --target=thumbv7em-none-eabi --examples $(features) |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 101 | |
Alistair Francis | cb3d5b8 | 2020-03-10 13:43:48 -0700 | [diff] [blame] | 102 | .PHONY: flash-hail |
| 103 | flash-hail: |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 104 | PLATFORM=hail cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) |
Alistair Francis | cb3d5b8 | 2020-03-10 13:43:48 -0700 | [diff] [blame] | 105 | |
Alexandru Radovici | c0a7cc2 | 2020-06-06 17:40:36 +0300 | [diff] [blame] | 106 | .PHONY: nucleo_f429zi |
| 107 | nucleo_f429zi: |
| 108 | PLATFORM=nucleo_f429zi cargo build $(release) --target=thumbv7em-none-eabi --examples $(features) |
| 109 | |
| 110 | .PHONY: flash-nucleo_f429zi |
| 111 | flash-nucleo_f429zi: |
| 112 | PLATFORM=nucleo_f429zi cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) |
| 113 | |
| 114 | .PHONY: nucleo_f446re |
| 115 | nucleo_f446re: |
| 116 | PLATFORM=nucleo_f446re cargo build $(release) --target=thumbv7em-none-eabi --examples $(features) |
| 117 | |
| 118 | .PHONY: flash-nucleo_f446re |
| 119 | flash-nucleo_f446re: |
| 120 | PLATFORM=nucleo_f446re cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) |
| 121 | |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 122 | .PHONY: nrf52840 |
| 123 | nrf52840: |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 124 | PLATFORM=nrf52840 cargo build $(release) --target=thumbv7em-none-eabi --examples $(features) |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 125 | |
Alistair Francis | cb3d5b8 | 2020-03-10 13:43:48 -0700 | [diff] [blame] | 126 | .PHONY: flash-nrf52840 |
| 127 | flash-nrf52840: |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 128 | PLATFORM=nrf52840 cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) |
Alistair Francis | cb3d5b8 | 2020-03-10 13:43:48 -0700 | [diff] [blame] | 129 | |
l162 | 50f187b | 2020-11-12 19:32:01 -0500 | [diff] [blame] | 130 | .PHONY: stm32f3discovery |
| 131 | stm32f3discovery: |
| 132 | PLATFORM=stm32f3discovery cargo build $(release) --target=thumbv7em-none-eabi --examples $(features) |
| 133 | |
| 134 | .PHONY: flash-stm32f3discovery |
| 135 | flash-stm32f3discovery: |
| 136 | PLATFORM=stm32f3discovery cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) |
| 137 | |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 138 | .PHONY: opentitan |
| 139 | opentitan: |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 140 | PLATFORM=opentitan cargo build $(release) --target=riscv32imc-unknown-none-elf --examples $(features) |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 141 | |
Alistair Francis | cb3d5b8 | 2020-03-10 13:43:48 -0700 | [diff] [blame] | 142 | .PHONY: flash-opentitan |
| 143 | flash-opentitan: |
Alistair Francis | 37bdcb0 | 2020-03-20 14:35:47 -0700 | [diff] [blame] | 144 | PLATFORM=opentitan cargo run $(release) --target=riscv32imc-unknown-none-elf --example $(EXAMPLE) $(features) |
Alistair Francis | cb3d5b8 | 2020-03-10 13:43:48 -0700 | [diff] [blame] | 145 | |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 146 | .PHONY: hifive1 |
| 147 | hifive1: |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 148 | PLATFORM=hifive1 cargo build $(release) --target=riscv32imac-unknown-none-elf --examples $(features) |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 149 | |
Alistair Francis | cb3d5b8 | 2020-03-10 13:43:48 -0700 | [diff] [blame] | 150 | .PHONY: flash-hifive1 |
| 151 | flash-hifive1: |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 152 | PLATFORM=hifive1 cargo run $(release) --target=riscv32imac-unknown-none-elf --example $(EXAMPLE) $(features) |
Alistair Francis | cb3d5b8 | 2020-03-10 13:43:48 -0700 | [diff] [blame] | 153 | |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 154 | .PHONY: nrf52 |
| 155 | nrf52: |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 156 | PLATFORM=nrf52 cargo build $(release) --target=thumbv7em-none-eabi --examples $(features) |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 157 | |
Alistair Francis | cb3d5b8 | 2020-03-10 13:43:48 -0700 | [diff] [blame] | 158 | .PHONY: flash-nrf52 |
| 159 | flash-nrf52: |
Alistair Francis | bb437f6 | 2020-03-10 14:07:36 -0700 | [diff] [blame] | 160 | PLATFORM=nrf52 cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) |
Alistair Francis | cb3d5b8 | 2020-03-10 13:43:48 -0700 | [diff] [blame] | 161 | |
Vochescu Alexandru | d560977 | 2020-06-06 17:13:36 +0300 | [diff] [blame] | 162 | .PHONY: imxrt1050 |
| 163 | imxrt1050: |
| 164 | PLATFORM=imxrt1050 cargo build $(release) --target=thumbv7em-none-eabi --examples $(features) |
| 165 | |
| 166 | .PHONY: flash-imxrt1050 |
| 167 | flash-imxrt1050: |
| 168 | PLATFORM=imxrt1050 cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) |
| 169 | |
hotschi | f6cd66b | 2020-08-07 14:52:04 +0200 | [diff] [blame] | 170 | .PHONY: msp432 |
| 171 | msp432: |
| 172 | PLATFORM=msp432 cargo build $(release) --target=thumbv7em-none-eabi --examples $(features) |
| 173 | |
hotschi | e53bb53 | 2020-08-08 08:24:39 +0200 | [diff] [blame] | 174 | .PHONY: flash-msp432 |
hotschi | f6cd66b | 2020-08-07 14:52:04 +0200 | [diff] [blame] | 175 | flash-msp432: |
| 176 | PLATFORM=msp432 cargo run $(release) --target=thumbv7em-none-eabi --example $(EXAMPLE) $(features) |
Vochescu Alexandru | d560977 | 2020-06-06 17:13:36 +0300 | [diff] [blame] | 177 | |
Alistair Francis | 9f0b5ee | 2020-03-09 17:01:53 -0700 | [diff] [blame] | 178 | .PHONY: clean |
| 179 | clean: |
Johnathan Van Why | c0d2b6f | 2020-06-15 15:29:54 -0700 | [diff] [blame] | 180 | cargo clean |
| 181 | $(MAKE) -C tock clean |