说明
所有 DDR 内存中,一部分由操作系统管理,称为 OS 内存;另一部分由 MMZ 模块管理,供媒体业务单独使用,称为 MMZ 内存。具体描述参考《SS928V100 SDK 安装以及升级使用说明.pdf》的“第5部分 地址空间分配与使用”。
通过查看"/proc/meminfo"文件的内容:
MemTotal: 87384 kB
MemFree: 23760 kB
MemAvailable: 21016 kB
Buffers: 228 kB
Cached: 15296 kB
SwapCached: 0 kB
... ...
可以看到,硬件一共有8G内存。
OS
通过检查文件"/proc/iomem"的内容,可以看到linux kernel占用的内存空间:
... ...
17c00000-17c0ffff : aiao
17c40000-17c4ffff : acodec
50000000-57ffffff : System RAM50080000-5096ffff : Kernel code50970000-509cffff : reserved509d0000-50a78fff : Kernel data52000000-52005fff : reserved52fff000-54a00fff : reserved56800000-569fffff : reserved56bd9000-579fffff : reserved57b54000-57bd7fff : reserved57bda000-57bdafff : reserved57bdb000-57bf6fff : reserved57bf7000-57bfefff : reserved57bff000-57bfffff : reserved57c00000-57ffffff : reserved
可以看到OS内存从地址0x50000000~0x57ffffff,与uboot变量"bootargs=mem=xxx"一致。
使用dmesg
命令查看板子的启动日志,其中也有内存的使用情况:
... ...
Memory limited to 128MB
... ...
Memory: 82904K/141284K available (7358K kernel code, 384K rwdata, 1760K rodata, 384K init, 267K bss, 54284K reserved, 4096K cma-reserved)
修改内存的开始地址,需要修改编译环境中”./ss928v100_sdk/SS928V100_SDK_V2.0.2.1/open_source/linux/linux-4.19.y/arch/arm64/boot/dts/vendor/ss928v100-demb.dts“
memory {device_type = "memory";reg = <0x0 0x50000000 0x1 0xf0000000>; /* system memory base */};
0x50000000
是起始物理地址;0xf0000000
表示内存区域的大小,以字节为单位,转换成十进制大约是4000MB(或4GB)。
修改内存的大小,需要修改uboot变量。
MMZ
通过检查文件”/proc/umap/media-mem"的内容,可以看到MMZ占用的内存空间:
+---ZONE: PHYS(0x70000000, 0x13FFFFFFF), GFP=0, nBYTES=3407872KB, NAME="anonymous"|-MMB: phys(0x70000000, 0x70011FFF), kvirt=0xFFFFFF800BE80000, flags=0x00000001, length=72KB, name="sys_scale_coef"|-MMB: phys(0x70012000, 0x7006DFFF), kvirt=0x00000000, flags=0x00000000, length=368KB, name="tde_mem_pool_mmb"|-MMB: phys(0x7006E000, 0x700C2FFF), kvirt=0xFFFFFF800C200000, flags=0x00000001, length=340KB, name="gdc_node_buf"|-MMB: phys(0x700C3000, 0x700C3FFF), kvirt=0xFFFFFF8008EED000, flags=0x00000001, length=4KB, name="gdc_int_pole_coef"|-MMB: phys(0x700C4000, 0x701E9FFF), kvirt=0xFFFFFF800C600000, flags=0x00000001, length=1176KB, name="vgs_node_buf"|-MMB: phys(0x701EA000, 0x701EAFFF), kvirt=0xFFFFFF8008EFD000, flags=0x00000001, length=4KB, name="vgs_mcf_sum"|-MMB: phys(0x701EB000, 0x701EBFFF), kvirt=0xFFFFFF8008F15000, flags=0x00000001, length=4KB, name="dis_node_buf"|-MMB: phys(0x701EC000, 0x701ECFFF), kvirt=0xFFFFFF8008F65000, flags=0x00000001, length=4KB, name="vo_coef_buf"|-MMB: phys(0x701ED000, 0x72190FFF), kvirt=0x00000000, flags=0x00000000, length=32400KB, name="gfbg_layer0"|-MMB: phys(0x72191000, 0x73162FFF), kvirt=0x00000000, flags=0x00000000, length=16200KB, name="gfbg_layer1"|-MMB: phys(0x73163000, 0x73557FFF), kvirt=0x00000000, flags=0x00000000, length=4052KB, name="gfbg_layer3"|-MMB: phys(0x73558000, 0x73567FFF), kvirt=0xFFFFFF800CD90000, flags=0x00000001, length=64KB, name="gfbg_coef"|-MMB: phys(0x73568000, 0x73568FFF), kvirt=0xFFFFFF8008F75000, flags=0x00000001, length=4KB, name="gfbg_clut_table_g3"|-MMB: phys(0x73569000, 0x73569FFF), kvirt=0xFFFFFF8008F7D000, flags=0x00000001, length=4KB, name="gfbg_clut_table_g4"|-MMB: phys(0x7356A000, 0x73589FFF), kvirt=0x00000000, flags=0x00000000, length=128KB, name="vedu_hal_0"|-MMB: phys(0x7358A000, 0x735BEFFF), kvirt=0xFFFFFF8010980000, flags=0x00000001, length=212KB, name="ive_queue"|-MMB: phys(0x735BF000, 0x735BFFFF), kvirt=0xFFFFFF8008FA5000, flags=0x00000003, length=4KB, name="ive_tmp_node"|-MMB: phys(0x735C0000, 0x735DFFFF), kvirt=0xFFFFFF8010A80000, flags=0x00000001, length=128KB, name="svp_mau_queue"|-MMB: phys(0x735E0000, 0x737DFFFF), kvirt=0xFFFFFF8011600000, flags=0x00000001, length=2048KB, name="cq_base"|-MMB: phys(0x737E0000, 0x737E1FFF), kvirt=0xFFFFFF800C29C000, flags=0x00000001, length=8KB, name="sq_static_info"---MMZ_USE_INFO:total size=3407872KB(3328MB),used=57224KB(55MB + 904KB),remain=3350648KB(3272MB + 120KB),zone_number=1,block_number=20
修改MMZ的开始地址和大小,需要修改编译环境中”ss928v100_sdk/SS928V100_SDK_V2.0.2.1/osdrv/rootfs_scripts/A393_ss928_ubi_rootfs/rootfs_glibc_arm64/ko/load_ss928v100“文件的内容:
#DDR start:0x40000000, IPCM(2M); DSP(62M); MCU(192M); kernel start:0x50000000, OS(512M); MMZ start:0x70000000
mem_total=4096 # 4096M, total mem
mem_start=0x40000000 # phy mem start
ipcm_mem_size=2 # 2M, ipcm mem
dsp_mem_size=62 # 62M, dsp mem
mcu_mem_size=192 # 192M, mcu mem
os_mem_size=512 # 512M, os memmmz_start=0x70000000; # mmz start addr
mmz_size=3328M; # 3328M, mmz sizereserve_mem_size=0 # 0M, reserve mmz size
注意:这里的mmz_start
和mmz_size
只是初始值,后面的函数calc_mmz_info
会根据上面的其他值重新计算这两个变量。