Blame view

release/mk-fusingsd.sh 3.22 KB
9510093c0   larche   = Fusing SD 관련 추가
1
2
3
4
  #!/bin/bash
  
  C_NC='\033[0m'
  C_LRED='\033[1;31m'
ecc75a727   larche   = Fusing SD Scrip...
5
6
  #### Partition Number ####
  P1_NUM="1"
ecc75a727   larche   = Fusing SD Scrip...
7
9510093c0   larche   = Fusing SD 관련 추가
8
9
10
11
12
13
14
15
  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"
f27446b7a   남새힘   images: 1920x1080...
16
  FNAME_DTB_JIG="imx6s-prime-oven_jig.dtb"
9510093c0   larche   = Fusing SD 관련 추가
17
  FNAME_KERNEL="uImage"
c02be3f88   larche   = FS NAME 수정
18
  FNAME_FSCPIO="ramdisk-prime_oven.uboot"
9510093c0   larche   = Fusing SD 관련 추가
19
  FNAME_RFS="rootfs.tar"
5749fe191   김민수   생산 스크립트 수정
20
  FNAME_APP="application.tar"
9510093c0   larche   = Fusing SD 관련 추가
21
22
23
24
25
26
27
28
29
  
  MOUNT_PATH_P1="/tmp/mmcblk0p1"
  
  
  function create_partition()
  {
  	echo ""
  	echo -e "${C_LRED}### Fdisk Create Partition - create_partition() ###${C_NC}"
  	echo ""
3331432f5   larche   = fusing script
30
31
32
33
34
35
  fdisk $DEV_PATH << EOF
  o
  n
  p
  1
  262144
3331432f5   larche   = fusing script
36
37
38
  
  p
  w
9510093c0   larche   = Fusing SD 관련 추가
39
40
41
42
43
44
45
46
  EOF
  }
  
  function run_format()
  {
  	echo ""
  	echo -e "${C_LRED}### Format SDCARD - run_format() ###${C_NC}"
  	echo ""
ecc75a727   larche   = Fusing SD Scrip...
47
  	echo "y" | mkfs.ext4 ${DEV_PATH}${P1_NUM} -L BOOT0
9510093c0   larche   = Fusing SD 관련 추가
48
49
50
51
52
53
54
55
56
57
  }
  
  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
ecc75a727   larche   = Fusing SD Scrip...
58
  	mount ${DEV_PATH}${P1_NUM} ${MOUNT_PATH_P1}
9510093c0   larche   = Fusing SD 관련 추가
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  }
  
  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/
f27446b7a   남새힘   images: 1920x1080...
81
  	cp -v ./$FNAME_DTB_JIG ${MOUNT_PATH_P1}/boot/
9510093c0   larche   = Fusing SD 관련 추가
82
  	cp -v ./$FNAME_KERNEL ${MOUNT_PATH_P1}/boot/
c02be3f88   larche   = FS NAME 수정
83
  	cp -v ./$FNAME_FSCPIO ${MOUNT_PATH_P1}/boot/
9510093c0   larche   = Fusing SD 관련 추가
84
  	cp -v ./$FNAME_RFS ${MOUNT_PATH_P1}/boot/
5749fe191   김민수   생산 스크립트 수정
85
  	cp -v ./$FNAME_APP ${MOUNT_PATH_P1}/boot/
9510093c0   larche   = Fusing SD 관련 추가
86
87
88
89
90
91
92
93
94
95
96
97
98
  	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
c02be3f88   larche   = FS NAME 수정
99
  	dd if=./$FNAME_FSCPIO of=$DEV_PATH bs=512 seek=28672
9510093c0   larche   = Fusing SD 관련 추가
100
101
102
103
104
105
106
107
108
  	sleep 1
  	sync
  }
  
  function Init_Unmount()
  {
  	echo ""
  	echo -e "${C_LRED}### Unmount SD - Init_Unmount() ###${C_NC}"
  	echo ""
ecc75a727   larche   = Fusing SD Scrip...
109
110
  #	umount $DEV_PATH_P1
  	umount $DEV_PATH*
9510093c0   larche   = Fusing SD 관련 추가
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  }
  
  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
  }
ecc75a727   larche   = Fusing SD Scrip...
128
129
130
  if [[ "$1" == "sd"* ]]; then
  	if [ "$1" != "sd" ]; then
  		P1_NUM="1"
ecc75a727   larche   = Fusing SD Scrip...
131
132
133
134
135
136
137
138
  	else
  		echo "Missing Partition Number"
  		exit
  	fi
  
  elif [[ "$1" == "mmcblk"* ]]; then
  	if [ "$1" != "mmcblk" ]; then
  		P1_NUM="p1"
ecc75a727   larche   = Fusing SD Scrip...
139
140
141
142
143
144
145
146
  	else
  		echo "Missing Partition Number"
  		exit
  	fi
  else
  	echo "Wrong Device Name"
  	exit
  fi
9510093c0   larche   = Fusing SD 관련 추가
147
148
149
150
151
  if [ "$1" != "" ]; then
  	DEVNAME=$1
  fi
  
  DEV_PATH="/dev/${DEVNAME}"
ecc75a727   larche   = Fusing SD Scrip...
152
153
  DEV_PATH_P1="${DEV_PATH}${P1_NUM}"
  MOUNT_PATH_P1="/tmp/${DEVNAME}${P1_NUM}"
9510093c0   larche   = Fusing SD 관련 추가
154
155
156
157
158
159
160
161
  
  echo ""
  echo "================================"
  echo "DEV_Name:     $DEVNAME"
  echo "DEV_Path:     $DEV_PATH"
  echo "P1 MountPath: $MOUNT_PATH_P1"
  echo "================================"
  echo ""
ecc75a727   larche   = Fusing SD Scrip...
162
163
164
165
166
167
168
169
170
171
  read -p "IS Right? (y/n): " -n 2 -e IS_RIGHT
  
  if [ "$IS_RIGHT" == "y" ]; then
  	main
  elif [ "$IS_RIGHT" == "Y" ]; then
  	main
  else
  	echo -e "Exit This Script"
  	exit
  fi