Commit a818f21afddff0a08a1cc2487d4aa00ca3eddf04
1 parent
bbdc7484db
Exists in
master
and in
2 other branches
= Script 따로 관리 =
Showing
3 changed files
with
357 additions
and
0 deletions
Show diff stats
scripts/README.md
... | ... | @@ -0,0 +1,30 @@ |
1 | + | |
2 | + | |
3 | + | |
4 | +## [mk-fusing.sh] | |
5 | +--------------------------- | |
6 | + | |
7 | +* 작업자 : larche@falinux.com | |
8 | + | |
9 | +* 설명 : | |
10 | + | |
11 | + 생산용 eMMC 에 이미지를 fusing 하는 Fusing-SDCard 만드는 스크립트이다. | |
12 | + 이미지파일과 같은 폴더에 두고 사용하며 SD 디바이스파일의 이름은 mmcblk0 번으로 정함 (상황에 맞게 수정바람) | |
13 | + | |
14 | + | |
15 | + | |
16 | +## [mk-emmc-fusing.sh] | |
17 | +--------------------------- | |
18 | + | |
19 | +* 작업자 : larche@falinux.com | |
20 | + | |
21 | +* 설명 : | |
22 | + | |
23 | + Fusing-SDcard 로 부팅시 eMMC에 부트 이미지를 실제로 퓨징하는 작업을 하는 스크립트이다. | |
24 | + buildroot/buildroot-2016.08.1/board/falinux/prime_oven/rootfs_overlay/root/.falinux | |
25 | + 위치하며 FusingSD 로 부팅시, prime 보드의 /etc/init.d/S83fusing 에서 해당 스크립트를 자동으로 실행한다. | |
26 | + Fusing-SDCard 로 부팅시 Bootcommand 모드에서 run fw 를 입력하면 bootargs 에 fusing=1 이라는 값이 들어가며 | |
27 | + S83fusing 스크립트에서 이 값의 유무를 통해 mk-emmc-fusing.sh 실행할지를 결정한다. | |
28 | + (참고로 Test-Jig 스크립트도 여기에서 실행한다.) | |
29 | + | |
30 | + | ... | ... |
scripts/mk-emmc-fusing.sh
... | ... | @@ -0,0 +1,176 @@ |
1 | +#!/bin/bash | |
2 | + | |
3 | +C_NC='\033[0m' | |
4 | +C_LRED='\033[1;31m' | |
5 | + | |
6 | + | |
7 | +EMMC_DEV_PATH="/dev/mmcblk3" | |
8 | +SD_DEV_PATH="/dev/mmcblk2" | |
9 | +PART1=p1 | |
10 | +PART2=p2 | |
11 | +PART3=p3 | |
12 | +PART4=p4 | |
13 | + | |
14 | +FNAME_UBOOT="u-boot.imx" | |
15 | +FNAME_LOGO="init.bmp" | |
16 | +FNAME_DTB="imx6s-prime-oven.dtb" | |
17 | +FNAME_KERNEL="uImage" | |
18 | +FNAME_FS128="ramdisk-prime_oven-128M.gz" | |
19 | +FNAME_FS64="ramdisk-prime_oven-64M.gz" | |
20 | +FNAME_RFS="rootfs.tar" | |
21 | + | |
22 | +SD_MOUNT_PATH_P1="/tmp/mmcblk2p1" | |
23 | +EMMC_MOUNT_PATH_P1="/tmp/mmcblk3p1" | |
24 | +EMMC_MOUNT_PATH_P2="/tmp/mmcblk3p2" | |
25 | + | |
26 | +function Init_Unmount() | |
27 | +{ | |
28 | + echo "" | |
29 | + echo -e "${C_LRED}### UnMount - Init_Unmount() ### ${C_NC}" | |
30 | + echo "" | |
31 | + umount ${EMMC_DEV_PATH}${PART1} | |
32 | + umount ${EMMC_DEV_PATH}${PART2} | |
33 | + umount ${EMMC_DEV_PATH}${PART3} | |
34 | + umount ${EMMC_DEV_PATH}${PART4} | |
35 | + umount ${SD_DEV_PATH}${PART1} | |
36 | + umount ${SD_DEV_PATH}${PART2} | |
37 | +} | |
38 | + | |
39 | +function create_partition() | |
40 | +{ | |
41 | + echo "" | |
42 | + echo -e "${C_LRED}### Fdisk Create Partition - create_partition() ###${C_NC}" | |
43 | + echo "" | |
44 | + fdisk ${EMMC_DEV_PATH} << EOF | |
45 | + o | |
46 | + n | |
47 | + p | |
48 | + 1 | |
49 | + 4096 | |
50 | + 8191 | |
51 | + n | |
52 | + p | |
53 | + 2 | |
54 | + 8192 | |
55 | + 16383 | |
56 | + n | |
57 | + p | |
58 | + 3 | |
59 | + 16384 | |
60 | + 32767 | |
61 | + n | |
62 | + p | |
63 | + 32768 | |
64 | + | |
65 | + p | |
66 | + w | |
67 | +EOF | |
68 | +} | |
69 | + | |
70 | +function run_format() | |
71 | +{ | |
72 | + echo "" | |
73 | + echo -e "${C_LRED}### Format eMMC - run_format() ###${C_NC}" | |
74 | + echo "" | |
75 | + mkfs.ext3 -F ${EMMC_DEV_PATH}${PART1} -L BOOT0 | |
76 | + mkfs.ext4 -j -F ${EMMC_DEV_PATH}${PART2} -L SYSTEM | |
77 | + mkfs.ext4 -j -F ${EMMC_DEV_PATH}${PART3} -L FALINUX | |
78 | + mkfs.ext4 -j -F ${EMMC_DEV_PATH}${PART4} -L PRIME | |
79 | +} | |
80 | + | |
81 | +function run_mount() | |
82 | +{ | |
83 | + echo "" | |
84 | + echo -e "${C_LRED}### Mount SD/eMMC - run_mount() ###${C_NC}" | |
85 | + echo "" | |
86 | + | |
87 | + if [ ! -d ${SD_MOUNT_PATH_P1} ]; then | |
88 | + mkdir ${SD_MOUNT_PATH_P1} | |
89 | + fi | |
90 | + | |
91 | + if [ ! -d ${EMMC_MOUNT_PATH_P1} ]; then | |
92 | + mkdir ${EMMC_MOUNT_PATH_P1} | |
93 | + fi | |
94 | + | |
95 | + if [ ! -d ${EMMC_MOUNT_PATH_P2} ]; then | |
96 | + mkdir ${EMMC_MOUNT_PATH_P2} | |
97 | + fi | |
98 | + | |
99 | + mount -t ext4 ${SD_DEV_PATH}${PART1} ${SD_MOUNT_PATH_P1} | |
100 | + mount -t ext3 ${EMMC_DEV_PATH}${PART1} ${EMMC_MOUNT_PATH_P1} | |
101 | + mount -t ext4 ${EMMC_DEV_PATH}${PART2} ${EMMC_MOUNT_PATH_P2} | |
102 | +} | |
103 | + | |
104 | +function run_copy_image() | |
105 | +{ | |
106 | + echo "" | |
107 | + echo -e "${C_LRED}### Write SD Boot Image - run_copy_image() ###${C_NC}" | |
108 | + echo "" | |
109 | + | |
110 | + if [ ! -d ${EMMC_MOUNT_PATH_P1}/boot ]; then | |
111 | + mkdir ${EMMC_MOUNT_PATH_P1}/boot | |
112 | + fi | |
113 | + | |
114 | + cp -v ${SD_MOUNT_PATH_P1}/boot/${FNAME_UBOOT} ${EMMC_MOUNT_PATH_P1}/boot/ | |
115 | + cp -v ${SD_MOUNT_PATH_P1}/boot/${FNAME_LOGO} ${EMMC_MOUNT_PATH_P1}/boot/ | |
116 | + cp -v ${SD_MOUNT_PATH_P1}/boot/${FNAME_DTB} ${EMMC_MOUNT_PATH_P1}/boot/ | |
117 | + cp -v ${SD_MOUNT_PATH_P1}/boot/${FNAME_KERNEL} ${EMMC_MOUNT_PATH_P1}/boot/ | |
118 | + cp -v ${SD_MOUNT_PATH_P1}/boot/${FNAME_FS128} ${EMMC_MOUNT_PATH_P1}/boot/ | |
119 | + run_copy_rootfs | |
120 | + sleep 1 | |
121 | + sync | |
122 | +} | |
123 | + | |
124 | +function run_copy_rootfs() | |
125 | +{ | |
126 | + echo "" | |
127 | + echo -e "${C_LRED}### Make MMC Filesystem ###${C_NC}" | |
128 | + echo "" | |
129 | + | |
130 | + tar -xf ${SD_MOUNT_PATH_P1}/boot/${FNAME_RFS} -C ${EMMC_MOUNT_PATH_P2} | |
131 | + | |
132 | + cp /etc/ssh/ssh_host_ed25519_key ${EMMC_MOUNT_PATH_P2}/etc/ssh/ | |
133 | +} | |
134 | + | |
135 | +function run_raw_write() | |
136 | +{ | |
137 | + echo "" | |
138 | + echo -e "${C_LRED}### Write SD Boot Image to RAW - run_raw_write() ###${C_NC}" | |
139 | + echo "" | |
140 | + dd if=${SD_MOUNT_PATH_P1}/boot/${FNAME_UBOOT} of=${EMMC_DEV_PATH} bs=512 seek=2 | |
141 | + dd if=${SD_MOUNT_PATH_P1}/boot/${FNAME_LOGO} of=${EMMC_DEV_PATH} bs=512 seek=2048 | |
142 | + dd if=${SD_MOUNT_PATH_P1}/boot/${FNAME_DTB} of=${EMMC_DEV_PATH} bs=512 seek=11264 | |
143 | + dd if=${SD_MOUNT_PATH_P1}/boot/${FNAME_KERNEL} of=${EMMC_DEV_PATH} bs=512 seek=12288 | |
144 | + dd if=${SD_MOUNT_PATH_P1}/boot/${FNAME_FS128} of=${EMMC_DEV_PATH} bs=512 seek=28672 | |
145 | +# dd if=./$FNAME_FS64 of=$EMMC_DEV_PATH bs=512 seek=28672 | |
146 | + sleep 1 | |
147 | + sync | |
148 | +} | |
149 | + | |
150 | +function run_umount() | |
151 | +{ | |
152 | + echo "" | |
153 | + echo -e "${C_LRED}### UnMount - run_umount() ###${C_NC}" | |
154 | + echo "" | |
155 | + umount ${SD_MOUNT_PATH_P1} | |
156 | + umount ${EMMC_MOUNT_PATH_P1} | |
157 | + umount ${EMMC_MOUNT_PATH_P2} | |
158 | +} | |
159 | + | |
160 | + | |
161 | +function main() | |
162 | +{ | |
163 | + echo "" | |
164 | + echo -e "${C_LRED}#### Start - main() ####${C_NC}" | |
165 | + echo "" | |
166 | + | |
167 | + Init_Unmount | |
168 | + create_partition | |
169 | + run_format | |
170 | + run_mount | |
171 | + run_copy_image | |
172 | + run_raw_write | |
173 | + run_umount | |
174 | +} | |
175 | + | |
176 | +main | ... | ... |
scripts/mk-fusingsd.sh
... | ... | @@ -0,0 +1,151 @@ |
1 | +#!/bin/bash | |
2 | + | |
3 | +C_NC='\033[0m' | |
4 | +C_LRED='\033[1;31m' | |
5 | + | |
6 | +DEVNAME="mmcblk0" | |
7 | +DEV_PATH="/dev/mmcblk0" | |
8 | +DEV_PATH_P1="/dev/mmcblk0p1" | |
9 | +INPUT="/tmp/input" | |
10 | + | |
11 | +FNAME_UBOOT="u-boot.imx" | |
12 | +FNAME_LOGO="init.bmp" | |
13 | +FNAME_DTB="imx6s-prime-oven.dtb" | |
14 | +FNAME_KERNEL="uImage" | |
15 | +FNAME_FSCPIO="ramdisk-prime_oven.uboot" | |
16 | +#FNAME_FS128="ramdisk-prime_oven-128M.gz" | |
17 | +#FNAME_FS64="ramdisk-prime_oven-64M.gz" | |
18 | +FNAME_RFS="rootfs.tar" | |
19 | + | |
20 | +MOUNT_PATH_P1="/tmp/mmcblk0p1" | |
21 | + | |
22 | + | |
23 | +function create_partition() | |
24 | +{ | |
25 | + echo "" | |
26 | + echo -e "${C_LRED}### Fdisk Create Partition - create_partition() ###${C_NC}" | |
27 | + echo "" | |
28 | + fdisk $DEV_PATH << EOF | |
29 | + o | |
30 | + n | |
31 | + p | |
32 | + 1 | |
33 | + 262144 | |
34 | + 1310719 | |
35 | + n | |
36 | + p | |
37 | + 2 | |
38 | + 1310720 | |
39 | + | |
40 | + p | |
41 | + w | |
42 | +EOF | |
43 | +} | |
44 | + | |
45 | +function run_format() | |
46 | +{ | |
47 | + echo "" | |
48 | + echo -e "${C_LRED}### Format SDCARD - run_format() ###${C_NC}" | |
49 | + echo "" | |
50 | + mkfs.ext4 ${DEV_PATH}p1 -L BOOT0 | |
51 | + mkfs.ext4 ${DEV_PATH}p2 -L DATA | |
52 | +} | |
53 | + | |
54 | +function run_mount() | |
55 | +{ | |
56 | + echo "" | |
57 | + echo -e "${C_LRED}### Mount SD - run_mount() ###${C_NC}" | |
58 | + echo "" | |
59 | + if [ ! -d ${MOUNT_PATH_P1} ]; then | |
60 | + mkdir ${MOUNT_PATH_P1} | |
61 | + fi | |
62 | + | |
63 | + mount ${DEV_PATH}p1 ${MOUNT_PATH_P1} | |
64 | +} | |
65 | + | |
66 | +function run_umount() | |
67 | +{ | |
68 | + echo "" | |
69 | + echo -e "${C_LRED}### UnMount - run_umount() ###${C_NC}" | |
70 | + echo "" | |
71 | + umount ${MOUNT_PATH_P1} | |
72 | +} | |
73 | + | |
74 | +function run_copy_image() | |
75 | +{ | |
76 | + # SD Boot Image(SD 카드 부팅용 이미지) | |
77 | + echo "" | |
78 | + echo -e "${C_LRED}### Write SD Boot Image - run_copy_image() ###${C_NC}" | |
79 | + echo "" | |
80 | + if [ ! -d ${MOUNT_PATH_P1}/boot ]; then | |
81 | + mkdir ${MOUNT_PATH_P1}/boot | |
82 | + fi | |
83 | + cp -v ./$FNAME_UBOOT ${MOUNT_PATH_P1}/boot/ | |
84 | + cp -v ./$FNAME_LOGO ${MOUNT_PATH_P1}/boot/ | |
85 | + cp -v ./$FNAME_DTB ${MOUNT_PATH_P1}/boot/ | |
86 | + cp -v ./$FNAME_KERNEL ${MOUNT_PATH_P1}/boot/ | |
87 | + cp -v ./$FNAME_FSCPIO ${MOUNT_PATH_P1}/boot/ | |
88 | +# cp -v ./$FNAME_FS128 ${MOUNT_PATH_P1}/boot/ | |
89 | +# cp -v ./$FNAME_FS64 ${MOUNT_PATH_P1}/boot/ | |
90 | + cp -v ./$FNAME_RFS ${MOUNT_PATH_P1}/boot/ | |
91 | + sleep 1 | |
92 | + sync | |
93 | +} | |
94 | + | |
95 | +function run_raw_write() | |
96 | +{ | |
97 | + echo "" | |
98 | + echo -e "${C_LRED}### Write SD Boot Image to RAW - run_raw_write() ###${C_NC}" | |
99 | + echo "" | |
100 | + dd if=./$FNAME_UBOOT of=$DEV_PATH bs=512 seek=2 | |
101 | + dd if=./$FNAME_LOGO of=$DEV_PATH bs=512 seek=2048 | |
102 | + dd if=./$FNAME_DTB of=$DEV_PATH bs=512 seek=11264 | |
103 | + dd if=./$FNAME_KERNEL of=$DEV_PATH bs=512 seek=12288 | |
104 | + dd if=./$FNAME_FSCPIO of=$DEV_PATH bs=512 seek=28672 | |
105 | +# dd if=./$FNAME_FS128 of=$DEV_PATH bs=512 seek=28672 | |
106 | +# dd if=./$FNAME_FS64 of=$DEV_PATH bs=512 seek=28672 | |
107 | + sleep 1 | |
108 | + sync | |
109 | +} | |
110 | + | |
111 | +function Init_Unmount() | |
112 | +{ | |
113 | + echo "" | |
114 | + echo -e "${C_LRED}### Unmount SD - Init_Unmount() ###${C_NC}" | |
115 | + echo "" | |
116 | + umount $DEV_PATH_P1 | |
117 | +} | |
118 | + | |
119 | +function main() | |
120 | +{ | |
121 | + echo "" | |
122 | + echo -e "${C_LRED}#### Start - main() ####${C_NC}" | |
123 | + echo "" | |
124 | + Init_Unmount | |
125 | + create_partition | |
126 | + | |
127 | + run_format | |
128 | + run_mount | |
129 | + run_raw_write | |
130 | + run_copy_image | |
131 | + run_umount | |
132 | + sync | |
133 | +} | |
134 | + | |
135 | +if [ "$1" != "" ]; then | |
136 | + DEVNAME=$1 | |
137 | +fi | |
138 | + | |
139 | +DEV_PATH="/dev/${DEVNAME}" | |
140 | +DEV_PATH_P1="${DEV_PATH}p1" | |
141 | +MOUNT_PATH_P1="/tmp/${DEVNAME}p1" | |
142 | + | |
143 | +echo "" | |
144 | +echo "================================" | |
145 | +echo "DEV_Name: $DEVNAME" | |
146 | +echo "DEV_Path: $DEV_PATH" | |
147 | +echo "P1 MountPath: $MOUNT_PATH_P1" | |
148 | +echo "================================" | |
149 | +echo "" | |
150 | + | |
151 | +main | ... | ... |