Please navigate to the following link and download the archive containing Linux Documentation:
https://www.nxp.com/design/i.mx-developer-resources/i.mx-software-and-development-tool:IMX-SW
Inside you will find "i.MX Yocto Project User's Guide". Please follow the instructions to setup a Ubuntu host with the yocto environment. You can then build a SD-Card image and flash it. ATF is required on imx 8 and enabled through imx-atf by default. optee-os requires u-boot SPL to load it, which is used by default with imx8m, as well as optee-os itself. You can try running xtest to see if it is operational. If you use the yocto build, you don't need to run imx-mkimage manually. To be sure, check the output of "bitbake -e <YOUR_IMAGE> | grep IMAGE_INSTALL=.*optee", since packagegroup-fsl-optee must be included in your image, which happens if DISTRO_FEATURES and MACHINE_FEATURES include "optee".
Hope this helps!