Memory Allocation
The total DDR memory size of the 1684X box is 16G. You can use a script to modify the memory allocation of the NPU, VPU, and VPP of the BM1684X computing box. After adjusting NPU, VPU, and VPP, the SOC operating system uses all the remaining memory except for the NPU, VPU, VPP, and the uboot firmware.
1. Tool Installation
The memory-modification tool is preinstalled inside the box system at /home/linaro/bsp-debs/memory_edit_V2.5.deb. Install it with the command 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
/2. Tool Usage
1. Use the command sudo memory_edit.sh -p to view memory information:
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]The output similar to the following shows the system's total memory:
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]The output similar to the following shows the maximum configurable memory:
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]The output similar to the following shows the current memory:
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]Warning
Check whether the output contains any Error. If it does, verify whether the SOC runtime environment supports memory modification.
Tips
Here, MiB (Mebibyte) is a unit of computer storage capacity: 1 MiB = 1024 KiB = 1024 * 1024 Byte.
2. Modify the memory layout. The three input parameters are the decimal sizes (in MiB) to allocate for NPU, VPU, and VPP; or hexadecimal values in Byte.
# 十进制,单位MiB
sudo memory_edit.sh -c -npu 2048 -vpu 2048 -vpp 2048
# 十六进制,单位Byte
sudo memory_edit.sh -c -npu 0x80000000 -vpu 0x80000000 -vpp 0x80000000Warning
Check whether the output contains any Error, and whether the three sizes in output similar to the above match the sizes you intend to configure.
3. If everything checks out, save your current work, replace the boot image in the boot partition with the modified emmcboot.itb file, and reboot for the changes to take effect.
sudo cp /opt/sophon/memory_edit/emmcboot.itb /boot/emmcboot.itb && sync
sudo reboot4. After rebooting, run sudo memory_edit.sh -p again to verify whether the configuration succeeded.
