From a818f21afddff0a08a1cc2487d4aa00ca3eddf04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EA=B7=9C=ED=98=95?= Date: Tue, 30 May 2017 16:33:52 +0900 Subject: [PATCH] =?UTF-8?q?=3D=20Script=20=EB=94=B0=EB=A1=9C=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20=3D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/README.md | 30 ++++++++ scripts/mk-emmc-fusing.sh | 176 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/mk-fusingsd.sh | 151 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 357 insertions(+) create mode 100644 scripts/README.md create mode 100755 scripts/mk-emmc-fusing.sh create mode 100755 scripts/mk-fusingsd.sh diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..eba07d6 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,30 @@ + + + +## [mk-fusing.sh] +--------------------------- + +* 작업자 : larche@falinux.com + +* 설명 : + + 생산용 eMMC 에 이미지를 fusing 하는 Fusing-SDCard 만드는 스크립트이다. + 이미지파일과 같은 폴더에 두고 사용하며 SD 디바이스파일의 이름은 mmcblk0 번으로 정함 (상황에 맞게 수정바람) + + + +## [mk-emmc-fusing.sh] +--------------------------- + +* 작업자 : larche@falinux.com + +* 설명 : + + Fusing-SDcard 로 부팅시 eMMC에 부트 이미지를 실제로 퓨징하는 작업을 하는 스크립트이다. + buildroot/buildroot-2016.08.1/board/falinux/prime_oven/rootfs_overlay/root/.falinux + 위치하며 FusingSD 로 부팅시, prime 보드의 /etc/init.d/S83fusing 에서 해당 스크립트를 자동으로 실행한다. + Fusing-SDCard 로 부팅시 Bootcommand 모드에서 run fw 를 입력하면 bootargs 에 fusing=1 이라는 값이 들어가며 + S83fusing 스크립트에서 이 값의 유무를 통해 mk-emmc-fusing.sh 실행할지를 결정한다. + (참고로 Test-Jig 스크립트도 여기에서 실행한다.) + + diff --git a/scripts/mk-emmc-fusing.sh b/scripts/mk-emmc-fusing.sh new file mode 100755 index 0000000..9988c95 --- /dev/null +++ b/scripts/mk-emmc-fusing.sh @@ -0,0 +1,176 @@ +#!/bin/bash + +C_NC='\033[0m' +C_LRED='\033[1;31m' + + +EMMC_DEV_PATH="/dev/mmcblk3" +SD_DEV_PATH="/dev/mmcblk2" +PART1=p1 +PART2=p2 +PART3=p3 +PART4=p4 + +FNAME_UBOOT="u-boot.imx" +FNAME_LOGO="init.bmp" +FNAME_DTB="imx6s-prime-oven.dtb" +FNAME_KERNEL="uImage" +FNAME_FS128="ramdisk-prime_oven-128M.gz" +FNAME_FS64="ramdisk-prime_oven-64M.gz" +FNAME_RFS="rootfs.tar" + +SD_MOUNT_PATH_P1="/tmp/mmcblk2p1" +EMMC_MOUNT_PATH_P1="/tmp/mmcblk3p1" +EMMC_MOUNT_PATH_P2="/tmp/mmcblk3p2" + +function Init_Unmount() +{ + echo "" + echo -e "${C_LRED}### UnMount - Init_Unmount() ### ${C_NC}" + echo "" + umount ${EMMC_DEV_PATH}${PART1} + umount ${EMMC_DEV_PATH}${PART2} + umount ${EMMC_DEV_PATH}${PART3} + umount ${EMMC_DEV_PATH}${PART4} + umount ${SD_DEV_PATH}${PART1} + umount ${SD_DEV_PATH}${PART2} +} + +function create_partition() +{ + echo "" + echo -e "${C_LRED}### Fdisk Create Partition - create_partition() ###${C_NC}" + echo "" + fdisk ${EMMC_DEV_PATH} << EOF + o + n + p + 1 + 4096 + 8191 + n + p + 2 + 8192 + 16383 + n + p + 3 + 16384 + 32767 + n + p + 32768 + + p + w +EOF +} + +function run_format() +{ + echo "" + echo -e "${C_LRED}### Format eMMC - run_format() ###${C_NC}" + echo "" + mkfs.ext3 -F ${EMMC_DEV_PATH}${PART1} -L BOOT0 + mkfs.ext4 -j -F ${EMMC_DEV_PATH}${PART2} -L SYSTEM + mkfs.ext4 -j -F ${EMMC_DEV_PATH}${PART3} -L FALINUX + mkfs.ext4 -j -F ${EMMC_DEV_PATH}${PART4} -L PRIME +} + +function run_mount() +{ + echo "" + echo -e "${C_LRED}### Mount SD/eMMC - run_mount() ###${C_NC}" + echo "" + + if [ ! -d ${SD_MOUNT_PATH_P1} ]; then + mkdir ${SD_MOUNT_PATH_P1} + fi + + if [ ! -d ${EMMC_MOUNT_PATH_P1} ]; then + mkdir ${EMMC_MOUNT_PATH_P1} + fi + + if [ ! -d ${EMMC_MOUNT_PATH_P2} ]; then + mkdir ${EMMC_MOUNT_PATH_P2} + fi + + mount -t ext4 ${SD_DEV_PATH}${PART1} ${SD_MOUNT_PATH_P1} + mount -t ext3 ${EMMC_DEV_PATH}${PART1} ${EMMC_MOUNT_PATH_P1} + mount -t ext4 ${EMMC_DEV_PATH}${PART2} ${EMMC_MOUNT_PATH_P2} +} + +function run_copy_image() +{ + echo "" + echo -e "${C_LRED}### Write SD Boot Image - run_copy_image() ###${C_NC}" + echo "" + + if [ ! -d ${EMMC_MOUNT_PATH_P1}/boot ]; then + mkdir ${EMMC_MOUNT_PATH_P1}/boot + fi + + cp -v ${SD_MOUNT_PATH_P1}/boot/${FNAME_UBOOT} ${EMMC_MOUNT_PATH_P1}/boot/ + cp -v ${SD_MOUNT_PATH_P1}/boot/${FNAME_LOGO} ${EMMC_MOUNT_PATH_P1}/boot/ + cp -v ${SD_MOUNT_PATH_P1}/boot/${FNAME_DTB} ${EMMC_MOUNT_PATH_P1}/boot/ + cp -v ${SD_MOUNT_PATH_P1}/boot/${FNAME_KERNEL} ${EMMC_MOUNT_PATH_P1}/boot/ + cp -v ${SD_MOUNT_PATH_P1}/boot/${FNAME_FS128} ${EMMC_MOUNT_PATH_P1}/boot/ + run_copy_rootfs + sleep 1 + sync +} + +function run_copy_rootfs() +{ + echo "" + echo -e "${C_LRED}### Make MMC Filesystem ###${C_NC}" + echo "" + + tar -xf ${SD_MOUNT_PATH_P1}/boot/${FNAME_RFS} -C ${EMMC_MOUNT_PATH_P2} + + cp /etc/ssh/ssh_host_ed25519_key ${EMMC_MOUNT_PATH_P2}/etc/ssh/ +} + +function run_raw_write() +{ + echo "" + echo -e "${C_LRED}### Write SD Boot Image to RAW - run_raw_write() ###${C_NC}" + echo "" + dd if=${SD_MOUNT_PATH_P1}/boot/${FNAME_UBOOT} of=${EMMC_DEV_PATH} bs=512 seek=2 + dd if=${SD_MOUNT_PATH_P1}/boot/${FNAME_LOGO} of=${EMMC_DEV_PATH} bs=512 seek=2048 + dd if=${SD_MOUNT_PATH_P1}/boot/${FNAME_DTB} of=${EMMC_DEV_PATH} bs=512 seek=11264 + dd if=${SD_MOUNT_PATH_P1}/boot/${FNAME_KERNEL} of=${EMMC_DEV_PATH} bs=512 seek=12288 + dd if=${SD_MOUNT_PATH_P1}/boot/${FNAME_FS128} of=${EMMC_DEV_PATH} bs=512 seek=28672 +# dd if=./$FNAME_FS64 of=$EMMC_DEV_PATH bs=512 seek=28672 + sleep 1 + sync +} + +function run_umount() +{ + echo "" + echo -e "${C_LRED}### UnMount - run_umount() ###${C_NC}" + echo "" + umount ${SD_MOUNT_PATH_P1} + umount ${EMMC_MOUNT_PATH_P1} + umount ${EMMC_MOUNT_PATH_P2} +} + + +function main() +{ + echo "" + echo -e "${C_LRED}#### Start - main() ####${C_NC}" + echo "" + + Init_Unmount + create_partition + run_format + run_mount + run_copy_image + run_raw_write + run_umount +} + +main diff --git a/scripts/mk-fusingsd.sh b/scripts/mk-fusingsd.sh new file mode 100755 index 0000000..79c5430 --- /dev/null +++ b/scripts/mk-fusingsd.sh @@ -0,0 +1,151 @@ +#!/bin/bash + +C_NC='\033[0m' +C_LRED='\033[1;31m' + +DEVNAME="mmcblk0" +DEV_PATH="/dev/mmcblk0" +DEV_PATH_P1="/dev/mmcblk0p1" +INPUT="/tmp/input" + +FNAME_UBOOT="u-boot.imx" +FNAME_LOGO="init.bmp" +FNAME_DTB="imx6s-prime-oven.dtb" +FNAME_KERNEL="uImage" +FNAME_FSCPIO="ramdisk-prime_oven.uboot" +#FNAME_FS128="ramdisk-prime_oven-128M.gz" +#FNAME_FS64="ramdisk-prime_oven-64M.gz" +FNAME_RFS="rootfs.tar" + +MOUNT_PATH_P1="/tmp/mmcblk0p1" + + +function create_partition() +{ + echo "" + echo -e "${C_LRED}### Fdisk Create Partition - create_partition() ###${C_NC}" + echo "" + fdisk $DEV_PATH << EOF + o + n + p + 1 + 262144 + 1310719 + n + p + 2 + 1310720 + + p + w +EOF +} + +function run_format() +{ + echo "" + echo -e "${C_LRED}### Format SDCARD - run_format() ###${C_NC}" + echo "" + mkfs.ext4 ${DEV_PATH}p1 -L BOOT0 + mkfs.ext4 ${DEV_PATH}p2 -L DATA +} + +function run_mount() +{ + echo "" + echo -e "${C_LRED}### Mount SD - run_mount() ###${C_NC}" + echo "" + if [ ! -d ${MOUNT_PATH_P1} ]; then + mkdir ${MOUNT_PATH_P1} + fi + + mount ${DEV_PATH}p1 ${MOUNT_PATH_P1} +} + +function run_umount() +{ + echo "" + echo -e "${C_LRED}### UnMount - run_umount() ###${C_NC}" + echo "" + umount ${MOUNT_PATH_P1} +} + +function run_copy_image() +{ + # SD Boot Image(SD 카드 부팅용 이미지) + echo "" + echo -e "${C_LRED}### Write SD Boot Image - run_copy_image() ###${C_NC}" + echo "" + if [ ! -d ${MOUNT_PATH_P1}/boot ]; then + mkdir ${MOUNT_PATH_P1}/boot + fi + cp -v ./$FNAME_UBOOT ${MOUNT_PATH_P1}/boot/ + cp -v ./$FNAME_LOGO ${MOUNT_PATH_P1}/boot/ + cp -v ./$FNAME_DTB ${MOUNT_PATH_P1}/boot/ + cp -v ./$FNAME_KERNEL ${MOUNT_PATH_P1}/boot/ + cp -v ./$FNAME_FSCPIO ${MOUNT_PATH_P1}/boot/ +# cp -v ./$FNAME_FS128 ${MOUNT_PATH_P1}/boot/ +# cp -v ./$FNAME_FS64 ${MOUNT_PATH_P1}/boot/ + cp -v ./$FNAME_RFS ${MOUNT_PATH_P1}/boot/ + sleep 1 + sync +} + +function run_raw_write() +{ + echo "" + echo -e "${C_LRED}### Write SD Boot Image to RAW - run_raw_write() ###${C_NC}" + echo "" + dd if=./$FNAME_UBOOT of=$DEV_PATH bs=512 seek=2 + dd if=./$FNAME_LOGO of=$DEV_PATH bs=512 seek=2048 + dd if=./$FNAME_DTB of=$DEV_PATH bs=512 seek=11264 + dd if=./$FNAME_KERNEL of=$DEV_PATH bs=512 seek=12288 + dd if=./$FNAME_FSCPIO of=$DEV_PATH bs=512 seek=28672 +# dd if=./$FNAME_FS128 of=$DEV_PATH bs=512 seek=28672 +# dd if=./$FNAME_FS64 of=$DEV_PATH bs=512 seek=28672 + sleep 1 + sync +} + +function Init_Unmount() +{ + echo "" + echo -e "${C_LRED}### Unmount SD - Init_Unmount() ###${C_NC}" + echo "" + umount $DEV_PATH_P1 +} + +function main() +{ + echo "" + echo -e "${C_LRED}#### Start - main() ####${C_NC}" + echo "" + Init_Unmount + create_partition + + run_format + run_mount + run_raw_write + run_copy_image + run_umount + sync +} + +if [ "$1" != "" ]; then + DEVNAME=$1 +fi + +DEV_PATH="/dev/${DEVNAME}" +DEV_PATH_P1="${DEV_PATH}p1" +MOUNT_PATH_P1="/tmp/${DEVNAME}p1" + +echo "" +echo "================================" +echo "DEV_Name: $DEVNAME" +echo "DEV_Path: $DEV_PATH" +echo "P1 MountPath: $MOUNT_PATH_P1" +echo "================================" +echo "" + +main -- 2.1.4