[关闭]
@leaveye 2017-11-27T02:13:01.000000Z 字数 2278 阅读 903

w1302-HD Making SD Card

w1302


for ALL card:

  1. enter work dir

    1. cd ~/sd_files/20160331/
  2. set argument for burn disk.

    edit burn.config file to have these lines:

    1. # device node root name, to be partitioned
    2. device=/dev/sdc
    3. # directory where system automounts the partitions into
    4. mountroot=/media
    5. # tarballs to be installed
    6. BOOT=repack-boot-20160331.tgz
    7. ROOTFS=repack-rootfs-20160331.tgz

for new card:

  1. ./burn-stage01-newcardonly
  2. ./burn-stage02-rewritecard

for partitioned card:

  1. ./burn-stage02-rewritecard

Appendix

burn.config

This code is for demo only !

  1. # device node root name, to be partitioned
  2. device=/dev/sdc
  3. # directory where system automounts the partitions into
  4. mountroot=/media
  5. # tarballs to be installed
  6. BOOT=repack-boot-20160331.tgz
  7. ROOTFS=repack-rootfs-20160331.tgz
  8. #ROOTFS=repack-rootfs160-20160331.tgz

burn-stage01-newcardonly

  1. #!/bin/bash
  2. # reference command:
  3. # ./format_sd.sh --device /dev/sdc --sdk /home/dev/ti-ezsdk_dm816x-evm_5_05_02_00
  4. { test -r burn.config && . ./burn.config; } ||
  5. { echo 'you need file "burn.config"'; exit 1; }
  6. test -b "$device" ||
  7. { echo 'illegal "burn.config": no device specified'; exit 1; }
  8. unmount() {
  9. for i in `ls -1 $device?`; do
  10. echo "unmounting '$i'"
  11. umount $i 2>/dev/null
  12. done
  13. }
  14. partition() {
  15. # get the partition information.
  16. total_size=`fdisk -l $device | grep Disk | awk '{print $5}'`
  17. total_cyln=`echo $total_size/255/63/512 | bc`
  18. # default number of cylinder for first parition
  19. pc1=5
  20. # do partition
  21. {
  22. echo ,$pc1,0x0C,*
  23. echo ,,,-
  24. } |
  25. sfdisk -D -H 255 -S 63 -C $total_cyln $device
  26. }
  27. format() {
  28. mkfs.vfat -F 32 -n BOOT ${device}1
  29. mkfs.ext3 -j -L ROOTFS ${device}2
  30. }
  31. remount() {
  32. mkdir -p /media/BOOT
  33. mount ${device}1 /media/BOOT
  34. mkdir -p /media/ROOTFS
  35. mount ${device}2 /media/ROOTFS
  36. }
  37. unmount
  38. erase0
  39. partition
  40. format
  41. remount

burn-stage02-rewritecard

  1. #!/bin/bash
  2. { test -r burn.config && . ./burn.config; } ||
  3. { echo 'you need file "burn.config"'; exit 1; }
  4. test -b "$device" ||
  5. { echo 'illegal "burn.config": no device specified'; exit 1; }
  6. burn() {
  7. SRC="$(eval "echo \"\$$1\"")"
  8. DST="$mountroot/$1"
  9. test -r "$SRC" || { echo "burn $1: no $SRC found"; return 1; }
  10. test -d "$DST" || { echo "burn $1: no $DST found"; return 1; }
  11. shift
  12. case "$SRC" in
  13. *.tar) opt=;;
  14. *.tar.gz|*.tgz) opt=-z;;
  15. *.tar.bz2) opt=-j;;
  16. *) ;;
  17. esac
  18. pv -N "burn '$DST'" "$SRC" | {
  19. ( cd "$DST" && rm -rf * >/dev/null 2>&1; )
  20. sudo tar -C "$DST" --no-same-owner $opt $* -x
  21. }
  22. return $?
  23. }
  24. {
  25. echo '==== Round 1 ===='
  26. burn BOOT &&
  27. burn ROOTFS
  28. } &&
  29. {
  30. echo '==== Round 2 ===='
  31. burn BOOT &&
  32. burn ROOTFS
  33. } &&
  34. echo '==== all DONE ===='
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注