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 - petalinuxを使用したzephyr rtosの起動

1
Posted at

KV260 - petalinuxを使用したzephyr rtosの起動

  • はじめに

    • KV260とpetalinuxを使ったzephyr rtosの起動手順の記録メモです。

  • 作業環境

    • VirtualBox7.1.4で、Ubuntu24.04 LTSを使用
      • petalinuxとzephyr rtosのビルドに使用。

  • petalinuxのビルド環境構築

    • petalinuxインストーラ実行前の準備(ツール群のパッケージの導入)
    $ apt update && apt install -y xz-utils gcc xterm autoconf libtool less rsync bc texinfo zlib1g-dev gcc-multilib build-essential python3 lsb-release ncurses-dev dnsutils sudo locales iputils-ping net-tools screen && rm -rf /var/lib/apt/list/*  
    

    • petalinuxインストーラの実行(petalinuxツールの導入)
      • 使用インストーラ petalinux-v2025.1-05180714-installer.run
    $ sudo ./petalinux-v2025.1-05180714-installer.run --platform aarch64 -d ./インストール先のディレクトリ  
    

    • Pathの設定
      • インストール先のディレクトリをこの文書上は、buildとしているので、
        buildに移動して、path設定を行うスクリプトを実行する。 
    $ cd ./build  
    $ source ./settings.sh  
    $ 
    

    • petalinux bspからprojectを作成
      • 使用bsp xilinx-kv260-starterkit-v2025.1-05221048.bsp
    $ petalinux-create -t project -s ../xilinx-kv260-starterkit-v2025.1-05221048.bsp 
    

  • device treeの編集

    /include/ "system-conf.dtsi" 
    / {
          reserved-memory {
          #address-cells = <0x02>;
          #size-cells = <0x02>;
          ranges;
    
          rpu0vdev0vring: rpu0vdev0vring0@3ed40000 {
              no-map;
              reg = <0x00 0x3ed40000 0x00 0x4000>;
          };
    
          rpu0vdev0vring1: rpu0vdev0vring1@3ed44000 {
              no-map;
              reg = <0x00 0x3ed44000 0x00 0x4000>;
          };
    
          rpu0vdev0buffer: rpu0vdev0buffer@3ed48000 {
              no-map;
              reg = <0x00 0x3ed48000 0x00 0x100000>;
          };
    
          rproc: rproc@3ed00000 {
              no-map;
              reg = <0x00 0x3ed00000 0x00 0x40000>;
          };
      };
    
      tcm_0a: tcm_0a@ffe00000 {
          reg = <0x0 0xffe00000 0x0 0x10000>;
          status = "okay";
          compatible = "mmio-sram";
          power-domains = <&zynqmp_firmware 15>;
      };
    
      tcm_0b: tcm_0b@ffe20000 {
          no-map;
          reg = <0x0 0xffe20000 0x0 0x10000>;
          status = "okay";
          compatible = "mmio-sram";
          power-domains = <&zynqmp_firmware 16>;
          };
    
      r5fss@ff9a0000 {
          compatible = "xlnx,zynqmp-r5fss";
          xlnx,cluster-mode = <1>;
          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 &rpu0vdev0buffer &rpu0vdev0vring &rpu0vdev0vring1>;
              power-domains = <&zynqmp_firmware 7>;
              mboxes = <&ipi_mailbox_rpu0 0>, <&ipi_mailbox_rpu0 1>;
              mbox-names = "tx", "rx";
                      tcm_0_a: tcm_0@ffe00000 {
                          reg = <0x0 0xFFE00000 0x0 0x10000>;
                          status = "okay";
                          compatible = "mmio-sram";
                          power-domains = <&zynqmp_firmware 15>;
                      };
                      tcm_0_b: tcm_0@ffe20000 {
                          reg = <0x0 0xFFE20000 0x0 0x10000>;
                          status = "okay";
                          compatible = "mmio-sram";
                          power-domains = <&zynqmp_firmware 16>;
                      };
                 };
          };
    
      zynqmp_ipi1 {
          compatible = "xlnx,zynqmp-ipi-mailbox";
          interrupt-parent = <&gic>;
          interrupts = <0 29 4>;
          xlnx,ipi-id = <7>;
          #address-cells = <1>;
          #size-cells = <1>;
          ranges;
    
          /* APU<->RPU0 IPI mailbox controller */
          ipi_mailbox_rpu0: mailbox@ff990600 {
                  compatible = "xlnx,zynqmp-ipi-dest-mailbox";
              reg = <0xff990600 0x20>,
                    <0xff990620 0x20>,
                    <0xff9900c0 0x20>,
                    <0xff9900e0 0x20>;
              reg-names = "local_request_region",
                      "local_response_region",
                      "remote_request_region",
                      "remote_response_region";
              #mbox-cells = <1>;
              xlnx,ipi-id = <1>;
          };
      };
    };
    

  • シリアルコンソール競合の回避対応
    シリアルコンソールを利用する際、UARTを用いるため、
    zephyr rtosでUARTを使用するため、petalinuxのUARTの利用を無効化する。
    (petalinuxのシリアルコンソールには、USBシリアル変換ケーブルを用いた。)

    • 編集するファイル
      • xilinx-kv260-starterkit-2025.1/project-spec/dts_dir/zynqmp-sck-kv-g-revB.dtso
      &uart1 {
          status = "disabled";
    

  • カーネル起動パラメータの編集

    • petalinux側でUARTをシリアルコンソールとして用いないが、
      zephyr rtos側で利用するため、ハードウェアが停止しないように、
      カーネル起動パラメータを編集する。(clk_ignore_unusedを追加)
      • コマンド petalinux-config
      • メニュー DT Settings → Kernel Bootargsで遷移 → clk_ignore_unusedをextra argsへ追加する
      • system-user.dtsiを使用する場合、コマンド petalinux-configによる追加が
        上書きで削除されるので、system-user.dtsiにも記載する。
        USBシリアル変換ケーブルを用いたためttyUSB0の記載をしているが
        USBシリアル変換ケーブルを用いない場合は記載不要。
    / { 
          chosen {
              bootargs = "console=ttyUSB0,115200 root=/dev/ram0 rw init_fatal_sh=1 cma=900M clk_ignore_unused";
          };
      };
    

  • petalinuxのビルド

    $ cd xilinx-kv260-starterkit-2025.1
    $ petalinux-build
    

  • package化とSDカードへの書き込み

    $ petalinux-package --boot --u-boot --force 
    $ petalinux-packge --wic --images-dir images/linux/ --bootfiles "ramdisk.cpio.gz.u-boot,boot.scr,Image,system.dtb,system-zynqmp-sck-kv-g-revB.dtb"
    $ sudo dd if=petalinux-sdimage.wic of=/dev/sdb bs=4M status=progress oflag=sync
    

  • zephyr rtosのビルド環境構築
     参照サイト
      https://docs.zephyrproject.org/latest/develop/getting_started/index.html
      https://docs.zephyrproject.org/latest/boards/amd/kv260_r5/doc/index.html

  • ビルド

    • 動作確認用のアプリケーションには、zephyr rtosに附属する
      サンプルアプリケーションhello_worldを使用
    west build -b kv260_r5 samples/hello_worlds -p always
    

  • ビルド後の生成ファイルをpetalinux起動後にコピー

    • この確認では、USBメモリを使用して以下にコピー
    $ mount /dev/sda /tmp
    $ cp /tmp/zephyr.elf /lib/firmware/
    

  • zephyr rtosの起動(petalinux操作)

    xilinx-kv260-starterkit-20251:~$ sudo -i
    root@xilinx-kv260-starterkit-20251:~# 
    root@xilinx-kv260-starterkit-20251:~# echo zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
    root@xilinx-kv260-starterkit-20251:~# echo start > /sys/class/remoteproc/remoteproc0/state
    

  • zephyr rtosの起動(zephyr rtosのシリアルコンソール出力)

    *** Booting Zephyr OS build v4.2.0-5452-g169cf86969d7 ***
    Hello World! kv260_r5/zynqmp_rpu
    
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?