boards: mimxrt1170_evk: add support for loading M4 image from OCRAM

Add support for loading M4 image from OCRAM when running with dual core
operation. The M7 core will copy the M4 image from flash into OCRAM, and
the M4 core will execute it there.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
diff --git a/boards/arm/mimxrt1170_evk/Kconfig.defconfig b/boards/arm/mimxrt1170_evk/Kconfig.defconfig
index ed2cf29..9ad85f1 100644
--- a/boards/arm/mimxrt1170_evk/Kconfig.defconfig
+++ b/boards/arm/mimxrt1170_evk/Kconfig.defconfig
@@ -11,9 +11,25 @@
 
 choice CODE_LOCATION
 	default CODE_FLEXSPI if BOARD_MIMXRT1170_EVK_CM7
+	default CODE_OCRAM if BOARD_MIMXRT1170_EVK_CM4 && SECOND_CORE_MCUX
 	default CODE_SRAM0 if BOARD_MIMXRT1170_EVK_CM4
 endchoice
 
+if SECOND_CORE_MCUX && BOARD_MIMXRT1170_EVK_CM4
+
+config BUILD_OUTPUT_INFO_HEADER
+	default y
+
+DT_CHOSEN_IMAGE_M4 = nxp,m4-partition
+
+# Adjust the offset of the output image if building for RT11xx SOC
+config BUILD_OUTPUT_ADJUST_LMA
+	default "($(dt_chosen_reg_addr_hex,$(DT_CHOSEN_IMAGE_M4)) + \
+	$(dt_node_reg_addr_hex,/soc/spi@400cc000,1)) - \
+	$(dt_node_reg_addr_hex,/soc/ocram@20200000)"
+
+endif
+
 if DISK_DRIVERS
 
 config IMX_USDHC_DAT3_PWR_TOGGLE
diff --git a/boards/arm/mimxrt1170_evk/mimxrt1170_evk_cm4.dts b/boards/arm/mimxrt1170_evk/mimxrt1170_evk_cm4.dts
index 49ace92..165cbfa 100644
--- a/boards/arm/mimxrt1170_evk/mimxrt1170_evk_cm4.dts
+++ b/boards/arm/mimxrt1170_evk/mimxrt1170_evk_cm4.dts
@@ -26,6 +26,7 @@
 		zephyr,canbus = &flexcan2;
 		zephyr,flash-controller = &is25wp128;
 		zephyr,flash = &is25wp128;
+		nxp,m4-partition = &slot1_partition;
 	};
 
 	sdram0: memory@80000000 {
diff --git a/boards/arm/mimxrt1170_evk/mimxrt1170_evk_cm7.dts b/boards/arm/mimxrt1170_evk/mimxrt1170_evk_cm7.dts
index 2eea81a..2fbb945 100644
--- a/boards/arm/mimxrt1170_evk/mimxrt1170_evk_cm7.dts
+++ b/boards/arm/mimxrt1170_evk/mimxrt1170_evk_cm7.dts
@@ -30,6 +30,7 @@
 		zephyr,code-partition = &slot0_partition;
 		zephyr,display = &lcdif;
 		zephyr,keyboard-scan = &touch_controller;
+		zephyr,cpu1-region = &ocram;
 	};
 
 	sdram0: memory@80000000 {