Part 1
요약·해설
Vector·memory 설정, 두 instance 실행과 송수신 console을 모두 보존합니다.
2
2
4 MiB
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
152425FFBEA9476C2807C7D97D697C9D92841B572D7ADE4D7DCC75DA1BBCE5E6
.. zephyr:code-sample:: ipm-ivshmem
:name: IPM over IVSHMEM
:relevant-api: ipm_interface
Implement inter-processor mailbox (IPM) over IVSHMEM (Inter-VM shared memory)
Prerequisites
*************
* QEMU needs to available.
ivshmem-server needs to be available and running. The server is available in
Zephyr SDK or pre-built in some distributions. Otherwise, it is available in
QEMU source tree.
ivshmem-client needs to be available as it is employed in this sample as an
external application. The same conditions of ivshmem-server apply to the
ivshmem-server, as it is also available via QEMU.
Preparing IVSHMEM server
************************
#. The ivshmem-server utility for QEMU can be found into the Zephyr SDK
directory, in:
``/path/to/your/zephyr-sdk/zephyr-<version>/sysroots/x86_64-pokysdk-linux/usr/xilinx/bin/``
#. You may also find ivshmem-client utility, it can be useful to check if everything works
as expected.
#. Run ivshmem-server. For the ivshmem-server, both number of vectors and
shared memory size are decided at run-time (when the server is executed).
For Zephyr, the number of vectors and shared memory size of ivshmem are
decided at compile-time and run-time, respectively. For Arm64 we use
vectors == 2 for the project configuration in this sample. Here is an example:
.. code-block:: console
# n = number of vectors
$ sudo ivshmem-server -n 2
$ *** Example code, do not use in production ***
#. Appropriately set ownership of ``/dev/shm/ivshmem`` and
``/tmp/ivshmem_socket`` for your deployment scenario. For instance:
.. code-block:: console
$ sudo chgrp $USER /dev/shm/ivshmem
$ sudo chmod 060 /dev/shm/ivshmem
$ sudo chgrp $USER /tmp/ivshmem_socket
$ sudo chmod 060 /tmp/ivshmem_socket
Building and Running
********************
After getting QEMU ready to go, first create two output folders, so open two terminals
and create them, these folders will receive the output of Zephyr west commands:
.. code-block:: console
$ mkdir -p path/to/instance_1
On another terminal window do:
.. code-block:: console
$ mkdir -p path/to/instance_2
Then build the sample as follows, don't forget, two builds are necessary
to test this sample, so append the option ``-d path/to/instance_1`` and
on the other terminal window do the same, that is it ``-d path/to/instance_2``
.. zephyr-app-commands::
:zephyr-app: samples/drivers/ipm/ipm_ivshmem
:board: qemu_cortex_a53
:goals: build
:compact:
To run both QEMU sides, repeat the west build command followed
by ``-d path/to/instance_x`` where x is 1 or 2 depending on the
terminal window, using the run target:
.. zephyr-app-commands::
:zephyr-app: samples/drivers/ipm/ipm_ivshmem
:board: qemu_cortex_a53
:goals: run
:compact:
Expected output
***************
On the console just use the ``ivshmem_ipm_send`` command
followed by the destination peer-id, to get the peer-id destination
go to the other terminal window and check with ``ivshmem`` command:
.. code-block:: console
*** Booting Zephyr OS build zephyr-v3.4.0-974-g7fba7d395750 ***
uart:~$ ivshmem
IVshmem up and running:
Shared memory: 0xafa00000 of size 4194304 bytes
Peer id: 12
Notification vectors: 2
uart:~$
For example one of the instances has the peer-id 12, so go the other
instance and use the command to send the IPM notification followed
by this peer-id:
.. code-block:: console
*** Booting Zephyr OS build zephyr-v3.4.0-974-g7fba7d395750 ***
uart:~$ ivshmem
IVshmem up and running:
Shared memory: 0xafa00000 of size 4194304 bytes
Peer id: 11
Notification vectors: 2
uart:~$ ivshmem_ipm_send 12
Then go back to the other terminal window where user may see the reception
of the notification on the terminal:
.. code-block:: console
uart:~$ ivshmem
IVshmem up and running:
Shared memory: 0xafa00000 of size 4194304 bytes
Peer id: 12
Notification vectors: 2
uart:~$ Received IPM notification over IVSHMEM
Part 3
한국어 전문 번역
사전 요구 사항
- QEMU를 사용할 수 있어야 합니다.
ivshmem-server가 설치되어 실행 중이어야 합니다. Server는 Zephyr SDK나 일부 distribution에 prebuilt 형태로 포함되며, 그렇지 않으면 QEMU source tree에서 구할 수 있습니다.
이 sample이 external application으로 사용하는 ivshmem-client도 필요합니다. Client 역시 QEMU를 통해 구할 수 있는 등 ivshmem-server와 같은 조건이 적용됩니다.
IVSHMEM Server 준비
- QEMU용
ivshmem-serverutility는 Zephyr SDK의/path/to/your/zephyr-sdk/zephyr-<version>/sysroots/x86_64-pokysdk-linux/usr/xilinx/bin/에서 찾을 수 있습니다. ivshmem-clientutility도 찾을 수 있으며 모든 것이 예상대로 동작하는지 확인할 때 유용합니다.ivshmem-server를 실행합니다. Server의 vector 수와 shared memory size는 실행 시 결정됩니다. Zephyr에서는 IVSHMEM vector 수는 compile time, shared memory size는 run time에 결정됩니다. 이 sample의 Arm64 project 구성은vectors == 2를 사용합니다.
# n = number of vectors
$ sudo ivshmem-server -n 2
$ *** Example code, do not use in production ***
Deployment 환경에 맞게 /dev/shm/ivshmem과 /tmp/ivshmem_socket의 ownership을 설정합니다. 예는 다음과 같습니다.
$ sudo chgrp $USER /dev/shm/ivshmem
$ sudo chmod 060 /dev/shm/ivshmem
$ sudo chgrp $USER /tmp/ivshmem_socket
$ sudo chmod 060 /tmp/ivshmem_socket
Build와 실행
QEMU를 준비한 뒤 output folder 두 개를 만듭니다. Terminal 두 개를 열고 각각 directory를 만드십시오. 이 folder는 Zephyr west 명령의 output을 받습니다.
$ mkdir -p path/to/instance_1
다른 terminal window에서는 다음을 실행합니다.
$ mkdir -p path/to/instance_2
다음과 같이 sample을 build합니다. 이 sample을 시험하려면 build가 두 개 필요합니다. 한 terminal에서는 -d path/to/instance_1 option을 붙이고 다른 terminal에서는 -d path/to/instance_2를 붙이십시오.
west build -b qemu_cortex_a53 samples/drivers/ipm/ipm_ivshmem
QEMU 양쪽을 실행하려면 terminal window에 따라 1 또는 2를 뜻하는 x를 사용해 -d path/to/instance_x를 붙인 다음, run target으로 west build 명령을 반복합니다.
west build -b qemu_cortex_a53 samples/drivers/ipm/ipm_ivshmem
west build -t run
예상 출력
Console에서 ivshmem_ipm_send 명령 뒤에 destination peer-id를 지정합니다. Destination peer-id를 확인하려면 다른 terminal window로 가서 ivshmem 명령을 실행합니다.
*** Booting Zephyr OS build zephyr-v3.4.0-974-g7fba7d395750 ***
uart:~$ ivshmem
IVshmem up and running:
Shared memory: 0xafa00000 of size 4194304 bytes
Peer id: 12
Notification vectors: 2
uart:~$
예를 들어 instance 하나의 peer-id가 12라면 다른 instance로 가서 이 peer-id를 붙인 명령으로 IPM notification을 보냅니다.
*** Booting Zephyr OS build zephyr-v3.4.0-974-g7fba7d395750 ***
uart:~$ ivshmem
IVshmem up and running:
Shared memory: 0xafa00000 of size 4194304 bytes
Peer id: 11
Notification vectors: 2
uart:~$ ivshmem_ipm_send 12
다른 terminal window로 돌아가면 notification을 수신한 출력을 볼 수 있습니다.
uart:~$ ivshmem
IVshmem up and running:
Shared memory: 0xafa00000 of size 4194304 bytes
Peer id: 12
Notification vectors: 2
uart:~$ Received IPM notification over IVSHMEM
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.