--- /dev/null
+%define buildplat rpi3
+%define builddbg 1
+%if %{builddbg} == 1
+%define buildtype debug
+%define compile_flags BUILD_STRING="" LOG_LEVEL=40 DEBUG=1 V=0 CRASH_REPORTING=1 SPD=opteed
+%else
+%define buildtype release
+%define compile_flags BUILD_STRING="" LOG_LEVEL=20 DEBUG=0 V=0 CRASH_REPORTING=1 SPD=opteed
+%endif
+
+Name: atf-rpi3
+Summary: Trusted firmware for Embedded boards based on ARM processor
+Version: 2017.05
+Release: 0
+Group: Security/test
+License: BSD 3-Clause
+ExclusiveArch: aarch64
+URL: https://github.com/linaro-swg/arm-trusted-firmware.git
+Source0: %{name}-%{version}.tar.bz2
+
+BuildRequires: git
+BuildRequires: optee-os
+
+Provides: optee.bin
+
+%description
+Trusted firmware for Embedded boards based on ARM processor
+
+%prep
+%setup -q -n optee-os
+
+%build
+
+# Build image
+export CFLAGS="-O0 -gdwarf-2"
+make %{?_smp_mflags} BL32=/boot/tee.bin %{compile_flags} PLAT=%{buildplat} all
+
+dd if=/dev/zero of=scratch bs=1c count=131072
+cat build/%{buildplat}/%{buildtype}/bl31.bin scratch > bl31.tmp
+dd if=bl31.tmp of=bl31.head bs=1c count=131072
+cat bl31.head /boot/tee-pager.bin > optee.bin
+
+rm scratch bl31.tmp bl31.head
+
+
+%install
+mkdir -p %{buildroot}/boot/spl
+install -m 644 optee.bin %{buildroot}/boot/spl/
+
+%clean
+
+%files
+%defattr(-,root,root,-)
+/boot/*