milkv-duo use a separate script to create sd image

This commit is contained in:
carbon
2023-06-12 20:29:03 +08:00
parent 69c5b08231
commit db74adc752
4 changed files with 89 additions and 17 deletions

View File

@ -602,7 +602,11 @@ ifeq ($(CONFIG_BUILDROOT_FS),y)
else
${Q}ln -s $(OUTPUT_DIR)/rootfs $(OUTPUT_DIR)/fs
endif
ifeq ($(MV_VENDOR), milkv)
$(TOP_DIR)/$(MV_VENDOR)/gen_burn_image_sd.sh $(OUTPUT_DIR)
else
$(COMMON_TOOLS_PATH)/sd_tools/sd_gen_burn_image.sh $(OUTPUT_DIR)
endif
jffs2:
$(call print_target)

View File

@ -114,23 +114,6 @@ function milkv_duo_pack()
image_count=`ls ${install_dir}/*.img | wc -l`
if [ ${image_count} -ge 0 ]; then
mv ${install_dir}/*.img out/
pushd out
for img in sophpi*.img
do
#echo $img
milkv_img=$(echo $img | sed -e 's/sophpi/milkv/')
#echo $milkv_img
if [ -f $img ]; then
mv ${img} ${milkv_img}
if [ $? -ne 0 ]; then
print_err "Rename failed!"
exit 1
fi
fi
done
popd
# show latest img
latest_img=`ls -t out/*.img | head -n1`
@ -177,6 +160,8 @@ if [ -z "${MILKV_BOARD// }" ]; then
exit 1
fi
export MILKV_BOARD="${MILKV_BOARD}"
MILKV_BOARD_CONFIG=${MILKV_BOARD_DIR}/boardconfig-${MILKV_BOARD}.sh
if [ ! -f ${MILKV_BOARD_CONFIG} ]; then

View File

@ -1,6 +1,7 @@
#!/bin/bash
export MV_BOARD_CPU=cv1800b
export MV_VENDOR=milkv
export MV_BUILD_ENV=milkvsetup.sh
export MV_BOARD_LINK=cv1800b_milkv_duo_sd

82
milkv/gen_burn_image_sd.sh Executable file
View File

@ -0,0 +1,82 @@
#!/bin/bash
# sd image generator
# usage
if [ "$#" -ne "1" ]; then
echo "usage: sudo ${0} OUTPUT_DIR"
echo ""
echo " The script is used to create a sdcard image with two partitions, "
echo " one is fat32 with 128MB, the other is ext4 with 256MB."
echo " You can modify the capacities in this script as you wish!"
echo ""
echo "Note: Please backup you sdcard files before using this image!"
exit
fi
vfat_cap=128M
vfat_label="boot"
ext4_cap=256M
ext4_label="rootfs"
output_dir=$1
echo ${output_dir}
pushd ${output_dir}
# gen a empty image
image=${MILKV_BOARD}-`date +%Y%m%d-%H%M`.img
echo ${image}
dd if=/dev/zero of=./${image} bs=1M count=512
################################
# Note: do not change this flow
################################
sudo fdisk ./${image} << EOF
n
p
1
+${vfat_cap}
n
p
2
+${ext4_cap}
w
EOF
# Note end
################################
dev_name=`sudo losetup -f`
echo ${dev_name}
echo ""
sudo losetup ${dev_name} ./${image}
sudo partprobe ${dev_name}
sudo mkfs.vfat -F 32 -n ${vfat_label} ${dev_name}p1
sudo mkfs.ext4 -L ${ext4_label} ${dev_name}p2
# mount partitions
rm ./tmp1 ./tmp2 -rf
mkdir tmp1 tmp2
sudo mount -t vfat ${dev_name}p1 tmp1/
sudo mount -t ext4 ${dev_name}p2 tmp2/
# copy boot file and rootfs
sudo cp ${output_dir}/fip.bin ./tmp1/
sudo cp ${output_dir}/rawimages/boot.sd ./tmp1/
sudo cp -raf ${output_dir}/fs/* ./tmp2
sync
# umount
sudo umount tmp1 tmp2
sudo losetup -d ${dev_name}
rmdir tmp1 tmp2
echo "Gen image successful: ${image}"
echo ""
popd