#!/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_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_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_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