| # Copyright 2024 Googl4 LLC | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # https://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| BUFFER_OVERFLOW_DIR := $(OUT)/cheriot/sencha/buffer_overflow | |
| BUFFER_OVERFLOW := $(BUFFER_OVERFLOW_DIR)/release/cheriot/cheriot/release/buffer_overflow-firmware | |
| BUFFER_OVERFLOW_SRC_DIR := ${ROOTDIR}/hw/matcha/sw/device/cheriot/buffer_overflow | |
| cheriot-buffer_overflow: __sail-buffer_overflow | |
| ${MAKE} \ | |
| __CHERIOT_ELF="@${BUFFER_OVERFLOW}" \ | |
| __cheriot-simulate | |
| cheriot-buffer_overflow+cli: __sail-buffer_overflow | |
| ${MAKE} \ | |
| __CHERIOT_ELF="@${BUFFER_OVERFLOW}" \ | |
| __cheriot-simulate+cli | |
| # Generates the buffer overflow firmware for sail | |
| __sail-buffer_overflow: | |
| ${MAKE} CHERIOT_BOARD=sail __buffer_overflow | |
| .PHONY:: cheriot-buffer_overflow cheriot-buffer_overflow+cli | |
| .PHONY:: __sail-buffer_overflow | |
| BUFFER_OVERFLOW_FLASH_RELEASE=$(CHERIOT_OUT_RELEASE)/buffer_overflow_flash.tar | |
| # XXX symlink cheriot fw to "kernel" to satisfy elfloader | |
| $(BUFFER_OVERFLOW_FLASH_RELEASE): $(MATCHA_BUNDLE_RELEASE) | $(TMP_RELEASE) | |
| cp -f $(MATCHA_BUNDLE_RELEASE) $(TMP_RELEASE)/matcha-tock-bundle | |
| ${C_PREFIX}strip $(TMP_RELEASE)/matcha-tock-bundle | |
| ${C_PREFIX}objcopy -O binary -g $(TMP_RELEASE)/matcha-tock-bundle $(TMP_RELEASE)/matcha-tock-bundle.bin | |
| ln -sf $(BUFFER_OVERFLOW) $(TMP_RELEASE)/kernel | |
| tar -C $(TMP_RELEASE) -cvhf $@ matcha-tock-bundle.bin kernel | |
| buffer_overflow_flash_release: __sencha-buffer_overflow $(BUFFER_OVERFLOW_FLASH_RELEASE) | |
| ## Runs the buffer overflow demo in renode on sencha | |
| sencha-buffer_overflow: buffer_overflow_flash_release | |
| ${MAKE} \ | |
| __SENCHA_TAR="@${BUFFER_OVERFLOW_FLASH_RELEASE}" \ | |
| __SENCHA_CHERIOT_ELF="@${TMP_RELEASE}/kernel" \ | |
| __sencha-simulate | |
| ## Version of the `sencha-buffer_overflow` target that also enables the simulator command | |
| ## line interface on port 4567. To access the simulator use something like | |
| ## telnet localhost 4567. Note renode will block until the cli is connected. | |
| sencha-buffer_overflow+cli: buffer_overflow_flash_release | |
| ${MAKE} \ | |
| __SENCHA_TAR="@${BUFFER_OVERFLOW_FLASH_RELEASE}" \ | |
| __SENCHA_CHERIOT_ELF="@${TMP_RELEASE}/kernel" \ | |
| __sencha-simulate+cli | |
| # Generates the buffer overflow firmware for sencha | |
| __sencha-buffer_overflow: | |
| ${MAKE} CHERIOT_BOARD=sencha __buffer_overflow | |
| # Helper that requires CHERIOT_BOARD be supplied on the cmd line | |
| __buffer_overflow: | |
| ${MAKE} \ | |
| CHERIOT_OUT_DIR=${BUFFER_OVERFLOW_DIR} \ | |
| CHERIOT_FIRMWARE_SRC_DIR=${BUFFER_OVERFLOW_SRC_DIR} \ | |
| CHERIOT_FIRMWARE_RELEASE=$(BUFFER_OVERFLOW) \ | |
| $(BUFFER_OVERFLOW) | |
| ## Cleans all build artifacts for the buffer_overflow demo | |
| buffer_overflow-clean: | |
| rm -rf ${BUFFER_OVERFLOW_DIR} | |
| .PHONY:: sencha-buffer_overflow sencha-buffer_overflow+cli | |
| .PHONY:: buffer_overflow_flash_release | |
| .PHONY:: buffer_overflow-clean | |
| .PHONY:: __sencha-buffer_overflow __buffer_overflow |