内存分配 ========== 1684X盒子总共内存ddr大小为16G,可以使用脚本修改算力盒子BM1864X 的 NPU、VPU、VPP 的内存分配。同时,调整 NPU、VPU、VPP 后,SOC的操作系统将使用除了NPU、VPU、VPP、uboot固件之外的所有内存。 一、工具安装 -------------- 盒子系统内部下载有修改内存的工具,放在/home/linaro/bsp-debs/memory_edit_V2.5.deb 使用命令 ``sudo dpkg -i /home/linaro/bsp-debs/memory_edit_V2.5.deb`` 安装 :: linaro@bm1684:~/bsp-debs$ sudo dpkg -i /home/linaro/bsp-debs/memory_edit_V2.5.deb Selecting previously unselected package memory-edit. (Reading database ... 57356 files and directories currently installed.) Preparing to unpack .../bsp-debs/memory_edit_V2.5.deb ... Unpacking memory-edit (2.5) ... Setting up memory-edit (2.5) ... /opt/sophon / tar: memory_edit/bintools/mkimage: time stamp 2023-09-26 10:40:36 is 109934001.85539626 s in the future tar: memory_edit/bintools/cpio: time stamp 2023-09-26 10:53:16 is 109934761.84963502 s in the future tar: memory_edit/bintools/dumpimage: time stamp 2023-09-26 10:40:18 is 109933983.84811622 s in the future tar: memory_edit/bintools/dtc: time stamp 2023-09-26 10:40:49 is 109934014.8448481 s in the future tar: memory_edit/bintools: time stamp 2023-09-26 10:53:33 is 109934778.84480478 s in the future tar: memory_edit/memory_edit.sh: time stamp 2023-12-27 17:58:53 is 117909098.84420608 s in the future tar: memory_edit: time stamp 2023-12-27 18:01:14 is 117909239.84378812 s in the future / 二、工具使用 -------------- **1.使用命令 ``sudo memory_edit.sh -p`` 查看内存信息** :: linaro@bm1684:/$ sudo memory_edit.sh -p Info: use dts file /opt/sophon/memory_edit/output/bm1684x_sm7m_v1.0.dts Info: chip is bm1684x Info: ======================================================================= Info: get ddr information ... Info: ddr12_size 8589934592 Byte [8192 MiB] Info: ddr3_size 4294967296 Byte [4096 MiB] Info: ddr4_size 4294967296 Byte [4096 MiB] Info: ddr_size 16384 MiB Info: ======================================================================= Info: get max memory size ... Info: max npu size: 0x1dbf00000 [7615 MiB] Info: max vpu size: 0xc0000000 [3072 MiB] Info: max vpp size: 0x100000000 [4096 MiB] Info: ======================================================================= Info: get now memory size ... Info: now npu size: 0x96e00000 [2414 MiB] Info: now vpu size: 0xb7ff0000 [2943 MiB] Info: now vpp size: 0xc0000000 [3072 MiB] 其中类似如下的输出显示了系统的最大内存。 :: Info: get ddr information ... Info: ddr12_size 8589934592 Byte [8192 MiB] Info: ddr3_size 4294967296 Byte [4096 MiB] Info: ddr4_size 4294967296 Byte [4096 MiB] 其中类似如下的输出显示了可配置的最大内存。 :: Info: get max memory size ... Info: max npu size: 0x1dbf00000 [7615 MiB] Info: max vpu size: 0xc0000000 [3072 MiB] Info: max vpp size: 0x100000000 [4096 MiB] 其中类似如下的输出显示了当前内存。 :: Info: get now memory size ... Info: now npu size: 0x96e00000 [2414 MiB] Info: now vpu size: 0xb7ff0000 [2943 MiB] Info: now vpp size: 0xc0000000 [3072 MiB] 请检查输出中是否有 Error ,如果有请检查SOC运行环境是否支持内存修改。 .. note:: 其中, MiB(Mebibyte)是计算机存储容量的单位, 1 MiB = 1024 KiB = 1024*1024 Byte **2.进行内存布局的修改,其中输入的三个参数是需要 NPU、VPU、VPP 配置的大小的十进制数字,单位MiB;或者为十六进制数值,单位Byte。** :: # 十进制,单位MiB sudo memory_edit.sh -c -npu 2048 -vpu 2048 -vpp 2048 # 十六进制,单位Byte sudo memory_edit.sh -c -npu 0x80000000 -vpu 0x80000000 -vpp 0x80000000 .. attention:: 请检查输出中是否有 Error ,以及类似于如下输出中三个部分的大小是否与您所需要配置的大小相同。 **3.如果检查无误,请保存当前工作,​将修改后的 emmcboot.itb 文件替换启动分区中的启动映像,并重启机器使修改生效。** :: sudo cp /opt/sophon/memory_edit/emmcboot.itb /boot/emmcboot.itb && sync sudo reboot **4.重启后继续使用 ``sudo memory_edit.sh -p`` 看是否配置成功**