diff --git a/.gitignore b/.gitignore index ee36f3f47763bd42da0706bdb1b3e88a0f2bfd71..07d85d6a471ca4a218301d7739087419d7b61da6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -Makefile +/Makefile *.swp /serial0.log /serial1.log diff --git a/dra7xx.mk b/dra7xx.mk new file mode 100644 index 0000000000000000000000000000000000000000..91b7c03f29a29fdf6116012ae01692b8c329e473 --- /dev/null +++ b/dra7xx.mk @@ -0,0 +1,167 @@ +############################################################################### +# Following variables defines how the NS_USER (Non Secure User - Client +# Application), NS_KERNEL (Non Secure Kernel), S_KERNEL (Secure Kernel) and +# S_USER (Secure User - TA) are compiled +############################################################################### +override COMPILE_NS_USER := 32 +override COMPILE_NS_KERNEL := 32 +override COMPILE_S_USER := 32 +override COMPILE_S_KERNEL := 32 + +############################################################################### +# Includes +############################################################################### +-include common.mk + +############################################################################### +# Paths to git projects and various binaries +############################################################################### +STAGING_AREA ?= $(ROOT)/out +U-BOOT_PATH ?= $(ROOT)/u-boot +UBOOT_SPL ?= $(U-BOOT_PATH)/u-boot-spl_HS_MLO +UBOOT_IMG ?= $(U-BOOT_PATH)/u-boot_HS.img +UBOOT_ENV ?= $(BUILD_PATH)/dra7xx/uEnv.txt +LINUX_IMAGE ?= $(LINUX_PATH)/arch/arm/boot/zImage +LINUX_DTBS ?= $(wildcard $(LINUX_PATH)/arch/arm/boot/dts/dra7*.dtb) +FIT_SOURCE ?= $(BUILD_PATH)/dra7xx/fitImage.its +FIT_MAKEFILE ?= $(BUILD_PATH)/dra7xx/Makefile + +############################################################################### +# Targets +############################################################################### +.PHONY: all clean cleaner prepare + +all: u-boot linux optee-os optee-client xtest helloworld build-fit update_rootfs +clean: linux-clean busybox-clean u-boot-clean optee-os-clean optee-client-clean build-fit-clean +cleaner: clean prepare-cleaner busybox-cleaner linux-cleaner + +-include toolchain.mk + +prepare: + @if [ ! -d $(STAGING_AREA) ]; then mkdir $(STAGING_AREA); fi + +.PHONY: prepare-cleaner +prepare-cleaner: + rm -rf $(STAGING_AREA) + +############################################################################### +# Das U-Boot +############################################################################### +.PHONY: u-boot u-boot-clean + +U-BOOT_EXPORTS ?= CROSS_COMPILE=$(CROSS_COMPILE_NS_KERNEL) ARCH=arm + +u-boot: + $(U-BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) dra7xx_hs_evm_defconfig + $(U-BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) all + +u-boot-clean: + $(U-BOOT_EXPORTS) $(MAKE) -C $(U-BOOT_PATH) clean + +############################################################################### +# Linux kernel +############################################################################### +.PHONY: linux-defconfig linux linux-defconfig-clean linux-clean linux-cleaner + +LINUX_DEFCONFIG_COMMON_ARCH := arm +LINUX_DEFCONFIG_COMMON_FILES := \ + $(LINUX_PATH)/arch/arm/configs/multi_v7_defconfig \ + $(LINUX_PATH)/ti_config_fragments/multi_v7_prune.cfg \ + $(LINUX_PATH)/ti_config_fragments/baseport.cfg \ + $(LINUX_PATH)/ti_config_fragments/ipc.cfg \ + $(LINUX_PATH)/ti_config_fragments/connectivity.cfg \ + $(LINUX_PATH)/ti_config_fragments/audio_display.cfg \ + $(LINUX_PATH)/ti_config_fragments/wlan.cfg \ + $(LINUX_PATH)/ti_config_fragments/omap_soc.cfg \ + $(LINUX_PATH)/ti_config_fragments/lpae.cfg \ + $(LINUX_PATH)/ti_config_fragments/dra7_only.cfg \ + $(LINUX_PATH)/ti_config_fragments/debug_options.cfg + +linux-defconfig: $(LINUX_PATH)/.config + +LINUX_COMMON_FLAGS += ARCH=arm +linux: linux-common +linux-defconfig-clean: linux-defconfig-clean-common + +LINUX_CLEAN_COMMON_FLAGS += ARCH=arm +linux-clean: linux-clean-common + +LINUX_CLEANER_COMMON_FLAGS += ARCH=arm +linux-cleaner: linux-cleaner-common + +############################################################################### +# OP-TEE +############################################################################### +.PHONY: optee-os optee-os-clean optee-client optee-client-clean + +OPTEE_OS_COMMON_FLAGS += PLATFORM=ti-dra7xx +optee-os: optee-os-common + +OPTEE_OS_CLEAN_COMMON_FLAGS += PLATFORM=ti-dra7xx +optee-os-clean: optee-os-clean-common + +optee-client: optee-client-common +optee-client-clean: optee-client-clean-common + +############################################################################### +# xtest / optee_test +############################################################################### +.PHONY: xtest xtest-clean xtest-patch + +xtest: xtest-common +xtest-clean: xtest-clean-common +xtest-patch: xtest-patch-common + +############################################################################### +# hello_world +############################################################################### +.PHONY: helloworld helloworld-clean + +helloworld: helloworld-common +helloworld-clean: helloworld-clean-common + +############################################################################### +# Busybox +############################################################################### +.PHONY: busybox busybox-clean busybox-cleaner + +BUSYBOX_COMMON_TARGET = dra7xx +BUSYBOX_CLEAN_COMMON_TARGET = dra7xx clean + +busybox: busybox-common +busybox-clean: busybox-clean-common +busybox-cleaner: busybox-cleaner-common + +############################################################################### +# Build FIT +############################################################################### +.PHONY: build-fit build-fit-clean + +build-fit: prepare linux optee-os + cp $(LINUX_IMAGE) $(STAGING_AREA)/ + cp $(LINUX_DTBS) $(STAGING_AREA)/ + cp $(OPTEE_OS_BIN) $(STAGING_AREA)/ + cp $(FIT_SOURCE) $(STAGING_AREA)/ + cp $(FIT_MAKEFILE) $(STAGING_AREA)/ + MKIMAGE=$(U-BOOT_PATH)/tools/mkimage $(MAKE) -C $(STAGING_AREA) + +build-fit-clean: + $(RM) $(STAGING_AREA)/Makefile + $(RM) $(STAGING_AREA)/fitImage.its + $(RM) $(STAGING_AREA)/tee.bin + $(RM) $(STAGING_AREA)/*.dtb + $(RM) $(STAGING_AREA)/zImage + +############################################################################### +# Root FS +############################################################################### +.PHONY: filelist-tee update_rootfs + +filelist-tee: filelist-tee-common u-boot build-fit + @echo "dir /boot 755 0 0" >> $(GEN_ROOTFS_FILELIST) + @echo "file /boot/MLO $(UBOOT_SPL) 644 0 0" >> $(GEN_ROOTFS_FILELIST) + @echo "file /boot/u-boot.img $(UBOOT_IMG) 644 0 0" >> $(GEN_ROOTFS_FILELIST) + @echo "file /boot/uEnv.txt $(UBOOT_ENV) 644 0 0" >> $(GEN_ROOTFS_FILELIST) + @echo "file /boot/fitImage.itb $(STAGING_AREA)/fitImage.itb 644 0 0" >> $(GEN_ROOTFS_FILELIST) + +update_rootfs: update_rootfs-common diff --git a/dra7xx/Makefile b/dra7xx/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..7918ef823a4df6244b3d6f1e180dc125869e7ad9 --- /dev/null +++ b/dra7xx/Makefile @@ -0,0 +1,51 @@ +#!/usr/bin/make -f +# +# Sign/encrypt a Linux Kernel zImage, a DTB file, and a rootfs (to be used +# as an initramfs) into a FIT image tree blob for loading through U-Boot on a +# TI High Security (HS) SoC. +# +# Copyright (C) 2016, Texas Instruments, Incorporated - http://www.ti.com/ +# Andreas Dannenberg <dannenberg@ti.com> +# Andrew F. Davis <afd@ti.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# + +ITS ?= fitImage.its +ITB ?= $(ITS:.its=.itb) + +SEC_IMAGES := $(shell sed -n 's/.*\/incbin\/.*\"\(.*\.sec\)\".*/\1/p' $(ITS)) + +.PHONY: all +all: $(ITB) + +# Invoke signing tool from the TI Secure Dev package to sign and optionally +# encrypt a binary blob. This tool is accessed through the use of the +# TI_SECURE_DEV_PKG environmental variable in the same fashion as it is used +# when building secure U-Boot for TI devices. +%.sec: % +ifneq ($(TI_SECURE_DEV_PKG),) +ifneq ($(wildcard $(TI_SECURE_DEV_PKG)/scripts/secure-binary-image.sh),) + $(TI_SECURE_DEV_PKG)/scripts/secure-binary-image.sh $(patsubst %.sec,%,$@) $@ +else + @echo "ERROR: $(TI_SECURE_DEV_PKG)/scripts/secure-binary-image.sh not found." \ + "$@ was NOT created!"; exit 1 +endif +else + @echo "ERROR: TI_SECURE_DEV_PKG environment variable must be defined" \ + "for TI secure devices. $@ was NOT created!"; exit 1 +endif + +# Compile a FIT image tree source file describing the final image tree blob. +# Use the mkimage tool that comes with U-Boot to make sure we have the latest/ +# greatest as we are using advanced features such as FIT... +MKIMAGE ?= mkimage +%.itb: %.its $(SEC_IMAGES) + $(MKIMAGE) -f $< -r $@ + +.PHONY: clean +clean: + -$(RM) -v $(SEC_IMAGES) + -$(RM) -v $(ITB) diff --git a/dra7xx/fitImage.its b/dra7xx/fitImage.its new file mode 100644 index 0000000000000000000000000000000000000000..191466e09d9c1ea2fa6f893a94c897696a3d4bca --- /dev/null +++ b/dra7xx/fitImage.its @@ -0,0 +1,76 @@ +/dts-v1/; + +/ { + description = "U-Boot fitImage"; + #address-cells = <1>; + + images { + kernel@1 { + description = "Linux kernel"; + data = /incbin/("zImage.sec"); + type = "kernel"; + arch = "arm"; + os = "linux"; + compression = "none"; + load = <0x82000000>; + entry = <0x82000000>; + }; + + dra7-evm.dtb { + description = "Flattened Device Tree blob"; + data = /incbin/("dra7-evm.dtb.sec"); + type = "flat_dt"; + arch = "arm"; + compression = "none"; + }; + + dra72-evm-revc.dtb { + description = "Flattened Device Tree blob"; + data = /incbin/("dra72-evm-revc.dtb.sec"); + type = "flat_dt"; + arch = "arm"; + compression = "none"; + }; + + dra71-evm.dtb { + description = "Flattened Device Tree blob"; + data = /incbin/("dra71-evm.dtb.sec"); + type = "flat_dt"; + arch = "arm"; + compression = "none"; + }; + + optee { + description = "OPTEE OS Image"; + data = /incbin/("tee.bin.sec"); + type = "tee"; + arch = "arm"; + compression = "none"; + }; + }; + + configurations { + default = "dra7-evm.dtb"; + + dra7-evm.dtb { + description = "Linux kernel, FDT blob, OPTEE OS"; + kernel = "kernel@1"; + fdt = "dra7-evm.dtb"; + loadables = "optee"; + }; + + dra72-evm-revc.dtb { + description = "Linux kernel, FDT blob, OPTEE OS"; + kernel = "kernel@1"; + fdt = "dra72-evm-revc.dtb"; + loadables = "optee"; + }; + + dra71-evm.dtb { + description = "Linux kernel, FDT blob, OPTEE OS"; + kernel = "kernel@1"; + fdt = "dra71-evm.dtb"; + loadables = "optee"; + }; + }; +}; diff --git a/dra7xx/uEnv.txt b/dra7xx/uEnv.txt new file mode 100644 index 0000000000000000000000000000000000000000..fa129b6408fe16c4e47aef336463de3751522797 --- /dev/null +++ b/dra7xx/uEnv.txt @@ -0,0 +1 @@ +loadfit=run args_mmc; bootm ${loadaddr}#${fdtfile};