2015年2月25日 星期三

燒code用...for SD card

燒code用...for SD card
環境: Freescale imx6 (sabresd_6dq)

device/fsl/sabresd_6dq/fstab.freescale
/devices/platform/sdhci-esdhc-imx.1/mmc_host/mmc2 /mnt/media_rw/extsd vfat defaults voldmanaged=extsd:auto
/devices/platform/fsl-ehci /mnt/media_rw/udisk vfat defaults voldmanaged=udisk:auto
/dev/block/mmcblk1p5    /system      ext4    ro                                                                               wait
/dev/block/mmcblk1p4    /data        ext4    nosuid,nodev,nodiratime,noatime,nomblk_io_submit,noauto_da_alloc,errors=panic    wait,encryptable=footer
/dev/block/mmcblk1p6    /cache       ext4    nosuid,nodev,nomblk_io_submit                                                    wait
/dev/block/mmcblk1p7    /device      ext4    ro,nosuid,nodev                                                                  wait
/dev/block/mmcblk1p1    /boot        emmc    defaults                                                                         defaults
/dev/block/mmcblk1p2    /recovery    emmc    defaults                                                                         defaults
/dev/block/mmcblk1p8    /misc        emmc    defaults                                                                         defaults
如果是emmc的話,
1. sdhci-esdhc-imx.2/mmc_host/mmc1
2. 把其它的mmcblk1 全改成 mmcblk0

./dl.sh
#!/bin/bash

dl_filepath="/dev/mmcblk0"
ddimg_path="out/target/product/sabresd_6dq/"

function UmountDisk()
{
    #file_count=$(ls /dev/mmcblk0* | wc -l)
    file_count=$(df | grep /dev/mmcblk0 | wc -l)
    echo $file_count;

    if [ $file_count -eq 0 ]; then
        echo "but $dl_filepath"p[4-7]" doesn't exists";
        return 0;
    fi

    for((i=4; i<$file_count+4; i++))
    do
        if [ -e $dir $dl_filepath"p"$i ]; then
            echo $dir $dl_filepath"p"$i;
            case $i in
                [4-7])
                    echo "remove this partition $(sudo -s umount $dir $dl_filepath"p"$i)"
                ;;
                *)
                ;;
            esac
        else
            echo "This $dir $dl_filepath"p"$i doesn't exists."
            return 0;
        fi
    done
    return 1;
}

function DDImage()
{
    if [ -e $ddimg_path"/boot.img" ];then
        $(sudo dd if=$ddimg_path"/boot.img" of=/dev/mmcblk0p1; sync)
        echo "finished boot.img"
    else
        echo "boot.img doesn't exists"
    fi

    if [ -e $ddimg_path"/system.img" ];then
        $(sudo dd if=$ddimg_path"/system.img" of=/dev/mmcblk0p5; sync)
        echo "finished system.img"
    else
        echo "system.img doesn't exists"
    fi

    if [ -e $ddimg_path"/recovery.img" ];then
        $(sudo dd if=$ddimg_path"/recovery.img" of=/dev/mmcblk0p2; sync)
        echo "finished recovery.img"
    else
        echo "recovery.img doesn't exists"
    fi
}

if [ -e $dl_filepath ];then
    echo "The file $dl_filepath exists";
    ret=$(UmountDisk);
    if [ $? -eq 0 ]; then
        DDImage;
    fi
else
    echo "The file $dl_filepath does not exist";

沒有留言:

張貼留言