partition_copy

本文介绍了一个实用的C++标准库函数partition_copy。该函数能够根据指定条件将容器中的元素分为两组并拷贝到不同的目标容器中。文章通过示例展示了如何使用此函数,并解释了其返回值的含义。

partition_copy可以根据指定条件,把容器中的元素分成两组,并把分组拷贝到新的容器中;

该函数返回一个 pair 类型值,其中包含 2 个迭代器,第一个迭代器指向第一个分组的最后一个元素在新容器中的位置,第二个迭代器指向第二个分组的最后一个元素在新容器中的位置。

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool comp(int i) { return i >= 5; }

int main()
{
    vector<int> v{ 1,9,2,8,3,7,4,6,5 };
    vector<int> p1(9);
    vector<int> p2(9);

    auto result = partition_copy(v.begin(), v.end(), p1.begin(), p2.begin(), comp);

    for (int i = 0; i < result.first - p1.begin(); i++)
        cout << p1[i] << "->";
    cout << endl;

    for (int i = 0; i < result.second - p2.begin(); i++)
        cout << p2[i] << "->";
    cout << endl;

    return 0;
}

输出结果:

9->8->7->6->5->
1->2->3->4->

[2025-08-19T09:29:30.737Z] [2025-08-19T09:29:30.737Z] vendor/mediatek/proprietary/tools/ptgen/common/ptgen_android_u.mk:164: error: ptgen error=1: MTK_PLATFORM=MT6878 PLATFORM=MT6878 MTK_TARGET_PROJECT=k6878v1_64 TARGET_BUILD_VARIANT=user BUILD_MTK_LDVT= MTK_NAND_PAGE_SIZE= MTK_EMMC_SUPPORT=yes MTK_UFS_SUPPORT=yes MTK_EMMC_SUPPORT_OTP=yes MTK_UFS_OTP=yes MTK_NAND_UBIFS_SUPPORT= MTK_COMBO_NAND_SUPPORT= PL_MODE= MTK_ATF_SUPPORT=yes MTK_TEE_SUPPORT=yes MTK_PERSIST_PARTITION_SUPPORT=yes MTK_BASE_PROJECT= PTGEN_MK_OUT=out/target/product/k6878v1_64/obj/PTGEN OUT_DIR=out CUSTOM_MODEM="mt6878_sp_nlwcg_vmoly0472_prod" PRELOADER_TARGET=k6878v1_64 MTK_FACTORY_RESET_PROTECTION_SUPPORT=yes MTK_EFUSE_WRITER_SUPPORT=no MTK_TINYSYS_SCP_SUPPORT=yes MTK_TINYSYS_SSPM_SUPPORT=yes MTK_TINYSYS_MCUPM_SUPPORT=yes MTK_TINYSYS_GPUEB_SUPPORT=yes MTK_TINYSYS_VCP_SUPPORT=yes MTK_DPM_SUPPORT=yes MTK_SIM_LOCK_POWER_ON_WRITE_PROTECT= MTK_VPU2_SUPPORT=no MTK_VPU_SUPPORT=no MTK_COMBO_CHIP=CONSYS_6878 SPM_FW_USE_PARTITION=yes MCUPM_FW_USE_PARTITION= MTK_AB_OTA_UPDATER=yes TARGET_COPY_OUT_ODM="odm" TARGET_COPY_OUT_VENDOR_DLKM="vendor_dlkm" TARGET_COPY_OUT_SYSTEM_DLKM="system_dlkm" TARGET_COPY_OUT_ODM_DLKM="odm_dlkm" MTK_SINGLE_BIN_MODEM_SUPPORT=yes MTK_ENABLE_GENIEZONE=yes MTK_GMO_RAM_OPTIMIZE=no MTK_AUDIODSP_SUPPORT=no MTK_BOARD_AVB_ENABLE=true MTK_BUILD_ROOT= MTK_BOARD_USES_METADATA_PARTITION=true PRODUCT_USE_DYNAMIC_PARTITIONS=true PRODUCT_RETROFIT_DYNAMIC_PARTITIONS= TARGET_NO_RECOVERY=true MTK_RESERVE_ENG_PARTITIONS= BOARD_MTK_GROUP_SIZE_KB="" BOARD_BOOT_HEADER_VERSION=4 MTK_CUSTOM_PTGEN_CSV= TARGET_COPY_OUT_VENDOR="vendor" TARGET_COPY_OUT_PRODUCT="product" TARGET_COPY_OUT_SYSTEM_EXT="system_ext" MTK_APUSYS_TINYSYS_SUPPORT=yes MTK_THINMD_FLASHLESS_BOOTING= BOARD_APUSYSIMAGE_PARTITION_SIZE="4194304" BOARD_AUDIO_DSPIMAGE_PARTITION_SIZE="16777216" BOARD_BOOTIMAGE_PARTITION_SIZE="67108864" BOARD_BOOT_PARAIMAGE_PARTITION_SIZE="1048576" BOARD_CCUIMAGE_PARTITION_SIZE="4194304" BOARD_CONNSYS_BTIMAGE_PARTITION_SIZE="8388608" BOARD_CONNSYS_GNSSIMAGE_PARTITION_SIZE="8388608" BOARD_CONNSYS_WIFIIMAGE_PARTITION_SIZE="8388608" BOARD_DPMIMAGE_PARTITION_SIZE="4194304" BOARD_DRAM_PARAIMAGE_PARTITION_SIZE="27262976" BOARD_DTBOIMAGE_PARTITION_SIZE="8388608" BOARD_EFUSEIMAGE_PARTITION_SIZE="524288" BOARD_EXPDBIMAGE_PARTITION_SIZE="134217728" BOARD_FLASHINFOIMAGE_PARTITION_SIZE="16777216" BOARD_FRPIMAGE_PARTITION_SIZE="1048576" BOARD_GPUEBIMAGE_PARTITION_SIZE="2097152" BOARD_GZIMAGE_PARTITION_SIZE="33554432" BOARD_INIT_BOOTIMAGE_PARTITION_SIZE="8388608" BOARD_LKIMAGE_PARTITION_SIZE="16777216" BOARD_LOGOIMAGE_PARTITION_SIZE="33554432" BOARD_MCF_OTAIMAGE_PARTITION_SIZE="33554432" BOARD_SAPIMAGE_PARTITION_SIZE="67108864" BOARD_TMODEMIMAGE_PARTITION_SIZE="209715200" BOARD_MCUPMIMAGE_PARTITION_SIZE="1048576" BOARD_MODEMIMAGE_PARTITION_SIZE="209715200" BOARD_METADATAIMAGE_PARTITION_SIZE="76513280" BOARD_MISCIMAGE_PARTITION_SIZE="524288" BOARD_MRDUMPIMAGE_PARTITION_SIZE="268435456" BOARD_MVPU_ALGOIMAGE_PARTITION_SIZE="67108864" BOARD_NVCFGIMAGE_PARTITION_SIZE="33554432" BOARD_NVDATAIMAGE_PARTITION_SIZE="83886080" BOARD_NVRAMIMAGE_PARTITION_SIZE="67108864" BOARD_OTPIMAGE_PARTITION_SIZE="45088768" BOARD_PARAIMAGE_PARTITION_SIZE="524288" BOARD_PGPTIMAGE_PARTITION_SIZE="32768" BOARD_PI_IMGIMAGE_PARTITION_SIZE="2097152" BOARD_PRELOADERIMAGE_PARTITION_SIZE="1048576" BOARD_PRELOADER_BACKUPIMAGE_PARTITION_SIZE="1048576" BOARD_PROINFOIMAGE_PARTITION_SIZE="3145728" BOARD_PROTECT1IMAGE_PARTITION_SIZE="8388608" BOARD_PROTECT2IMAGE_PARTITION_SIZE="8388608" BOARD_PSTOREIMAGE_PARTITION_SIZE="139460608" BOARD_SCPIMAGE_PARTITION_SIZE="16777216" BOARD_SEC1IMAGE_PARTITION_SIZE="2097152" BOARD_SECCFGIMAGE_PARTITION_SIZE="8388608" BOARD_SGPTIMAGE_PARTITION_SIZE="32768" BOARD_SPMFWIMAGE_PARTITION_SIZE="1048576" BOARD_SSPMIMAGE_PARTITION_SIZE="2097152" BOARD_SUPERIMAGE_PARTITION_SIZE="21474836480" BOARD_TEEIMAGE_PARTITION_SIZE="5242880" BOARD_USERDATAIMAGE_PARTITION_SIZE="3221225472" BOARD_VBMETAIMAGE_PARTITION_SIZE="8388608" BOARD_VBMETA_SYSTEMIMAGE_PARTITION_SIZE="8388608" BOARD_VBMETA_VENDORIMAGE_PARTITION_SIZE="8388608" BOARD_VCPIMAGE_PARTITION_SIZE="6291456" BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE="67108864" BOARD_PERSISTIMAGE_PARTITION_SIZE="50331648" BOARD_ISEIMAGE_PARTITION_SIZE="" MTK_ISE_SUPPORT=no MTK_PTGEN_ALIGN_POLICY="RESIZE_AHEAD" BOARD_MD1DSPIMAGE_PARTITION_SIZE="16777216" BOARD_OPLUSRESERVE1IMAGE_PARTITION_SIZE="8388608" BOARD_OPLUSRESERVE2IMAGE_PARTITION_SIZE="268435456" BOARD_OPLUSRESERVE3IMAGE_PARTITION_SIZE="67108864" BOARD_OPLUS_CUSTOMIMAGE_PARTITION_SIZE="1048576" BOARD_CDT_ENGINEERINGIMAGE_PARTITION_SIZE="13631488" BOARD_OCDTIMAGE_PARTITION_SIZE="8388608" BOARD_PVMFWIMAGE_PARTITION_SIZE="4194304" BOARD_VBIMAGE_PARTITION_SIZE="4194304" BOARD_MD_SECIMAGE_PARTITION_SIZE="8388608" BOARD_SPLASH_ODMIMAGE_PARTITION_SIZE="41943040" BOARD_OPLUSRESERVE5IMAGE_PARTITION_SIZE="67108864" BOARD_OPLUSRESERVE6IMAGE_PARTITION_SIZE="67108864" BOARD_HYBRIDSWAP_PARTITION_SIZE="" BOARD_OPLUS_STORAGEFWIMAGE_PARTITION_SIZE="" PRODUCT_LIST="23261 23262 23265 24035 24051 24271 24345 24606 24608 24626 24678 24679 24680 24681 24703 24705 24706 24716 24750 24774 24780 24781 25612 25664 25677 25680 25693 25694 25714 25715 25921" python3 vendor/mediatek/proprietary/tools/ptgen/common/ptgen_ver_u.py.
08-20
case SLP_IOC_FLASH_PARTITION_WRITE: partition_idx = (enum partition_index)addr; if (!access_ok((void __user *)usrBuf, _IOC_SIZE(cmd))) { ret = -EFAULT; goto free_and_out; } ret = get_info_from_mtd_partition_name(partition_names[partition_idx], &partition_offset, &partition_size); if (ret) { goto free_and_out; } /* If partition is Firmware, partition write is used to upgrade firmware. * Firmware binary file size depend on sum of kernel size and romfs size, which varies constantly. * We cannot use __current__ kernel & romfs size to presume the to-be-upgraded firmware. So kernel * and romfs partition writing require @arg contains a valid length. */ if (partition_idx == FIRMWARE || partition_idx == KERNEL || partition_idx == ROMFS || partition_idx == JFFS2) { if (pArg.len == 0) { ret = -EINVAL; goto free_and_out; } partition_size = pArg.len; } if (partition_idx == ROMFS) { if (romfs_offset == 0) { ret = -EINVAL; goto free_and_out; } partition_offset = romfs_offset; romfs_offset = 0; } if (UC == partition_idx) { partition_size = partition_size / 2; handle_another_uc = true; /* 只写第二分区 */ if (pArg.sub_index == 1) { partition_offset += partition_size; handle_another_uc = false; } } printk("start write %s partition...partition_offset is 0x%x,addrStart is 0x%x\n", partition_names[partition_idx], partition_offset, addrStart); write_uc_part_2: ret = slp_flash_erase_improved(partition_offset, partition_size, mtd, rwBuf); if (ret) { goto free_and_out; } nSector = partition_size >> 16; oddLen = partition_size & 0x0000FFFF; addrStart = partition_offset; for (i = 0; i < nSector; i++) { if (copy_from_user(rwBuf, usrBuf, SLP_FLASH_SECTOR_SIZE_64K)) { printk("config write copy_from_usr failed!\n"); goto free_and_out; } ret = slp_flash_write(mtd, addrStart, SLP_FLASH_SECTOR_SIZE_64K, &retlen, rwBuf); printk("."); if ((ret != 0) || (retlen != SLP_FLASH_SECTOR_SIZE_64K)) { printk("\nWrite to flash failed status:%ld retlen:%d\n", ret, retlen); goto free_and_out; } addrStart += SLP_FLASH_SECTOR_SIZE_64K; usrBuf += SLP_FLASH_SECTOR_SIZE_64K; } if (oddLen) { if (copy_from_user(rwBuf, usrBuf, oddLen)) { printk("config write copy_from_usr failed!\n"); goto free_and_out; } ret = slp_flash_write(mtd, addrStart, oddLen, &retlen, rwBuf); printk("."); if ((ret != 0) || (retlen != oddLen)) { printk("\nWrite to flash failed status:%ld retlen:%d\n", ret, retlen); goto free_and_out; } } /* 在UC中保留两份相同的用户配置数据 */ if (UC == partition_idx && true == handle_another_uc) { partition_offset += partition_size; handle_another_uc = false; usrBuf -= SLP_FLASH_SECTOR_SIZE_64K * nSector; goto write_uc_part_2; } if (partition_idx == KERNEL) { romfs_offset = partition_offset + partition_size; } printk("done\n"); break;
10-15
分析从代码 ################################## # # author:liqianning@tp-link.com.hk # describe:拓展slp openwrt lib # ################################## get_raw_16 = $(shell echo $(1)|sed "s/0x//g") cal_sub_16 = `echo "obase=16;ibase=16;$(subst 0x,,$(1))-$(subst 0x,,$(2))"|bc` cal_add_16 = `echo "obase=16;ibase=16;$(subst 0x,,$(1))+$(subst 0x,,$(2))"|bc` cal_div_16 = `echo "obase=16;ibase=16;$(subst 0x,,$(1))/$(subst 0x,,$(2))"|bc` text_cut = cut_num=$(firstword $(shell cat $1|grep -n $2|awk -F ":" '{print $$1}')); \ cat $1|awk -v line_num=$$cut_num 'NR<line_num{print}' > $3 text_upper = $(shell echo $1|tr a-z A-Z) check_file_exit = $(shell if [ -e $1 ];then echo y;fi) check_file_exit_cmd = if [ -e $1 ];then \ $2;\ fi add_front_addx = $(2)_$(1) add_end_addx = $(1)_$(2) cal_16_to_10 = `echo $(1)|sed 's/0x//g'|xargs -i echo 'obase=10;ibase=16;{}'|bc` cal_10_to_16 = `echo $(1)|sed 's/0x//g'|xargs -i echo 'obase=16;ibase=10;{}'|bc` add_num_10 = `echo "$(1) + $(2)"|bc` define SAFE_COPY ifdef $(2) $(CP) $1 $(BIN_DIR)/build_fw_dir/$($(2)).bin endif endef define mini_install mkdir -p $(STAGING_DIR)/mini_compile $(CP) $1 $(STAGING_DIR)/mini_compile/ endef # 读dir/suffix_dir的mk define INCLUDE_MUTI_MK $(eval $(foreach _dir,$1,include $(_dir)/$(2)$(notdir $(_dir)))) endef read_file_len = `ls -l|grep $(1)|awk '{print $5}'` out_include_file:=partition_table.h build_pad_bin = dd if=$(1) of=$(2) ibs=$(3) obs=$(BLOCK_SIZE) conv=sync build_raw_bin = dd if=$(1) of=$(2) bs=$(BLOCK_SIZE) conv=sync ifeq ($(DUMP_OUT),) fix_size=$(if $1,$1,0x0) fix_name=$(if $2,$2,$1) define SAFE_COPY ifdef $(2) $(CP) $1 $(BIN_DIR)/build_fw_dir/$($(2)).bin endif endef define _ADD_TO_TABLE partition_table_list += partition_table_$1 partition_table_size += $(call fix_size,$2) partition_table_$1 = $(call fix_size,$2) partition_table_valid_size += $(call fix_size,$4) partition_table_version += $(call fix_size,$3) endef define _ADD_UBI_VOL ubi_$1 += ubi_create_vol_$1_$2 partition_ubi_list += ubi_$1 partition_ubivol_list += partition_ubivol_$1_$2 partition_ubivol_size += $(call fix_size,$3) partition_ubivol_valid_size += $(call fix_size,$5) partition_ubivol_version += $(call fix_size,$4) partition_ubivol_$1_$2_size = $(call fix_size,$3) partition_ubivol_$1_$2_valid_size = $(call fix_size,$5) partition_ubivol_$1_$2_file = $(call fix_name,$1_$2,$6).bin endef define _REGISTER_TO_FLASH ifeq ($1,pt_table) is_pt_table_flash:=1 endif ifeq ($1,pt_table_restore) is_pt_table_restore_flash:=1 endif partition_flash_$1_file = $(call fix_name,$1,$2)$(if $(filter pt_table%,$1),_flash,).bin partition_flash_list += partition_flash_$1 order_flash_length += $(partition_table_$1) endef define _REGISTER_TO_UPBOOT ifeq ($1,pt_table) is_pt_table_up:=1 endif partition_upboot_list += partition_upboot_$1 partition_upboot_$1_file = $(call fix_name,$1,$2)$(if $(filter pt_table%,$1),_upboot,).bin ifneq ($(3),) partition_upboot_ex_pack_list += $1 partition_upboot_ex_pack_type_list += $3_DMIC endif endef define _CHECK_PARTITION partition_check_list += partition_check_$1 partition_check_$1_file = $(call fix_name,$1,$2).bin endef define _FORBID_CHANGE partition_forbid_list += $1 endef define _NEED_DYNAMIC_FS partition_dynamic_fs_list += $1 endef define _PARTITION_MAP_SET map_list += partition_map_$1 partition_map_$1: echo \#define partition_map_$1 \"$2\" >> $(out_include_file) endef define _EXPORT_PARTITION partition_export_$2_name =$1 partition_export_$2_len =$(partition_table_$1) endef define ADD_TO_TABLE $(eval $(call _ADD_TO_TABLE,$1,$2,$3,$4)) endef define ADD_UBI_VOL $(eval $(call _ADD_UBI_VOL,$1,$2,$3,$4,$5,$6)) endef define REGISTER_TO_FLASH $(eval $(call _REGISTER_TO_FLASH,$1,$2)) endef define REGISTER_TO_UPBOOT $(eval $(call _REGISTER_TO_UPBOOT,$1,$2,$3,$4)) endef define CHECK_PARTITION $(eval $(call _CHECK_PARTITION,$1,$2)) endef define NEED_DYNAMIC_FS $(eval $(call _NEED_DYNAMIC_FS,$1)) endef define PARTITION_MAP_SET $(eval $(call _PARTITION_MAP_SET,$1,$2)) endef define FORBID_OP $(eval $(call _FORBID_CHANGE,$1)) endef define EXPORT_PARTITION $(eval $(call _EXPORT_PARTITION,$1,$2)) endef define create_ubi $1:$($1) $$(foreach vol,$($1),$$(shell if [ -f $$(vol) ];then cat $$(vol) >> $$@;fi)) endef else fix_empty=$(strip $1) point="," partition_dynamic_fs_list:=$(foreach table,$(partition_table_list), \ $(if $(ubi_$(patsubst partition_table_%,%,$(table))), \ $(foreach ubi_vol,$(ubi_$(patsubst partition_table_%,%,$(table))),\ $(if $(filter $(patsubst ubi_create_vol_%,%,$(ubi_vol)),$(partition_dynamic_fs_list)),\ $(patsubst ubi_create_vol_%,%,$(ubi_vol)),$(empty))),\ $(if $(filter $(patsubst partition_table_%,%,$(table)),$(partition_dynamic_fs_list)),\ $(patsubst partition_table_%,%,$(table)),$(empty)))) partition_table_list:=$(call fix_empty,$(partition_table_list)) partition_table_size:=$(call fix_empty,$(partition_table_size)) partition_ubivol_list:=$(call fix_empty,$(partition_ubivol_list)) partition_check_list:=$(call fix_empty,$(partition_check_list)) partition_ubivol_size:=$(call fix_empty,$(partition_ubivol_size)) partition_flash_list:=$(call fix_empty,$(partition_flash_list)) partition_upboot_list:=$(call fix_empty,$(partition_upboot_list)) partition_dynamic_fs_list:=$(call fix_empty,$(partition_dynamic_fs_list)) ifeq ($(is_pt_table_flash),) $(error must have pt_table partition in flash) endif ifeq ($(is_pt_table_restore_flash),) $(error must have pt_table_restore partition in flash) endif ifeq ($(is_pt_table_up),) $(error must have pt_table partition in up) endif partition_ubi_list:=$(sort $(partition_ubi_list)) $(foreach ubi,$(partition_ubi_list),$(eval $(call create_ubi,$(ubi)))) partition_ubivol_size:=$(subst $(empty) $(empty),$(point),$(partition_ubivol_size)) partition_table_size:=$(subst $(empty) $(empty),$(point),$(partition_table_size)) partition_table_%: table=$(patsubst partition_table_%,%,$@); \ echo \#define $@ \"$${table}\" >> $(out_include_file) partition_table_finish: echo \#define partition_table_list \{$(subst $(empty) $(empty),$(point),$(partition_table_list))\,NULL\} >> $(out_include_file) echo \#define partition_table_size \{$(partition_table_size)\} >> $(out_include_file) echo \#define partition_table_valid_size \{$(subst $(empty) $(empty),$(point),$(partition_table_valid_size))\} >> $(out_include_file) echo \#define partition_table_version \{$(subst $(empty) $(empty),$(point),$(partition_table_version))\} >> $(out_include_file) echo >> $(out_include_file) partition_flash_%: flash=$(partition_flash_$(patsubst partition_flash_%,%,$@)_file); \ echo \#define $@ \"$${flash}\" >> $(out_include_file) partition_flash_finish: echo \#define partition_flash_list \{$(subst $(empty) $(empty),$(point),$(partition_flash_list))\,NULL\} >> $(out_include_file) echo \#define partition_flash_name \{$(foreach flash,$(partition_flash_list),\"$(patsubst partition_flash_%,%,$(flash))\",)NULL\} >> $(out_include_file) echo >> $(out_include_file) partition_upboot_%: upboot=$(partition_upboot_$(patsubst partition_upboot_%,%,$@)_file); \ echo \#define $@ \"$${upboot}\" >> $(out_include_file) partition_upboot_finish: echo \#define partition_upboot_list \{$(subst $(empty) $(empty),$(point),$(partition_upboot_list))\,NULL\} >> $(out_include_file) echo \#define partition_upboot_name \{$(foreach ubi_vol,$(partition_upboot_list),\"$(patsubst partition_upboot_%,%,$(ubi_vol))\",)NULL\} >> $(out_include_file) echo >> $(out_include_file) partition_ubivol_finish: echo \#define partition_ubivol_list \{$(foreach ubi_vol,$(partition_ubivol_list),\"$(patsubst partition_ubivol_%,%,$(ubi_vol))\",)NULL\} >> $(out_include_file) echo \#define partition_ubivol_file_list \{$(foreach ubi_vol,$(partition_ubivol_list),\"$($(ubi_vol)_file)\",)NULL\} >> $(out_include_file) echo \#define partition_ubivol_size \{$(partition_ubivol_size)\} >> $(out_include_file) echo \#define partition_ubivol_valid_size \{$(subst $(empty) $(empty),$(point),$(partition_ubivol_valid_size))\} >> $(out_include_file) echo \#define partition_ubivol_version \{$(subst $(empty) $(empty),$(point),$(partition_ubivol_version))\} >> $(out_include_file) echo >> $(out_include_file) partition_check_finish: echo \#define partition_check_name \{$(foreach check,$(partition_check_list),\"$(patsubst partition_check_%,%,$(check))\",)NULL\} >> $(out_include_file) echo >> $(out_include_file) partition_upboot_ex_pack_finish: echo \#define partition_expack_list \{$(foreach expack,$(partition_upboot_ex_pack_list),\"$(expack)\",)NULL\} >> $(out_include_file) echo \#define partition_expack_type_list \{$(subst $(empty) $(empty),$(point),$(partition_upboot_ex_pack_type_list))\} >> $(out_include_file) echo >> $(out_include_file) ubi_create_vol_%: ubi_vol=$(patsubst ubi_create_vol_%,%,$@); \ ubi_id=$(shell ls -l|grep ubi_create_vol_$(firstword $(subst _, ,$(patsubst ubi_create_vol_%,%,$@)))|wc -l); \ echo \[$${ubi_vol}\] >> $@; \ echo mode=ubi >> $@; \ if [ -f $(partition_ubivol_$(patsubst ubi_create_vol_%,%,$@)_file) ];then \ echo image=$(partition_ubivol_$(patsubst ubi_create_vol_%,%,$@)_file) >> $@; else \ echo image=empty.bin >> $@;fi;\ echo vol_size=$(partition_ubivol_$(patsubst ubi_create_vol_%,%,$@)_size) >> $@; \ echo vol_type=dynamic >> $@; \ echo vol_alignment=1 >> $@; \ echo vol_name=$${ubi_vol} >> $@; \ echo vol_id=$${ubi_id} >> $@; \ echo >> $@; pre_create: rm -rf ubi_* rm -rf $(out_include_file) touch $(out_include_file) echo \#ifndef __PARTITION_TABLE_H_ >> $(out_include_file) echo \#define __PARTITION_TABLE_H_ >> $(out_include_file) echo >> $(out_include_file) $(out_include_file): pre_create $(partition_table_list) partition_table_finish \ $(partition_flash_list) partition_flash_finish \ $(partition_upboot_list) partition_upboot_finish partition_ubivol_finish partition_check_finish $(map_list) partition_upboot_ex_pack_finish echo \#define partition_dynamic_fs_list \{$(foreach fs,$(partition_dynamic_fs_list),\"$(fs)\",)NULL\} >> $@ echo \#define partition_forbid_list \{$(foreach fd,$(partition_forbid_list),\"$(fd)\",)NULL\} >> $@ echo \#define partition_table_num $(words $(partition_table_list)) >> $@ echo \#define FLASH_PAGE_SIZE $(FLASH_PAGE_SIZE) >> $@ echo \#define factory_info_max_size $(FAC_INFO_MAX_SIZE) >> $@ echo >> $@ echo \#define FLASH_UPDATE_MEM_ADDR $(call cal_16_to_10,$(FLASH_UPDATE_MEM_ADDR)) >> $@ echo \#define FLASH_MAX_SIZE $(FLASH_MAX_SIZE) >> $@ echo \#define FLASH_BLOCK_SIZE $(U_FLASH_BLOCK_SIZE) >> $@ echo \#endif >> $@ $(call text_cut,$(input_file),auto_cut,device_info) define table_auto_build all:$1 endef define make_ubi all:$(partition_ubi_list) $(foreach ubi,$(partition_ubi_list),if [ -f $(ubi) ];then ubinize -m $(FLASH_PAGE_SIZE) -p `echo "obase=10;ibase=16;$(subst 0x,,$(U_FLASH_BLOCK_SIZE))/$(subst 0x,,0x400)"|bc`KiB -o $(patsubst ubi_%,%,$(ubi)).bin $(ubi);fi;) endef endif
09-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值