Flash &DDR Reference


1. Flash Partition


1.1. Partition Config

  1. Compile phase

    After compilation, partition_layout.txt will be generated in the directory where the image is generated, and you can see the partition layout of the image.

  2. kernel phase

    After the kernel is running, you can view it by cat /proc/mtd.

  3. boot phase

    In uboot console, you can view it by mtdpart.


1.2. Partition Modification

  1. Find the corresponding partition config file used by the project

    Find the partition config specified by IMAGE_CONFIG, and take spinand.ubifs.partition.dualenv.dispcam.config as an example (directory: project\image\configs\p3\spinand.ubifs.partition.dualenv.dispcam.config )

  2. Open the partition config, take the kernel partition as an example, modify the value specified by *$(PATSIZE)

    Note: Due to the physical characteristics of flash, a block is the unit of erasing, and the partition config should be aligned according to the block size (nand flash partition is aligned according to 128K, nor flash is aligned according to 64K)


2. DDR Memory

  1. The composition of memory

    DDR total memory = linux memory + part of kernel reserved memory (including MMA)

  2. Memory checking

    1. check linux memory

      In order to accurately check the memory MemFree, it is recommended to execute echo 3 >/proc/sys/vm/drop_caches first, and then execute cat /proc/meminfo.

      MemTotal is the total memory of linux, MemFree is free memory.

    2. Check MMA memory

      length is the total size of the allocated MMA, which is 0x1e00000 Byte

      MMA remaining memory: chunk_mgr_avail = 0x132d000 Byte = 30M

  3. Configure MMA memory

    1. Open the config in project(Configs/defconfigs/dispcam_p3_spinand.glibc-9.1.0-s01a.64.qfn128.demo_camera_defconfig)

      Find CONFIG_KERNEL_BOOT_ENV, modify the sz corresponding to mma_heap_name0 (sz=0x1E00000 that is 30M MMA)

    2. Modify the bootargs parameters on the board in the boot console during debugging, then restart after execute saveenv to take effect.

  4. How to judge whether MMA/Linux is sufficient

    1. There are information such as MmaAlloc fail in the log, MMA memory may not be enough, execute echo 3 before the problem occurs > /proc/mi_moudles/mi_sys/debug_level to increase the debug level of sys, and the serial port will print MMA debug information after a problem occurs

    2. Linux memory is not enough, OOM will be generated, some applications will be killed, and the log will generate backtrace information

  5. How to debug after encountering memory-related problems in actual program operation?

    By adjusting the memory size of MMA to balance the available memory of MMA and Linux, you can confirm by following the steps below.

    1. Check whether there is a leak problem, if the available memory continues to decrease, please solve it first;

    2. Whether there is an Out of Memory problem, if there is, the memory is insufficient, if MMA has surplus, you can reduce the memory allocation of MMA to increase it to Linux memory;

    3. Whether there is MMA apply error such as MmaAlloc fail, if there is, the memory size of MMA in this usage scenario is insufficient, if linux has surplus, you can reduce the memory allocation of linux to increase it to MMA memory;

    4. There is no memory leak, Linux and MMA memory balance each other, but the memory is still insufficient. Please cut the function or replace the DDR with larger memory