blob: e4019d42c3f324c18fa5c5887ca9b48774680590 [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 Opaniukb81fe042018-10-09 13:40:30 +030032OPTEE_PATH ?= $(ROOT)/optee_os
Igor Opaniukd496f982018-06-04 12:05:57 +030033LINUX_PATH ?= $(ROOT)/linux
34TOOLS_PATH ?= $(ROOT)/poplar-tools
35
Victor Chong371d7c22019-08-08 17:17:14 +010036BL1_BIN ?= $(TF_A_PATH)/build/poplar/$(TF_A_BUILD)/bl1.bin
37FIP_BIN ?= $(TF_A_PATH)/build/poplar/$(TF_A_BUILD)/fip.bin
Igor Opaniukd496f982018-06-04 12:05:57 +030038LLOADER_BIN ?= $(LLOADER_PATH)/l-loader.bin
39
40LINUX_DTB ?= $(LINUX_PATH)/arch/arm64/boot/dts/hisilicon/hi3798cv200-poplar.dtb
41
42UBOOT_BIN ?= $(UBOOT_PATH)/u-boot.bin
43OPTEE_BIN ?= $(OPTEE_PATH)/out/arm/core/tee-header_v2.bin
44OPTEE_BIN_EXTRA1 ?= $(OPTEE_PATH)/out/arm/core/tee-pager_v2.bin
45OPTEE_BIN_EXTRA2 ?= $(OPTEE_PATH)/out/arm/core/tee-pageable_v2.bin
46
Igor Opaniukd496f982018-06-04 12:05:57 +030047################################################################################
48# Targets
49################################################################################
50.PHONY: all
Igor Opaniukb81fe042018-10-09 13:40:30 +030051all: u-boot arm-tf buildroot l-loader linux prepare-images | toolchains
Igor Opaniukd496f982018-06-04 12:05:57 +030052
53.PHONY: clean
Igor Opaniukb81fe042018-10-09 13:40:30 +030054clean: u-boot-clean arm-tf-clean l-loader-clean linux-clean optee-os-clean \
55 buildroot-clean
Igor Opaniukd496f982018-06-04 12:05:57 +030056
57################################################################################
58# Toolchain
59################################################################################
60include toolchain.mk
61
62################################################################################
63# U-Boot
64################################################################################
65.PHONY: u-boot-config
66u-boot-config:
67ifeq ($(wildcard $(UBOOT_PATH)/.config),)
68 $(MAKE) -C $(UBOOT_PATH) \
69 CROSS_COMPILE=$(AARCH64_CROSS_COMPILE) poplar_defconfig
70endif
71
72.PHONY: u-boot-menuconfig
73u-boot-menuconfig: u-boot-config
74 $(MAKE) -C $(UBOOT_PATH) \
75 CROSS_COMPILE=$(AARCH64_CROSS_COMPILE) menuconfig
76
77.PHONY: u-boot
78u-boot: u-boot-config
79 $(MAKE) -C $(UBOOT_PATH) \
80 CROSS_COMPILE="$(AARCH64_CROSS_COMPILE)"
81
82.PHONY: u-boot-clean
83u-boot-clean:
84 cd $(UBOOT_PATH) && git clean -xdf
85
86################################################################################
Igor Opaniukd496f982018-06-04 12:05:57 +030087# ARM Trusted Firmware
88################################################################################
89.PHONY: arm-tf
90arm-tf: u-boot optee-os
Victor Chong371d7c22019-08-08 17:17:14 +010091 $(MAKE) -C $(TF_A_PATH) \
Igor Opaniukd496f982018-06-04 12:05:57 +030092 CROSS_COMPILE="$(CCACHE)$(AARCH64_CROSS_COMPILE)" \
93 all fip \
94 DEBUG=$(DEBUG) \
95 PLAT=poplar \
96 SPD=opteed \
97 BL32=$(OPTEE_BIN) \
98 BL33=$(UBOOT_BIN) \
99 BL32_EXTRA1=$(OPTEE_BIN_EXTRA1) \
100 BL32_EXTRA2=$(OPTEE_BIN_EXTRA2)
101
102.PHONY: arm-tf-clean
103arm-tf-clean:
Victor Chong371d7c22019-08-08 17:17:14 +0100104 cd $(TF_A_PATH) && git clean -xdf
Igor Opaniukd496f982018-06-04 12:05:57 +0300105
106################################################################################
107# OP-TEE
108################################################################################
Igor Opaniuk5019afe2021-01-12 16:01:49 +0200109OPTEE_OS_COMMON_FLAGS += CFG_ARM64_core=y CFG_DRAM_SIZE_GB=1 \
110 CFG_ENABLE_EMBEDDED_TESTS=y
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 Opaniuk5b9a31a2021-09-29 19:40:02 +0300163 EMMC_DEV=/dev/mmcblk0 ./poplar_recovery_builder.sh \
Igor Opaniuk11f2da62020-05-11 15:54:41 +0300164 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 ""