blob: b9bf9fe061bfa5c4d98b505cdd147e20eaa3996a [file] [log] [blame]
Igor Opaniukd496f982018-06-04 12:05:57 +03001################################################################################
2# Following variables defines how the NS_USER (Non Secure User - Client
3# Application), NS_KERNEL (Non Secure Kernel), S_KERNEL (Secure Kernel) and
4# S_USER (Secure User - TA) are compiled
5################################################################################
6COMPILE_NS_USER ?= 64
7override COMPILE_NS_KERNEL := 64
8COMPILE_S_USER ?= 32
9COMPILE_S_KERNEL ?= 64
10
Etienne Carriere3768a2b2019-05-14 17:13:19 +020011OPTEE_OS_PLATFORM = poplar
12
Igor Opaniukd496f982018-06-04 12:05:57 +030013################################################################################
14# Includes
15################################################################################
16include common.mk
17
18################################################################################
19# Paths to git projects and various binaries
20################################################################################
21ifeq ($(DEBUG),1)
Victor Chong371d7c22019-08-08 17:17:14 +010022TF_A_BUILD ?= debug
Igor Opaniukd496f982018-06-04 12:05:57 +030023else
Victor Chong371d7c22019-08-08 17:17:14 +010024TF_A_BUILD ?= release
Igor Opaniukd496f982018-06-04 12:05:57 +030025endif
26
27OUT_PATH ?= $(ROOT)/out
Igor Opaniukb81fe042018-10-09 13:40:30 +030028ROOTFS_BIN ?= $(ROOT)/out-br/images/rootfs.tar
Victor Chongdf54b112019-08-11 15:58:12 +010029TF_A_PATH ?= $(ROOT)/trusted-firmware-a
Igor Opaniukd496f982018-06-04 12:05:57 +030030LLOADER_PATH ?= $(ROOT)/l-loader
31UBOOT_PATH ?= $(ROOT)/u-boot
Igor Opaniukd496f982018-06-04 12:05:57 +030032OPTEE_CLIENT_EXPORT ?= $(OPTEE_CLIENT_PATH)/out/export
Igor Opaniukb81fe042018-10-09 13:40:30 +030033OPTEE_PATH ?= $(ROOT)/optee_os
Igor Opaniukd496f982018-06-04 12:05:57 +030034LINUX_PATH ?= $(ROOT)/linux
35TOOLS_PATH ?= $(ROOT)/poplar-tools
36
Victor Chong371d7c22019-08-08 17:17:14 +010037BL1_BIN ?= $(TF_A_PATH)/build/poplar/$(TF_A_BUILD)/bl1.bin
38FIP_BIN ?= $(TF_A_PATH)/build/poplar/$(TF_A_BUILD)/fip.bin
Igor Opaniukd496f982018-06-04 12:05:57 +030039LLOADER_BIN ?= $(LLOADER_PATH)/l-loader.bin
40
41LINUX_DTB ?= $(LINUX_PATH)/arch/arm64/boot/dts/hisilicon/hi3798cv200-poplar.dtb
42
43UBOOT_BIN ?= $(UBOOT_PATH)/u-boot.bin
44OPTEE_BIN ?= $(OPTEE_PATH)/out/arm/core/tee-header_v2.bin
45OPTEE_BIN_EXTRA1 ?= $(OPTEE_PATH)/out/arm/core/tee-pager_v2.bin
46OPTEE_BIN_EXTRA2 ?= $(OPTEE_PATH)/out/arm/core/tee-pageable_v2.bin
47
Igor Opaniukd496f982018-06-04 12:05:57 +030048################################################################################
49# Targets
50################################################################################
51.PHONY: all
Igor Opaniukb81fe042018-10-09 13:40:30 +030052all: u-boot arm-tf buildroot l-loader linux prepare-images | toolchains
Igor Opaniukd496f982018-06-04 12:05:57 +030053
54.PHONY: clean
Igor Opaniukb81fe042018-10-09 13:40:30 +030055clean: u-boot-clean arm-tf-clean l-loader-clean linux-clean optee-os-clean \
56 buildroot-clean
Igor Opaniukd496f982018-06-04 12:05:57 +030057
58################################################################################
59# Toolchain
60################################################################################
61include toolchain.mk
62
63################################################################################
64# U-Boot
65################################################################################
66.PHONY: u-boot-config
67u-boot-config:
68ifeq ($(wildcard $(UBOOT_PATH)/.config),)
69 $(MAKE) -C $(UBOOT_PATH) \
70 CROSS_COMPILE=$(AARCH64_CROSS_COMPILE) poplar_defconfig
71endif
72
73.PHONY: u-boot-menuconfig
74u-boot-menuconfig: u-boot-config
75 $(MAKE) -C $(UBOOT_PATH) \
76 CROSS_COMPILE=$(AARCH64_CROSS_COMPILE) menuconfig
77
78.PHONY: u-boot
79u-boot: u-boot-config
80 $(MAKE) -C $(UBOOT_PATH) \
81 CROSS_COMPILE="$(AARCH64_CROSS_COMPILE)"
82
83.PHONY: u-boot-clean
84u-boot-clean:
85 cd $(UBOOT_PATH) && git clean -xdf
86
87################################################################################
Igor Opaniukd496f982018-06-04 12:05:57 +030088# ARM Trusted Firmware
89################################################################################
90.PHONY: arm-tf
91arm-tf: u-boot optee-os
Victor Chong371d7c22019-08-08 17:17:14 +010092 $(MAKE) -C $(TF_A_PATH) \
Igor Opaniukd496f982018-06-04 12:05:57 +030093 CROSS_COMPILE="$(CCACHE)$(AARCH64_CROSS_COMPILE)" \
94 all fip \
95 DEBUG=$(DEBUG) \
96 PLAT=poplar \
97 SPD=opteed \
98 BL32=$(OPTEE_BIN) \
99 BL33=$(UBOOT_BIN) \
100 BL32_EXTRA1=$(OPTEE_BIN_EXTRA1) \
101 BL32_EXTRA2=$(OPTEE_BIN_EXTRA2)
102
103.PHONY: arm-tf-clean
104arm-tf-clean:
Victor Chong371d7c22019-08-08 17:17:14 +0100105 cd $(TF_A_PATH) && git clean -xdf
Igor Opaniukd496f982018-06-04 12:05:57 +0300106
107################################################################################
108# OP-TEE
109################################################################################
Igor Opaniuk5019afe2021-01-12 16:01:49 +0200110OPTEE_OS_COMMON_FLAGS += CFG_ARM64_core=y CFG_DRAM_SIZE_GB=1 \
111 CFG_ENABLE_EMBEDDED_TESTS=y
Igor Opaniukd496f982018-06-04 12:05:57 +0300112
113.PHONY: optee-os
114optee-os: optee-os-common
115
116.PHONY: optee-os-clean
117optee-os-clean: optee-os-clean-common
118
119################################################################################
120# l-loader
121################################################################################
122l-loader: arm-tf
123 cp $(BL1_BIN) $(LLOADER_PATH)/atf
124 cp $(FIP_BIN) $(LLOADER_PATH)/atf
Igor Opaniuk9545cf92019-10-09 15:22:31 +0300125 $(MAKE) -C $(LLOADER_PATH) CROSS_COMPILE="$(AARCH32_CROSS_COMPILE)" \
126 ARM_TRUSTED_FIRMWARE="$(TF_A_PATH)"
Igor Opaniukd496f982018-06-04 12:05:57 +0300127
128.PHONY: l-loader-clean
129l-loader-clean:
130 cd $(LLOADER_PATH) && git clean -xdf
131
132################################################################################
Igor Opaniukd496f982018-06-04 12:05:57 +0300133# Linux
134################################################################################
135LINUX_DEFCONFIG_COMMON_ARCH := arm64
136LINUX_DEFCONFIG_COMMON_FILES := \
Igor Opaniuk11f2da62020-05-11 15:54:41 +0300137 $(LINUX_PATH)/arch/arm64/configs/defconfig \
138 $(CURDIR)/kconfigs/poplar.conf
Igor Opaniukd496f982018-06-04 12:05:57 +0300139
140linux-defconfig: $(LINUX_PATH)/.config
141
142LINUX_COMMON_FLAGS += ARCH=arm64
Igor Opaniukd496f982018-06-04 12:05:57 +0300143
144linux: linux-common
145
146linux-defconfig-clean: linux-defconfig-clean-common
147
148LINUX_CLEAN_COMMON_FLAGS += ARCH=arm64
149
150linux-clean: linux-clean-common
151
152LINUX_CLEANER_COMMON_FLAGS += ARCH=arm64
153
154linux-cleaner: linux-cleaner-common
155
Igor Opaniukd496f982018-06-04 12:05:57 +0300156.PHONY: prepare-images
Igor Opaniukb81fe042018-10-09 13:40:30 +0300157prepare-images: linux l-loader buildroot
Igor Opaniuk9b359162018-10-17 13:42:17 +0300158 @mkdir -p $(OUT_PATH)
Igor Opaniukd496f982018-06-04 12:05:57 +0300159 @cp $(TOOLS_PATH)/poplar_recovery_builder.sh $(OUT_PATH)
160 @cp $(LLOADER_BIN) $(OUT_PATH)
161 @cp $(LINUX_PATH)/arch/arm64/boot/Image $(OUT_PATH)
162 @cp $(LINUX_DTB) $(OUT_PATH)
Igor Opaniukb81fe042018-10-09 13:40:30 +0300163 @cd $(OUT_PATH) && PATH=$(UBOOT_PATH)/tools:$$PATH \
Igor Opaniuk11f2da62020-05-11 15:54:41 +0300164 EMMC_DEV=/dev/mmcblk1 ./poplar_recovery_builder.sh \
165 all "$(ROOTFS_BIN)"
Igor Opaniukb81fe042018-10-09 13:40:30 +0300166
167################################################################################
168# Buildroot/RootFS
169################################################################################
170.PHONY: update_rootfs
171update_rootfs: arm-tf u-boot
172
173.PHONY: buildroot
174buildroot: update_rootfs
Igor Opaniukd496f982018-06-04 12:05:57 +0300175
176################################################################################
177# Flash images
178################################################################################
179.PHONY: flash-help
180flash-help:
181 @echo "1. Install and configure TFTP server on your host PC:"
182 @echo ""
183 @echo " $$ sudo apt-get install atftpd # install atftpd server"
184 @echo " $$ sudo vim /etc/default/atftpd # edit atftpd server config"
185 @echo " $$ sudo service atftpd restart # restart atftpd server"
186 @echo ""
187 @echo "2. Proper configuration should look like:"
188 @echo ""
189 @echo " $$ cat /etc/default/atftpd"
190 @echo " USE_INETD=false"
191 @echo " OPTIONS=\"--tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 --maxthread 100 --verbose=5 /path/to/rep/out/dir\""
192 @echo ""
193 @echo "3. Flash proper U-boot build to USB stick."
194 @echo " It should be flashed to the first FAT32 partition. Then boot"
195 @echo " from it by pressing USB_BOOT switch on the board"
196 @echo ""
197 @echo "4. Connect to Poplar board over serial console (run on host PC):"
198 @echo ""
199 @echo " $$ screen /dev/ttyUSB0 115200"
200 @echo ""
201 @echo "5. Configure network interface in Poplar U-boot shell. If you can't"
202 @echo "get into U-boot console, press and hold Ctrl+C while booting:"
203 @echo ""
204 @echo " => setenv ipaddr 192.168.0.2"
205 @echo " => setenv netmask 255.255.255.0"
206 @echo " => setenv serverip 192.168.0.3"
207 @echo " ETH1: PHY(phyaddr=3, rgmii) link UP: DUPLEX=FULL : SPEED=1000M"
208 @echo " MAC: 00-16-8E-62-66-84"
209 @echo " host 192.168.0.3 is alive"
210 @echo ""
211 @echo "6. Verify connection is working (run in U-boot shell):"
212 @echo ""
213 @echo " => ping 192.168.0.3"
214 @echo ""
215 @echo "7. Run installer (run in U-boot shell):"
216 @echo ""
217 @echo " => tftp 0x08000000 recovery_files/install.scr"
218 @echo " => source 0x08000000"
219 @echo ""
220 @echo "8. After successful flashing reboot your board (U-boot shell):"
221 @echo ""
222 @echo " => reset"
223 @echo ""