rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | SNCFG_DIR_IMAGE_SIZE ?= "4096" |
| 2 | SNCFG_DIR_IMAGE_PATH = "${DEPLOY_DIR_IMAGE}/sncfg" |
| 3 | IMAGE_FSTYPES_NO_WHITESPACE="$(echo "${IMAGE_FSTYPES}" | tr -d '[:space:]')" |
| 4 | USERDATA_FS_PARTITION = "sncfg_fs.ubi" |
| 5 | USERDATA_PARTITION = "sncfg.ubi" |
| 6 | DEPENDS += "mtd-utils-native coreutils-native" |
| 7 | mk_sncfg_image() { |
| 8 | |
| 9 | rm -rf ${SNCFG_DIR_IMAGE_PATH} |
| 10 | mkdir -p ${SNCFG_DIR_IMAGE_PATH} |
| 11 | if [ -f ${DEPLOY_DIR_IMAGE}/ff.bin ]; then |
| 12 | cp ${DEPLOY_DIR_IMAGE}/ff.bin ${SNCFG_DIR_IMAGE_PATH}/configpack1 |
| 13 | cp ${DEPLOY_DIR_IMAGE}/ff.bin ${SNCFG_DIR_IMAGE_PATH}/configpack2 |
| 14 | touch ${SNCFG_DIR_IMAGE_PATH}/nvram |
| 15 | touch ${SNCFG_DIR_IMAGE_PATH}/proinfo |
| 16 | truncate -s 256K ${SNCFG_DIR_IMAGE_PATH}/configpack1 |
| 17 | truncate -s 256K ${SNCFG_DIR_IMAGE_PATH}/configpack2 |
| 18 | truncate -s 2048K ${SNCFG_DIR_IMAGE_PATH}/nvram |
| 19 | truncate -s 1536K ${SNCFG_DIR_IMAGE_PATH}/proinfo |
| 20 | fi |
| 21 | if [ -f ${DEPLOY_DIR_IMAGE}/fc-dongle.bin ]; then |
| 22 | cp ${DEPLOY_DIR_IMAGE}/fc-dongle.bin ${SNCFG_DIR_IMAGE_PATH}/factoryconfig |
| 23 | truncate -s 256K ${SNCFG_DIR_IMAGE_PATH}/factoryconfig |
| 24 | fi |
| 25 | |
| 26 | if test "${IMAGE_FSTYPES_NO_WHITESPACE}" = "ubi" || test "${IMAGE_FSTYPES_NO_WHITESPACE}" = "squashfs"; then |
| 27 | echo \[ubifs\] > ubinize.cfg |
| 28 | echo mode=ubi >> ubinize.cfg |
| 29 | echo image=${DEPLOY_DIR_IMAGE}/${USERDATA_FS_PARTITION} >> ubinize.cfg |
| 30 | echo vol_id=0 >> ubinize.cfg |
| 31 | echo vol_size=4096KiB |
| 32 | echo vol_type=dynamic >> ubinize.cfg |
| 33 | echo vol_name=sncfg >> ubinize.cfg |
| 34 | echo vol_flags=autoresize >> ubinize.cfg |
| 35 | echo dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${USERDATA_FS_PARTITION} seek=${SNCFG_DIR_IMAGE_SIZE} count=0 bs=1k |
| 36 | dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${USERDATA_FS_PARTITION} seek=${SNCFG_DIR_IMAGE_SIZE} count=0 bs=1k |
| 37 | echo mkfs.ubifs -r ${SNCFG_DIR_IMAGE_PATH} ${MKUBIFS_CONFIG_ARGS} -o ${DEPLOY_DIR_IMAGE}/${USERDATA_FS_PARTITION} |
| 38 | mkfs.ubifs -r ${SNCFG_DIR_IMAGE_PATH} ${MKUBIFS_CONFIG_ARGS} -o ${DEPLOY_DIR_IMAGE}/${USERDATA_FS_PARTITION} |
| 39 | echo ubinize -o ${USERDATA_PARTITION} ${UBINIZE_ARGS} ubinize.cfg |
| 40 | ubinize -o ${USERDATA_PARTITION} ${UBINIZE_ARGS} ubinize.cfg |
| 41 | cp ${USERDATA_PARTITION} ${DEPLOY_DIR_IMAGE}/${USERDATA_PARTITION} |
| 42 | elif test "${IMAGE_FSTYPES_NO_WHITESPACE}" = "ext4"; then |
| 43 | STATE_PARTITION="sncfg.ext4" |
| 44 | dd if=/dev/zero of=${DEPLOY_DIR_IMAGE}/${STATE_PARTITION} seek=${SNCFG_DIR_IMAGE_SIZE} count=0 bs=1k |
| 45 | mkfs.ext4 -F -i 4096 ${DEPLOY_DIR_IMAGE}/${STATE_PARTITION} -d ${SNCFG_DIR_IMAGE_PATH} |
| 46 | else |
| 47 | echo "No method to make ${IMAGE_FSTYPES_NO_WHITESPACE} type state image" |
| 48 | fi |
| 49 | } |
| 50 | |
| 51 | ROOTFS_POSTPROCESS_COMMAND += " mk_sncfg_image;" |
| 52 | |
| 53 | |