0
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 - zephyr rtosへのRAMの配置先、サイズの変更をconfigurationファイル(prj.conf)で行う。

0
Last updated at Posted at 2026-04-20
KV260 - zephyr rtosのRAMへの配置先、サイズの変更をconfigurationファイル(prj.conf)で行う。
  • はじめに

    • KV260とpetalinuxを使ってzephyr rtosを利用する際に、
      配置するRAMへの場所、サイズを設定する方法の記録です。

  • 使用するメモリサイズの増加

    • 以前の投稿でpetalinuxからzephyr rtosを起動させた内容を記載したが、
      SHELL機能の利用を試みたところ、使用するRAMのサイズが増え、
      petalinuxからzephyr rtosの起動の際に、ファイルのロードに失敗する
      状況となったため、 RAMへの配置場所やサイズの変更方法を確認

    以前の投稿 (KV260 - petalinuxを使用したzephyr rtosの起動)
    https://qiita.com/mana_t/items/e56bb6c94c9420167aa9#kv260---petalinux%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%9Fzephyr-rtos%E3%81%AE%E8%B5%B7%E5%8B%95

    SHELL機能使用の際のconfigurationファイル(prj.conf)の差
    # nothing here
    
    + CONFIG_SHELL=y
    
    linuxからファイルのロードする際の失敗エラーメッセージ
    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  
    Jan  8 15:05:39 xilinx-kv260-starterkit-20251 kernel: remoteproc remoteproc0: bad phdr da 0x8a20 mem 0x9980  
    Jan  8 15:05:39 xilinx-kv260-starterkit-20251 kernel: remoteproc remoteproc0: Failed to load program segments: -22
    
    SHELL機能有効前のRAMサイズ(サンプルアプリケーションhello world使用)
    Memory region         Used Size  Region Size  %age Used
           FLASH:          0 GB        32 MB      0.00%
             RAM:       37760 B        64 MB      0.06%
             OCM:          0 GB       256 KB      0.00%
        IDT_LIST:          0 GB        32 KB      0.00%
    
    SHELL機能有効後のRAMサイズ
    Memory region         Used Size  Region Size  %age Used
           FLASH:          0 GB        32 MB      0.00%
             RAM:       74656 B        64 MB      0.11%
             OCM:          0 GB       256 KB      0.00%
        IDT_LIST:          0 GB        32 KB      0.00%
    
  • RAMの配置の変更方法

    • petalinux側でreserved memoryに指定した場所に配置場所を変更して実動を確認。
      以下のdevice treeでは、0x3ed00000から256Kbyteをreserve。

      petalinuxのdevice tree編集(system-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>;
              };
          };
          
          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>;
                 };
          };
      };
      / {
        chosen {
        bootargs = "console=ttyUSB0,115200 root=/dev/ram0 rw init_fatal_sh=1 cma=900M clk_ignore_unused";
        };
      };
      

    • zephyrのkv260のdtsとconfigurationファイル(prj.conf)の変更

      boards/amd/kv260_r5/kv260_r5.dts
      - sram0: memory@0 {
      - 	compatible = "mmio-sram";
      - 	reg = <0 DT_SIZE_M(64)>;
      - };
      
      chosen {
      - 	zephyr,sram = &sram0;
      	zephyr,flash = &flash0;
      	zephyr,console = &uart1;
      	zephyr,shell-uart = &uart1;
      	zephyr,ocm = &ocm;
      };
      
      SHELL機能使用の際のconfigurationファイル(prj.conf)への追加
      # nothing here
      
      + CONFIG_SHELL=y
      + CONFIG_SRAM_BASE_ADDRESS=0x3ED00000
      + CONFIG_SRAM_SIZE=256
      + CONFIG_ROMSTART_RELOCATION_ROM=y
      + CONFIG_ROMSTART_REGION_ADDRESS=0x00000000
      + CONFIG_ROMSTART_REGION_SIZE=0x40
      
      SHELL機能有効前のRAMサイズ(configuration変更時)
      Memory region         Used Size  Region Size  %age Used
      ROMSTART_REGION:          60 B        64 KB      0.09%
                 FLASH:          0 GB        32 MB      0.00%
                   RAM:       74656 B       256 KB     28.48%
                   OCM:          0 GB       256 KB      0.00%
              IDT_LIST:          0 GB        32 KB      0.00%
      

    • 起動結果

      *** Booting Zephyr OS build v4.2.0-5452-g169cf86969d7 ***
      My Hello World! kv260_r5/zynqmp_rpu
      uart:~$
      

    • RAMへの配置の変更方法(kv260_r5.dtsを使用する場合)

      boards/amd/kv260_r5/kv260_r5.dts
      + #address-cells = <2>;
      + #size-cells = <2>;
       sram0: memory@0 {
       	compatible = "mmio-sram";
      -   reg = <0 DT_SIZE_M(64)>;
      +	reg = <0x0 0x3ed00000 0x0 0x40000>;
       };
      
      chosen {
       	zephyr,sram = &sram0;
      	zephyr,flash = &flash0;
      	zephyr,console = &uart1;
      	zephyr,shell-uart = &uart1;
      	zephyr,ocm = &ocm;
      };
      
      SHELL機能使用の際のconfigurationファイル(prj.conf)への追加
         kv260_r5.dtsを使用して配置を変更する場合の記述
      # nothing here
      
      + CONFIG_SHELL=y
      + CONFIG_ROMSTART_RELOCATION_ROM=y
      + CONFIG_ROMSTART_REGION_ADDRESS=0x00000000
      + CONFIG_ROMSTART_REGION_SIZE=0x40
      

  • メモリマップ上のromのスタート位置

    • prj.confに指定した、以下の項目により、ROMの開始ポイントの差は、
      メモリマップ上で以下の箇所で参照できる。

      • CONFIG_ROMSTART_RELOCATION_ROM
      • CONFIG_ROMSTART_REGION_ADDRESS
      • CONFIG_ROMSTART_REGION_SIZE
    CONFIG_ROMSTART_RELOCATION_ROMがある場合
    rom_start       0x0000000000000000       0x3c
                    0x0000000000000000                __rom_start_address = .
     FILL mask 0x00
                    0x0000000000000000                . = (. + (0x0 - (. - __rom_start_address)))
                    0x0000000000000000                . = ALIGN (0x4)
                    0x0000000000000000                _vector_start =
    *(SORT_BY_ALIGNMENT(.exc_vector_table))
    *(SORT_BY_ALIGNMENT(.exc_vector_table.*))
    .exc_vector_table._vector_table_section
                    0x0000000000000000       0x3c zephyr/arch/arch/arm/core/cortex_a_r/libarch__arm__core__cortex_a_r.a(vector_table.S.obj)
                    0x0000000000000000                _vector_table
    *(SORT_BY_ALIGNMENT(.vectors))
                    0x000000000000003c                _vector_end = .
    text            0x000000003ed00000     0x88e0
                    0x000000003ed00000                . = ALIGN (_region_min_align)
                    0x000000003ed00000                __text_region_start = .
                    
    
    CONFIG_ROMSTART_RELOCATION_ROMがない場合
    rom_start       0x000000003ed00000       0x3c
                    0x000000003ed00000                __rom_start_address = .
     FILL mask 0x00
                    0x000000003ed00000                . = (. + (0x0 - (. - __rom_start_address)))
                    0x000000003ed00000                . = ALIGN (0x4)
                    0x000000003ed00000                _vector_start =
    *(SORT_BY_ALIGNMENT(.exc_vector_table))
    *(SORT_BY_ALIGNMENT(.exc_vector_table.*))
    .exc_vector_table._vector_table_section
                    0x000000003ed00000       0x3c zephyr/arch/arch/arm/core/cortex_a_r/libarch__arm__core__cortex_a_r.a(vector_table.S.obj)
                    0x000000003ed00000                _vector_table
    *(SORT_BY_ALIGNMENT(.vectors))
                    0x000000003ed0003c                _vector_end = .
    
    text            0x000000003ed00040     0x88e0
                    0x000000003ed00040                . = ALIGN (_region_min_align)
                    0x000000003ed00040                __text_region_start = .
    
0
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
0
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?