blob: 44ad1e192f57c21dab69ff89dcbc5b4dcf306c06 [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################################################################################
Etienne Carriere3768a2b2019-05-14 17:13:19 +0200110OPTEE_OS_COMMON_FLAGS += CFG_ARM64_core=y CFG_DRAM_SIZE_GB=1
Igor Opaniukd496f982018-06-04 12:05:57 +0300111
112.PHONY: optee-os
113optee-os: optee-os-common
114
115.PHONY: optee-os-clean
116optee-os-clean: optee-os-clean-common
117
118################################################################################
119# l-loader
120################################################################################
121l-loader: arm-tf
122 cp $(BL1_BIN) $(LLOADER_PATH)/atf
123 cp $(FIP_BIN) $(LLOADER_PATH)/atf
Igor Opaniuk9545cf92019-10-09 15:22:31 +0300124 $(MAKE) -C $(LLOADER_PATH) CROSS_COMPILE="$(AARCH32_CROSS_COMPILE)" \
125 ARM_TRUSTED_FIRMWARE="$(TF_A_PATH)"
Igor Opaniukd496f982018-06-04 12:05:57 +0300126
127.PHONY: l-loader-clean
128l-loader-clean:
129 cd $(LLOADER_PATH) && git clean -xdf
130
131################################################################################
Igor Opaniukd496f982018-06-04 12:05:57 +0300132# Linux
133################################################################################
134LINUX_DEFCONFIG_COMMON_ARCH := arm64
135LINUX_DEFCONFIG_COMMON_FILES := \
Igor Opaniuk11f2da62020-05-11 15:54:41 +0300136 $(LINUX_PATH)/arch/arm64/configs/defconfig \
137 $(CURDIR)/kconfigs/poplar.conf
Igor Opaniukd496f982018-06-04 12:05:57 +0300138
139linux-defconfig: $(LINUX_PATH)/.config
140
141LINUX_COMMON_FLAGS += ARCH=arm64
Igor Opaniukd496f982018-06-04 12:05:57 +0300142
143linux: linux-common
144
145linux-defconfig-clean: linux-defconfig-clean-common
146
147LINUX_CLEAN_COMMON_FLAGS += ARCH=arm64
148
149linux-clean: linux-clean-common
150
151LINUX_CLEANER_COMMON_FLAGS += ARCH=arm64
152
153linux-cleaner: linux-cleaner-common
154
Igor Opaniukd496f982018-06-04 12:05:57 +0300155.PHONY: prepare-images
Igor Opaniukb81fe042018-10-09 13:40:30 +0300156prepare-images: linux l-loader buildroot
Igor Opaniuk9b359162018-10-17 13:42:17 +0300157 @mkdir -p $(OUT_PATH)
Igor Opaniukd496f982018-06-04 12:05:57 +0300158 @cp $(TOOLS_PATH)/poplar_recovery_builder.sh $(OUT_PATH)
159 @cp $(LLOADER_BIN) $(OUT_PATH)
160 @cp $(LINUX_PATH)/arch/arm64/boot/Image $(OUT_PATH)
161 @cp $(LINUX_DTB) $(OUT_PATH)
Igor Opaniukb81fe042018-10-09 13:40:30 +0300162 @cd $(OUT_PATH) && PATH=$(UBOOT_PATH)/tools:$$PATH \
Igor Opaniuk11f2da62020-05-11 15:54:41 +0300163 EMMC_DEV=/dev/mmcblk1 ./poplar_recovery_builder.sh \
164 all "$(ROOTFS_BIN)"
Igor Opaniukb81fe042018-10-09 13:40:30 +0300165
166################################################################################
167# Buildroot/RootFS
168################################################################################
169.PHONY: update_rootfs
170update_rootfs: arm-tf u-boot
171
172.PHONY: buildroot
173buildroot: update_rootfs
Igor Opaniukd496f982018-06-04 12:05:57 +0300174
175################################################################################
176# Flash images
177################################################################################
178.PHONY: flash-help
179flash-help:
180 @echo "1. Install and configure TFTP server on your host PC:"
181 @echo ""
182 @echo " $$ sudo apt-get install atftpd # install atftpd server"
183 @echo " $$ sudo vim /etc/default/atftpd # edit atftpd server config"
184 @echo " $$ sudo service atftpd restart # restart atftpd server"
185 @echo ""
186 @echo "2. Proper configuration should look like:"
187 @echo ""
188 @echo " $$ cat /etc/default/atftpd"
189 @echo " USE_INETD=false"
190 @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\""
191 @echo ""
192 @echo "3. Flash proper U-boot build to USB stick."
193 @echo " It should be flashed to the first FAT32 partition. Then boot"
194 @echo " from it by pressing USB_BOOT switch on the board"
195 @echo ""
196 @echo "4. Connect to Poplar board over serial console (run on host PC):"
197 @echo ""
198 @echo " $$ screen /dev/ttyUSB0 115200"
199 @echo ""
200 @echo "5. Configure network interface in Poplar U-boot shell. If you can't"
201 @echo "get into U-boot console, press and hold Ctrl+C while booting:"
202 @echo ""
203 @echo " => setenv ipaddr 192.168.0.2"
204 @echo " => setenv netmask 255.255.255.0"
205 @echo " => setenv serverip 192.168.0.3"
206 @echo " ETH1: PHY(phyaddr=3, rgmii) link UP: DUPLEX=FULL : SPEED=1000M"
207 @echo " MAC: 00-16-8E-62-66-84"
208 @echo " host 192.168.0.3 is alive"
209 @echo ""
210 @echo "6. Verify connection is working (run in U-boot shell):"
211 @echo ""
212 @echo " => ping 192.168.0.3"
213 @echo ""
214 @echo "7. Run installer (run in U-boot shell):"
215 @echo ""
216 @echo " => tftp 0x08000000 recovery_files/install.scr"
217 @echo " => source 0x08000000"
218 @echo ""
219 @echo "8. After successful flashing reboot your board (U-boot shell):"
220 @echo ""
221 @echo " => reset"
222 @echo ""