Blame view

scripts/mk-emmc-fusing.sh 4.08 KB
a818f21af   larche   = Script 따로 관리 =
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  #!/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"
99bdfc556   larche   = 스크립트 수정 =
18
  FNAME_FSCPIO="ramdisk-prime_oven.uboot"
a818f21af   larche   = Script 따로 관리 =
19
  FNAME_RFS="rootfs.tar"
5749fe191   김민수   생산 스크립트 수정
20
  FNAME_APP="application.tar"
a818f21af   larche   = Script 따로 관리 =
21
22
23
24
  
  SD_MOUNT_PATH_P1="/tmp/mmcblk2p1"
  EMMC_MOUNT_PATH_P1="/tmp/mmcblk3p1"
  EMMC_MOUNT_PATH_P2="/tmp/mmcblk3p2"
5749fe191   김민수   생산 스크립트 수정
25
26
  EMMC_MOUNT_PATH_P3="/tmp/mmcblk3p3"
  EMMC_MOUNT_PATH_P4="/tmp/mmcblk3p4"
a818f21af   larche   = Script 따로 관리 =
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  
  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 ""
3331432f5   larche   = fusing script
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  fdisk ${EMMC_DEV_PATH} << EOF
  o
  n
  p
  1
  4096
  8191
  n
  p
  2
  8192
  16383
  n
  p
  3
  16384
  32767
  n
  p
  32768
a818f21af   larche   = Script 따로 관리 =
66
3331432f5   larche   = fusing script
67
68
  p
  w
a818f21af   larche   = Script 따로 관리 =
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
  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
5749fe191   김민수   생산 스크립트 수정
100
101
102
103
104
105
106
  	if [ ! -d ${EMMC_MOUNT_PATH_P3} ]; then
  		mkdir ${EMMC_MOUNT_PATH_P3}
  	fi
  
  	if [ ! -d ${EMMC_MOUNT_PATH_P4} ]; then
  		mkdir ${EMMC_MOUNT_PATH_P4}
  	fi
a818f21af   larche   = Script 따로 관리 =
107
108
109
  	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}
5749fe191   김민수   생산 스크립트 수정
110
111
  	mount -t ext4 ${EMMC_DEV_PATH}${PART3}  ${EMMC_MOUNT_PATH_P3}
  	mount -t ext4 ${EMMC_DEV_PATH}${PART4}  ${EMMC_MOUNT_PATH_P4}
a818f21af   larche   = Script 따로 관리 =
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  }
  
  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/
99bdfc556   larche   = 스크립트 수정 =
128
  	cp -v ${SD_MOUNT_PATH_P1}/boot/${FNAME_FSCPIO} ${EMMC_MOUNT_PATH_P1}/boot/
a818f21af   larche   = Script 따로 관리 =
129
130
131
132
133
134
135
136
137
138
139
140
141
142
  	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/
5749fe191   김민수   생산 스크립트 수정
143
ab91daa64   larche   = Fusing 스크립트 버그 수정
144
145
  	tar -xf ${SD_MOUNT_PATH_P1}/boot/${FNAME_APP} -C ${EMMC_MOUNT_PATH_P3}
  	tar -xf ${SD_MOUNT_PATH_P1}/boot/${FNAME_APP} -C ${EMMC_MOUNT_PATH_P4}
a818f21af   larche   = Script 따로 관리 =
146
147
148
149
150
151
152
153
154
155
156
  }
  
  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
99bdfc556   larche   = 스크립트 수정 =
157
  	dd if=${SD_MOUNT_PATH_P1}/boot/${FNAME_FSCPIO} of=${EMMC_DEV_PATH} bs=512 seek=28672
a818f21af   larche   = Script 따로 관리 =
158
159
160
161
162
163
164
165
166
167
168
169
  	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}
5749fe191   김민수   생산 스크립트 수정
170
171
  	umount ${EMMC_MOUNT_PATH_P3}
  	umount ${EMMC_MOUNT_PATH_P4}
a818f21af   larche   = Script 따로 관리 =
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
  }
  
  
  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