samples/boards/nrf/nrf53_sync_rtc/README.html · samples/boards/nrf/nrf53_sync_rtc/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Boards · Nordic Dual Core

Synchronized RTC

Shared timestamp event를 이용해 두 core의 system tick 차이를 보정합니다.

Official pathsamples/boards/nrf/nrf53_sync_rtc/README.html
Source filesamples/boards/nrf/nrf53_sync_rtc/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

IPC interrupt latency, 1-tick 오차, real board와 simulator 실행을 설명합니다.

Cores

Application · Network

Offset

8270 ticks

Transport

IPM · IPC HAL

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 460F7B982DFD4F56CB8739C85FFEB02A6799F0C3D636E665249AF6110F8E3DB6
.. _nrf53_sync_rtc_sample:

Synchronized RTC
################

Overview
********

Sample is showing how RTC clocks used for system clock on application and network
core are synchronized. The result of synchronization is an offset value on network
core which can be applied to the system tick for logging timestamping.

Sample is using IPM driver and IPC HAL to produce events which occur at same time on
both cores. Application core periodically reads current system tick and stores it in
the shared memory and triggers IPC task which results in the interrupt on the network
core. In the context of the IPC interrupt handler, network core is logging timestamp
from shared memory and local system tick updated by the offset. User can observe
that before synchronization procedure is completed, timestamps differ significantly
and once procedure is completed timestamps are synchronized. Network core timestamp
may be slightly behind (usually 1 tick) due to latency introduced by the
interrupt handling.

For simplicity and low latency sample is not using more sophisticated IPM protocols.

Building the application for nrf5340dk/nrf5340/cpuapp
*****************************************************

.. zephyr-app-commands::
   :zephyr-app: samples/boards/nrf/nrf53_sync_rtc
   :board: nrf5340dk/nrf5340/cpuapp
   :goals: flash
   :flash-args: --hex-file build/nrf53_sync_rtc/zephyr/zephyr.hex
   :west-args: --sysbuild

Open a serial terminals (for example Minicom or PuTTY) and connect the board with the
following settings:

- Speed: 115200
- Data: 8 bits
- Parity: None
- Stop bits: 1

When you reset the development kit, the following messages (one for master and one for remote) will appear on the corresponding serial ports:

.. code-block:: console

   *** Booting Zephyr OS build v2.7.0-rc1-89-ge755863d66c9  ***
   [00:00:00.306,915] <inf> main: IPC send at 10056 ticks
   [00:00:00.356,903] <inf> main: IPC send at 11695 ticks
   [00:00:00.406,921] <inf> main: IPC send at 13334 ticks
   [00:00:00.456,939] <inf> main: IPC send at 14973 ticks
   [00:00:00.506,958] <inf> main: IPC send at 16612 ticks
   [00:00:00.556,976] <inf> main: IPC send at 18251 ticks
   [00:00:00.606,994] <inf> main: IPC send at 19890 ticks
   [00:00:00.657,012] <inf> main: IPC send at 21529 ticks
   [00:00:00.707,031] <inf> main: IPC send at 23168 ticks
   [00:00:00.757,049] <inf> main: IPC send at 24807 ticks


.. code-block:: console

   *** Booting Zephyr OS build v2.7.0-rc1-89-ge755863d66c9  ***
   [00:00:00.054,534] <inf> main: Local timestamp: 1787, application core timestamp: 10056
   [00:00:00.104,553] <inf> main: Local timestamp: 3426, application core timestamp: 11695
   [00:00:00.154,571] <inf> main: Local timestamp: 5065, application core timestamp: 13334
   [00:00:00.204,589] <inf> main: Local timestamp: 6704, application core timestamp: 14973
   [00:00:00.254,608] <inf> main: Local timestamp: 8343, application core timestamp: 16612
   [00:00:00.514,892] <inf> sync_rtc: Updated timestamp to synchronized RTC by 8270 ticks (252380us)
   [00:00:00.557,006] <inf> main: Local timestamp: 18252, application core timestamp: 18251
   [00:00:00.607,025] <inf> main: Local timestamp: 19891, application core timestamp: 19890
   [00:00:00.657,043] <inf> main: Local timestamp: 21530, application core timestamp: 21529
   [00:00:00.707,061] <inf> main: Local timestamp: 23169, application core timestamp: 23168
   [00:00:00.757,080] <inf> main: Local timestamp: 24807, application core timestamp: 24807

Observe that initially logging timestamps for the corresponding events on both cores
do not match. Same with local and remote timestamps reported on network core. After
RTC synchronization is completed they start to match.

.. _nrf53_sync_rtc_sample_build_bsim:

Building the application for the simulated nrf5340bsim
******************************************************

.. zephyr-app-commands::
   :zephyr-app: samples/boards/nrf/nrf53_sync_rtc
   :host-os: unix
   :board: nrf5340bsim/nrf5340/cpuapp
   :goals: build
   :west-args: --sysbuild

Then you can execute your application using:

.. code-block:: console

   $ ./build/zephyr/zephyr.exe -nosim
   # Press Ctrl+C to exit

You can expect a similar output as in the real HW in the invoking console.

Part 3

한국어 전문 번역

개요

이 sample은 application core와 network core에서 system clock으로 사용하는 RTC clock을 동기화하는 방법을 보여줍니다. 동기화 결과는 network core의 offset 값이며, logging timestamp를 만들 때 system tick에 적용할 수 있습니다.

Sample은 IPM driver와 IPC HAL을 사용해 두 core에서 동시에 발생하는 event를 만듭니다. Application core는 주기적으로 현재 system tick을 읽어 shared memory에 저장한 뒤 IPC task를 trigger하고, 그 결과 network core에서 interrupt가 발생합니다. Network core는 IPC interrupt handler 안에서 shared memory의 timestamp와 offset으로 보정한 local system tick을 기록합니다.

동기화 절차가 끝나기 전에는 두 timestamp가 크게 다르지만, 절차가 완료되면 서로 동기화된 것을 확인할 수 있습니다. Interrupt 처리 latency 때문에 network core timestamp가 약간, 보통 1 tick 정도 뒤처질 수 있습니다.

단순성과 낮은 latency를 위해 이 sample은 더 정교한 IPM protocol을 사용하지 않습니다.

nrf5340dk/nrf5340/cpuapp용 application build

# From the root of the zephyr repository
west build -b nrf5340dk/nrf5340/cpuapp --sysbuild samples/boards/nrf/nrf53_sync_rtc
west flash --hex-file build/nrf53_sync_rtc/zephyr/zephyr.hex

Minicom이나 PuTTY 같은 serial terminal을 열고 다음 설정으로 board에 연결합니다.

  • Speed: 115200
  • Data: 8 bits
  • Parity: None
  • Stop bits: 1

Development kit을 reset하면 master와 remote에 해당하는 다음 message가 각각의 serial port에 나타납니다.

*** Booting Zephyr OS build v2.7.0-rc1-89-ge755863d66c9  ***
[00:00:00.306,915] <inf> main: IPC send at 10056 ticks
[00:00:00.356,903] <inf> main: IPC send at 11695 ticks
[00:00:00.406,921] <inf> main: IPC send at 13334 ticks
[00:00:00.456,939] <inf> main: IPC send at 14973 ticks
[00:00:00.506,958] <inf> main: IPC send at 16612 ticks
[00:00:00.556,976] <inf> main: IPC send at 18251 ticks
[00:00:00.606,994] <inf> main: IPC send at 19890 ticks
[00:00:00.657,012] <inf> main: IPC send at 21529 ticks
[00:00:00.707,031] <inf> main: IPC send at 23168 ticks
[00:00:00.757,049] <inf> main: IPC send at 24807 ticks
*** Booting Zephyr OS build v2.7.0-rc1-89-ge755863d66c9  ***
[00:00:00.054,534] <inf> main: Local timestamp: 1787, application core timestamp: 10056
[00:00:00.104,553] <inf> main: Local timestamp: 3426, application core timestamp: 11695
[00:00:00.154,571] <inf> main: Local timestamp: 5065, application core timestamp: 13334
[00:00:00.204,589] <inf> main: Local timestamp: 6704, application core timestamp: 14973
[00:00:00.254,608] <inf> main: Local timestamp: 8343, application core timestamp: 16612
[00:00:00.514,892] <inf> sync_rtc: Updated timestamp to synchronized RTC by 8270 ticks (252380us)
[00:00:00.557,006] <inf> main: Local timestamp: 18252, application core timestamp: 18251
[00:00:00.607,025] <inf> main: Local timestamp: 19891, application core timestamp: 19890
[00:00:00.657,043] <inf> main: Local timestamp: 21530, application core timestamp: 21529
[00:00:00.707,061] <inf> main: Local timestamp: 23169, application core timestamp: 23168
[00:00:00.757,080] <inf> main: Local timestamp: 24807, application core timestamp: 24807

처음에는 두 core에서 같은 event에 기록한 logging timestamp가 일치하지 않으며, network core가 보고하는 local timestamp와 remote timestamp도 다릅니다. RTC 동기화가 완료된 뒤에는 이 값들이 서로 맞기 시작합니다.

Simulated nrf5340bsim용 application build

# From the root of the zephyr repository
west build -b nrf5340bsim/nrf5340/cpuapp --sysbuild samples/boards/nrf/nrf53_sync_rtc

그다음 다음 명령으로 application을 실행합니다.

$ ./build/zephyr/zephyr.exe -nosim
# Press Ctrl+C to exit

명령을 실행한 console에서 실제 hardware와 비슷한 출력을 확인할 수 있습니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.