Michael Grand | b76287b | 2019-02-24 23:38:57 +0100 | [diff] [blame] | 1 | PLATFORM ?= zcu102 |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 2 | BSP_PATH ?= ../xilinx-${PLATFORM}-v$(PETALINUX_VER)-final.bsp |
| 3 | PRJ_PATH ?= ../petalinux-optee-$(PLATFORM) |
Michael Grand | b76287b | 2019-02-24 23:38:57 +0100 | [diff] [blame] | 4 | OPTEE_VER ?= latest |
| 5 | |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 6 | PYTHON_PATH ?= ${PRJ_PATH}/project-spec/meta-user/recipes-devtools/python |
| 7 | |
Michael Grand | b76287b | 2019-02-24 23:38:57 +0100 | [diff] [blame] | 8 | define set_cfg |
| 9 | @sed -i 's/$(1)=.*/$(1)=$(2)/' $(3) |
| 10 | endef |
| 11 | |
| 12 | define set_optee_version |
| 13 | @if [ "$(1)" != "latest" ]; then \ |
| 14 | echo 'OPTEE_VERSION ?= "$(1)"' > $(2); \ |
| 15 | echo 'SRCREV ?= "$(1)"' >> $(2); \ |
| 16 | else \ |
| 17 | echo 'OPTEE_VERSION ?= "latest"' > $(2); \ |
| 18 | echo 'SRCREV ?= "$${AUTOREV}"' >> $(2); \ |
| 19 | fi |
| 20 | endef |
| 21 | |
Michael Grand | 08b8dde | 2019-03-13 17:56:04 +0100 | [diff] [blame] | 22 | ifeq ($(PLATFORM),ultra96-reva) |
| 23 | ZYNQMP_CONSOLE=cadence1 |
| 24 | else |
| 25 | ZYNQMP_CONSOLE=cadence0 |
| 26 | endif |
Michael Grand | b76287b | 2019-02-24 23:38:57 +0100 | [diff] [blame] | 27 | |
Michael Grand | 08b8dde | 2019-03-13 17:56:04 +0100 | [diff] [blame] | 28 | .PHONY: all |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 29 | all: create build package |
Michael Grand | 08b8dde | 2019-03-13 17:56:04 +0100 | [diff] [blame] | 30 | |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 31 | .PHONY: check |
| 32 | check: |
Michael Grand | b76287b | 2019-02-24 23:38:57 +0100 | [diff] [blame] | 33 | ifndef PETALINUX_VER |
| 34 | $(error You have to source Petalinux settings) |
| 35 | endif |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 36 | ifneq ($(PETALINUX_VER),2020.2) |
| 37 | $(error This makefile only support Petalinux 2020.2) |
Michael Grand | b76287b | 2019-02-24 23:38:57 +0100 | [diff] [blame] | 38 | endif |
| 39 | |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 40 | create: check |
| 41 | @# Create TMP directory to avoid issues with .. in the path name |
| 42 | @mkdir -p /tmp/petalinux-optee-${PLATFORM} |
| 43 | @petalinux-create -n $(PRJ_PATH) -t project -s $(BSP_PATH) --tmpdir /tmp/petalinux-optee-${PLATFORM} |
Michael Grand | b76287b | 2019-02-24 23:38:57 +0100 | [diff] [blame] | 44 | @# |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 45 | @# Append the ATF recipe to include opteed as SPD |
| 46 | @mkdir -p ${PRJ_PATH}/project-spec/meta-user/recipes-bsp/arm-trusted-firmware |
| 47 | @cp zynqmp/arm-trusted-firmware/*.bbappend ${PRJ_PATH}/project-spec/meta-user/recipes-bsp/arm-trusted-firmware/. |
Michael Grand | b76287b | 2019-02-24 23:38:57 +0100 | [diff] [blame] | 48 | @# |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 49 | @# Download optee package recipes from meta-arm layer using gatesgarth branch as there were not available for zeus |
| 50 | @curl -s https://git.yoctoproject.org/cgit/cgit.cgi/meta-arm/snapshot/meta-arm-3.2.tar.gz -o ../meta-arm-3.2.tar.gz |
| 51 | @tar -C ${PRJ_PATH}/project-spec/meta-user --strip-components=2 -xvf ../meta-arm-3.2.tar.gz meta-arm-3.2/meta-arm/recipes-security > /dev/null |
Michael Grand | 08b8dde | 2019-03-13 17:56:04 +0100 | [diff] [blame] | 52 | @# |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 53 | @# Copy the bbapend files for our target |
| 54 | @cp zynqmp/optee/* ${PRJ_PATH}/project-spec/meta-user/recipes-security/optee/. |
Michael Grand | b76287b | 2019-02-24 23:38:57 +0100 | [diff] [blame] | 55 | @# |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 56 | @# Download python package dependencies from meta-core layer using gatesgarth branch as there were not available for zeus |
| 57 | @mkdir -p ${PYTHON_PATH} |
| 58 | @curl -s http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-devtools/python/python3-pycryptodome_3.9.8.bb?h=gatesgarth \ |
| 59 | -o ${PYTHON_PATH}/python3-pycryptodome_3.9.8.bb |
| 60 | @curl -s http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-devtools/python/python3-pycryptodomex_3.9.8.bb?h=gatesgarth \ |
| 61 | -o ${PYTHON_PATH}/python3-pycryptodomex_3.9.8.bb |
| 62 | @curl -s http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-devtools/python/python3-pyelftools_0.26.bb?h=gatesgarth \ |
| 63 | -o ${PYTHON_PATH}/python3-pyelftools_0.26.bb |
| 64 | @curl -s http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-devtools/python/python-pycryptodome.inc?h=gatesgarth \ |
| 65 | -o ${PYTHON_PATH}/python-pycryptodome.inc |
| 66 | @# |
| 67 | @# Add packages to the image |
| 68 | @echo IMAGE_INSTALL_append = \" optee-os optee-client optee-test\" >> ${PRJ_PATH}/project-spec/meta-user/conf/petalinuxbsp.conf |
| 69 | @# |
| 70 | @# Add optee kernel options to the exisiting kernel append recipe |
| 71 | @echo SRC_URI_append += \"file://kernel_optee.cfg\" >> ${PRJ_PATH}/project-spec/meta-user/recipes-kernel/linux/linux-xlnx_%.bbappend |
| 72 | @cp zynqmp/kernel/kernel_optee.cfg ${PRJ_PATH}/project-spec/meta-user/recipes-kernel/linux/linux-xlnx/kernel_optee.cfg |
| 73 | @# |
| 74 | @# Replace exisiting user configued dts file to add optee node |
| 75 | @cp zynqmp/device-tree/system-user.dtsi ${PRJ_PATH}/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi |
Michael Grand | b76287b | 2019-02-24 23:38:57 +0100 | [diff] [blame] | 76 | |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 77 | |
| 78 | build: create |
Michael Grand | 08b8dde | 2019-03-13 17:56:04 +0100 | [diff] [blame] | 79 | @petalinux-build -p $(PRJ_PATH) |
Michael Grand | b76287b | 2019-02-24 23:38:57 +0100 | [diff] [blame] | 80 | |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 81 | qemu: check |
Michael Grand | 08b8dde | 2019-03-13 17:56:04 +0100 | [diff] [blame] | 82 | @cd $(PRJ_PATH) && petalinux-boot --qemu \ |
| 83 | --qemu-args "-device loader,file=${PRJ_PATH}/images/linux/bl32.elf" \ |
| 84 | --kernel |
| 85 | |
Ibai Erkiaga | d7c761d | 2021-03-31 10:54:12 +0100 | [diff] [blame] | 86 | package: check |
| 87 | @petalinux-package --boot --pmufw --fpga --u-boot --add ${PRJ_PATH}/images/linux/tee_raw.bin --cpu a53-0 \ |
| 88 | --file-attribute "load=0x60000000, startup=0x60000000, exception_level=el-1, trustzone" --force -p ${PRJ_PATH} |