1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

KV260 - 2つのzephyr rtosの間で、OpenAMPを使って通信

1
Posted at

KV260 - 2つのzephyr rtosの間で、OpenAMPを使って通信

  • はじめに
    KV260を使用して、RPU0(cortex-R5-0)上のzephyr rtosとRPU1(cortex-R5-1)上の
    zephyr rtosとの間で、OpenAMPにより通信動作が行われるのかを確認したときの
    設定などの記録メモです。

project-spec/meta-user/recipes-bsp/device-tree/filessystem-user.dtsi
/include/ "system-conf.dtsi"
/ {
+	reserved-memory {
+		#address-cells = <0x02>;
+		#size-cells = <0x02>;
+		ranges;
+
+		rproc_0_fw_image: memory@3ed00000 {
+			no-map;
+			reg = <0x0 0x3ed00000 0x0 0x40000>;
+		};
+
+		rproc_1_fw_image: memory@3ed40000 {
+			no-map;
+			reg = <0x0 0x3ed40000 0x0 0x40000>;
+		};
+
+        shared_mem: memory@3ed80000 {
+			no-map;
+			reg = <0x0 0x3ed80000 0x0 0x480000>;
+		};		
+	};
+
+	r5fss@ff9a0000 {
+		compatible = "xlnx,zynqmp-r5fss";
+		xlnx,cluster-mode = <0>;
+		ranges;
+		reg = <0x0 0xFF9A0000 0x0 0x10000>;
+		status = "okay"; 
+		#address-cells = <0x2>;
+		#size-cells = <0x2>;
+
+		r5f_0: r5f@0 {
+		    compatible = "xilinx,r5f";
+		    #address-cells = <0x2>;
+		    #size-cells = <0x2>;
+		    ranges;
+           memory-region = <&rproc_0_fw_image>;
+		    power-domains = <&zynqmp_firmware 7>;
+       };
+
+       r5f_1: r5f@1 {
+           compatible = "xilinx,r5f";
+           #address-cells = <0x2>;
+           #size-cells = <0x2>;
+           ranges;
+           memory-region = <&rproc_1_fw_image>;
+           power-domains = <&zynqmp_firmware 8>;
+       };
+   };
+};
+/ { 
+    chosen {
+        bootargs = "console=ttyUSB0,115200 root=/dev/ram0 rw init_fatal_sh=1 cma=900M +clk_ignore_unused";
+    };
};
  • 編集したdtsの内容(zephyr rtos) (1)
    ★の部分は、RPU1に適用するファームウェアの時は、
    zephyr,ipc = &rpu1_rpu0_mailbox;とする。
zephyr/boards/amd/kv260_r5/kv260_r5.dtsi
/dts-v1/;
#include <arm/xilinx/zynqmp_rpu.dtsi>

/ {
	model = "KV260 Cortex-R5";
	compatible = "xlnx,zynqmp-r5";

	chosen {
-        zephyr,sram = &sram0;
	    zephyr,flash = &flash0;
		zephyr,console = &uart1;
		zephyr,shell-uart = &uart1;
-        zephyr,ocm = &ocm;
+		zephyr,ipc = &rpu0_rpu1_mailbox; 
+		zephyr,ipc_shm = &ipc_shm;
	};

	aliases {
		eeprom-0 = &eeprom0;
		eeprom-1 = &eeprom1;
	};

	i2c_ref_clk: i2c-ref-clk {
		compatible = "fixed-clock";
		clock-frequency = <100000000>;
		#clock-cells = <0>;
	};

+	reserved-memory {
+		compatible = "reserved-memory";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		status = "okay";
+		ranges;
+
+		ipc_shm: ipc-shm@3ed80000 {
+			compatible = "mmio-sram";
+			reg = <0x3ed80000 DT_SIZE_K(288)>;
+		};
+	};
};

&uart1 {
	status = "okay";
	current-speed = <115200>;
	clock-frequency = <99999901>;
};

&ttc0 {
	status = "okay";
	clock-frequency = <100000000>;
};

&psgpio {
	status = "okay";
};

&i2c1 {
	status = "okay";
	clocks = <&i2c_ref_clk>;
	clock-frequency = <400000>;

	eeprom0: eeprom@50 {
		compatible = "st,24c64", "atmel,at24";
		reg = <0x50>;
		size = <DT_SIZE_K(8)>;
		pagesize = <32>;
		address-width = <16>;
		timeout = <5>;
		read-only;
	};

	eeprom1: eeprom@51 {
		compatible = "st,24c64", "atmel,at24";
		reg = <0x51>;
		size = <DT_SIZE_K(8)>;
		pagesize = <32>;
		address-width = <16>;
		timeout = <5>;
		read-only;
	};
};

+&rpu0_ipi {
+	status = "okay";
+};

+&rpu1_ipi {
+	status = "okay";
+};

+&rpu0_rpu1_mailbox {
+	status = "okay";
+	remote-ipi-id = <2>;
+};

+&rpu1_rpu0_mailbox {
+	status = "okay";
+	remote-ipi-id = <1>;
+};

+&rpu0_apu_mailbox {
+	status = "disabled";
+	remote-ipi-id = <0>; /* APU */
+};

+&rpu1_apu_mailbox {
+	status = "disabled";
+	remote-ipi-id = <0>; /* APU */
+};

  • 編集したdtsの内容(zephyr rtos) (2)
    ★の部分は、RPU0に適用するファームウェアの時は、0、
    RPU1に適用するファームウェアの時は、1とする。
zephyr/dts/arm/xilinx/zynqmp_rpu.dtsi
#include <arm/xilinx/zynqmp.dtsi>

/ {
	cpus {
		#address-cells = <1>;
		#size-cells = <0>;

		cpu@0 { 
			device_type = "cpu";
			compatible = "arm,cortex-r5f";
			reg = <0>; 
		};
	};
  • 割り込みコントローラのドライバに関する対応
    RPU0、RPU1、共通の割り込みコントローラが使用されるので、
    割り込みの配信設定について、RPU1では、行わないように修正する。
    また、RPU0実行時の配信設定が実行される際に、RPU1で受けたい割り込みを
    設定しておく。
    対応方法は、動作確認のための暫定的対処。
zephyr/drivers/interrupt_controller/intc_gic.c
@@ -182,6 +182,14 @@ static void gic_dist_init(void)
 	uint8_t cpu_mask = 0;
 	uint32_t reg_val;
 
+	/*
+	 * If Distributor is already enabled by another OS/firmware,
+	 * do not reconfigure global GIC state.
+	 */
+	if (sys_read32(GICD_CTLR) & 0x1U) {
+		return;
+	}
+
 	gic_irqs = sys_read32(GICD_TYPER) & 0x1f;
 	gic_irqs = (gic_irqs + 1) * 32;
    
@@ -208,6 +216,8 @@ static void gic_dist_init(void)
 	for (i = GIC_SPI_INT_BASE; i < gic_irqs; i += 4) {
 		sys_write32(reg_val, GICD_ITARGETSRn + i);
 	}
+	/* rewrite for rpu1 */
+   sys_write8(0x02, GICD_ITARGETSRn + 66);
  • IPIドライバ初期化に対する対応
    対応方法は、動作確認のための暫定的対処。
zephyr/drivers/ipm/ipm_xlnx_ipi.c
static int xlnx_ipi_init(const struct device *dev)
{
	const struct xlnx_ipi_config *conf = dev->config;

	/* disable all the interrupts */
-	sys_write32(0xFFFFFFFF, conf->host_ipi_reg + IPI_IDR);
+//	sys_write32(0xFFFFFFFF, conf->host_ipi_reg + IPI_IDR);

	/* clear status of any previous interrupts */
	sys_write32(0xFFFFFFFF, conf->host_ipi_reg + IPI_ISR);
  • サンプルアプリケーション(RPU0で用いる)に対するprj.conf
prj.conf
# nothing here

#FW-R0
CONFIG_KERNEL_BIN_NAME="zephyr_r0"
CONFIG_SRAM_BASE_ADDRESS=0x3ED00000
CONFIG_SRAM_SIZE=1024
CONFIG_ROMSTART_RELOCATION_ROM=y
CONFIG_ROMSTART_REGION_ADDRESS=0x00000000
CONFIG_ROMSTART_REGION_SIZE=0x40

CONFIG_IPM=y
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_OPENAMP=y
CONFIG_OPENAMP_SLAVE=n
  • サンプルアプリケーション(RPU1で用いる)に対するprj.conf
prj.conf
# nothing here

#FW-R1
CONFIG_KERNEL_BIN_NAME="zephyr_r1"
CONFIG_SRAM_BASE_ADDRESS=0x3ED40000
CONFIG_SRAM_SIZE=548
CONFIG_ROMSTART_RELOCATION_ROM=y
CONFIG_ROMSTART_REGION_ADDRESS=0x00000000
CONFIG_ROMSTART_REGION_SIZE=0x40

CONFIG_IPM=y
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_OPENAMP=y
CONFIG_OPENAMP_MASTER=n
  • petalinux側のコンソール上での、実行コマンド
    ファームウェア(elfファイル)のコピー~開始まで。
petalinux
$ sudo cp /tmp/zephyr_r0.elf /lib/firmware
$ sudo cp /tmp/zephyr_r1.elf /lib/firmware
$ sudo -i
# echo zephyr_r0.elf > /sys/class/remoteproc/remoteproc0/firmware
# echo start > /sys/class/remoteproc/remoteproc0/state

# echo zephyr_r1.elf > /sys/class/remoteproc/remoteproc1/firmware
# echo start > /sys/class/remoteproc/remoteproc1/state
  • 実行時のzephyr rtos側のコンソールのメッセージ
zephyr rtos
*** Booting Zephyr OS build v4.2.0-5452-g169cf86969d7 ***
Starting application thread!

OpenAMP[master] demo started
*** Booting Zephyr OS build v4.2.0-5452-g169cf86969d7 ***
Starting application thread!

OpenAMP[remote] demo started
Remote core received a message: 0
Master core received a message: 1
Remote core received a message: 2
Master core received a message: 3
Remote core received a message: 4
Master core received a message: 5
Remote core received a message: 6
Master core received a message: 7
Remote core received a message: 8
Master core received a message: 9
Remote core received a message: 10
Master core received a message: 11
Remote core received a message: 12
Master core received a message: 13
Remote core received a message: 14
Master core received a message: 15
~中略~
Remote core received a message: 90
Master core received a message: 91
Remote core received a message: 92
Master core received a message: 93
Remote core received a message: 94
Master core received a message: 95
Remote core received a message: 96
Master core received a message: 97
Remote core received a message: 98
 a message: 99eceive
OpenAMP demo ended.
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?