Commit c32b3691391372430bef783569e5ba421618e572

Authored by Eric Lee
1 parent 5fe0cef331

Resolve build-essential dependency problem

Showing 1 changed file with 13 additions and 2 deletions Inline Diff

embedian/weston_rootfs.sh
1 # Must be called after make_prepare in main script 1 # Must be called after make_prepare in main script
2 # generate weston rootfs in input dir 2 # generate weston rootfs in input dir
3 # $1 - rootfs base dir 3 # $1 - rootfs base dir
4 function make_debian_weston_rootfs() 4 function make_debian_weston_rootfs()
5 { 5 {
6 local ROOTFS_BASE=$1 6 local ROOTFS_BASE=$1
7 7
8 pr_info "Make Debian (${DEB_RELEASE}) rootfs start..." 8 pr_info "Make Debian (${DEB_RELEASE}) rootfs start..."
9 9
10 # umount previus mounts (if fail) 10 # umount previus mounts (if fail)
11 umount ${ROOTFS_BASE}/{sys,proc,dev/pts,dev} 2>/dev/null || true 11 umount ${ROOTFS_BASE}/{sys,proc,dev/pts,dev} 2>/dev/null || true
12 12
13 # clear rootfs dir 13 # clear rootfs dir
14 rm -rf ${ROOTFS_BASE}/* 14 rm -rf ${ROOTFS_BASE}/*
15 15
16 pr_info "rootfs: debootstrap" 16 pr_info "rootfs: debootstrap"
17 debootstrap --verbose --no-check-gpg --foreign --arch arm64 ${DEB_RELEASE} \ 17 debootstrap --verbose --no-check-gpg --foreign --arch arm64 ${DEB_RELEASE} \
18 ${ROOTFS_BASE}/ ${PARAM_DEB_LOCAL_MIRROR} 18 ${ROOTFS_BASE}/ ${PARAM_DEB_LOCAL_MIRROR}
19 19
20 # prepare qemu 20 # prepare qemu
21 pr_info "rootfs: debootstrap in rootfs (second-stage)" 21 pr_info "rootfs: debootstrap in rootfs (second-stage)"
22 cp ${G_EMBEDIAN_PATH}/qemu_64bit/qemu-aarch64-static ${ROOTFS_BASE}/usr/bin/qemu-aarch64-static 22 cp ${G_EMBEDIAN_PATH}/qemu_64bit/qemu-aarch64-static ${ROOTFS_BASE}/usr/bin/qemu-aarch64-static
23 mount -o bind /proc ${ROOTFS_BASE}/proc 23 mount -o bind /proc ${ROOTFS_BASE}/proc
24 mount -o bind /dev ${ROOTFS_BASE}/dev 24 mount -o bind /dev ${ROOTFS_BASE}/dev
25 mount -o bind /dev/pts ${ROOTFS_BASE}/dev/pts 25 mount -o bind /dev/pts ${ROOTFS_BASE}/dev/pts
26 mount -o bind /sys ${ROOTFS_BASE}/sys 26 mount -o bind /sys ${ROOTFS_BASE}/sys
27 chroot $ROOTFS_BASE /debootstrap/debootstrap --second-stage 27 chroot $ROOTFS_BASE /debootstrap/debootstrap --second-stage
28 28
29 # delete unused folder 29 # delete unused folder
30 chroot $ROOTFS_BASE rm -rf ${ROOTFS_BASE}/debootstrap 30 chroot $ROOTFS_BASE rm -rf ${ROOTFS_BASE}/debootstrap
31 31
32 pr_info "rootfs: generate default configs" 32 pr_info "rootfs: generate default configs"
33 mkdir -p ${ROOTFS_BASE}/etc/sudoers.d/ 33 mkdir -p ${ROOTFS_BASE}/etc/sudoers.d/
34 echo "user ALL=(root) /usr/bin/apt-get, /usr/bin/dpkg, /usr/bin/vi, /sbin/reboot" > ${ROOTFS_BASE}/etc/sudoers.d/user 34 echo "user ALL=(root) /usr/bin/apt-get, /usr/bin/dpkg, /usr/bin/vi, /sbin/reboot" > ${ROOTFS_BASE}/etc/sudoers.d/user
35 chmod 0440 ${ROOTFS_BASE}/etc/sudoers.d/user 35 chmod 0440 ${ROOTFS_BASE}/etc/sudoers.d/user
36 mkdir -p ${ROOTFS_BASE}/srv/local-apt-repository 36 mkdir -p ${ROOTFS_BASE}/srv/local-apt-repository
37 37
38 # imx-firmware 38 # imx-firmware
39 cp -r ${G_EMBEDIAN_PATH}/deb/imx-firmware-${IMX_FIRMWARE_VERSION}/* \ 39 cp -r ${G_EMBEDIAN_PATH}/deb/imx-firmware-${IMX_FIRMWARE_VERSION}/* \
40 ${ROOTFS_BASE}/srv/local-apt-repository 40 ${ROOTFS_BASE}/srv/local-apt-repository
41 41
42 # cairo 42 # cairo
43 cp -r ${G_EMBEDIAN_PATH}/deb/cairo/* \ 43 cp -r ${G_EMBEDIAN_PATH}/deb/cairo/* \
44 ${ROOTFS_BASE}/srv/local-apt-repository 44 ${ROOTFS_BASE}/srv/local-apt-repository
45 45
46 # libdrm 46 # libdrm
47 cp -r ${G_EMBEDIAN_PATH}/deb/libdrm/* \ 47 cp -r ${G_EMBEDIAN_PATH}/deb/libdrm/* \
48 ${ROOTFS_BASE}/srv/local-apt-repository 48 ${ROOTFS_BASE}/srv/local-apt-repository
49 49
50 # waylandprotocols 50 # waylandprotocols
51 cp -r ${G_EMBEDIAN_PATH}/deb/waylandprotocols/* \ 51 cp -r ${G_EMBEDIAN_PATH}/deb/waylandprotocols/* \
52 ${ROOTFS_BASE}/srv/local-apt-repository 52 ${ROOTFS_BASE}/srv/local-apt-repository
53 53
54 # Vivante GPU libraries 54 # Vivante GPU libraries
55 if [ ! -z "${G_GPU_IMX_VIV_PACKAGE_DIR}" ]; then 55 if [ ! -z "${G_GPU_IMX_VIV_PACKAGE_DIR}" ]; then
56 cp -r ${G_EMBEDIAN_PATH}/deb/${G_GPU_IMX_VIV_PACKAGE_DIR}/* \ 56 cp -r ${G_EMBEDIAN_PATH}/deb/${G_GPU_IMX_VIV_PACKAGE_DIR}/* \
57 ${ROOTFS_BASE}/srv/local-apt-repository 57 ${ROOTFS_BASE}/srv/local-apt-repository
58 fi 58 fi
59 # Vivante GPU SDK Binaries 59 # Vivante GPU SDK Binaries
60 if [ ! -z "${G_GPU_IMX_VIV_SDK_PACKAGE_DIR}" ]; then 60 if [ ! -z "${G_GPU_IMX_VIV_SDK_PACKAGE_DIR}" ]; then
61 cp -r ${G_EMBEDIAN_PATH}/deb/${G_GPU_IMX_VIV_SDK_PACKAGE_DIR}/* \ 61 cp -r ${G_EMBEDIAN_PATH}/deb/${G_GPU_IMX_VIV_SDK_PACKAGE_DIR}/* \
62 ${ROOTFS_BASE}/srv/local-apt-repository 62 ${ROOTFS_BASE}/srv/local-apt-repository
63 fi 63 fi
64 64
65 # imxcodec 65 # imxcodec
66 if [ ! -z "${G_IMX_CODEC_DIR}" ]; then 66 if [ ! -z "${G_IMX_CODEC_DIR}" ]; then
67 cp -r ${G_EMBEDIAN_PATH}/deb/${G_IMX_CODEC_DIR}/* \ 67 cp -r ${G_EMBEDIAN_PATH}/deb/${G_IMX_CODEC_DIR}/* \
68 ${ROOTFS_BASE}/srv/local-apt-repository 68 ${ROOTFS_BASE}/srv/local-apt-repository
69 fi 69 fi
70 70
71 # imxparser 71 # imxparser
72 if [ ! -z "${G_IMX_PARSER_DIR}" ]; then 72 if [ ! -z "${G_IMX_PARSER_DIR}" ]; then
73 cp -r ${G_EMBEDIAN_PATH}/deb/${G_IMX_PARSER_DIR}/* \ 73 cp -r ${G_EMBEDIAN_PATH}/deb/${G_IMX_PARSER_DIR}/* \
74 ${ROOTFS_BASE}/srv/local-apt-repository 74 ${ROOTFS_BASE}/srv/local-apt-repository
75 fi 75 fi
76 76
77 # imxvpuhantro 77 # imxvpuhantro
78 if [ ! -z "${G_IMX_VPU_HANTRO_DIR}" ]; then 78 if [ ! -z "${G_IMX_VPU_HANTRO_DIR}" ]; then
79 cp -r ${G_EMBEDIAN_PATH}/deb/${G_IMX_VPU_HANTRO_DIR}/* \ 79 cp -r ${G_EMBEDIAN_PATH}/deb/${G_IMX_VPU_HANTRO_DIR}/* \
80 ${ROOTFS_BASE}/srv/local-apt-repository 80 ${ROOTFS_BASE}/srv/local-apt-repository
81 fi 81 fi
82 82
83 # gstpluginsbad 83 # gstpluginsbad
84 cp -r ${G_EMBEDIAN_PATH}/deb/gstpluginsbad/${GST_MM_VERSION}/* \ 84 cp -r ${G_EMBEDIAN_PATH}/deb/gstpluginsbad/${GST_MM_VERSION}/* \
85 ${ROOTFS_BASE}/srv/local-apt-repository 85 ${ROOTFS_BASE}/srv/local-apt-repository
86 86
87 # gstpluginsbase 87 # gstpluginsbase
88 cp -r ${G_EMBEDIAN_PATH}/deb/gstpluginsbase/${GST_MM_VERSION}/* \ 88 cp -r ${G_EMBEDIAN_PATH}/deb/gstpluginsbase/${GST_MM_VERSION}/* \
89 ${ROOTFS_BASE}/srv/local-apt-repository 89 ${ROOTFS_BASE}/srv/local-apt-repository
90 90
91 # gstpluginsgood 91 # gstpluginsgood
92 cp -r ${G_EMBEDIAN_PATH}/deb/gstpluginsgood/${GST_MM_VERSION}/* \ 92 cp -r ${G_EMBEDIAN_PATH}/deb/gstpluginsgood/${GST_MM_VERSION}/* \
93 ${ROOTFS_BASE}/srv/local-apt-repository 93 ${ROOTFS_BASE}/srv/local-apt-repository
94 94
95 # gstreamer 95 # gstreamer
96 cp -r ${G_EMBEDIAN_PATH}/deb/gstreamer/${GST_MM_VERSION}/* \ 96 cp -r ${G_EMBEDIAN_PATH}/deb/gstreamer/${GST_MM_VERSION}/* \
97 ${ROOTFS_BASE}/srv/local-apt-repository 97 ${ROOTFS_BASE}/srv/local-apt-repository
98 98
99 # imx-vpuwrap 99 # imx-vpuwrap
100 if [ ! -z "${G_IMX_VPU_WRAPPER_DIR}" ]; then 100 if [ ! -z "${G_IMX_VPU_WRAPPER_DIR}" ]; then
101 cp -r ${G_EMBEDIAN_PATH}/deb/${G_IMX_VPU_WRAPPER_DIR}/* \ 101 cp -r ${G_EMBEDIAN_PATH}/deb/${G_IMX_VPU_WRAPPER_DIR}/* \
102 ${ROOTFS_BASE}/srv/local-apt-repository 102 ${ROOTFS_BASE}/srv/local-apt-repository
103 fi 103 fi
104 104
105 # imxgstplugin 105 # imxgstplugin
106 cp -r ${G_EMBEDIAN_PATH}/deb/imxgstplugin/${GST_MM_VERSION}/* \ 106 cp -r ${G_EMBEDIAN_PATH}/deb/imxgstplugin/${GST_MM_VERSION}/* \
107 ${ROOTFS_BASE}/srv/local-apt-repository 107 ${ROOTFS_BASE}/srv/local-apt-repository
108 108
109 # weston 109 # weston
110 cp -r ${G_EMBEDIAN_PATH}/deb/weston/${WESTON_PACKAGE_DIR}/* \ 110 cp -r ${G_EMBEDIAN_PATH}/deb/weston/${WESTON_PACKAGE_DIR}/* \
111 ${ROOTFS_BASE}/srv/local-apt-repository 111 ${ROOTFS_BASE}/srv/local-apt-repository
112 112
113 # opencv 113 # opencv
114 if [ ! -z "${G_OPENCV_DIR}" ]; then 114 if [ ! -z "${G_OPENCV_DIR}" ]; then
115 cp -r ${G_EMBEDIAN_PATH}/deb/${G_OPENCV_DIR}/* \ 115 cp -r ${G_EMBEDIAN_PATH}/deb/${G_OPENCV_DIR}/* \
116 ${ROOTFS_BASE}/srv/local-apt-repository 116 ${ROOTFS_BASE}/srv/local-apt-repository
117 fi 117 fi
118 118
119 # add mirror to source list 119 # add mirror to source list
120 echo "deb ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE} main contrib non-free 120 echo "deb ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE} main contrib non-free
121 deb-src ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE} main contrib non-free 121 deb-src ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE} main contrib non-free
122 deb ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE}-backports main contrib non-free 122 deb ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE}-backports main contrib non-free
123 deb-src ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE}-backports main contrib non-free 123 deb-src ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE}-backports main contrib non-free
124 deb ${DEF_DEBIAN_MIRROR} testing main contrib non-free 124 deb ${DEF_DEBIAN_MIRROR} testing main contrib non-free
125 deb-src ${DEF_DEBIAN_MIRROR} testing main contrib non-free 125 deb-src ${DEF_DEBIAN_MIRROR} testing main contrib non-free
126 " > etc/apt/sources.list 126 " > etc/apt/sources.list
127 127
128 # maximize local repo priority 128 # maximize local repo priority
129 echo "Package: * 129 echo "Package: *
130 Pin: origin "" 130 Pin: origin ""
131 Pin-Priority: 1000 131 Pin-Priority: 1000
132 " > etc/apt/preferences.d/local 132 " > etc/apt/preferences.d/local
133 133
134 # raise backports priority 134 # raise backports priority
135 echo "Package: * 135 echo "Package: *
136 Pin: release n=${DEB_RELEASE}-backports 136 Pin: release n=${DEB_RELEASE}-backports
137 Pin-Priority: 600 137 Pin-Priority: 600
138 " > etc/apt/preferences.d/backports 138 " > etc/apt/preferences.d/backports
139 139
140 echo " 140 echo "
141 # /dev/mmcblk0p1 /boot vfat defaults 0 0 141 # /dev/mmcblk0p1 /boot vfat defaults 0 0
142 " > etc/fstab 142 " > etc/fstab
143 143
144 echo "${MACHINE}" > etc/hostname 144 echo "${MACHINE}" > etc/hostname
145 145
146 echo "auto lo 146 echo "auto lo
147 iface lo inet loopback 147 iface lo inet loopback
148 " > etc/network/interfaces 148 " > etc/network/interfaces
149 149
150 echo " 150 echo "
151 locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8 151 locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8
152 locales locales/default_environment_locale select en_US.UTF-8 152 locales locales/default_environment_locale select en_US.UTF-8
153 console-common console-data/keymap/policy select Select keymap from full list 153 console-common console-data/keymap/policy select Select keymap from full list
154 keyboard-configuration keyboard-configuration/variant select 'English (US)' 154 keyboard-configuration keyboard-configuration/variant select 'English (US)'
155 openssh-server openssh-server/permit-root-login select true 155 openssh-server openssh-server/permit-root-login select true
156 " > debconf.set 156 " > debconf.set
157 157
158 pr_info "rootfs: prepare install packages in rootfs" 158 pr_info "rootfs: prepare install packages in rootfs"
159 # apt-get install without starting 159 # apt-get install without starting
160 cat > ${ROOTFS_BASE}/usr/sbin/policy-rc.d << EOF 160 cat > ${ROOTFS_BASE}/usr/sbin/policy-rc.d << EOF
161 #!/bin/sh 161 #!/bin/sh
162 exit 101 162 exit 101
163 EOF 163 EOF
164 164
165 chmod +x ${ROOTFS_BASE}/usr/sbin/policy-rc.d 165 chmod +x ${ROOTFS_BASE}/usr/sbin/policy-rc.d
166 166
167 # third packages stage 167 # third packages stage
168 cat > third-stage << EOF 168 cat > third-stage << EOF
169 #!/bin/bash 169 #!/bin/bash
170 # apply debconfig options 170 # apply debconfig options
171 debconf-set-selections /debconf.set 171 debconf-set-selections /debconf.set
172 rm -f /debconf.set 172 rm -f /debconf.set
173 173
174 function protected_install() 174 function protected_install()
175 { 175 {
176 local _name=\${1} 176 local _name=\${1}
177 local repeated_cnt=5; 177 local repeated_cnt=5;
178 local RET_CODE=1; 178 local RET_CODE=1;
179 179
180 echo Installing \${_name} 180 echo Installing \${_name}
181 for (( c=0; c<\${repeated_cnt}; c++ )) 181 for (( c=0; c<\${repeated_cnt}; c++ ))
182 do 182 do
183 apt install -y \${_name} && { 183 apt install -y \${_name} && {
184 RET_CODE=0; 184 RET_CODE=0;
185 break; 185 break;
186 }; 186 };
187 187
188 echo 188 echo
189 echo "##########################" 189 echo "##########################"
190 echo "## Fix missing packages ##" 190 echo "## Fix missing packages ##"
191 echo "##########################" 191 echo "##########################"
192 echo 192 echo
193 193
194 sleep 2; 194 sleep 2;
195 195
196 apt --fix-broken install -y && { 196 apt --fix-broken install -y && {
197 RET_CODE=0; 197 RET_CODE=0;
198 break; 198 break;
199 }; 199 };
200 done 200 done
201 201
202 return \${RET_CODE} 202 return \${RET_CODE}
203 } 203 }
204 204
205 # update packages and install base 205 # update packages and install base
206 apt-get update || apt-get upgrade 206 apt-get update || apt-get upgrade
207 207
208 # local-apt-repository support 208 # local-apt-repository support
209 protected_install local-apt-repository 209 protected_install local-apt-repository
210 210
211 # update packages and install base 211 # update packages and install base
212 apt-get update || apt-get upgrade 212 apt-get update || apt-get upgrade
213 213
214 # libc6 >=2.29 by Vivnate GPU drivers 214 # libc6 >=2.29 by Vivnate GPU drivers
215 protected_install libc6/testing 215 protected_install libc6/testing
216 216
217 # maximize local repo priority 217 # maximize local repo priority
218 echo "Package: * 218 echo "Package: *
219 Pin: origin "" 219 Pin: origin ""
220 Pin-Priority: 1000 220 Pin-Priority: 1000
221 " > etc/apt/preferences.d/local 221 " > etc/apt/preferences.d/local
222 222
223 echo "Package: * 223 echo "Package: *
224 Pin: release n=${DEB_RELEASE} 224 Pin: release n=${DEB_RELEASE}
225 Pin-Priority: 990 225 Pin-Priority: 990
226 " > etc/apt/preferences.d/buster 226 " > etc/apt/preferences.d/buster
227 # raise backports priority 227 # raise backports priority
228 echo "Package: * 228 echo "Package: *
229 Pin: release n=${DEB_RELEASE}-backports 229 Pin: release n=${DEB_RELEASE}-backports
230 Pin-Priority: 500 230 Pin-Priority: 500
231 " > etc/apt/preferences.d/backports 231 " > etc/apt/preferences.d/backports
232 232
233 # raise backports priority 233 # raise backports priority
234 echo "Package: * 234 echo "Package: *
235 Pin: release n=testing 235 Pin: release n=testing
236 Pin-Priority: 90 236 Pin-Priority: 90
237 " > etc/apt/preferences.d/testing 237 " > etc/apt/preferences.d/testing
238 238
239 # update packages and install base 239 # update packages and install base
240 apt-get update 240 apt-get update
241 241
242 protected_install libc6-dev/testing 242 protected_install libc6-dev/testing
243 protected_install locales 243 protected_install locales
244 protected_install ntp 244 protected_install ntp
245 protected_install openssh-server 245 protected_install openssh-server
246 protected_install nfs-common 246 protected_install nfs-common
247 247
248 # packages required when flashing emmc 248 # packages required when flashing emmc
249 protected_install dosfstools 249 protected_install dosfstools
250 250
251 # fix config for sshd (permit root login) 251 # fix config for sshd (permit root login)
252 sed -i -e 's/#PermitRootLogin.*/PermitRootLogin\tyes/g' /etc/ssh/sshd_config 252 sed -i -e 's/#PermitRootLogin.*/PermitRootLogin\tyes/g' /etc/ssh/sshd_config
253 253
254 # net-tools (ifconfig, etc.) 254 # net-tools (ifconfig, etc.)
255 protected_install net-tools 255 protected_install net-tools
256 protected_install network-manager 256 protected_install network-manager
257 257
258 # sdma package 258 # sdma package
259 protected_install imx-firmware-sdma 259 protected_install imx-firmware-sdma
260 260
261 # VPU package 261 # VPU package
262 protected_install imx-firmware-vpu 262 protected_install imx-firmware-vpu
263 263
264 # epdc package 264 # epdc package
265 protected_install imx-firmware-epdc 265 protected_install imx-firmware-epdc
266 266
267 # graphical packages 267 # graphical packages
268 protected_install libdrm-vivante1 268 protected_install libdrm-vivante1
269 protected_install imx-gpu-viv-core 269 protected_install imx-gpu-viv-core
270 protected_install dpkg-dev 270 protected_install dpkg-dev
271 protected_install imx-gpu-viv-wl 271 protected_install imx-gpu-viv-wl
272 272
273 # GPU SDK 273 # GPU SDK
274 if [ ! -z "${G_GPU_IMX_VIV_SDK_PACKAGE_DIR}" ] 274 if [ ! -z "${G_GPU_IMX_VIV_SDK_PACKAGE_DIR}" ]
275 then 275 then
276 protected_install libwayland-egl-backend-dev/buster 276 protected_install libwayland-egl-backend-dev/buster
277 protected_install glslang-tools/buster 277 protected_install glslang-tools/buster
278 protected_install libtiff-dev/buster 278 protected_install libtiff-dev/buster
279 protected_install libdevil-dev/buster 279 protected_install libdevil-dev/buster
280 protected_install libassimp-dev/buster 280 protected_install libassimp-dev/buster
281 protected_install imx-gpu-sdk-console 281 protected_install imx-gpu-sdk-console
282 protected_install imx-gpu-sdk-gles2 282 protected_install imx-gpu-sdk-gles2
283 protected_install imx-gpu-sdk-gles3 283 protected_install imx-gpu-sdk-gles3
284 protected_install imx-gpu-sdk-opencl 284 protected_install imx-gpu-sdk-opencl
285 protected_install imx-gpu-sdk-window 285 protected_install imx-gpu-sdk-window
286 fi 286 fi
287 287
288 protected_install weston 288 protected_install weston
289 289
290 # alsa & gstreamer 290 # alsa & gstreamer
291 protected_install alsa-utils 291 protected_install alsa-utils
292 protected_install gstreamer1.0-alsa 292 protected_install gstreamer1.0-alsa
293 protected_install gstreamer1.0-plugins-bad 293 protected_install gstreamer1.0-plugins-bad
294 protected_install gstreamer1.0-plugins-base 294 protected_install gstreamer1.0-plugins-base
295 protected_install gstreamer1.0-plugins-base-apps 295 protected_install gstreamer1.0-plugins-base-apps
296 protected_install gstreamer1.0-plugins-ugly 296 protected_install gstreamer1.0-plugins-ugly
297 protected_install gstreamer1.0-plugins-good 297 protected_install gstreamer1.0-plugins-good
298 protected_install gstreamer1.0-tools 298 protected_install gstreamer1.0-tools
299 protected_install ${IMXGSTPLG} 299 protected_install ${IMXGSTPLG}
300 300
301 # i2c tools 301 # i2c tools
302 protected_install i2c-tools 302 protected_install i2c-tools
303 303
304 # usb tools 304 # usb tools
305 protected_install usbutils 305 protected_install usbutils
306 306
307 # net tools 307 # net tools
308 protected_install iperf 308 protected_install iperf
309 309
310 protected_install rng-tools 310 protected_install rng-tools
311 311
312 # mtd 312 # mtd
313 protected_install mtd-utils 313 protected_install mtd-utils
314 314
315 # bluetooth 315 # bluetooth
316 protected_install bluetooth 316 protected_install bluetooth
317 protected_install bluez-obexd 317 protected_install bluez-obexd
318 protected_install bluez-tools 318 protected_install bluez-tools
319 protected_install blueman 319 protected_install blueman
320 protected_install gconf2 320 protected_install gconf2
321 321
322 # wifi support packages 322 # wifi support packages
323 protected_install hostapd 323 protected_install hostapd
324 protected_install udhcpd 324 protected_install udhcpd
325 325
326 # disable the hostapd service by default 326 # disable the hostapd service by default
327 systemctl disable hostapd.service 327 systemctl disable hostapd.service
328 328
329 # can support 329 # can support
330 protected_install can-utils 330 protected_install can-utils
331 331
332 # pmount 332 # pmount
333 protected_install pmount 333 protected_install pmount
334 334
335 # pm-utils 335 # pm-utils
336 protected_install pm-utils 336 protected_install pm-utils
337 337
338 # build-essential (Fix dependendy issue)
339 protected_install libgcc/testing
340 protected_install gcc-9/testing
341 protected_install gcc/testing
342 protected_install libc6-dev/testing
343 protected_install libstdc++-9-dev/testing
344 protected_install g++-9/testing
345 protected_install g++/testing
346 protected_install build-essential/testing
347
338 apt-get -y autoremove 348 apt-get -y autoremove
339 349
340 #update iptables alternatives to legacy 350 #update iptables alternatives to legacy
341 update-alternatives --set iptables /usr/sbin/iptables-legacy 351 update-alternatives --set iptables /usr/sbin/iptables-legacy
342 update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy 352 update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
343 353
344 #install usleep busybox applet 354 #install usleep busybox applet
345 ln -sf /bin/busybox /bin/usleep 355 ln -sf /bin/busybox /bin/usleep
346 356
347 # create users and set password 357 # create users and set password
348 useradd -m -G audio -s /bin/bash user 358 useradd -m -G audio -s /bin/bash user
349 usermod -a -G video user 359 usermod -a -G video user
350 echo "user:user" | chpasswd 360 echo "user:user" | chpasswd
351 echo "root:root" | chpasswd 361 echo "root:root" | chpasswd
352 362
353 # sado kill 363 # sado kill
354 rm -f third-stage 364 rm -f third-stage
355 EOF 365 EOF
356 366
357 pr_info "rootfs: install selected Debian packages (third-stage)" 367 pr_info "rootfs: install selected Debian packages (third-stage)"
358 chmod +x third-stage 368 chmod +x third-stage
359 chroot ${ROOTFS_BASE} /third-stage 369 chroot ${ROOTFS_BASE} /third-stage
360 370
361 # fourth-stage 371 # fourth-stage
362 #install securetty 372 #install securetty
363 install -m 0644 ${G_EMBEDIAN_PATH}/securetty \ 373 install -m 0644 ${G_EMBEDIAN_PATH}/securetty \
364 ${ROOTFS_BASE}/etc/securetty 374 ${ROOTFS_BASE}/etc/securetty
365 375
366 # install weston service 376 # install weston service
367 install -d ${ROOTFS_BASE}/etc/xdg/weston 377 install -d ${ROOTFS_BASE}/etc/xdg/weston
368 if [ "${MACHINE}" = "smarcimx8m2g" ] || \ 378 if [ "${MACHINE}" = "smarcimx8m2g" ] || \
369 [ "${MACHINE}" = "smarcimx8m4g" ]; then 379 [ "${MACHINE}" = "smarcimx8m4g" ]; then
370 install -m 0644 ${G_EMBEDIAN_PATH}/smarcimx8mq/weston.ini \ 380 install -m 0644 ${G_EMBEDIAN_PATH}/smarcimx8mq/weston.ini \
371 ${ROOTFS_BASE}/etc/xdg/weston 381 ${ROOTFS_BASE}/etc/xdg/weston
372 install -m 0755 ${G_EMBEDIAN_PATH}/smarcimx8mq/weston.config \ 382 install -m 0755 ${G_EMBEDIAN_PATH}/smarcimx8mq/weston.config \
373 ${ROOTFS_BASE}/etc/default/weston 383 ${ROOTFS_BASE}/etc/default/weston
374 fi 384 fi
375 install -m 0755 ${G_EMBEDIAN_PATH}/weston-start \ 385 install -m 0755 ${G_EMBEDIAN_PATH}/weston-start \
376 ${ROOTFS_BASE}/usr/bin/weston-start 386 ${ROOTFS_BASE}/usr/bin/weston-start
377 install -m 0755 ${G_EMBEDIAN_PATH}/weston.profile \ 387 install -m 0755 ${G_EMBEDIAN_PATH}/weston.profile \
378 ${ROOTFS_BASE}/etc/profile.d/weston.sh 388 ${ROOTFS_BASE}/etc/profile.d/weston.sh
379 install -m 0644 ${G_EMBEDIAN_PATH}/weston.service \ 389 install -m 0644 ${G_EMBEDIAN_PATH}/weston.service \
380 ${ROOTFS_BASE}/lib/systemd/system 390 ${ROOTFS_BASE}/lib/systemd/system
381 ln -s /lib/systemd/system/weston.service \ 391 ln -s /lib/systemd/system/weston.service \
382 ${ROOTFS_BASE}/etc/systemd/system/multi-user.target.wants/weston.service 392 ${ROOTFS_BASE}/etc/systemd/system/multi-user.target.wants/weston.service
383 393
384 # remove pm-utils default scripts 394 # remove pm-utils default scripts
385 rm -rf ${ROOTFS_BASE}/usr/lib/pm-utils/sleep.d/ 395 rm -rf ${ROOTFS_BASE}/usr/lib/pm-utils/sleep.d/
386 rm -rf ${ROOTFS_BASE}/usr/lib/pm-utils/module.d/ 396 rm -rf ${ROOTFS_BASE}/usr/lib/pm-utils/module.d/
387 rm -rf ${ROOTFS_BASE}/usr/lib/pm-utils/power.d/ 397 rm -rf ${ROOTFS_BASE}/usr/lib/pm-utils/power.d/
388 398
389 ## end packages stage ## 399 ## end packages stage ##
390 if [ "${G_USER_PACKAGES}" != "" ] ; then 400 if [ "${G_USER_PACKAGES}" != "" ] ; then
391 pr_info "rootfs: install user defined packages (user-stage)" 401 pr_info "rootfs: install user defined packages (user-stage)"
392 pr_info "rootfs: G_USER_PACKAGES \"${G_USER_PACKAGES}\" " 402 pr_info "rootfs: G_USER_PACKAGES \"${G_USER_PACKAGES}\" "
393 403
394 echo "#!/bin/bash 404 echo "#!/bin/bash
395 # update packages 405 # update packages
396 apt-get update 406 apt-get update
397 apt-get upgrade 407 apt-get upgrade
398 408
399 # install all user packages 409 # install all user packages
400 apt-get -y install ${G_USER_PACKAGES} 410 apt-get -y install ${G_USER_PACKAGES}
401 411
402 rm -f user-stage 412 rm -f user-stage
403 " > user-stage 413 " > user-stage
404 414
405 chmod +x user-stage 415 chmod +x user-stage
406 chroot ${ROOTFS_BASE} /user-stage 416 chroot ${ROOTFS_BASE} /user-stage
407 fi 417 fi
408 418
409 # binaries rootfs patching 419 # binaries rootfs patching
410 install -m 0644 ${G_EMBEDIAN_PATH}/issue ${ROOTFS_BASE}/etc/ 420 install -m 0644 ${G_EMBEDIAN_PATH}/issue ${ROOTFS_BASE}/etc/
411 install -m 0644 ${G_EMBEDIAN_PATH}/issue.net ${ROOTFS_BASE}/etc/ 421 install -m 0644 ${G_EMBEDIAN_PATH}/issue.net ${ROOTFS_BASE}/etc/
412 install -m 0755 ${G_EMBEDIAN_PATH}/rc.local ${ROOTFS_BASE}/etc/ 422 install -m 0755 ${G_EMBEDIAN_PATH}/rc.local ${ROOTFS_BASE}/etc/
413 install -d ${ROOTFS_BASE}/boot/ 423 install -d ${ROOTFS_BASE}/boot/
414 install -m 0644 ${G_EMBEDIAN_PATH}/splash.bmp ${ROOTFS_BASE}/boot/ 424 install -m 0644 ${G_EMBEDIAN_PATH}/splash.bmp ${ROOTFS_BASE}/boot/
415 cp ${PARAM_OUTPUT_DIR}/Image ${ROOTFS_BASE}/boot 425 cp ${PARAM_OUTPUT_DIR}/Image ${ROOTFS_BASE}/boot
416 cp ${PARAM_OUTPUT_DIR}/*.dtb ${ROOTFS_BASE}/boot 426 cp ${PARAM_OUTPUT_DIR}/*.dtb ${ROOTFS_BASE}/boot
417 if [ "$DEFAULT_BOOT_DTB" != "$BOOT_DTB" ]; then 427 if [ "$DEFAULT_BOOT_DTB" != "$BOOT_DTB" ]; then
418 ln -sf ${DEFAULT_BOOT_DTB} ${ROOTFS_BASE}/boot/${BOOT_DTB} 428 ln -sf ${DEFAULT_BOOT_DTB} ${ROOTFS_BASE}/boot/${BOOT_DTB}
419 fi 429 fi
420 430
421 mkdir -p ${ROOTFS_BASE}/usr/share/images/desktop-base/ 431 mkdir -p ${ROOTFS_BASE}/usr/share/images/desktop-base/
422 install -m 0644 ${G_EMBEDIAN_PATH}/wallpaper_hd.png \ 432 install -m 0644 ${G_EMBEDIAN_PATH}/wallpaper_hd.png \
423 ${ROOTFS_BASE}/usr/share/images/desktop-base/default 433 ${ROOTFS_BASE}/usr/share/images/desktop-base/default
424 434
425 # Add alsa default configs 435 # Add alsa default configs
426 install -m 0644 ${G_EMBEDIAN_PATH}/asound.state \ 436 install -m 0644 ${G_EMBEDIAN_PATH}/asound.state \
427 ${ROOTFS_BASE}/var/lib/alsa/ 437 ${ROOTFS_BASE}/var/lib/alsa/
428 install -m 0644 ${G_EMBEDIAN_PATH}/asound.conf ${ROOTFS_BASE}/etc/ 438 install -m 0644 ${G_EMBEDIAN_PATH}/asound.conf ${ROOTFS_BASE}/etc/
429 439
430 # Revert regular booting 440 # Revert regular booting
431 rm -f ${ROOTFS_BASE}/usr/sbin/policy-rc.d 441 rm -f ${ROOTFS_BASE}/usr/sbin/policy-rc.d
432 442
433 # install kernel modules in rootfs 443 # install kernel modules in rootfs
434 install_kernel_modules \ 444 install_kernel_modules \
435 ${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} \ 445 ${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} \
436 ${G_LINUX_KERNEL_DEF_CONFIG} ${G_LINUX_KERNEL_SRC_DIR} \ 446 ${G_LINUX_KERNEL_DEF_CONFIG} ${G_LINUX_KERNEL_SRC_DIR} \
437 ${ROOTFS_BASE} 447 ${ROOTFS_BASE}
438 448
439 # copy all kernel headers for development 449 # copy all kernel headers for development
440 mkdir -p ${ROOTFS_BASE}/usr/local/src/linux-imx/drivers/staging/android/uapi 450 mkdir -p ${ROOTFS_BASE}/usr/local/src/linux-imx/drivers/staging/android/uapi
441 cp ${G_LINUX_KERNEL_SRC_DIR}/drivers/staging/android/uapi/* \ 451 cp ${G_LINUX_KERNEL_SRC_DIR}/drivers/staging/android/uapi/* \
442 ${ROOTFS_BASE}/usr/local/src/linux-imx/drivers/staging/android/uapi 452 ${ROOTFS_BASE}/usr/local/src/linux-imx/drivers/staging/android/uapi
443 cp -r ${G_LINUX_KERNEL_SRC_DIR}/include \ 453 cp -r ${G_LINUX_KERNEL_SRC_DIR}/include \
444 ${ROOTFS_BASE}/usr/local/src/linux-imx/ 454 ${ROOTFS_BASE}/usr/local/src/linux-imx/
445 455
446 # copy custom files 456 # copy custom files
447 cp ${G_EMBEDIAN_PATH}/10-imx.rules ${ROOTFS_BASE}/etc/udev/rules.d 457 cp ${G_EMBEDIAN_PATH}/10-imx.rules ${ROOTFS_BASE}/etc/udev/rules.d
448 cp ${G_EMBEDIAN_PATH}/mount.blacklist ${ROOTFS_BASE}/etc/udev/rules.d 458 cp ${G_EMBEDIAN_PATH}/mount.blacklist ${ROOTFS_BASE}/etc/udev/rules.d
449 cp ${G_EMBEDIAN_PATH}/automount.rules ${ROOTFS_BASE}/etc/udev/rules.d 459 cp ${G_EMBEDIAN_PATH}/automount.rules ${ROOTFS_BASE}/etc/udev/rules.d
450 mkdir -p ${ROOTFS_BASE}/etc/udev/scripts/ 460 mkdir -p ${ROOTFS_BASE}/etc/udev/scripts/
451 install -m 0755 ${G_EMBEDIAN_PATH}/mount.sh \ 461 install -m 0755 ${G_EMBEDIAN_PATH}/mount.sh \
452 ${ROOTFS_BASE}/etc/udev/scripts/mount.sh 462 ${ROOTFS_BASE}/etc/udev/scripts/mount.sh
453 463
454 if [ "${MACHINE}" = "smarcimx8m2g" ] || \ 464 if [ "${MACHINE}" = "smarcimx8m2g" ] || \
455 [ "${MACHINE}" = "smarcimx8m4g" ]; then 465 [ "${MACHINE}" = "smarcimx8m4g" ]; then
456 cp ${G_EMBEDIAN_PATH}/smarcimx8mq/*.rules ${ROOTFS_BASE}/etc/udev/rules.d 466 cp ${G_EMBEDIAN_PATH}/smarcimx8mq/*.rules ${ROOTFS_BASE}/etc/udev/rules.d
457 fi 467 fi
458 468
459 ## clenup command 469 ## clenup command
460 echo "#!/bin/bash 470 echo "#!/bin/bash
461 apt-get clean 471 apt-get clean
462 rm -f cleanup 472 rm -f cleanup
463 " > cleanup 473 " > cleanup
464 474
465 # clean all packages 475 # clean all packages
466 pr_info "rootfs: clean" 476 pr_info "rootfs: clean"
467 chmod +x cleanup 477 chmod +x cleanup
468 chroot ${ROOTFS_BASE} /cleanup 478 chroot ${ROOTFS_BASE} /cleanup
469 umount ${ROOTFS_BASE}/{sys,proc,dev/pts,dev} 2>/dev/null || true 479 umount ${ROOTFS_BASE}/{sys,proc,dev/pts,dev} 2>/dev/null || true
470 480
471 # kill latest dbus-daemon instance due to qemu-aarch64-static 481 # kill latest dbus-daemon instance due to qemu-aarch64-static
472 QEMU_PROC_ID=$(ps axf | grep dbus-daemon | grep qemu-aarch64-static | awk '{print $1}') 482 QEMU_PROC_ID=$(ps axf | grep dbus-daemon | grep qemu-aarch64-static | awk '{print $1}')
473 if [ -n "$QEMU_PROC_ID" ] 483 if [ -n "$QEMU_PROC_ID" ]
474 then 484 then
475 kill -9 $QEMU_PROC_ID 485 kill -9 $QEMU_PROC_ID
476 fi 486 fi
477 487
478 rm -f ${ROOTFS_BASE}/usr/bin/qemu-aarch64-static 488 rm -f ${ROOTFS_BASE}/usr/bin/qemu-aarch64-static
479 } 489 }
480 490
481 # make SD card for device 491 # make SD card for device
482 # $1 -- block device 492 # $1 -- block device
483 # $2 -- output images dir 493 # $2 -- output images dir
484 function make_weston_sdcard() 494 function make_weston_sdcard()
485 { 495 {
486 readonly local LPARAM_BLOCK_DEVICE=${1} 496 readonly local LPARAM_BLOCK_DEVICE=${1}
487 readonly local LPARAM_OUTPUT_DIR=${2} 497 readonly local LPARAM_OUTPUT_DIR=${2}
488 readonly local P1_MOUNT_DIR="${G_TMP_DIR}/p1" 498 readonly local P1_MOUNT_DIR="${G_TMP_DIR}/p1"
489 readonly local P2_MOUNT_DIR="${G_TMP_DIR}/p2" 499 readonly local P2_MOUNT_DIR="${G_TMP_DIR}/p2"
490 readonly local DEBIAN_IMAGES_TO_ROOTFS_POINT="opt/images/Debian" 500 readonly local DEBIAN_IMAGES_TO_ROOTFS_POINT="opt/images/Debian"
491 501
492 readonly local BOOTLOAD_RESERVE_SIZE=2 502 readonly local BOOTLOAD_RESERVE_SIZE=2
493 readonly local PART1_SIZE=48 503 readonly local PART1_SIZE=48
494 readonly local BOOTPART=1 504 readonly local BOOTPART=1
495 readonly local ROOTFSPART=2 505 readonly local ROOTFSPART=2
496 readonly local SPARE_SIZE=4 506 readonly local SPARE_SIZE=4
497 507
498 [ "${LPARAM_BLOCK_DEVICE}" = "na" ] && { 508 [ "${LPARAM_BLOCK_DEVICE}" = "na" ] && {
499 pr_error "No valid block device: ${LPARAM_BLOCK_DEVICE}" 509 pr_error "No valid block device: ${LPARAM_BLOCK_DEVICE}"
500 return 1; 510 return 1;
501 }; 511 };
502 512
503 local part="" 513 local part=""
504 if [ `echo ${LPARAM_BLOCK_DEVICE} | grep -c mmcblk` -ne 0 ]; then 514 if [ `echo ${LPARAM_BLOCK_DEVICE} | grep -c mmcblk` -ne 0 ]; then
505 part="p" 515 part="p"
506 fi 516 fi
507 517
508 # Check that we're using a valid device 518 # Check that we're using a valid device
509 if ! check_sdcard ${LPARAM_BLOCK_DEVICE}; then 519 if ! check_sdcard ${LPARAM_BLOCK_DEVICE}; then
510 return 1 520 return 1
511 fi 521 fi
512 522
513 for ((i=0; i<10; i++)) 523 for ((i=0; i<10; i++))
514 do 524 do
515 if [ `mount | grep -c ${LPARAM_BLOCK_DEVICE}${part}$i` -ne 0 ]; then 525 if [ `mount | grep -c ${LPARAM_BLOCK_DEVICE}${part}$i` -ne 0 ]; then
516 umount ${LPARAM_BLOCK_DEVICE}${part}$i 526 umount ${LPARAM_BLOCK_DEVICE}${part}$i
517 fi 527 fi
518 done 528 done
519 529
520 function format_sdcard 530 function format_sdcard
521 { 531 {
522 pr_info "Formating SD card partitions" 532 pr_info "Formating SD card partitions"
523 mkfs.vfat -F 16 ${LPARAM_BLOCK_DEVICE}${part}1 -n boot 533 mkfs.vfat -F 16 ${LPARAM_BLOCK_DEVICE}${part}1 -n boot
524 mkfs.ext4 ${LPARAM_BLOCK_DEVICE}${part}2 -L rootfs 534 mkfs.ext4 ${LPARAM_BLOCK_DEVICE}${part}2 -L rootfs
525 } 535 }
526 536
527 function flash_u-boot 537 function flash_u-boot
528 { 538 {
529 pr_info "Flashing U-Boot" 539 pr_info "Flashing U-Boot"
530 dd if=${LPARAM_OUTPUT_DIR}/${G_UBOOT_NAME_FOR_EMMC} \ 540 dd if=${LPARAM_OUTPUT_DIR}/${G_UBOOT_NAME_FOR_EMMC} \
531 of=${LPARAM_BLOCK_DEVICE} bs=1K seek=${BOOTLOADER_OFFSET}; sync 541 of=${LPARAM_BLOCK_DEVICE} bs=1K seek=${BOOTLOADER_OFFSET}; sync
532 } 542 }
533 543
534 function flash_sdcard 544 function flash_sdcard
535 { 545 {
536 pr_info "Flashing \"Image, device tree and rootfs\" partition" 546 pr_info "Flashing \"Image and device tree\" partition"
537 cp -v ${LPARAM_OUTPUT_DIR}/Image ${P1_MOUNT_DIR}/ 547 cp -v ${LPARAM_OUTPUT_DIR}/Image ${P1_MOUNT_DIR}/
538 mkdir -p ${P1_MOUNT_DIR}/dtbs/ 548 mkdir -p ${P1_MOUNT_DIR}/dtbs/
539 cp -v ${LPARAM_OUTPUT_DIR}/fsl-smarcimx8mq${DISPLAY}.dtb ${P1_MOUNT_DIR}/dtbs/fsl-smarcimx8mq.dtb 549 cp -v ${LPARAM_OUTPUT_DIR}/fsl-smarcimx8mq${DISPLAY}.dtb ${P1_MOUNT_DIR}/dtbs/fsl-smarcimx8mq.dtb
540 cp -v ${G_EMBEDIAN_PATH}/uEnv.txt ${P1_MOUNT_DIR}/ 550 cp -v ${G_EMBEDIAN_PATH}/uEnv.txt ${P1_MOUNT_DIR}/
551 pr_info "Flashing \"rootfs\" partition"
541 tar -xpf ${LPARAM_OUTPUT_DIR}/${DEF_ROOTFS_TARBALL_NAME} \ 552 tar -xpf ${LPARAM_OUTPUT_DIR}/${DEF_ROOTFS_TARBALL_NAME} \
542 -C ${P2_MOUNT_DIR}/ 553 -C ${P2_MOUNT_DIR}/
543 } 554 }
544 555
545 function copy_debian_images 556 function copy_debian_images
546 { 557 {
547 mkdir -p ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT} 558 mkdir -p ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}
548 559
549 pr_info "Copying Debian images to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" 560 pr_info "Copying Debian images to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}"
550 cp ${LPARAM_OUTPUT_DIR}/${DEF_ROOTFS_TARBALL_NAME} \ 561 cp ${LPARAM_OUTPUT_DIR}/${DEF_ROOTFS_TARBALL_NAME} \
551 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/${DEF_ROOTFS_TARBALL_NAME} 562 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/${DEF_ROOTFS_TARBALL_NAME}
552 563
553 pr_info "Copying U-Boot to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" 564 pr_info "Copying U-Boot to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}"
554 if [ "${MACHINE}" = "smarcimx8m2g" ] || \ 565 if [ "${MACHINE}" = "smarcimx8m2g" ] || \
555 [ "${MACHINE}" = "smarcimx8m4g" ]; then 566 [ "${MACHINE}" = "smarcimx8m4g" ]; then
556 cp ${LPARAM_OUTPUT_DIR}/imx-boot-* \ 567 cp ${LPARAM_OUTPUT_DIR}/imx-boot-* \
557 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/ 568 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/
558 else 569 else
559 cp ${LPARAM_OUTPUT_DIR}/${G_UBOOT_NAME_FOR_EMMC} \ 570 cp ${LPARAM_OUTPUT_DIR}/${G_UBOOT_NAME_FOR_EMMC} \
560 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/ 571 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/
561 fi 572 fi
562 pr_info "Copying Image and device tree files to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" 573 pr_info "Copying Image and device tree files to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}"
563 cp ${LPARAM_OUTPUT_DIR}/Image \ 574 cp ${LPARAM_OUTPUT_DIR}/Image \
564 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/ 575 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/
565 cp ${LPARAM_OUTPUT_DIR}/*.dtb \ 576 cp ${LPARAM_OUTPUT_DIR}/*.dtb \
566 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/ 577 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/
567 cp ${G_EMBEDIAN_PATH}/uEnv_emmc.txt \ 578 cp ${G_EMBEDIAN_PATH}/uEnv_emmc.txt \
568 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/uEnv.txt 579 ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/uEnv.txt
569 } 580 }
570 581
571 function copy_scripts 582 function copy_scripts
572 { 583 {
573 pr_info "Copying scripts to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" 584 pr_info "Copying scripts to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}"
574 cp ${G_EMBEDIAN_PATH}/mx8_install_debian.sh \ 585 cp ${G_EMBEDIAN_PATH}/mx8_install_debian.sh \
575 ${P2_MOUNT_DIR}/usr/sbin/install_debian.sh 586 ${P2_MOUNT_DIR}/usr/sbin/install_debian.sh
576 } 587 }
577 588
578 function ceildiv 589 function ceildiv
579 { 590 {
580 local num=$1 591 local num=$1
581 local div=$2 592 local div=$2
582 echo $(( (num + div - 1) / div )) 593 echo $(( (num + div - 1) / div ))
583 } 594 }
584 595
585 # Delete the partitions 596 # Delete the partitions
586 for ((i=0; i<=10; i++)) 597 for ((i=0; i<=10; i++))
587 do 598 do
588 if [ -e ${LPARAM_BLOCK_DEVICE}${part}${i} ]; then 599 if [ -e ${LPARAM_BLOCK_DEVICE}${part}${i} ]; then
589 dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE}${part}$i bs=512 count=1024 2> /dev/null || true 600 dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE}${part}$i bs=512 count=1024 2> /dev/null || true
590 fi 601 fi
591 done 602 done
592 sync 603 sync
593 604
594 ((echo d; echo 1; echo d; echo 2; echo d; echo 3; echo d; echo w) | \ 605 ((echo d; echo 1; echo d; echo 2; echo d; echo 3; echo d; echo w) | \
595 fdisk ${LPARAM_BLOCK_DEVICE} &> /dev/null) || true 606 fdisk ${LPARAM_BLOCK_DEVICE} &> /dev/null) || true
596 sync 607 sync
597 608
598 dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE} bs=1M count=${BOOTLOAD_RESERVE_SIZE} 609 dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE} bs=1M count=100
599 sync; sleep 2 610 sync; sleep 2
600 611
601 # Create a new partition table 612 # Create a new partition table
602 pr_info "Creating new partitions" 613 pr_info "Creating new partitions"
603 614
604 # Get total card size 615 # Get total card size
605 TOTAL_SIZE=`fdisk -s ${LPARAM_BLOCK_DEVICE}` 616 TOTAL_SIZE=`fdisk -s ${LPARAM_BLOCK_DEVICE}`
606 TOTAL_SIZE=`expr ${TOTAL_SIZE} / 1024` 617 TOTAL_SIZE=`expr ${TOTAL_SIZE} / 1024`
607 ROOTFS_SIZE=`expr ${TOTAL_SIZE} - ${BOOTLOAD_RESERVE_SIZE} - ${PART1_SIZE} - ${SPARE_SIZE}` 618 ROOTFS_SIZE=`expr ${TOTAL_SIZE} - ${BOOTLOAD_RESERVE_SIZE} - ${PART1_SIZE} - ${SPARE_SIZE}`
608 619
609 pr_info "ROOT SIZE=${ROOTFS_SIZE} TOTAl SIZE=${TOTAL_SIZE}" 620 pr_info "ROOT SIZE=${ROOTFS_SIZE} TOTAl SIZE=${TOTAL_SIZE}"
610 621
611 BLOCK=`echo ${LPARAM_BLOCK_DEVICE} | cut -d "/" -f 3` 622 BLOCK=`echo ${LPARAM_BLOCK_DEVICE} | cut -d "/" -f 3`
612 SECT_SIZE_BYTES=`cat /sys/block/${BLOCK}/queue/physical_block_size` 623 SECT_SIZE_BYTES=`cat /sys/block/${BLOCK}/queue/physical_block_size`
613 624
614 BOOTLOAD_RESERVE_SIZE_BYTES=$((BOOTLOAD_RESERVE_SIZE * 1024 * 1024)) 625 BOOTLOAD_RESERVE_SIZE_BYTES=$((BOOTLOAD_RESERVE_SIZE * 1024 * 1024))
615 PART1_SIZE_BYTES=$((PART1_SIZE * 1024 * 1024)) 626 PART1_SIZE_BYTES=$((PART1_SIZE * 1024 * 1024))
616 PART1_END_BYTES=`expr ${BOOTLOAD_RESERVE_SIZE_BYTES} + ${PART1_SIZE_BYTES}` 627 PART1_END_BYTES=`expr ${BOOTLOAD_RESERVE_SIZE_BYTES} + ${PART1_SIZE_BYTES}`
617 ROOTFS_SIZE_BYTES=$((ROOTFS_SIZE * 1024 * 1024)) 628 ROOTFS_SIZE_BYTES=$((ROOTFS_SIZE * 1024 * 1024))
618 629
619 PART1_FIRST_SECT=`ceildiv ${BOOTLOAD_RESERVE_SIZE_BYTES} ${SECT_SIZE_BYTES}` 630 PART1_FIRST_SECT=`ceildiv ${BOOTLOAD_RESERVE_SIZE_BYTES} ${SECT_SIZE_BYTES}`
620 PART1_END_SECT=`ceildiv ${PART1_END_BYTES} ${SECT_SIZE_BYTES}` 631 PART1_END_SECT=`ceildiv ${PART1_END_BYTES} ${SECT_SIZE_BYTES}`
621 PART2_FIRST_SECT=`expr ${PART1_END_SECT} + 1 ` 632 PART2_FIRST_SECT=`expr ${PART1_END_SECT} + 1 `
622 633
623 (echo n; echo p; echo $BOOTPART; echo $PART1_FIRST_SECT; \ 634 (echo n; echo p; echo $BOOTPART; echo $PART1_FIRST_SECT; \
624 echo $PART1_END_SECT; echo n; echo p; echo $ROOTFSPART; \ 635 echo $PART1_END_SECT; echo n; echo p; echo $ROOTFSPART; \
625 echo $PART2_FIRST_SECT; echo; echo p; echo w) | fdisk -u ${LPARAM_BLOCK_DEVICE} > /dev/null 636 echo $PART2_FIRST_SECT; echo; echo p; echo w) | fdisk -u ${LPARAM_BLOCK_DEVICE} > /dev/null
626 637
627 sleep 2; sync; 638 sleep 2; sync;
628 fdisk -l ${LPARAM_BLOCK_DEVICE} 639 fdisk -l ${LPARAM_BLOCK_DEVICE}
629 640
630 sleep 2; sync; 641 sleep 2; sync;
631 642
632 # Format the partitions 643 # Format the partitions
633 format_sdcard 644 format_sdcard
634 sleep 2; sync; 645 sleep 2; sync;
635 646
636 flash_u-boot 647 flash_u-boot
637 sleep 2; sync; 648 sleep 2; sync;
638 649
639 # Mount the partitions 650 # Mount the partitions
640 mkdir -p ${P1_MOUNT_DIR} 651 mkdir -p ${P1_MOUNT_DIR}
641 mkdir -p ${P2_MOUNT_DIR} 652 mkdir -p ${P2_MOUNT_DIR}
642 sync 653 sync
643 654
644 mount ${LPARAM_BLOCK_DEVICE}${part}1 ${P1_MOUNT_DIR} 655 mount ${LPARAM_BLOCK_DEVICE}${part}1 ${P1_MOUNT_DIR}
645 mount ${LPARAM_BLOCK_DEVICE}${part}2 ${P2_MOUNT_DIR} 656 mount ${LPARAM_BLOCK_DEVICE}${part}2 ${P2_MOUNT_DIR}
646 sleep 2; sync; 657 sleep 2; sync;
647 658
648 flash_sdcard 659 flash_sdcard
649 copy_debian_images 660 copy_debian_images
650 copy_scripts 661 copy_scripts
651 662
652 pr_info "Sync sdcard..." 663 pr_info "Sync sdcard..."
653 sync 664 sync
654 umount ${P1_MOUNT_DIR} 665 umount ${P1_MOUNT_DIR}
655 umount ${P2_MOUNT_DIR} 666 umount ${P2_MOUNT_DIR}
656 667
657 rm -rf ${P1_MOUNT_DIR} 668 rm -rf ${P1_MOUNT_DIR}
658 rm -rf ${P2_MOUNT_DIR} 669 rm -rf ${P2_MOUNT_DIR}
659 670
660 pr_info "Done make sdcard!" 671 pr_info "Done make sdcard!"
661 672
662 return 0; 673 return 0;
663 } 674 }
664 675