@@ -9,3 +9,7 @@  EXTRA_IMAGEDEPENDS += "gem5-m5term-native"
 MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-module-atp atp-uapi gem5-m5readfile"
 # Optionally provide ATP kernel tests
 MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "atp-test"
+
+# Use ATP Engine gem5 models in gem5 build
+DEPENDS:append:pn-gem5-aarch64-native = " atp-gem5-native"
+GEM5_EXTRAS:pn-gem5-aarch64-native = "${STAGING_DATADIR_NATIVE}/atp"
@@ -13,7 +13,7 @@  The resulting gem5 native executable contains the AMBA ATP Engine. The resulting
 Users should run the environment as follows:
 
 ```bash
-./tmp/deploy/tools/start-gem5-atp.sh
+oe-run-native atp-gem5-native start-gem5-atp.sh
 ```
 
 This script launches a fast simulation to fast-forward Linux boot. Once Linux boot is completed, the fast simulation switches into a detailed simulation for the final usable environment. Users can connect and interact with the environment as follows:
new file mode 100644
@@ -0,0 +1,24 @@ 
+require atp-source_3.1.inc
+inherit native
+
+SUMMARY = "AMBA ATP Engine gem5 models"
+
+S = "${WORKDIR}/git"
+SRC_URI = "${ATP_SRC} file://start-gem5-atp.sh"
+
+do_configure[noexec] = "1"
+do_compile[noexec] = "1"
+
+do_install() {
+    install -d ${D}${datadir}/gem5/configs ${D}${datadir}/atp ${D}${bindir}
+
+    # baremetal_atp.py machine configuration and sample stream.atp file
+    install ${S}/gem5/baremetal_atp.py ${S}/configs/stream.atp ${D}${datadir}/gem5/configs
+    # ATP Engine sources for gem5 to use
+    install ${S}/SConscript ${S}/*.hh ${S}/*.cc ${D}${datadir}/atp
+    cp -RL ${S}/gem5 ${S}/proto ${D}${datadir}/atp
+
+    install ${WORKDIR}/start-gem5-atp.sh ${D}${bindir}
+}
+
+addtask addto_recipe_sysroot after do_populate_sysroot before do_build
similarity index 100%
rename from meta-atp/recipes-devtools/gem5/gem5-aarch64-native/start-gem5-atp.sh
rename to meta-atp/recipes-devtools/atp/atp-gem5/start-gem5-atp.sh
deleted file mode 100644
@@ -1,24 +0,0 @@ 
-require recipes-devtools/atp/atp-source_3.1.inc
-
-FILESEXTRAPATHS:prepend := "${THISDIR}/${BPN}:"
-
-SRC_URI += "${ATP_SRC};destsuffix=git/atp;name=atp \
-            file://start-gem5-atp.sh"
-SRCREV_FORMAT = "gem5_atp"
-SRCREV_atp = "${ATP_REV}"
-LICENSE += "& ${ATP_LIC}"
-LIC_FILES_CHKSUM += "file://atp/LICENSE;md5=${ATP_LIC_MD5}"
-
-EXTRA_OESCONS += "EXTRAS=${S}/atp"
-
-do_install:append() {
-    # baremetal_atp.py machine configuration and sample stream.atp file
-    install -m 644 ${B}/atp/gem5/baremetal_atp.py \
-                   ${B}/atp/configs/stream.atp \
-                   ${D}${datadir}/gem5/configs
-}
-
-do_deploy:append() {
-    # start-gem5-atp.sh launch script
-    install -m 755 ${WORKDIR}/start-gem5-atp.sh ${DEPLOYDIR}
-}