Compilation and Packaging Introduction
1. Compilation directory and config introduction¶
The compilation directory is project, the compilation script is the Makefile under project, the compilation configuration script is in /project/configs/verify/defconfigs or /project/configs/demo/defconfigs. The compilation configuration script for Comake D1 is located in /project/configs/demo/defconfigs, and the compilation configuration script directory is as follows:

The above figure shows the platform compilation configuration script, taking dispcam_pcupid.emmc.glibc-12.4.0-squashfs.comake.pi.d1.1024.dual_sensor.bga_ddr4_riscv_defconfig as an example;
dispcam represents the product line;
emmc represents emmc startup;
glibc means that the C library uses glibc;
12.4.0 represents the toolchain version number;
squashfs represents the file system type of rootfs;
comake.pi.d represents chips with different packages;
riscv stands for riscv
2. Compile and execute commands¶
(1) cd project; make dispcam_pcupid.emmc.glibc-12.4.0-squashfs.comake.pi.d1.1024.dual_sensor.bga_ddr4_riscv_defconfig;
After execution, current.configs will be regenerated in the /project/configs directory; in current.configs, you can find uboot, kernel compiled config files and compilation file information, sdk compilation scripts, rootfs production scripts and other parameter information;
(2) Project compilation is divided into three methods: whole package compilation, separate kernel compilation, separate SDK compilation, and separate package compilation. The specific execution instructions are as follows:

(3) After the compilation and packaging is completed, the corresponding bin file will be generated in /project/image/output/images
3. Script configuration introduction¶
Partition changes are divided into two parts: partition creation, packaging, and partition burning script creation. As shown in the following figure:

(1)xxx.partition.config:
Script location: project/image/configs/general/
The general script of the partition configuration information. All the codes related to partition adjustment are implemented in this config file. There will be many copies of this config file. Each different chip and different storage medium will have its own partition config file.
(2) Partition packaging script:
Script location: project/image/packaging/common/
rootfs.mk: root file system packaging script, such as busybox decompression, init.d/rcS production, /etc/profile production are all processed in rootfs.mk
misc.mk: misc partition packaging script, screen parameter files, boot logo related are all processed in misc.mk;
miservice.mk: miservice partition packaging script, ko, lib files, ipu related files, etc. are all processed in miservice.mk;
customer.mk: customer partition packaging script, used to store customized information, currently contains some tool classes and sample code;
(3) Special partitions:
KERNEL, uboot, IPL, misc, cis and other partitions are special partitions. These partitions do not have special file systems, so they cannot be processed centrally in the Makefile script and must be processed by case. Therefore, to add a special partition, you need to understand the following steps. Take the kernel partition as an example:
The script command for partition packaging needs to be written in image.mk
kernel_nofsimage: @echo [[$@]] cp -rvf $($(patsubst %_nofsimage,%,$@)$(RESOUCE)) (IMAGEDIR)/$(patsubst %_nofsimage,%,$@)
Write the commands generated by the partition burning script in script.mk:
kernel_$(FLASH_TYPE)__script:
@echo "# <- this is for comment / total file size must be less than 4KB" > $(SCRIPTDIR)/[[kernel.$(FILE_TYPE)
@echo $(LOAD_CMD) $(DOWNLOADADDR) kernel >> $(SCRIPTDIR)/[[kernel.$(FILE_TYPE)
@echo $(FLASH_PROBE) >> $(SCRIPTDIR)/[[kernel.$(FILE_TYPE)
if [ -n "$(kernel$(PATNAME))" ]; then \
for i in $(kernel$(PATNAME));do \
echo $(FLASH_ERASE_PART) $$i >> $(SCRIPTDIR)/[[kernel.$(FILE_TYPE); \
echo $(FLASH_WRITE_PART) $(DOWNLOADADDR) $$i \$${filesize} >> $(SCRIPTDIR)/[[kernel.$(FILE_TYPE); \
done; \
else \
echo $(FLASH_ERASE_PART) KERNEL >> $(SCRIPTDIR)/[[kernel.$(FILE_TYPE); \
echo $(FLASH_WRITE_PART) $(DOWNLOADADDR) KERNEL \$${filesize} >> $(SCRIPTDIR)/[[kernel.$(FILE_TYPE); \
fi;
@$(call docuscmd,"$(kernel$(CUSCMD))",$(SCRIPTDIR)/[[kernel.$(FILE_TYPE))
@$(call doblkenv,"$(kernel$(BLKENV))",$(SCRIPTDIR)/[[kernel.$(FILE_TYPE),1)
@echo "% <- this is end of file symbol" >> $(SCRIPTDIR)/[[kernel.$(FILE_TYPE)
@echo kernel-image done!!!