Honestly, @MrVan wrote good instruction for I.MX6Q sabresd.
1. Building U-BOOT for IMX
I used branch "boundary-v2017.07"
[u-boot]$ make nitrogen6q_defconfig [u-boot]$ make ARCH=arm
You can burn u-boot on sdcard. I just used imx usb loader
2. Get Linux Kernel with OP-TEE driver
[linux]$ make ARCH=arm imx_v6_v7_defconfig [linux]$ make menuconfig // Enable TEE and OPTEE drivers //In config file these configs should //look like //CONFIG_TEE=y //CONFIG_OPTEE=y // You also should disable CONFIG_CRYPTO_HW to disable CAAM driver. // I was getting error from this driver, so I decided to just disable it for now
[linux]$ make ARCH=arm
Now tee and optee drivers should be statically linked into kernel image.
Next, you have to compile optee
make PLATFORM=imx-mx6qsabrelite ARCH=arm CFG_BUILT_IN_ARGS=y CFG_PAGEABLE_ADDR=0 CFG_NS_ENTRY_ADDR=0x12000000 CFG_DT_ADDR=0x18000000 CFG_DT=y CFG_PSCI_ARM32=y DEBUG=y CFG_TEE_CORE_LOG_LEVEL=4 CFG_BOOT_SYNC_CPU=n CFG_BOOT_SECONDARY_REQUEST=y
${UBOOT_PATH}/tools/mkimage -A arm -O linux -C none -a 0x4dffffe4 -e 0x4e000000 -d out/arm-plat-imx/core/tee.bin uTee
You can boot your kernel by TFTP or from sdcard. You also need .dtb for OPTEE. File could be found by "${LINUX_PATH}/arch/arm/boot/dts/imx6q-nitrogen6x.dtb" path. You should load dtb file by address 0x18000000(OPTEE expects it to be loaded there). I wrote following boot script
setexpr a_script 0x10000000
setexpr a_zImage 0x12000000
setexpr a_fdt 0x18000000
setexpr a_ramdisk 0x13800000
setenv bootargs "console=${console} root=/dev/mmcblk1p2 rootwait earlyprintk"
setenv loadaddr ${a_zImage}
tftp ${a_zImage} zImage
# ext2load mmc 1:1 ${a_ramdisk} uramdisk.img
tftp ${a_fdt} dts.dtb
tftp 0x20000000 uTee
bootm 0x20000000 - ${a_fdt}
echo "Error loading the OS"
Note: I prepared rootfs on sdcard (/dev/mmcblk1p2 in my bootargs). After booting /dev/tee0 and /dev/teepriv0 char devices should exist in your filesystem. To interact with them you need OPTEE client.