samples: ipc: openamp: Enable openamp sample for iMX.RT1170 EVK

Enable the openamp sample for RT1170EVK. CM4 core has a custom DTS
overlay to use LPUART2 for console information, and use a secondary GPT
timer for the system tick.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
diff --git a/boards/arm/mimxrt1170_evk/board.cmake b/boards/arm/mimxrt1170_evk/board.cmake
index 286dd1f..e743455 100644
--- a/boards/arm/mimxrt1170_evk/board.cmake
+++ b/boards/arm/mimxrt1170_evk/board.cmake
@@ -4,12 +4,10 @@
 # SPDX-License-Identifier: Apache-2.0
 #
 
-if(CONFIG_SOC_MIMXRT1176_CM7)
+if(CONFIG_SOC_MIMXRT1176_CM7 OR CONFIG_SECOND_CORE_MCUX)
 board_runner_args(pyocd "--target=mimxrt1170_cm7")
 board_runner_args(jlink "--device=MIMXRT1176xxxA_M7" "--reset-after-load")
-endif()
-
-if(CONFIG_SOC_MIMXRT1176_CM4)
+elseif(CONFIG_SOC_MIMXRT1176_CM4)
 board_runner_args(pyocd "--target=mimxrt1170_cm4")
 # Note: Please use JLINK above V7.50 (Only support run cm4 image when debugging due to default boot core on board is cm7 core)
 board_runner_args(jlink "--device=MIMXRT1176xxxA_M4")
diff --git a/samples/subsys/ipc/openamp/Kconfig.sysbuild b/samples/subsys/ipc/openamp/Kconfig.sysbuild
index 6e8b813..d302687 100644
--- a/samples/subsys/ipc/openamp/Kconfig.sysbuild
+++ b/samples/subsys/ipc/openamp/Kconfig.sysbuild
@@ -10,3 +10,4 @@
 	default "lpcxpresso55s69_cpu1" if $(BOARD) = "lpcxpresso55s69_cpu0"
 	default "mps2_an521_remote" if $(BOARD) = "mps2_an521"
 	default "v2m_musca_b1_ns" if $(BOARD) = "v2m_musca_b1"
+	default "mimxrt1170_evk_cm4" if $(BOARD) = "mimxrt1170_evk_cm7"
diff --git a/samples/subsys/ipc/openamp/README.rst b/samples/subsys/ipc/openamp/README.rst
index 5ed19c8..2a1655a 100644
--- a/samples/subsys/ipc/openamp/README.rst
+++ b/samples/subsys/ipc/openamp/README.rst
@@ -43,6 +43,14 @@
    :board: v2m_musca_b1
    :goals: debug
 
+Building the application for mimxrt1170_evk_cm7
+***********************************************
+
+.. zephyr-app-commands::
+   :zephyr-app: samples/subsys/ipc/openamp
+   :board: mimxrt1170_evk_cm7
+   :goals: debug
+
 Open a serial terminal (minicom, putty, etc.) and connect the board with the
 following settings:
 
diff --git a/samples/subsys/ipc/openamp/boards/mimxrt1170_evk_cm7.conf b/samples/subsys/ipc/openamp/boards/mimxrt1170_evk_cm7.conf
new file mode 100644
index 0000000..630a193
--- /dev/null
+++ b/samples/subsys/ipc/openamp/boards/mimxrt1170_evk_cm7.conf
@@ -0,0 +1,2 @@
+CONFIG_INCLUDE_REMOTE_DIR=y
+CONFIG_SECOND_CORE_MCUX=y
diff --git a/samples/subsys/ipc/openamp/boards/mimxrt1170_evk_cm7.overlay b/samples/subsys/ipc/openamp/boards/mimxrt1170_evk_cm7.overlay
new file mode 100644
index 0000000..467595f
--- /dev/null
+++ b/samples/subsys/ipc/openamp/boards/mimxrt1170_evk_cm7.overlay
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2022 NXP
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/ {
+	chosen {
+		zephyr,ipc_shm = &ocram2_overlay;
+	};
+
+	/* OpenAMP fails with full 512K OCRAM2 memory region as shared memory.
+	 * Define a subset of the OCRAM2 region for demo to use
+	 * Note that shared memory must have specific MPU attributes set.
+	 */
+	ocram2_overlay: memory@202c0000{
+		compatible = "zephyr,memory-region", "mmio-sram";
+		reg = <0x202c0000 DT_SIZE_K(16)>;
+		zephyr,memory-region="OCRAM2_OVERLAY";
+		zephyr,memory-region-mpu = "IO";
+	};
+};
diff --git a/samples/subsys/ipc/openamp/remote/boards/mimxrt1170_evk_cm4.conf b/samples/subsys/ipc/openamp/remote/boards/mimxrt1170_evk_cm4.conf
new file mode 100644
index 0000000..4dfc4a6
--- /dev/null
+++ b/samples/subsys/ipc/openamp/remote/boards/mimxrt1170_evk_cm4.conf
@@ -0,0 +1,3 @@
+CONFIG_BUILD_OUTPUT_INFO_HEADER=y
+CONFIG_BUILD_OUTPUT_HEX=y
+CONFIG_SECOND_CORE_MCUX=y
diff --git a/samples/subsys/ipc/openamp/remote/boards/mimxrt1170_evk_cm4.overlay b/samples/subsys/ipc/openamp/remote/boards/mimxrt1170_evk_cm4.overlay
new file mode 100644
index 0000000..caff1f4
--- /dev/null
+++ b/samples/subsys/ipc/openamp/remote/boards/mimxrt1170_evk_cm4.overlay
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2022 NXP
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/ {
+	/* Switch to lpuart2, since primary core uses lpuart1 */
+	chosen {
+		zephyr,console = &lpuart2;
+		zephyr,shell-uart = &lpuart2;
+		zephyr,ipc_shm = &ocram2_overlay;
+	};
+
+	soc {
+		/delete-node/ gpt@400f0000;
+
+		/* Replace GPT2 with another GPT kernel timer */
+		gpt2_hw_timer:gpt@400f0000 {
+			compatible = "nxp,gpt-hw-timer";
+			reg = <0x400f0000 0x4000>;
+			interrupts = <120 0>;
+			status = "okay";
+		};
+	};
+
+	/* OpenAMP fails with full 512K OCRAM2 memory region as shared memory.
+	 * Define a subset of the OCRAM2 region for demo to use
+	 * Note that shared memory must have specific MPU attributes set
+	 */
+	ocram2_overlay: memory@202c0000 {
+		compatible = "zephyr,memory-region", "mmio-sram";
+		reg = <0x202c0000 DT_SIZE_K(16)>;
+		zephyr,memory-region="OCRAM2_OVERLAY";
+		zephyr,memory-region-mpu = "IO";
+	};
+};
+
+/* Enable secondary LPUART */
+&lpuart2 {
+	status = "okay";
+	current-speed = <115200>;
+};
+
+/* Disable primary GPT timer */
+&gpt_hw_timer {
+	status = "disabled";
+};