Commit c657273d3c50860e035707da8d283086e2a1eb6c
1 parent
a0ccd91125
Exists in
debian_stretch_mx8mm_smarc01
Fix U-Boot Boot_SEL detection problem
Showing 1 changed file with 1 additions and 1 deletions Inline Diff
make_smarc_mx8m_debian.sh
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | # It is designed to build Debian linux for Embedian SMARC-imx8m modules | 2 | # It is designed to build Debian linux for Embedian SMARC-imx8m modules |
3 | # prepare host OS system: | 3 | # prepare host OS system: |
4 | # sudo apt-get install binfmt-support qemu qemu-user-static debootstrap kpartx | 4 | # sudo apt-get install binfmt-support qemu qemu-user-static debootstrap kpartx |
5 | # sudo apt-get install lvm2 dosfstools gpart binutils git lib32ncurses5-dev python-m2crypto | 5 | # sudo apt-get install lvm2 dosfstools gpart binutils git lib32ncurses5-dev python-m2crypto |
6 | # sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev | 6 | # sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev |
7 | # sudo apt-get install autoconf libtool libglib2.0-dev libarchive-dev | 7 | # sudo apt-get install autoconf libtool libglib2.0-dev libarchive-dev |
8 | # sudo apt-get install python-git xterm sed cvs subversion coreutils texi2html | 8 | # sudo apt-get install python-git xterm sed cvs subversion coreutils texi2html |
9 | # sudo apt-get install docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils libgl1-mesa-dev | 9 | # sudo apt-get install docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils libgl1-mesa-dev |
10 | # sudo apt-get install libglu1-mesa-dev mercurial automake groff curl lzop asciidoc u-boot-tools mtd-utils | 10 | # sudo apt-get install libglu1-mesa-dev mercurial automake groff curl lzop asciidoc u-boot-tools mtd-utils |
11 | # | 11 | # |
12 | 12 | ||
13 | # -e Exit immediately if a command exits with a non-zero status. | 13 | # -e Exit immediately if a command exits with a non-zero status. |
14 | set -e | 14 | set -e |
15 | 15 | ||
16 | SCRIPT_NAME=${0##*/} | 16 | SCRIPT_NAME=${0##*/} |
17 | readonly SCRIPT_VERSION="0.5" | 17 | readonly SCRIPT_VERSION="0.5" |
18 | 18 | ||
19 | 19 | ||
20 | #### Exports Variables #### | 20 | #### Exports Variables #### |
21 | #### global variables #### | 21 | #### global variables #### |
22 | readonly ABSOLUTE_FILENAME=`readlink -e "$0"` | 22 | readonly ABSOLUTE_FILENAME=`readlink -e "$0"` |
23 | readonly ABSOLUTE_DIRECTORY=`dirname ${ABSOLUTE_FILENAME}` | 23 | readonly ABSOLUTE_DIRECTORY=`dirname ${ABSOLUTE_FILENAME}` |
24 | readonly SCRIPT_POINT=${ABSOLUTE_DIRECTORY} | 24 | readonly SCRIPT_POINT=${ABSOLUTE_DIRECTORY} |
25 | readonly SCRIPT_START_DATE=`date +%Y%m%d` | 25 | readonly SCRIPT_START_DATE=`date +%Y%m%d` |
26 | readonly LOOP_MAJOR=7 | 26 | readonly LOOP_MAJOR=7 |
27 | 27 | ||
28 | # default mirror | 28 | # default mirror |
29 | readonly DEF_DEBIAN_MIRROR="http://httpredir.debian.org/debian" | 29 | readonly DEF_DEBIAN_MIRROR="http://httpredir.debian.org/debian" |
30 | readonly DEB_RELEASE="stretch" | 30 | readonly DEB_RELEASE="stretch" |
31 | readonly DEF_ROOTFS_TARBAR_NAME="rootfs.tar.gz" | 31 | readonly DEF_ROOTFS_TARBAR_NAME="rootfs.tar.gz" |
32 | 32 | ||
33 | ## base paths | 33 | ## base paths |
34 | readonly DEF_BUILDENV="${ABSOLUTE_DIRECTORY}" | 34 | readonly DEF_BUILDENV="${ABSOLUTE_DIRECTORY}" |
35 | readonly DEF_SRC_DIR="${DEF_BUILDENV}/src" | 35 | readonly DEF_SRC_DIR="${DEF_BUILDENV}/src" |
36 | readonly G_ROOTFS_DIR="${DEF_BUILDENV}/rootfs" | 36 | readonly G_ROOTFS_DIR="${DEF_BUILDENV}/rootfs" |
37 | readonly G_TMP_DIR="${DEF_BUILDENV}/tmp" | 37 | readonly G_TMP_DIR="${DEF_BUILDENV}/tmp" |
38 | readonly G_TOOLS_PATH="${DEF_BUILDENV}/toolchain" | 38 | readonly G_TOOLS_PATH="${DEF_BUILDENV}/toolchain" |
39 | readonly G_EMBEDIAN_PATH="${DEF_BUILDENV}/embedian" | 39 | readonly G_EMBEDIAN_PATH="${DEF_BUILDENV}/embedian" |
40 | 40 | ||
41 | ## LINUX kernel: git, config, paths and etc | 41 | ## LINUX kernel: git, config, paths and etc |
42 | readonly G_LINUX_KERNEL_SRC_DIR="${DEF_SRC_DIR}/kernel" | 42 | readonly G_LINUX_KERNEL_SRC_DIR="${DEF_SRC_DIR}/kernel" |
43 | readonly G_LINUX_KERNEL_GIT="git@git.embedian.com:developer/smarc-fsl-linux-kernel.git" | 43 | readonly G_LINUX_KERNEL_GIT="git@git.embedian.com:developer/smarc-fsl-linux-kernel.git" |
44 | readonly G_LINUX_KERNEL_BRANCH="smarc_8mm_imx_4.14.78_1.0.0_ga" | 44 | readonly G_LINUX_KERNEL_BRANCH="smarc_8mm_imx_4.14.78_1.0.0_ga" |
45 | readonly G_LINUX_KERNEL_REV="0a7c3816fc861b630f20ffa2eda660704519420c" | 45 | readonly G_LINUX_KERNEL_REV="0a7c3816fc861b630f20ffa2eda660704519420c" |
46 | readonly G_LINUX_KERNEL_DEF_CONFIG='smarcimx8mm_defconfig' | 46 | readonly G_LINUX_KERNEL_DEF_CONFIG='smarcimx8mm_defconfig' |
47 | readonly G_LINUX_DTB='embedian/fsl-smarcimx8mm.dtb' | 47 | readonly G_LINUX_DTB='embedian/fsl-smarcimx8mm.dtb' |
48 | 48 | ||
49 | ## uboot | 49 | ## uboot |
50 | readonly G_UBOOT_SRC_DIR="${DEF_SRC_DIR}/uboot" | 50 | readonly G_UBOOT_SRC_DIR="${DEF_SRC_DIR}/uboot" |
51 | readonly G_UBOOT_GIT="git@git.embedian.com:developer/smarc-t335x-uboot.git" | 51 | readonly G_UBOOT_GIT="git@git.embedian.com:developer/smarc-t335x-uboot.git" |
52 | readonly G_UBOOT_BRANCH="smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga" | 52 | readonly G_UBOOT_BRANCH="smarc_8mm-imx_v2018.03_4.14.98_2.0.0_ga" |
53 | readonly G_UBOOT_REV="77f9e189ffd989486d49035ba08c1c76e1e19e8c" | 53 | readonly G_UBOOT_REV="ee073b5ec68c550662a815327a335770eeaf2249" |
54 | readonly G_UBOOT_DEF_CONFIG='smarcimx8mm_2g_ser3_defconfig' | 54 | readonly G_UBOOT_DEF_CONFIG='smarcimx8mm_2g_ser3_defconfig' |
55 | readonly G_UBOOT_NAME='imx-boot-sd.bin' | 55 | readonly G_UBOOT_NAME='imx-boot-sd.bin' |
56 | 56 | ||
57 | ## CROSS_COMPILER config and paths | 57 | ## CROSS_COMPILER config and paths |
58 | readonly G_CROSS_COMPILER_NAME="gcc-linaro-6.4.1-2017.11-x86_64_aarch64-linux-gnu" | 58 | readonly G_CROSS_COMPILER_NAME="gcc-linaro-6.4.1-2017.11-x86_64_aarch64-linux-gnu" |
59 | readonly G_CROSS_COMPILER_ARCHIVE="${G_CROSS_COMPILER_NAME}.tar.xz" | 59 | readonly G_CROSS_COMPILER_ARCHIVE="${G_CROSS_COMPILER_NAME}.tar.xz" |
60 | readonly G_CROSS_COMPILER_PATH="${G_TOOLS_PATH}/${G_CROSS_COMPILER_NAME}/bin" | 60 | readonly G_CROSS_COMPILER_PATH="${G_TOOLS_PATH}/${G_CROSS_COMPILER_NAME}/bin" |
61 | readonly G_CROSS_COMPILER_PREFIX="aarch64-linux-gnu-" | 61 | readonly G_CROSS_COMPILER_PREFIX="aarch64-linux-gnu-" |
62 | readonly G_CROSS_COMPILER_JOPTION="-j 4" | 62 | readonly G_CROSS_COMPILER_JOPTION="-j 4" |
63 | readonly G_EXT_CROSS_COMPILER_LINK="http://releases.linaro.org/components/toolchain/binaries/6.4-2017.11/aarch64-linux-gnu/${G_CROSS_COMPILER_ARCHIVE}" | 63 | readonly G_EXT_CROSS_COMPILER_LINK="http://releases.linaro.org/components/toolchain/binaries/6.4-2017.11/aarch64-linux-gnu/${G_CROSS_COMPILER_ARCHIVE}" |
64 | 64 | ||
65 | ############## user rootfs packages ########## | 65 | ############## user rootfs packages ########## |
66 | readonly G_USER_PACKAGES="" | 66 | readonly G_USER_PACKAGES="" |
67 | 67 | ||
68 | export LC_ALL=C | 68 | export LC_ALL=C |
69 | 69 | ||
70 | SOM="smarc-imx8mm" | 70 | SOM="smarc-imx8mm" |
71 | 71 | ||
72 | #### Input params ##### | 72 | #### Input params ##### |
73 | PARAM_DEB_LOCAL_MIRROR="${DEF_DEBIAN_MIRROR}" | 73 | PARAM_DEB_LOCAL_MIRROR="${DEF_DEBIAN_MIRROR}" |
74 | PARAM_OUTPUT_DIR="${DEF_BUILDENV}/output" | 74 | PARAM_OUTPUT_DIR="${DEF_BUILDENV}/output" |
75 | PARAM_DEBUG="0" | 75 | PARAM_DEBUG="0" |
76 | PARAM_CMD="all" | 76 | PARAM_CMD="all" |
77 | PARAM_BLOCK_DEVICE="na" | 77 | PARAM_BLOCK_DEVICE="na" |
78 | 78 | ||
79 | 79 | ||
80 | ### usage ### | 80 | ### usage ### |
81 | function usage() { | 81 | function usage() { |
82 | echo "This program version ${SCRIPT_VERSION}" | 82 | echo "This program version ${SCRIPT_VERSION}" |
83 | echo " Used for make debian(${DEB_RELEASE}) image for \"smarc-imx8mm\" board" | 83 | echo " Used for make debian(${DEB_RELEASE}) image for \"smarc-imx8mm\" board" |
84 | echo " and create booted sdcard" | 84 | echo " and create booted sdcard" |
85 | echo "" | 85 | echo "" |
86 | echo "Usage:" | 86 | echo "Usage:" |
87 | echo " ./${SCRIPT_NAME} options" | 87 | echo " ./${SCRIPT_NAME} options" |
88 | echo "" | 88 | echo "" |
89 | echo "Options:" | 89 | echo "Options:" |
90 | echo " -h|--help -- print this help" | 90 | echo " -h|--help -- print this help" |
91 | echo " -c|--cmd <command>" | 91 | echo " -c|--cmd <command>" |
92 | echo " Supported commands:" | 92 | echo " Supported commands:" |
93 | echo " deploy -- prepare environment for all commands" | 93 | echo " deploy -- prepare environment for all commands" |
94 | echo " all -- build or rebuild kernel/bootloader/rootfs" | 94 | echo " all -- build or rebuild kernel/bootloader/rootfs" |
95 | echo " bootloader -- build or rebuild bootloader (u-boot+SPL)" | 95 | echo " bootloader -- build or rebuild bootloader (u-boot+SPL)" |
96 | echo " kernel -- build or rebuild linux kernel for this board" | 96 | echo " kernel -- build or rebuild linux kernel for this board" |
97 | echo " modules -- build or rebuild linux kernel modules and install in rootfs directory for this board" | 97 | echo " modules -- build or rebuild linux kernel modules and install in rootfs directory for this board" |
98 | echo " rootfs -- build or rebuild debian rootfs filesystem (includes: make debian apks, make and install kernel moduled," | 98 | echo " rootfs -- build or rebuild debian rootfs filesystem (includes: make debian apks, make and install kernel moduled," |
99 | echo " make and install extern modules (wifi/bt), create rootfs.tar.gz)" | 99 | echo " make and install extern modules (wifi/bt), create rootfs.tar.gz)" |
100 | echo " rtar -- generate or regenerate rootfs.tar.gz image from rootfs folder " | 100 | echo " rtar -- generate or regenerate rootfs.tar.gz image from rootfs folder " |
101 | echo " clean -- clean all build artifacts (not delete sources code and resulted images (output folder))" | 101 | echo " clean -- clean all build artifacts (not delete sources code and resulted images (output folder))" |
102 | echo " sdcard -- create bootting sdcard for this device" | 102 | echo " sdcard -- create bootting sdcard for this device" |
103 | echo " -o|--output -- custom select output directory (default: \"${PARAM_OUTPUT_DIR}\")" | 103 | echo " -o|--output -- custom select output directory (default: \"${PARAM_OUTPUT_DIR}\")" |
104 | echo " -d|--dev -- select sdcard device (exmple: -d /dev/sde)" | 104 | echo " -d|--dev -- select sdcard device (exmple: -d /dev/sde)" |
105 | echo " --debug -- enable debug mode for this script" | 105 | echo " --debug -- enable debug mode for this script" |
106 | echo "Examples of use:" | 106 | echo "Examples of use:" |
107 | echo " make only linux kernel for board: sudo ./${SCRIPT_NAME} --cmd kernel" | 107 | echo " make only linux kernel for board: sudo ./${SCRIPT_NAME} --cmd kernel" |
108 | echo " make only rootfs for board: sudo ./${SCRIPT_NAME} --cmd rootfs" | 108 | echo " make only rootfs for board: sudo ./${SCRIPT_NAME} --cmd rootfs" |
109 | echo " create boot sdcard: sudo ./${SCRIPT_NAME} --cmd sdcard --dev /dev/sdX" | 109 | echo " create boot sdcard: sudo ./${SCRIPT_NAME} --cmd sdcard --dev /dev/sdX" |
110 | echo " deploy and build: ./${SCRIPT_NAME} --cmd deploy && sudo ./${SCRIPT_NAME} --cmd all" | 110 | echo " deploy and build: ./${SCRIPT_NAME} --cmd deploy && sudo ./${SCRIPT_NAME} --cmd all" |
111 | echo "" | 111 | echo "" |
112 | } | 112 | } |
113 | 113 | ||
114 | ###### parse input arguments ## | 114 | ###### parse input arguments ## |
115 | readonly SHORTOPTS="c:o:d:s:h" | 115 | readonly SHORTOPTS="c:o:d:s:h" |
116 | readonly LONGOPTS="cmd:,output:,dev:,som:,help,debug" | 116 | readonly LONGOPTS="cmd:,output:,dev:,som:,help,debug" |
117 | 117 | ||
118 | ARGS=$(getopt -s bash --options ${SHORTOPTS} \ | 118 | ARGS=$(getopt -s bash --options ${SHORTOPTS} \ |
119 | --longoptions ${LONGOPTS} --name ${SCRIPT_NAME} -- "$@" ) | 119 | --longoptions ${LONGOPTS} --name ${SCRIPT_NAME} -- "$@" ) |
120 | 120 | ||
121 | eval set -- "$ARGS" | 121 | eval set -- "$ARGS" |
122 | 122 | ||
123 | while true; do | 123 | while true; do |
124 | case $1 in | 124 | case $1 in |
125 | -c|--cmd ) # script command | 125 | -c|--cmd ) # script command |
126 | shift | 126 | shift |
127 | PARAM_CMD="$1"; | 127 | PARAM_CMD="$1"; |
128 | ;; | 128 | ;; |
129 | -o|--output ) # select output dir | 129 | -o|--output ) # select output dir |
130 | shift | 130 | shift |
131 | PARAM_OUTPUT_DIR="$1"; | 131 | PARAM_OUTPUT_DIR="$1"; |
132 | ;; | 132 | ;; |
133 | -d|--dev ) # block device (for create sdcard) | 133 | -d|--dev ) # block device (for create sdcard) |
134 | shift | 134 | shift |
135 | [ -e ${1} ] && { | 135 | [ -e ${1} ] && { |
136 | PARAM_BLOCK_DEVICE=${1}; | 136 | PARAM_BLOCK_DEVICE=${1}; |
137 | }; | 137 | }; |
138 | ;; | 138 | ;; |
139 | --debug ) # enable debug | 139 | --debug ) # enable debug |
140 | PARAM_DEBUG=1; | 140 | PARAM_DEBUG=1; |
141 | ;; | 141 | ;; |
142 | -h|--help ) # get help | 142 | -h|--help ) # get help |
143 | usage | 143 | usage |
144 | exit 0; | 144 | exit 0; |
145 | ;; | 145 | ;; |
146 | -s|--som ) # target SOM | 146 | -s|--som ) # target SOM |
147 | shift | 147 | shift |
148 | SOM="$1"; | 148 | SOM="$1"; |
149 | ;; | 149 | ;; |
150 | -- ) | 150 | -- ) |
151 | shift | 151 | shift |
152 | break | 152 | break |
153 | ;; | 153 | ;; |
154 | * ) | 154 | * ) |
155 | shift | 155 | shift |
156 | break | 156 | break |
157 | ;; | 157 | ;; |
158 | esac | 158 | esac |
159 | shift | 159 | shift |
160 | done | 160 | done |
161 | 161 | ||
162 | ## enable tarce options in debug mode | 162 | ## enable tarce options in debug mode |
163 | [ "${PARAM_DEBUG}" = "1" ] && { | 163 | [ "${PARAM_DEBUG}" = "1" ] && { |
164 | echo "Debug mode enabled!" | 164 | echo "Debug mode enabled!" |
165 | set -x | 165 | set -x |
166 | }; | 166 | }; |
167 | 167 | ||
168 | if [ "${SOM}" = "smarc-imx8m" ]; then | 168 | if [ "${SOM}" = "smarc-imx8m" ]; then |
169 | IMXGSTPLG="imx-gst1.0-plugin-mx8mq" | 169 | IMXGSTPLG="imx-gst1.0-plugin-mx8mq" |
170 | elif [ "${SOM}" = "smarc-imx8mm" ]; then | 170 | elif [ "${SOM}" = "smarc-imx8mm" ]; then |
171 | IMXGSTPLG="imx-gst1.0-plugin-mx8mm" | 171 | IMXGSTPLG="imx-gst1.0-plugin-mx8mm" |
172 | else | 172 | else |
173 | echo "Unknown target SOM ${SOM}" | 173 | echo "Unknown target SOM ${SOM}" |
174 | exit 1 | 174 | exit 1 |
175 | fi | 175 | fi |
176 | 176 | ||
177 | if [ -d ${G_EMBEDIAN_PATH}/${SOM} ]; then | 177 | if [ -d ${G_EMBEDIAN_PATH}/${SOM} ]; then |
178 | echo "Building Debian for SOM ${SOM}" | 178 | echo "Building Debian for SOM ${SOM}" |
179 | else | 179 | else |
180 | echo "Missing custom files for SOM ${SOM}" | 180 | echo "Missing custom files for SOM ${SOM}" |
181 | exit 1 | 181 | exit 1 |
182 | fi | 182 | fi |
183 | 183 | ||
184 | ## declarate dinamic variables ## | 184 | ## declarate dinamic variables ## |
185 | readonly G_ROOTFS_TARBAR_PATH="${PARAM_OUTPUT_DIR}/${DEF_ROOTFS_TARBAR_NAME}" | 185 | readonly G_ROOTFS_TARBAR_PATH="${PARAM_OUTPUT_DIR}/${DEF_ROOTFS_TARBAR_NAME}" |
186 | 186 | ||
187 | ###### local functions ###### | 187 | ###### local functions ###### |
188 | 188 | ||
189 | ### printing functions ### | 189 | ### printing functions ### |
190 | 190 | ||
191 | # print error message | 191 | # print error message |
192 | # $1 - printing string | 192 | # $1 - printing string |
193 | function pr_error() { | 193 | function pr_error() { |
194 | echo "E: $1" | 194 | echo "E: $1" |
195 | } | 195 | } |
196 | 196 | ||
197 | # print warning message | 197 | # print warning message |
198 | # $1 - printing string | 198 | # $1 - printing string |
199 | function pr_warning() { | 199 | function pr_warning() { |
200 | echo "W: $1" | 200 | echo "W: $1" |
201 | } | 201 | } |
202 | 202 | ||
203 | # print info message | 203 | # print info message |
204 | # $1 - printing string | 204 | # $1 - printing string |
205 | function pr_info() { | 205 | function pr_info() { |
206 | echo "I: $1" | 206 | echo "I: $1" |
207 | } | 207 | } |
208 | 208 | ||
209 | # print debug message | 209 | # print debug message |
210 | # $1 - printing string | 210 | # $1 - printing string |
211 | function pr_debug() { | 211 | function pr_debug() { |
212 | echo "D: $1" | 212 | echo "D: $1" |
213 | } | 213 | } |
214 | 214 | ||
215 | ### work functions ### | 215 | ### work functions ### |
216 | 216 | ||
217 | # get sources from git repository | 217 | # get sources from git repository |
218 | # $1 - git repository | 218 | # $1 - git repository |
219 | # $2 - branch name | 219 | # $2 - branch name |
220 | # $3 - output dir | 220 | # $3 - output dir |
221 | # $4 - commit id | 221 | # $4 - commit id |
222 | function get_git_src() { | 222 | function get_git_src() { |
223 | # clone src code | 223 | # clone src code |
224 | git clone ${1} -b ${2} ${3} | 224 | git clone ${1} -b ${2} ${3} |
225 | cd ${3} | 225 | cd ${3} |
226 | git reset --hard ${4} | 226 | git reset --hard ${4} |
227 | RET=$? | 227 | RET=$? |
228 | cd - | 228 | cd - |
229 | return $RET | 229 | return $RET |
230 | } | 230 | } |
231 | 231 | ||
232 | # get remote file | 232 | # get remote file |
233 | # $1 - remote file | 233 | # $1 - remote file |
234 | # $2 - local file | 234 | # $2 - local file |
235 | function get_remote_file() { | 235 | function get_remote_file() { |
236 | # download remote file | 236 | # download remote file |
237 | wget -c ${1} -O ${2} | 237 | wget -c ${1} -O ${2} |
238 | return $? | 238 | return $? |
239 | } | 239 | } |
240 | 240 | ||
241 | function make_prepare() { | 241 | function make_prepare() { |
242 | ## create src dir | 242 | ## create src dir |
243 | mkdir -p ${DEF_SRC_DIR} && :; | 243 | mkdir -p ${DEF_SRC_DIR} && :; |
244 | 244 | ||
245 | ## create toolchain dir | 245 | ## create toolchain dir |
246 | mkdir -p ${G_TOOLS_PATH} && :; | 246 | mkdir -p ${G_TOOLS_PATH} && :; |
247 | 247 | ||
248 | ## create rootfs dir | 248 | ## create rootfs dir |
249 | mkdir -p ${G_ROOTFS_DIR} && :; | 249 | mkdir -p ${G_ROOTFS_DIR} && :; |
250 | 250 | ||
251 | ## create out dir | 251 | ## create out dir |
252 | mkdir -p ${PARAM_OUTPUT_DIR} && :; | 252 | mkdir -p ${PARAM_OUTPUT_DIR} && :; |
253 | 253 | ||
254 | ## create tmp dir | 254 | ## create tmp dir |
255 | mkdir -p ${G_TMP_DIR} && :; | 255 | mkdir -p ${G_TMP_DIR} && :; |
256 | } | 256 | } |
257 | 257 | ||
258 | # function generate rootfs in input dir | 258 | # function generate rootfs in input dir |
259 | # $1 - rootfs base dir | 259 | # $1 - rootfs base dir |
260 | function make_debian_rootfs() { | 260 | function make_debian_rootfs() { |
261 | local ROOTFS_BASE=$1 | 261 | local ROOTFS_BASE=$1 |
262 | 262 | ||
263 | pr_info "Make debian(${DEB_RELEASE}) rootfs start..." | 263 | pr_info "Make debian(${DEB_RELEASE}) rootfs start..." |
264 | 264 | ||
265 | ## umount previus mounts (if fail) | 265 | ## umount previus mounts (if fail) |
266 | umount ${ROOTFS_BASE}/{sys,proc,dev/pts,dev} 2>/dev/null && :; | 266 | umount ${ROOTFS_BASE}/{sys,proc,dev/pts,dev} 2>/dev/null && :; |
267 | 267 | ||
268 | ## clear rootfs dir | 268 | ## clear rootfs dir |
269 | rm -rf ${ROOTFS_BASE}/* && :; | 269 | rm -rf ${ROOTFS_BASE}/* && :; |
270 | 270 | ||
271 | pr_info "rootfs: debootstrap" | 271 | pr_info "rootfs: debootstrap" |
272 | debootstrap --verbose --foreign --arch arm64 ${DEB_RELEASE} ${ROOTFS_BASE}/ ${PARAM_DEB_LOCAL_MIRROR} | 272 | debootstrap --verbose --foreign --arch arm64 ${DEB_RELEASE} ${ROOTFS_BASE}/ ${PARAM_DEB_LOCAL_MIRROR} |
273 | 273 | ||
274 | ## prepare qemu | 274 | ## prepare qemu |
275 | pr_info "rootfs: debootstrap in rootfs (second-stage)" | 275 | pr_info "rootfs: debootstrap in rootfs (second-stage)" |
276 | cp /usr/bin/qemu-aarch64-static ${ROOTFS_BASE}/usr/bin/ | 276 | cp /usr/bin/qemu-aarch64-static ${ROOTFS_BASE}/usr/bin/ |
277 | mount -o bind /proc ${ROOTFS_BASE}/proc | 277 | mount -o bind /proc ${ROOTFS_BASE}/proc |
278 | mount -o bind /dev ${ROOTFS_BASE}/dev | 278 | mount -o bind /dev ${ROOTFS_BASE}/dev |
279 | mount -o bind /dev/pts ${ROOTFS_BASE}/dev/pts | 279 | mount -o bind /dev/pts ${ROOTFS_BASE}/dev/pts |
280 | mount -o bind /sys ${ROOTFS_BASE}/sys | 280 | mount -o bind /sys ${ROOTFS_BASE}/sys |
281 | chroot $ROOTFS_BASE /debootstrap/debootstrap --second-stage | 281 | chroot $ROOTFS_BASE /debootstrap/debootstrap --second-stage |
282 | 282 | ||
283 | # delete unused folder | 283 | # delete unused folder |
284 | chroot $ROOTFS_BASE rm -rf ${ROOTFS_BASE}/debootstrap | 284 | chroot $ROOTFS_BASE rm -rf ${ROOTFS_BASE}/debootstrap |
285 | 285 | ||
286 | pr_info "rootfs: generate default configs" | 286 | pr_info "rootfs: generate default configs" |
287 | mkdir -p ${ROOTFS_BASE}/etc/sudoers.d/ | 287 | mkdir -p ${ROOTFS_BASE}/etc/sudoers.d/ |
288 | echo "user ALL=(root) /usr/bin/apt-get, /usr/bin/dpkg, /usr/bin/vi, /sbin/reboot" > ${ROOTFS_BASE}/etc/sudoers.d/user | 288 | echo "user ALL=(root) /usr/bin/apt-get, /usr/bin/dpkg, /usr/bin/vi, /sbin/reboot" > ${ROOTFS_BASE}/etc/sudoers.d/user |
289 | chmod 0440 ${ROOTFS_BASE}/etc/sudoers.d/user | 289 | chmod 0440 ${ROOTFS_BASE}/etc/sudoers.d/user |
290 | 290 | ||
291 | mkdir -p ${ROOTFS_BASE}/srv/local-apt-repository | 291 | mkdir -p ${ROOTFS_BASE}/srv/local-apt-repository |
292 | cp -r ${G_EMBEDIAN_PATH}/deb/* ${ROOTFS_BASE}/srv/local-apt-repository | 292 | cp -r ${G_EMBEDIAN_PATH}/deb/* ${ROOTFS_BASE}/srv/local-apt-repository |
293 | 293 | ||
294 | ## added mirror to source list | 294 | ## added mirror to source list |
295 | echo "deb ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE} main contrib non-free | 295 | echo "deb ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE} main contrib non-free |
296 | deb-src ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE} main contrib non-free | 296 | deb-src ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE} main contrib non-free |
297 | deb ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE}-backports main contrib non-free | 297 | deb ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE}-backports main contrib non-free |
298 | deb-src ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE}-backports main contrib non-free | 298 | deb-src ${DEF_DEBIAN_MIRROR} ${DEB_RELEASE}-backports main contrib non-free |
299 | " > etc/apt/sources.list | 299 | " > etc/apt/sources.list |
300 | 300 | ||
301 | ## raise backports priority | 301 | ## raise backports priority |
302 | echo "Package: * | 302 | echo "Package: * |
303 | Pin: release n=${DEB_RELEASE}-backports | 303 | Pin: release n=${DEB_RELEASE}-backports |
304 | Pin-Priority: 500 | 304 | Pin-Priority: 500 |
305 | " > etc/apt/preferences.d/backports | 305 | " > etc/apt/preferences.d/backports |
306 | 306 | ||
307 | ## maximize local repo priority | 307 | ## maximize local repo priority |
308 | echo "Package: * | 308 | echo "Package: * |
309 | Pin: origin "" | 309 | Pin: origin "" |
310 | Pin-Priority: 1000 | 310 | Pin-Priority: 1000 |
311 | " > etc/apt/preferences.d/local | 311 | " > etc/apt/preferences.d/local |
312 | 312 | ||
313 | echo " | 313 | echo " |
314 | # /dev/mmcblk0p1 /boot vfat defaults 0 0 | 314 | # /dev/mmcblk0p1 /boot vfat defaults 0 0 |
315 | " > etc/fstab | 315 | " > etc/fstab |
316 | 316 | ||
317 | echo "smarc-imx8mm" > etc/hostname | 317 | echo "smarc-imx8mm" > etc/hostname |
318 | 318 | ||
319 | echo "auto lo | 319 | echo "auto lo |
320 | iface lo inet loopback | 320 | iface lo inet loopback |
321 | " > etc/network/interfaces | 321 | " > etc/network/interfaces |
322 | 322 | ||
323 | echo " | 323 | echo " |
324 | locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8 | 324 | locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8 |
325 | locales locales/default_environment_locale select en_US.UTF-8 | 325 | locales locales/default_environment_locale select en_US.UTF-8 |
326 | console-common console-data/keymap/policy select Select keymap from full list | 326 | console-common console-data/keymap/policy select Select keymap from full list |
327 | keyboard-configuration keyboard-configuration/variant select 'English (US)' | 327 | keyboard-configuration keyboard-configuration/variant select 'English (US)' |
328 | openssh-server openssh-server/permit-root-login select true | 328 | openssh-server openssh-server/permit-root-login select true |
329 | " > debconf.set | 329 | " > debconf.set |
330 | 330 | ||
331 | pr_info "rootfs: prepare install packages in rootfs" | 331 | pr_info "rootfs: prepare install packages in rootfs" |
332 | ## apt-get install without starting | 332 | ## apt-get install without starting |
333 | cat > ${ROOTFS_BASE}/usr/sbin/policy-rc.d << EOF | 333 | cat > ${ROOTFS_BASE}/usr/sbin/policy-rc.d << EOF |
334 | #!/bin/sh | 334 | #!/bin/sh |
335 | exit 101 | 335 | exit 101 |
336 | EOF | 336 | EOF |
337 | 337 | ||
338 | chmod +x ${ROOTFS_BASE}/usr/sbin/policy-rc.d | 338 | chmod +x ${ROOTFS_BASE}/usr/sbin/policy-rc.d |
339 | 339 | ||
340 | ## third packages stage | 340 | ## third packages stage |
341 | cat > third-stage << EOF | 341 | cat > third-stage << EOF |
342 | #!/bin/bash | 342 | #!/bin/bash |
343 | # apply debconfig options | 343 | # apply debconfig options |
344 | debconf-set-selections /debconf.set | 344 | debconf-set-selections /debconf.set |
345 | rm -f /debconf.set | 345 | rm -f /debconf.set |
346 | 346 | ||
347 | 347 | ||
348 | function protected_install() { | 348 | function protected_install() { |
349 | local _name=\${1} | 349 | local _name=\${1} |
350 | local repeated_cnt=5; | 350 | local repeated_cnt=5; |
351 | local RET_CODE=1; | 351 | local RET_CODE=1; |
352 | 352 | ||
353 | echo Installing \${_name} | 353 | echo Installing \${_name} |
354 | for (( c=0; c<\${repeated_cnt}; c++ )) | 354 | for (( c=0; c<\${repeated_cnt}; c++ )) |
355 | do | 355 | do |
356 | apt install -y \${_name} && { | 356 | apt install -y \${_name} && { |
357 | RET_CODE=0; | 357 | RET_CODE=0; |
358 | break; | 358 | break; |
359 | }; | 359 | }; |
360 | 360 | ||
361 | echo "" | 361 | echo "" |
362 | echo "###########################" | 362 | echo "###########################" |
363 | echo "## Fix missing packages ###" | 363 | echo "## Fix missing packages ###" |
364 | echo "###########################" | 364 | echo "###########################" |
365 | echo "" | 365 | echo "" |
366 | 366 | ||
367 | sleep 2; | 367 | sleep 2; |
368 | 368 | ||
369 | apt --fix-broken install -y && { | 369 | apt --fix-broken install -y && { |
370 | RET_CODE=0; | 370 | RET_CODE=0; |
371 | break; | 371 | break; |
372 | }; | 372 | }; |
373 | done | 373 | done |
374 | 374 | ||
375 | return \${RET_CODE} | 375 | return \${RET_CODE} |
376 | } | 376 | } |
377 | 377 | ||
378 | # update packages and install base | 378 | # update packages and install base |
379 | apt-get update || apt-get upgrade | 379 | apt-get update || apt-get upgrade |
380 | 380 | ||
381 | # local-apt-repository support | 381 | # local-apt-repository support |
382 | protected_install local-apt-repository | 382 | protected_install local-apt-repository |
383 | 383 | ||
384 | # update packages and install base | 384 | # update packages and install base |
385 | apt-get update || apt-get upgrade | 385 | apt-get update || apt-get upgrade |
386 | 386 | ||
387 | protected_install locales | 387 | protected_install locales |
388 | protected_install ntp | 388 | protected_install ntp |
389 | protected_install openssh-server | 389 | protected_install openssh-server |
390 | protected_install nfs-common | 390 | protected_install nfs-common |
391 | 391 | ||
392 | # packages required when flashing emmc | 392 | # packages required when flashing emmc |
393 | protected_install dosfstools | 393 | protected_install dosfstools |
394 | 394 | ||
395 | # fix config for sshd (permit root login) | 395 | # fix config for sshd (permit root login) |
396 | sed -i -e 's/#PermitRootLogin.*/PermitRootLogin\tyes/g' /etc/ssh/sshd_config | 396 | sed -i -e 's/#PermitRootLogin.*/PermitRootLogin\tyes/g' /etc/ssh/sshd_config |
397 | 397 | ||
398 | # net-tools (ifconfig, etc.) | 398 | # net-tools (ifconfig, etc.) |
399 | protected_install net-tools | 399 | protected_install net-tools |
400 | protected_install network-manager | 400 | protected_install network-manager |
401 | 401 | ||
402 | # sdma package | 402 | # sdma package |
403 | protected_install imx-firmware-sdma | 403 | protected_install imx-firmware-sdma |
404 | 404 | ||
405 | # graphical packages | 405 | # graphical packages |
406 | protected_install libdrm-vivante1 | 406 | protected_install libdrm-vivante1 |
407 | protected_install imx-gpu-viv-core | 407 | protected_install imx-gpu-viv-core |
408 | protected_install weston | 408 | protected_install weston |
409 | 409 | ||
410 | # added alsa & gstreamer | 410 | # added alsa & gstreamer |
411 | protected_install alsa-utils | 411 | protected_install alsa-utils |
412 | protected_install gstreamer1.0-alsa | 412 | protected_install gstreamer1.0-alsa |
413 | protected_install gstreamer1.0-plugins-bad | 413 | protected_install gstreamer1.0-plugins-bad |
414 | protected_install gstreamer1.0-plugins-base | 414 | protected_install gstreamer1.0-plugins-base |
415 | protected_install gstreamer1.0-plugins-base-apps | 415 | protected_install gstreamer1.0-plugins-base-apps |
416 | protected_install gstreamer1.0-plugins-ugly | 416 | protected_install gstreamer1.0-plugins-ugly |
417 | protected_install gstreamer1.0-plugins-good | 417 | protected_install gstreamer1.0-plugins-good |
418 | protected_install gstreamer1.0-tools | 418 | protected_install gstreamer1.0-tools |
419 | protected_install ${IMXGSTPLG} | 419 | protected_install ${IMXGSTPLG} |
420 | 420 | ||
421 | # added i2c tools | 421 | # added i2c tools |
422 | protected_install i2c-tools | 422 | protected_install i2c-tools |
423 | 423 | ||
424 | # added usb tools | 424 | # added usb tools |
425 | protected_install usbutils | 425 | protected_install usbutils |
426 | 426 | ||
427 | # added net tools | 427 | # added net tools |
428 | protected_install iperf | 428 | protected_install iperf |
429 | 429 | ||
430 | # mtd | 430 | # mtd |
431 | protected_install mtd-utils | 431 | protected_install mtd-utils |
432 | 432 | ||
433 | # bluetooth | 433 | # bluetooth |
434 | protected_install bluetooth | 434 | protected_install bluetooth |
435 | protected_install bluez-obexd | 435 | protected_install bluez-obexd |
436 | protected_install bluez-tools | 436 | protected_install bluez-tools |
437 | protected_install blueman | 437 | protected_install blueman |
438 | protected_install gconf2 | 438 | protected_install gconf2 |
439 | 439 | ||
440 | # wifi support packages | 440 | # wifi support packages |
441 | #protected_install hostapd | 441 | #protected_install hostapd |
442 | protected_install udhcpd | 442 | protected_install udhcpd |
443 | 443 | ||
444 | # can support | 444 | # can support |
445 | protected_install can-utils | 445 | protected_install can-utils |
446 | 446 | ||
447 | apt-get -y autoremove | 447 | apt-get -y autoremove |
448 | 448 | ||
449 | # create users and set password | 449 | # create users and set password |
450 | useradd -m -G audio -s /bin/bash user | 450 | useradd -m -G audio -s /bin/bash user |
451 | usermod -a -G video user | 451 | usermod -a -G video user |
452 | echo "user:user" | chpasswd | 452 | echo "user:user" | chpasswd |
453 | echo "root:root" | chpasswd | 453 | echo "root:root" | chpasswd |
454 | 454 | ||
455 | # sado kill | 455 | # sado kill |
456 | rm -f third-stage | 456 | rm -f third-stage |
457 | EOF | 457 | EOF |
458 | 458 | ||
459 | pr_info "rootfs: install selected debian packages (third-stage)" | 459 | pr_info "rootfs: install selected debian packages (third-stage)" |
460 | chmod +x third-stage | 460 | chmod +x third-stage |
461 | chroot ${ROOTFS_BASE} /third-stage | 461 | chroot ${ROOTFS_BASE} /third-stage |
462 | 462 | ||
463 | ### install weston service | 463 | ### install weston service |
464 | install -d -m 0755 ${ROOTFS_BASE}/etc/xdg/weston | 464 | install -d -m 0755 ${ROOTFS_BASE}/etc/xdg/weston |
465 | install -m 0644 ${G_EMBEDIAN_PATH}/${SOM}/weston.ini ${ROOTFS_BASE}/etc/xdg/weston | 465 | install -m 0644 ${G_EMBEDIAN_PATH}/${SOM}/weston.ini ${ROOTFS_BASE}/etc/xdg/weston |
466 | install -m 0755 ${G_EMBEDIAN_PATH}/${SOM}/weston.config ${ROOTFS_BASE}/etc/default/weston | 466 | install -m 0755 ${G_EMBEDIAN_PATH}/${SOM}/weston.config ${ROOTFS_BASE}/etc/default/weston |
467 | install -m 0755 ${G_EMBEDIAN_PATH}/weston-start ${ROOTFS_BASE}/usr/bin/weston-start | 467 | install -m 0755 ${G_EMBEDIAN_PATH}/weston-start ${ROOTFS_BASE}/usr/bin/weston-start |
468 | install -m 0755 ${G_EMBEDIAN_PATH}/weston.profile ${ROOTFS_BASE}/etc/profile.d/weston.sh | 468 | install -m 0755 ${G_EMBEDIAN_PATH}/weston.profile ${ROOTFS_BASE}/etc/profile.d/weston.sh |
469 | install -m 0644 ${G_EMBEDIAN_PATH}/weston.service ${ROOTFS_BASE}/lib/systemd/system | 469 | install -m 0644 ${G_EMBEDIAN_PATH}/weston.service ${ROOTFS_BASE}/lib/systemd/system |
470 | ln -s /lib/systemd/system/weston.service \ | 470 | ln -s /lib/systemd/system/weston.service \ |
471 | ${ROOTFS_BASE}/etc/systemd/system/multi-user.target.wants/weston.service | 471 | ${ROOTFS_BASE}/etc/systemd/system/multi-user.target.wants/weston.service |
472 | 472 | ||
473 | ## end packages stage ## | 473 | ## end packages stage ## |
474 | [ "${G_USER_PACKAGES}" != "" ] && { | 474 | [ "${G_USER_PACKAGES}" != "" ] && { |
475 | 475 | ||
476 | pr_info "rootfs: install user defined packages (user-stage)" | 476 | pr_info "rootfs: install user defined packages (user-stage)" |
477 | pr_info "rootfs: G_USER_PACKAGES \"${G_USER_PACKAGES}\" " | 477 | pr_info "rootfs: G_USER_PACKAGES \"${G_USER_PACKAGES}\" " |
478 | 478 | ||
479 | echo "#!/bin/bash | 479 | echo "#!/bin/bash |
480 | # update packages | 480 | # update packages |
481 | apt-get update | 481 | apt-get update |
482 | apt-get upgrade | 482 | apt-get upgrade |
483 | 483 | ||
484 | # install all user packages | 484 | # install all user packages |
485 | apt-get -y install ${G_USER_PACKAGES} | 485 | apt-get -y install ${G_USER_PACKAGES} |
486 | 486 | ||
487 | rm -f user-stage | 487 | rm -f user-stage |
488 | " > user-stage | 488 | " > user-stage |
489 | 489 | ||
490 | chmod +x user-stage | 490 | chmod +x user-stage |
491 | chroot ${ROOTFS_BASE} /user-stage | 491 | chroot ${ROOTFS_BASE} /user-stage |
492 | 492 | ||
493 | }; | 493 | }; |
494 | 494 | ||
495 | ## binaries rootfs patching ## | 495 | ## binaries rootfs patching ## |
496 | install -m 0644 ${G_EMBEDIAN_PATH}/issue ${ROOTFS_BASE}/etc/ | 496 | install -m 0644 ${G_EMBEDIAN_PATH}/issue ${ROOTFS_BASE}/etc/ |
497 | install -m 0644 ${G_EMBEDIAN_PATH}/issue.net ${ROOTFS_BASE}/etc/ | 497 | install -m 0644 ${G_EMBEDIAN_PATH}/issue.net ${ROOTFS_BASE}/etc/ |
498 | install -m 0755 ${G_EMBEDIAN_PATH}/rc.local ${ROOTFS_BASE}/etc/ | 498 | install -m 0755 ${G_EMBEDIAN_PATH}/rc.local ${ROOTFS_BASE}/etc/ |
499 | install -m 0644 ${G_EMBEDIAN_PATH}/splash.bmp ${ROOTFS_BASE}/boot/ | 499 | install -m 0644 ${G_EMBEDIAN_PATH}/splash.bmp ${ROOTFS_BASE}/boot/ |
500 | cp ${PARAM_OUTPUT_DIR}/Image ${ROOTFS_BASE}/boot | 500 | cp ${PARAM_OUTPUT_DIR}/Image ${ROOTFS_BASE}/boot |
501 | cp ${PARAM_OUTPUT_DIR}/*.dtb ${ROOTFS_BASE}/boot | 501 | cp ${PARAM_OUTPUT_DIR}/*.dtb ${ROOTFS_BASE}/boot |
502 | ln -sf fsl-smarcimx8mm.dtb ${ROOTFS_BASE}/boot/fsl-smarcimx8mm.dtb | 502 | ln -sf fsl-smarcimx8mm.dtb ${ROOTFS_BASE}/boot/fsl-smarcimx8mm.dtb |
503 | 503 | ||
504 | mkdir -p ${ROOTFS_BASE}/usr/share/images/desktop-base/ | 504 | mkdir -p ${ROOTFS_BASE}/usr/share/images/desktop-base/ |
505 | install -m 0644 ${G_EMBEDIAN_PATH}/wallpaper.png \ | 505 | install -m 0644 ${G_EMBEDIAN_PATH}/wallpaper.png \ |
506 | ${ROOTFS_BASE}/usr/share/images/desktop-base/default | 506 | ${ROOTFS_BASE}/usr/share/images/desktop-base/default |
507 | 507 | ||
508 | ## added alsa default configs ## | 508 | ## added alsa default configs ## |
509 | install -m 0644 ${G_EMBEDIAN_PATH}/asound.state ${ROOTFS_BASE}/var/lib/alsa/ | 509 | install -m 0644 ${G_EMBEDIAN_PATH}/asound.state ${ROOTFS_BASE}/var/lib/alsa/ |
510 | install -m 0644 ${G_EMBEDIAN_PATH}/asound.conf ${ROOTFS_BASE}/etc/ | 510 | install -m 0644 ${G_EMBEDIAN_PATH}/asound.conf ${ROOTFS_BASE}/etc/ |
511 | 511 | ||
512 | ## Revert regular booting | 512 | ## Revert regular booting |
513 | rm -f ${ROOTFS_BASE}/usr/sbin/policy-rc.d | 513 | rm -f ${ROOTFS_BASE}/usr/sbin/policy-rc.d |
514 | 514 | ||
515 | ## install kernel modules in rootfs | 515 | ## install kernel modules in rootfs |
516 | install_kernel_modules ${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_LINUX_KERNEL_DEF_CONFIG} ${G_LINUX_KERNEL_SRC_DIR} ${ROOTFS_BASE} || { | 516 | install_kernel_modules ${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_LINUX_KERNEL_DEF_CONFIG} ${G_LINUX_KERNEL_SRC_DIR} ${ROOTFS_BASE} || { |
517 | pr_error "Failed #$? in function install_kernel_modules" | 517 | pr_error "Failed #$? in function install_kernel_modules" |
518 | return 2; | 518 | return 2; |
519 | } | 519 | } |
520 | 520 | ||
521 | ## copy all kernel headers for development | 521 | ## copy all kernel headers for development |
522 | mkdir -p ${ROOTFS_BASE}/usr/local/src/linux-imx/drivers/staging/android/uapi | 522 | mkdir -p ${ROOTFS_BASE}/usr/local/src/linux-imx/drivers/staging/android/uapi |
523 | cp ${G_LINUX_KERNEL_SRC_DIR}/drivers/staging/android/uapi/* ${ROOTFS_BASE}/usr/local/src/linux-imx/drivers/staging/android/uapi | 523 | cp ${G_LINUX_KERNEL_SRC_DIR}/drivers/staging/android/uapi/* ${ROOTFS_BASE}/usr/local/src/linux-imx/drivers/staging/android/uapi |
524 | cp -r ${G_LINUX_KERNEL_SRC_DIR}/include ${ROOTFS_BASE}/usr/local/src/linux-imx/ | 524 | cp -r ${G_LINUX_KERNEL_SRC_DIR}/include ${ROOTFS_BASE}/usr/local/src/linux-imx/ |
525 | 525 | ||
526 | ## copy custom files | 526 | ## copy custom files |
527 | cp ${G_EMBEDIAN_PATH}/10-imx.rules ${ROOTFS_BASE}/etc/udev/rules.d | 527 | cp ${G_EMBEDIAN_PATH}/10-imx.rules ${ROOTFS_BASE}/etc/udev/rules.d |
528 | cp ${G_EMBEDIAN_PATH}/${SOM}/*.rules ${ROOTFS_BASE}/etc/udev/rules.d | 528 | cp ${G_EMBEDIAN_PATH}/${SOM}/*.rules ${ROOTFS_BASE}/etc/udev/rules.d |
529 | 529 | ||
530 | 530 | ||
531 | ## clenup command | 531 | ## clenup command |
532 | echo "#!/bin/bash | 532 | echo "#!/bin/bash |
533 | apt-get clean | 533 | apt-get clean |
534 | rm -f cleanup | 534 | rm -f cleanup |
535 | " > cleanup | 535 | " > cleanup |
536 | 536 | ||
537 | # clean all packages | 537 | # clean all packages |
538 | pr_info "rootfs: clean" | 538 | pr_info "rootfs: clean" |
539 | chmod +x cleanup | 539 | chmod +x cleanup |
540 | chroot ${ROOTFS_BASE} /cleanup | 540 | chroot ${ROOTFS_BASE} /cleanup |
541 | umount ${ROOTFS_BASE}/{sys,proc,dev/pts,dev} | 541 | umount ${ROOTFS_BASE}/{sys,proc,dev/pts,dev} |
542 | 542 | ||
543 | ## kill latest dbus-daemon instance due to qemu-aarch64-static | 543 | ## kill latest dbus-daemon instance due to qemu-aarch64-static |
544 | QEMU_PROC_ID=$(ps axf | grep dbus-daemon | grep qemu-aarch64-static | awk '{print $1}') | 544 | QEMU_PROC_ID=$(ps axf | grep dbus-daemon | grep qemu-aarch64-static | awk '{print $1}') |
545 | if [ -n "$QEMU_PROC_ID" ] | 545 | if [ -n "$QEMU_PROC_ID" ] |
546 | then | 546 | then |
547 | kill -9 $QEMU_PROC_ID | 547 | kill -9 $QEMU_PROC_ID |
548 | fi | 548 | fi |
549 | 549 | ||
550 | rm ${ROOTFS_BASE}/usr/bin/qemu-aarch64-static | 550 | rm ${ROOTFS_BASE}/usr/bin/qemu-aarch64-static |
551 | 551 | ||
552 | return 0; | 552 | return 0; |
553 | } | 553 | } |
554 | 554 | ||
555 | # make tarbar arx from footfs | 555 | # make tarbar arx from footfs |
556 | # $1 -- packet folder | 556 | # $1 -- packet folder |
557 | # $2 -- output arx full name | 557 | # $2 -- output arx full name |
558 | function make_tarbar() { | 558 | function make_tarbar() { |
559 | cd $1 | 559 | cd $1 |
560 | 560 | ||
561 | chown root:root . | 561 | chown root:root . |
562 | pr_info "make tarbar arx from folder ${1}" | 562 | pr_info "make tarbar arx from folder ${1}" |
563 | pr_info "Remove old arx $2" | 563 | pr_info "Remove old arx $2" |
564 | rm $2 > /dev/null 2>&1 && :; | 564 | rm $2 > /dev/null 2>&1 && :; |
565 | 565 | ||
566 | pr_info "Create $2" | 566 | pr_info "Create $2" |
567 | 567 | ||
568 | tar czf $2 . | 568 | tar czf $2 . |
569 | success=$? | 569 | success=$? |
570 | [ $success -eq 0 ] || { | 570 | [ $success -eq 0 ] || { |
571 | # fail | 571 | # fail |
572 | rm $2 > /dev/null 2>&1 && :; | 572 | rm $2 > /dev/null 2>&1 && :; |
573 | }; | 573 | }; |
574 | 574 | ||
575 | cd - | 575 | cd - |
576 | } | 576 | } |
577 | 577 | ||
578 | # make linux kernel modules | 578 | # make linux kernel modules |
579 | # $1 -- cross compiler prefix | 579 | # $1 -- cross compiler prefix |
580 | # $2 -- linux defconfig file | 580 | # $2 -- linux defconfig file |
581 | # $3 -- linux dtb files | 581 | # $3 -- linux dtb files |
582 | # $4 -- linux dirname | 582 | # $4 -- linux dirname |
583 | # $5 -- out path | 583 | # $5 -- out path |
584 | function make_kernel() { | 584 | function make_kernel() { |
585 | pr_info "make kernel .config" | 585 | pr_info "make kernel .config" |
586 | make ARCH=arm64 CROSS_COMPILE=${1} ${G_CROSS_COMPILER_JOPTION} -C ${4}/ ${2} | 586 | make ARCH=arm64 CROSS_COMPILE=${1} ${G_CROSS_COMPILER_JOPTION} -C ${4}/ ${2} |
587 | 587 | ||
588 | pr_info "make kernel" | 588 | pr_info "make kernel" |
589 | make CROSS_COMPILE=${1} ARCH=arm64 ${G_CROSS_COMPILER_JOPTION} -C ${4}/ Image | 589 | make CROSS_COMPILE=${1} ARCH=arm64 ${G_CROSS_COMPILER_JOPTION} -C ${4}/ Image |
590 | 590 | ||
591 | pr_info "make ${3}" | 591 | pr_info "make ${3}" |
592 | make CROSS_COMPILE=${1} ARCH=arm64 ${G_CROSS_COMPILER_JOPTION} -C ${4} ${3} | 592 | make CROSS_COMPILE=${1} ARCH=arm64 ${G_CROSS_COMPILER_JOPTION} -C ${4} ${3} |
593 | 593 | ||
594 | pr_info "Copy kernel and dtb files to output dir: ${5}" | 594 | pr_info "Copy kernel and dtb files to output dir: ${5}" |
595 | cp ${4}/arch/arm64/boot/Image ${5}/; | 595 | cp ${4}/arch/arm64/boot/Image ${5}/; |
596 | cp ${4}/arch/arm64/boot/dts/embedian/*.dtb ${5}/; | 596 | cp ${4}/arch/arm64/boot/dts/embedian/*.dtb ${5}/; |
597 | 597 | ||
598 | return 0; | 598 | return 0; |
599 | } | 599 | } |
600 | 600 | ||
601 | # clean kernel | 601 | # clean kernel |
602 | # $1 -- linux dir path | 602 | # $1 -- linux dir path |
603 | function clean_kernel() { | 603 | function clean_kernel() { |
604 | pr_info "Clean linux kernel" | 604 | pr_info "Clean linux kernel" |
605 | 605 | ||
606 | make ARCH=arm64 -C ${1}/ mrproper | 606 | make ARCH=arm64 -C ${1}/ mrproper |
607 | 607 | ||
608 | return 0; | 608 | return 0; |
609 | } | 609 | } |
610 | 610 | ||
611 | # make linux kernel modules | 611 | # make linux kernel modules |
612 | # $1 -- cross compiler prefix | 612 | # $1 -- cross compiler prefix |
613 | # $2 -- linux defconfig file | 613 | # $2 -- linux defconfig file |
614 | # $3 -- linux dirname | 614 | # $3 -- linux dirname |
615 | # $4 -- out modules path | 615 | # $4 -- out modules path |
616 | function make_kernel_modules() { | 616 | function make_kernel_modules() { |
617 | pr_info "make kernel defconfig" | 617 | pr_info "make kernel defconfig" |
618 | make ARCH=arm64 CROSS_COMPILE=${1} ${G_CROSS_COMPILER_JOPTION} -C ${3} ${2} | 618 | make ARCH=arm64 CROSS_COMPILE=${1} ${G_CROSS_COMPILER_JOPTION} -C ${3} ${2} |
619 | 619 | ||
620 | pr_info "Compiling kernel modules" | 620 | pr_info "Compiling kernel modules" |
621 | make ARCH=arm64 CROSS_COMPILE=${1} ${G_CROSS_COMPILER_JOPTION} -C ${3} modules | 621 | make ARCH=arm64 CROSS_COMPILE=${1} ${G_CROSS_COMPILER_JOPTION} -C ${3} modules |
622 | } | 622 | } |
623 | 623 | ||
624 | # install linux kernel modules | 624 | # install linux kernel modules |
625 | # $1 -- cross compiler prefix | 625 | # $1 -- cross compiler prefix |
626 | # $2 -- linux defconfig file | 626 | # $2 -- linux defconfig file |
627 | # $3 -- linux dirname | 627 | # $3 -- linux dirname |
628 | # $4 -- out modules path | 628 | # $4 -- out modules path |
629 | function install_kernel_modules() { | 629 | function install_kernel_modules() { |
630 | pr_info "Installing kernel headers to ${4}" | 630 | pr_info "Installing kernel headers to ${4}" |
631 | make ARCH=arm64 CROSS_COMPILE=${1} ${G_CROSS_COMPILER_JOPTION} -C ${3} INSTALL_HDR_PATH=${4}/usr/local headers_install | 631 | make ARCH=arm64 CROSS_COMPILE=${1} ${G_CROSS_COMPILER_JOPTION} -C ${3} INSTALL_HDR_PATH=${4}/usr/local headers_install |
632 | 632 | ||
633 | pr_info "Installing kernel modules to ${4}" | 633 | pr_info "Installing kernel modules to ${4}" |
634 | make ARCH=arm64 CROSS_COMPILE=${1} ${G_CROSS_COMPILER_JOPTION} -C ${3} INSTALL_MOD_PATH=${4} modules_install | 634 | make ARCH=arm64 CROSS_COMPILE=${1} ${G_CROSS_COMPILER_JOPTION} -C ${3} INSTALL_MOD_PATH=${4} modules_install |
635 | 635 | ||
636 | return 0; | 636 | return 0; |
637 | } | 637 | } |
638 | 638 | ||
639 | # make uboot | 639 | # make uboot |
640 | # $1 uboot path | 640 | # $1 uboot path |
641 | # $2 outputdir | 641 | # $2 outputdir |
642 | function make_uboot() { | 642 | function make_uboot() { |
643 | ### make emmc uboot ### | 643 | ### make emmc uboot ### |
644 | pr_info "Make SPL & u-boot: ${G_UBOOT_DEF_CONFIG}" | 644 | pr_info "Make SPL & u-boot: ${G_UBOOT_DEF_CONFIG}" |
645 | # clean work directory | 645 | # clean work directory |
646 | make ARCH=arm64 -C ${1} CROSS_COMPILE=${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_CROSS_COMPILER_JOPTION} mrproper | 646 | make ARCH=arm64 -C ${1} CROSS_COMPILE=${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_CROSS_COMPILER_JOPTION} mrproper |
647 | 647 | ||
648 | # make uboot config for mmc | 648 | # make uboot config for mmc |
649 | make ARCH=arm64 -C ${1} CROSS_COMPILE=${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_CROSS_COMPILER_JOPTION} ${G_UBOOT_DEF_CONFIG} | 649 | make ARCH=arm64 -C ${1} CROSS_COMPILE=${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_CROSS_COMPILER_JOPTION} ${G_UBOOT_DEF_CONFIG} |
650 | 650 | ||
651 | # make uboot | 651 | # make uboot |
652 | make -C ${1} CROSS_COMPILE=${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_CROSS_COMPILER_JOPTION} | 652 | make -C ${1} CROSS_COMPILE=${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_CROSS_COMPILER_JOPTION} |
653 | 653 | ||
654 | if [ "${SOM}" = "smarc-imx8m" ]; then | 654 | if [ "${SOM}" = "smarc-imx8m" ]; then |
655 | HDMI=yes | 655 | HDMI=yes |
656 | UBOOT_DTB="fsl-smarcimx8mq.dtb" | 656 | UBOOT_DTB="fsl-smarcimx8mq.dtb" |
657 | else | 657 | else |
658 | HDMI=no | 658 | HDMI=no |
659 | UBOOT_DTB="fsl-smarcimx8mm.dtb" | 659 | UBOOT_DTB="fsl-smarcimx8mm.dtb" |
660 | fi | 660 | fi |
661 | 661 | ||
662 | # Copy u-boot, SPL and DTB | 662 | # Copy u-boot, SPL and DTB |
663 | cd ${G_EMBEDIAN_PATH}/${SOM}/imx-mkimage | 663 | cd ${G_EMBEDIAN_PATH}/${SOM}/imx-mkimage |
664 | rm -f iMX8M/u-boot* iMX8M/*.dtb | 664 | rm -f iMX8M/u-boot* iMX8M/*.dtb |
665 | cp ${1}/u-boot.bin ${1}/u-boot-nodtb.bin ${1}/spl/u-boot-spl.bin ${1}/arch/arm/dts/${UBOOT_DTB} iMX8M/ | 665 | cp ${1}/u-boot.bin ${1}/u-boot-nodtb.bin ${1}/spl/u-boot-spl.bin ${1}/arch/arm/dts/${UBOOT_DTB} iMX8M/ |
666 | cp ${1}/tools/mkimage iMX8M/mkimage_uboot | 666 | cp ${1}/tools/mkimage iMX8M/mkimage_uboot |
667 | 667 | ||
668 | # Build final image | 668 | # Build final image |
669 | if [ "${HDMI}" = "yes" ]; then | 669 | if [ "${HDMI}" = "yes" ]; then |
670 | make CROSS_COMPILE=${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_CROSS_COMPILER_JOPTION} SOC=iMX8M flash_hdmi_spl_uboot | 670 | make CROSS_COMPILE=${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_CROSS_COMPILER_JOPTION} SOC=iMX8M flash_hdmi_spl_uboot |
671 | else | 671 | else |
672 | make CROSS_COMPILE=${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_CROSS_COMPILER_JOPTION} SOC=iMX8MM flash_spl_uboot | 672 | make CROSS_COMPILE=${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_CROSS_COMPILER_JOPTION} SOC=iMX8MM flash_spl_uboot |
673 | fi | 673 | fi |
674 | 674 | ||
675 | # copy images | 675 | # copy images |
676 | cp iMX8M/flash.bin ${2}/${G_UBOOT_NAME} | 676 | cp iMX8M/flash.bin ${2}/${G_UBOOT_NAME} |
677 | 677 | ||
678 | return 0; | 678 | return 0; |
679 | } | 679 | } |
680 | 680 | ||
681 | # clean uboot | 681 | # clean uboot |
682 | # $1 -- u-boot dir path | 682 | # $1 -- u-boot dir path |
683 | function clean_uboot() { | 683 | function clean_uboot() { |
684 | pr_info "Clean uboot" | 684 | pr_info "Clean uboot" |
685 | 685 | ||
686 | make ARCH=arm64 -C ${1}/ mrproper | 686 | make ARCH=arm64 -C ${1}/ mrproper |
687 | 687 | ||
688 | return 0; | 688 | return 0; |
689 | } | 689 | } |
690 | 690 | ||
691 | # make sdcard for device | 691 | # make sdcard for device |
692 | # $1 -- block device | 692 | # $1 -- block device |
693 | function check_sdcard() | 693 | function check_sdcard() |
694 | { | 694 | { |
695 | # Check that parameter is a valid block device | 695 | # Check that parameter is a valid block device |
696 | if [ ! -b "$1" ]; then | 696 | if [ ! -b "$1" ]; then |
697 | pr_error "$1 is not a valid block device, exiting" | 697 | pr_error "$1 is not a valid block device, exiting" |
698 | return 1 | 698 | return 1 |
699 | fi | 699 | fi |
700 | 700 | ||
701 | local dev=$(basename $1) | 701 | local dev=$(basename $1) |
702 | 702 | ||
703 | # Check that /sys/block/$dev exists | 703 | # Check that /sys/block/$dev exists |
704 | if [ ! -d /sys/block/$dev ]; then | 704 | if [ ! -d /sys/block/$dev ]; then |
705 | pr_error "Directory /sys/block/${dev} missing, exiting" | 705 | pr_error "Directory /sys/block/${dev} missing, exiting" |
706 | return 1 | 706 | return 1 |
707 | fi | 707 | fi |
708 | 708 | ||
709 | # Get device parameters | 709 | # Get device parameters |
710 | local removable=$(cat /sys/block/${dev}/removable) | 710 | local removable=$(cat /sys/block/${dev}/removable) |
711 | local block_size=$(cat /sys/class/block/${dev}/queue/physical_block_size) | 711 | local block_size=$(cat /sys/class/block/${dev}/queue/physical_block_size) |
712 | local size_bytes=$((${block_size}*$(cat /sys/class/block/${dev}/size))) | 712 | local size_bytes=$((${block_size}*$(cat /sys/class/block/${dev}/size))) |
713 | local size_gib=$(bc <<< "scale=1; ${size_bytes}/(1024*1024*1024)") | 713 | local size_gib=$(bc <<< "scale=1; ${size_bytes}/(1024*1024*1024)") |
714 | 714 | ||
715 | # non removable SD card readers require additional check | 715 | # non removable SD card readers require additional check |
716 | if [ "${removable}" != "1" ]; then | 716 | if [ "${removable}" != "1" ]; then |
717 | local drive=$(udisksctl info -b /dev/${dev}|grep "Drive:"|cut -d"'" -f 2) | 717 | local drive=$(udisksctl info -b /dev/${dev}|grep "Drive:"|cut -d"'" -f 2) |
718 | local mediaremovable=$(gdbus call --system --dest org.freedesktop.UDisks2 --object-path ${drive} --method org.freedesktop.DBus.Properties.Get org.freedesktop.UDisks2.Drive MediaRemovable) | 718 | local mediaremovable=$(gdbus call --system --dest org.freedesktop.UDisks2 --object-path ${drive} --method org.freedesktop.DBus.Properties.Get org.freedesktop.UDisks2.Drive MediaRemovable) |
719 | if [[ "${mediaremovable}" = *"true"* ]]; then | 719 | if [[ "${mediaremovable}" = *"true"* ]]; then |
720 | removable=1 | 720 | removable=1 |
721 | fi | 721 | fi |
722 | fi | 722 | fi |
723 | 723 | ||
724 | # Check that device is either removable or loop | 724 | # Check that device is either removable or loop |
725 | if [ "$removable" != "1" -a $(stat -c '%t' /dev/$dev) != ${LOOP_MAJOR} ]; then | 725 | if [ "$removable" != "1" -a $(stat -c '%t' /dev/$dev) != ${LOOP_MAJOR} ]; then |
726 | pr_error "$1 is not a removable device, exiting" | 726 | pr_error "$1 is not a removable device, exiting" |
727 | return 1 | 727 | return 1 |
728 | fi | 728 | fi |
729 | 729 | ||
730 | # Check that device is attached | 730 | # Check that device is attached |
731 | if [ ${size_bytes} -eq 0 ]; then | 731 | if [ ${size_bytes} -eq 0 ]; then |
732 | pr_error "$1 is not attached, exiting" | 732 | pr_error "$1 is not attached, exiting" |
733 | return 1 | 733 | return 1 |
734 | fi | 734 | fi |
735 | 735 | ||
736 | pr_info "Device: ${LPARAM_BLOCK_DEVICE}, ${size_gib}GiB" | 736 | pr_info "Device: ${LPARAM_BLOCK_DEVICE}, ${size_gib}GiB" |
737 | pr_info "================================================" | 737 | pr_info "================================================" |
738 | read -p "Press Enter to continue" | 738 | read -p "Press Enter to continue" |
739 | 739 | ||
740 | return 0 | 740 | return 0 |
741 | } | 741 | } |
742 | 742 | ||
743 | # make sdcard for device | 743 | # make sdcard for device |
744 | # $1 -- block device | 744 | # $1 -- block device |
745 | # $2 -- output images dir | 745 | # $2 -- output images dir |
746 | function make_sdcard() { | 746 | function make_sdcard() { |
747 | readonly local LPARAM_BLOCK_DEVICE=${1} | 747 | readonly local LPARAM_BLOCK_DEVICE=${1} |
748 | readonly local LPARAM_OUTPUT_DIR=${2} | 748 | readonly local LPARAM_OUTPUT_DIR=${2} |
749 | readonly local P1_MOUNT_DIR="${G_TMP_DIR}/p1" | 749 | readonly local P1_MOUNT_DIR="${G_TMP_DIR}/p1" |
750 | readonly local P2_MOUNT_DIR="${G_TMP_DIR}/p2" | 750 | readonly local P2_MOUNT_DIR="${G_TMP_DIR}/p2" |
751 | readonly local DEBIAN_IMAGES_TO_ROOTFS_POINT="opt/images/Debian" | 751 | readonly local DEBIAN_IMAGES_TO_ROOTFS_POINT="opt/images/Debian" |
752 | 752 | ||
753 | readonly local BOOTLOAD_RESERVE_SIZE=2 | 753 | readonly local BOOTLOAD_RESERVE_SIZE=2 |
754 | readonly local PART1_SIZE=48 | 754 | readonly local PART1_SIZE=48 |
755 | readonly local BOOTPART=1 | 755 | readonly local BOOTPART=1 |
756 | readonly local ROOTFSPART=2 | 756 | readonly local ROOTFSPART=2 |
757 | readonly local SPARE_SIZE=4 | 757 | readonly local SPARE_SIZE=4 |
758 | 758 | ||
759 | [ "${LPARAM_BLOCK_DEVICE}" = "na" ] && { | 759 | [ "${LPARAM_BLOCK_DEVICE}" = "na" ] && { |
760 | pr_warning "No valid block device: ${LPARAM_BLOCK_DEVICE}" | 760 | pr_warning "No valid block device: ${LPARAM_BLOCK_DEVICE}" |
761 | return 1; | 761 | return 1; |
762 | }; | 762 | }; |
763 | 763 | ||
764 | local part="" | 764 | local part="" |
765 | if [ `echo ${LPARAM_BLOCK_DEVICE} | grep -c mmcblk` -ne 0 ]; then | 765 | if [ `echo ${LPARAM_BLOCK_DEVICE} | grep -c mmcblk` -ne 0 ]; then |
766 | part="p" | 766 | part="p" |
767 | fi | 767 | fi |
768 | 768 | ||
769 | # Check that we're using a valid device | 769 | # Check that we're using a valid device |
770 | if ! check_sdcard ${LPARAM_BLOCK_DEVICE}; then | 770 | if ! check_sdcard ${LPARAM_BLOCK_DEVICE}; then |
771 | return 1 | 771 | return 1 |
772 | fi | 772 | fi |
773 | 773 | ||
774 | for ((i=0; i<10; i++)) | 774 | for ((i=0; i<10; i++)) |
775 | do | 775 | do |
776 | if [ `mount | grep -c ${LPARAM_BLOCK_DEVICE}${part}$i` -ne 0 ]; then | 776 | if [ `mount | grep -c ${LPARAM_BLOCK_DEVICE}${part}$i` -ne 0 ]; then |
777 | umount ${LPARAM_BLOCK_DEVICE}${part}$i | 777 | umount ${LPARAM_BLOCK_DEVICE}${part}$i |
778 | fi | 778 | fi |
779 | done | 779 | done |
780 | 780 | ||
781 | function format_sdcard | 781 | function format_sdcard |
782 | { | 782 | { |
783 | pr_info "Formating SDCARD partitions" | 783 | pr_info "Formating SDCARD partitions" |
784 | mkfs.vfat -F 16 ${LPARAM_BLOCK_DEVICE}${part}1 -n boot | 784 | mkfs.vfat -F 16 ${LPARAM_BLOCK_DEVICE}${part}1 -n boot |
785 | mkfs.ext4 ${LPARAM_BLOCK_DEVICE}${part}2 -L rootfs | 785 | mkfs.ext4 ${LPARAM_BLOCK_DEVICE}${part}2 -L rootfs |
786 | } | 786 | } |
787 | 787 | ||
788 | function flash_u-boot | 788 | function flash_u-boot |
789 | { | 789 | { |
790 | pr_info "Flashing U-Boot" | 790 | pr_info "Flashing U-Boot" |
791 | dd if=${LPARAM_OUTPUT_DIR}/${G_UBOOT_NAME} of=${LPARAM_BLOCK_DEVICE} bs=1K seek=33; sync | 791 | dd if=${LPARAM_OUTPUT_DIR}/${G_UBOOT_NAME} of=${LPARAM_BLOCK_DEVICE} bs=1K seek=33; sync |
792 | } | 792 | } |
793 | 793 | ||
794 | function flash_sdcard | 794 | function flash_sdcard |
795 | { | 795 | { |
796 | pr_info "Flashing \"Image, device tree and rootfs\" partition" | 796 | pr_info "Flashing \"Image, device tree and rootfs\" partition" |
797 | cp -v ${LPARAM_OUTPUT_DIR}/Image ${P1_MOUNT_DIR}/ | 797 | cp -v ${LPARAM_OUTPUT_DIR}/Image ${P1_MOUNT_DIR}/ |
798 | mkdir -p ${P1_MOUNT_DIR}/dtbs/ | 798 | mkdir -p ${P1_MOUNT_DIR}/dtbs/ |
799 | cp -v ${LPARAM_OUTPUT_DIR}/fsl-smarcimx8mm.dtb ${P1_MOUNT_DIR}/dtbs/fsl-smarcimx8mm.dtb | 799 | cp -v ${LPARAM_OUTPUT_DIR}/fsl-smarcimx8mm.dtb ${P1_MOUNT_DIR}/dtbs/fsl-smarcimx8mm.dtb |
800 | cp -v ${G_EMBEDIAN_PATH}/uEnv_8mm.txt ${P1_MOUNT_DIR}/uEnv.txt | 800 | cp -v ${G_EMBEDIAN_PATH}/uEnv_8mm.txt ${P1_MOUNT_DIR}/uEnv.txt |
801 | tar -xpf ${LPARAM_OUTPUT_DIR}/${DEF_ROOTFS_TARBAR_NAME} -C ${P2_MOUNT_DIR}/ | 801 | tar -xpf ${LPARAM_OUTPUT_DIR}/${DEF_ROOTFS_TARBAR_NAME} -C ${P2_MOUNT_DIR}/ |
802 | } | 802 | } |
803 | 803 | ||
804 | function copy_debian_images | 804 | function copy_debian_images |
805 | { | 805 | { |
806 | mkdir -p ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT} | 806 | mkdir -p ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT} |
807 | 807 | ||
808 | pr_info "Copying Debian images to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" | 808 | pr_info "Copying Debian images to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" |
809 | cp ${LPARAM_OUTPUT_DIR}/${DEF_ROOTFS_TARBAR_NAME} ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/${DEF_ROOTFS_TARBAR_NAME} | 809 | cp ${LPARAM_OUTPUT_DIR}/${DEF_ROOTFS_TARBAR_NAME} ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/${DEF_ROOTFS_TARBAR_NAME} |
810 | 810 | ||
811 | pr_info "Copying U-Boot to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" | 811 | pr_info "Copying U-Boot to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" |
812 | cp ${LPARAM_OUTPUT_DIR}/${G_UBOOT_NAME} ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/ | 812 | cp ${LPARAM_OUTPUT_DIR}/${G_UBOOT_NAME} ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/ |
813 | 813 | ||
814 | pr_info "Copying Image and device tree files to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" | 814 | pr_info "Copying Image and device tree files to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" |
815 | cp ${LPARAM_OUTPUT_DIR}/Image ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/ | 815 | cp ${LPARAM_OUTPUT_DIR}/Image ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/ |
816 | cp ${LPARAM_OUTPUT_DIR}/*.dtb ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/ | 816 | cp ${LPARAM_OUTPUT_DIR}/*.dtb ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/ |
817 | cp ${G_EMBEDIAN_PATH}/uEnv_emmc_8mm.txt ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/uEnv.txt | 817 | cp ${G_EMBEDIAN_PATH}/uEnv_emmc_8mm.txt ${P2_MOUNT_DIR}/${DEBIAN_IMAGES_TO_ROOTFS_POINT}/uEnv.txt |
818 | 818 | ||
819 | return 0; | 819 | return 0; |
820 | } | 820 | } |
821 | 821 | ||
822 | function copy_scripts | 822 | function copy_scripts |
823 | { | 823 | { |
824 | pr_info "Copying scripts to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" | 824 | pr_info "Copying scripts to /${DEBIAN_IMAGES_TO_ROOTFS_POINT}" |
825 | cp ${G_EMBEDIAN_PATH}/debian-emmc.sh ${P2_MOUNT_DIR}/usr/sbin/ | 825 | cp ${G_EMBEDIAN_PATH}/debian-emmc.sh ${P2_MOUNT_DIR}/usr/sbin/ |
826 | } | 826 | } |
827 | 827 | ||
828 | function ceildiv | 828 | function ceildiv |
829 | { | 829 | { |
830 | local num=$1 | 830 | local num=$1 |
831 | local div=$2 | 831 | local div=$2 |
832 | echo $(( (num + div - 1) / div )) | 832 | echo $(( (num + div - 1) / div )) |
833 | } | 833 | } |
834 | 834 | ||
835 | # Delete the partitions | 835 | # Delete the partitions |
836 | for ((i=0; i<10; i++)) | 836 | for ((i=0; i<10; i++)) |
837 | do | 837 | do |
838 | if [ `ls ${LPARAM_BLOCK_DEVICE}${part}$i 2> /dev/null | grep -c ${LPARAM_BLOCK_DEVICE}${part}$i` -ne 0 ]; then | 838 | if [ `ls ${LPARAM_BLOCK_DEVICE}${part}$i 2> /dev/null | grep -c ${LPARAM_BLOCK_DEVICE}${part}$i` -ne 0 ]; then |
839 | dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE}${part}$i bs=512 count=1024 | 839 | dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE}${part}$i bs=512 count=1024 |
840 | fi | 840 | fi |
841 | done | 841 | done |
842 | sync | 842 | sync |
843 | 843 | ||
844 | ((echo d; echo 1; echo d; echo 2; echo d; echo 3; echo d; echo w) | fdisk ${LPARAM_BLOCK_DEVICE} &> /dev/null) || true | 844 | ((echo d; echo 1; echo d; echo 2; echo d; echo 3; echo d; echo w) | fdisk ${LPARAM_BLOCK_DEVICE} &> /dev/null) || true |
845 | sync | 845 | sync |
846 | 846 | ||
847 | dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE} bs=1024 count=4096 | 847 | dd if=/dev/zero of=${LPARAM_BLOCK_DEVICE} bs=1024 count=4096 |
848 | sleep 2; sync; | 848 | sleep 2; sync; |
849 | 849 | ||
850 | pr_info "Creating new partitions" | 850 | pr_info "Creating new partitions" |
851 | 851 | ||
852 | # Create a new partition table | 852 | # Create a new partition table |
853 | 853 | ||
854 | # Get total card size | 854 | # Get total card size |
855 | TOTAL_SIZE=`fdisk -s ${LPARAM_BLOCK_DEVICE}` | 855 | TOTAL_SIZE=`fdisk -s ${LPARAM_BLOCK_DEVICE}` |
856 | TOTAL_SIZE=`expr ${TOTAL_SIZE} / 1024` | 856 | TOTAL_SIZE=`expr ${TOTAL_SIZE} / 1024` |
857 | ROOTFS_SIZE=`expr ${TOTAL_SIZE} - ${BOOTLOAD_RESERVE_SIZE} - ${PART1_SIZE} - ${SPARE_SIZE}` | 857 | ROOTFS_SIZE=`expr ${TOTAL_SIZE} - ${BOOTLOAD_RESERVE_SIZE} - ${PART1_SIZE} - ${SPARE_SIZE}` |
858 | 858 | ||
859 | pr_info "ROOT SIZE=${ROOTFS_SIZE} TOTAl SIZE=${TOTAL_SIZE}" | 859 | pr_info "ROOT SIZE=${ROOTFS_SIZE} TOTAl SIZE=${TOTAL_SIZE}" |
860 | 860 | ||
861 | BLOCK=`echo ${LPARAM_BLOCK_DEVICE} | cut -d "/" -f 3` | 861 | BLOCK=`echo ${LPARAM_BLOCK_DEVICE} | cut -d "/" -f 3` |
862 | SECT_SIZE_BYTES=`cat /sys/block/${BLOCK}/queue/physical_block_size` | 862 | SECT_SIZE_BYTES=`cat /sys/block/${BLOCK}/queue/physical_block_size` |
863 | 863 | ||
864 | BOOTLOAD_RESERVE_SIZE_BYTES=$((BOOTLOAD_RESERVE_SIZE * 1024 * 1024)) | 864 | BOOTLOAD_RESERVE_SIZE_BYTES=$((BOOTLOAD_RESERVE_SIZE * 1024 * 1024)) |
865 | PART1_SIZE_BYTES=$((PART1_SIZE * 1024 * 1024)) | 865 | PART1_SIZE_BYTES=$((PART1_SIZE * 1024 * 1024)) |
866 | PART1_END_BYTES=`expr ${BOOTLOAD_RESERVE_SIZE_BYTES} + ${PART1_SIZE_BYTES}` | 866 | PART1_END_BYTES=`expr ${BOOTLOAD_RESERVE_SIZE_BYTES} + ${PART1_SIZE_BYTES}` |
867 | ROOTFS_SIZE_BYTES=$((ROOTFS_SIZE * 1024 * 1024)) | 867 | ROOTFS_SIZE_BYTES=$((ROOTFS_SIZE * 1024 * 1024)) |
868 | 868 | ||
869 | PART1_FIRST_SECT=`ceildiv ${BOOTLOAD_RESERVE_SIZE_BYTES} ${SECT_SIZE_BYTES}` | 869 | PART1_FIRST_SECT=`ceildiv ${BOOTLOAD_RESERVE_SIZE_BYTES} ${SECT_SIZE_BYTES}` |
870 | PART1_END_SECT=`ceildiv ${PART1_END_BYTES} ${SECT_SIZE_BYTES}` | 870 | PART1_END_SECT=`ceildiv ${PART1_END_BYTES} ${SECT_SIZE_BYTES}` |
871 | PART2_FIRST_SECT=`expr ${PART1_END_SECT} + 1 ` | 871 | PART2_FIRST_SECT=`expr ${PART1_END_SECT} + 1 ` |
872 | 872 | ||
873 | (echo n; echo p; echo $BOOTPART; echo $PART1_FIRST_SECT; \ | 873 | (echo n; echo p; echo $BOOTPART; echo $PART1_FIRST_SECT; \ |
874 | echo $PART1_END_SECT; echo n; echo p; echo $ROOTFSPART; \ | 874 | echo $PART1_END_SECT; echo n; echo p; echo $ROOTFSPART; \ |
875 | echo $PART2_FIRST_SECT; echo; echo p; echo w) | fdisk -u ${LPARAM_BLOCK_DEVICE} > /dev/null | 875 | echo $PART2_FIRST_SECT; echo; echo p; echo w) | fdisk -u ${LPARAM_BLOCK_DEVICE} > /dev/null |
876 | 876 | ||
877 | sleep 2; sync; | 877 | sleep 2; sync; |
878 | fdisk -l ${LPARAM_BLOCK_DEVICE} | 878 | fdisk -l ${LPARAM_BLOCK_DEVICE} |
879 | 879 | ||
880 | sleep 2; sync; | 880 | sleep 2; sync; |
881 | 881 | ||
882 | # Format the partitions | 882 | # Format the partitions |
883 | format_sdcard | 883 | format_sdcard |
884 | sleep 2; sync; | 884 | sleep 2; sync; |
885 | 885 | ||
886 | flash_u-boot | 886 | flash_u-boot |
887 | sleep 2; sync; | 887 | sleep 2; sync; |
888 | 888 | ||
889 | # Mount the partitions | 889 | # Mount the partitions |
890 | mkdir -p ${P1_MOUNT_DIR} | 890 | mkdir -p ${P1_MOUNT_DIR} |
891 | mkdir -p ${P2_MOUNT_DIR} | 891 | mkdir -p ${P2_MOUNT_DIR} |
892 | sync | 892 | sync |
893 | 893 | ||
894 | mount ${LPARAM_BLOCK_DEVICE}${part}1 ${P1_MOUNT_DIR} | 894 | mount ${LPARAM_BLOCK_DEVICE}${part}1 ${P1_MOUNT_DIR} |
895 | mount ${LPARAM_BLOCK_DEVICE}${part}2 ${P2_MOUNT_DIR} | 895 | mount ${LPARAM_BLOCK_DEVICE}${part}2 ${P2_MOUNT_DIR} |
896 | sleep 2; sync; | 896 | sleep 2; sync; |
897 | 897 | ||
898 | flash_sdcard | 898 | flash_sdcard |
899 | copy_debian_images | 899 | copy_debian_images |
900 | copy_scripts | 900 | copy_scripts |
901 | 901 | ||
902 | pr_info "Sync sdcard..." | 902 | pr_info "Sync sdcard..." |
903 | sync | 903 | sync |
904 | umount ${P1_MOUNT_DIR} | 904 | umount ${P1_MOUNT_DIR} |
905 | umount ${P2_MOUNT_DIR} | 905 | umount ${P2_MOUNT_DIR} |
906 | 906 | ||
907 | rm -rf ${P1_MOUNT_DIR} | 907 | rm -rf ${P1_MOUNT_DIR} |
908 | rm -rf ${P2_MOUNT_DIR} | 908 | rm -rf ${P2_MOUNT_DIR} |
909 | 909 | ||
910 | pr_info "Done make sdcard!" | 910 | pr_info "Done make sdcard!" |
911 | 911 | ||
912 | return 0; | 912 | return 0; |
913 | } | 913 | } |
914 | 914 | ||
915 | #################### commands ################ | 915 | #################### commands ################ |
916 | 916 | ||
917 | function cmd_make_deploy() { | 917 | function cmd_make_deploy() { |
918 | make_prepare; | 918 | make_prepare; |
919 | 919 | ||
920 | # get linaro toolchain | 920 | # get linaro toolchain |
921 | (( `ls ${G_CROSS_COMPILER_PATH} 2>/dev/null | wc -l` == 0 )) && { | 921 | (( `ls ${G_CROSS_COMPILER_PATH} 2>/dev/null | wc -l` == 0 )) && { |
922 | pr_info "Get and unpack cross compiler"; | 922 | pr_info "Get and unpack cross compiler"; |
923 | get_remote_file ${G_EXT_CROSS_COMPILER_LINK} ${DEF_SRC_DIR}/${G_CROSS_COMPILER_ARCHIVE} | 923 | get_remote_file ${G_EXT_CROSS_COMPILER_LINK} ${DEF_SRC_DIR}/${G_CROSS_COMPILER_ARCHIVE} |
924 | tar -xJf ${DEF_SRC_DIR}/${G_CROSS_COMPILER_ARCHIVE} -C ${G_TOOLS_PATH}/ | 924 | tar -xJf ${DEF_SRC_DIR}/${G_CROSS_COMPILER_ARCHIVE} -C ${G_TOOLS_PATH}/ |
925 | }; | 925 | }; |
926 | 926 | ||
927 | # get uboot repository | 927 | # get uboot repository |
928 | (( `ls ${G_UBOOT_SRC_DIR} 2>/dev/null | wc -l` == 0 )) && { | 928 | (( `ls ${G_UBOOT_SRC_DIR} 2>/dev/null | wc -l` == 0 )) && { |
929 | pr_info "Get uboot repository"; | 929 | pr_info "Get uboot repository"; |
930 | get_git_src ${G_UBOOT_GIT} ${G_UBOOT_BRANCH} ${G_UBOOT_SRC_DIR} ${G_UBOOT_REV} | 930 | get_git_src ${G_UBOOT_GIT} ${G_UBOOT_BRANCH} ${G_UBOOT_SRC_DIR} ${G_UBOOT_REV} |
931 | }; | 931 | }; |
932 | 932 | ||
933 | # get kernel repository | 933 | # get kernel repository |
934 | (( `ls ${G_LINUX_KERNEL_SRC_DIR} 2>/dev/null | wc -l` == 0 )) && { | 934 | (( `ls ${G_LINUX_KERNEL_SRC_DIR} 2>/dev/null | wc -l` == 0 )) && { |
935 | pr_info "Get kernel repository"; | 935 | pr_info "Get kernel repository"; |
936 | get_git_src ${G_LINUX_KERNEL_GIT} ${G_LINUX_KERNEL_BRANCH} ${G_LINUX_KERNEL_SRC_DIR} ${G_LINUX_KERNEL_REV} | 936 | get_git_src ${G_LINUX_KERNEL_GIT} ${G_LINUX_KERNEL_BRANCH} ${G_LINUX_KERNEL_SRC_DIR} ${G_LINUX_KERNEL_REV} |
937 | cd ${G_LINUX_KERNEL_SRC_DIR} | 937 | cd ${G_LINUX_KERNEL_SRC_DIR} |
938 | git am < ${G_EMBEDIAN_PATH}/patches/kernel/0001-vivante-gpu-revert-to-6.2.4.p1-driver.patch | 938 | git am < ${G_EMBEDIAN_PATH}/patches/kernel/0001-vivante-gpu-revert-to-6.2.4.p1-driver.patch |
939 | git am < ${G_EMBEDIAN_PATH}/patches/kernel/0001-smarc-imx8mm-compile-imx-sdma-driver-as-module.patch | 939 | git am < ${G_EMBEDIAN_PATH}/patches/kernel/0001-smarc-imx8mm-compile-imx-sdma-driver-as-module.patch |
940 | cd - | 940 | cd - |
941 | }; | 941 | }; |
942 | 942 | ||
943 | return 0; | 943 | return 0; |
944 | } | 944 | } |
945 | 945 | ||
946 | function cmd_make_rootfs() { | 946 | function cmd_make_rootfs() { |
947 | make_prepare; | 947 | make_prepare; |
948 | 948 | ||
949 | ## make debian rootfs | 949 | ## make debian rootfs |
950 | cd ${G_ROOTFS_DIR} | 950 | cd ${G_ROOTFS_DIR} |
951 | make_debian_rootfs ${G_ROOTFS_DIR} || { | 951 | make_debian_rootfs ${G_ROOTFS_DIR} || { |
952 | pr_error "Failed #$? in function make_debian_rootfs" | 952 | pr_error "Failed #$? in function make_debian_rootfs" |
953 | cd -; | 953 | cd -; |
954 | return 1; | 954 | return 1; |
955 | } | 955 | } |
956 | cd - | 956 | cd - |
957 | 957 | ||
958 | ## pack rootfs | 958 | ## pack rootfs |
959 | make_tarbar ${G_ROOTFS_DIR} ${G_ROOTFS_TARBAR_PATH} || { | 959 | make_tarbar ${G_ROOTFS_DIR} ${G_ROOTFS_TARBAR_PATH} || { |
960 | pr_error "Failed #$? in function make_tarbar" | 960 | pr_error "Failed #$? in function make_tarbar" |
961 | return 4; | 961 | return 4; |
962 | } | 962 | } |
963 | 963 | ||
964 | return 0; | 964 | return 0; |
965 | } | 965 | } |
966 | 966 | ||
967 | function cmd_make_uboot() { | 967 | function cmd_make_uboot() { |
968 | make_uboot ${G_UBOOT_SRC_DIR} ${PARAM_OUTPUT_DIR} || { | 968 | make_uboot ${G_UBOOT_SRC_DIR} ${PARAM_OUTPUT_DIR} || { |
969 | pr_error "Failed #$? in function make_uboot" | 969 | pr_error "Failed #$? in function make_uboot" |
970 | return 1; | 970 | return 1; |
971 | }; | 971 | }; |
972 | 972 | ||
973 | return 0; | 973 | return 0; |
974 | } | 974 | } |
975 | 975 | ||
976 | function cmd_make_kernel() { | 976 | function cmd_make_kernel() { |
977 | make_kernel ${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_LINUX_KERNEL_DEF_CONFIG} "${G_LINUX_DTB}" ${G_LINUX_KERNEL_SRC_DIR} ${PARAM_OUTPUT_DIR} || { | 977 | make_kernel ${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_LINUX_KERNEL_DEF_CONFIG} "${G_LINUX_DTB}" ${G_LINUX_KERNEL_SRC_DIR} ${PARAM_OUTPUT_DIR} || { |
978 | pr_error "Failed #$? in function make_kernel" | 978 | pr_error "Failed #$? in function make_kernel" |
979 | return 1; | 979 | return 1; |
980 | }; | 980 | }; |
981 | 981 | ||
982 | return 0; | 982 | return 0; |
983 | } | 983 | } |
984 | 984 | ||
985 | function cmd_make_kmodules() { | 985 | function cmd_make_kmodules() { |
986 | make_prepare; | 986 | make_prepare; |
987 | 987 | ||
988 | rm -rf ${G_ROOTFS_DIR}/lib/modules/* || { | 988 | rm -rf ${G_ROOTFS_DIR}/lib/modules/* || { |
989 | pr_error "Failed #$? prepare modules dir" | 989 | pr_error "Failed #$? prepare modules dir" |
990 | return 1; | 990 | return 1; |
991 | }; | 991 | }; |
992 | 992 | ||
993 | make_kernel_modules ${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_LINUX_KERNEL_DEF_CONFIG} ${G_LINUX_KERNEL_SRC_DIR} ${G_ROOTFS_DIR} || { | 993 | make_kernel_modules ${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_LINUX_KERNEL_DEF_CONFIG} ${G_LINUX_KERNEL_SRC_DIR} ${G_ROOTFS_DIR} || { |
994 | pr_error "Failed #$? in function make_kernel_modules" | 994 | pr_error "Failed #$? in function make_kernel_modules" |
995 | return 2; | 995 | return 2; |
996 | }; | 996 | }; |
997 | 997 | ||
998 | install_kernel_modules ${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_LINUX_KERNEL_DEF_CONFIG} ${G_LINUX_KERNEL_SRC_DIR} ${G_ROOTFS_DIR} || { | 998 | install_kernel_modules ${G_CROSS_COMPILER_PATH}/${G_CROSS_COMPILER_PREFIX} ${G_LINUX_KERNEL_DEF_CONFIG} ${G_LINUX_KERNEL_SRC_DIR} ${G_ROOTFS_DIR} || { |
999 | pr_error "Failed #$? in function install_kernel_modules" | 999 | pr_error "Failed #$? in function install_kernel_modules" |
1000 | return 2; | 1000 | return 2; |
1001 | }; | 1001 | }; |
1002 | 1002 | ||
1003 | return 0; | 1003 | return 0; |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | function cmd_make_rfs_tar() { | 1006 | function cmd_make_rfs_tar() { |
1007 | ## pack rootfs | 1007 | ## pack rootfs |
1008 | make_tarbar ${G_ROOTFS_DIR} ${G_ROOTFS_TARBAR_PATH} || { | 1008 | make_tarbar ${G_ROOTFS_DIR} ${G_ROOTFS_TARBAR_PATH} || { |
1009 | pr_error "Failed #$? in function make_tarbar" | 1009 | pr_error "Failed #$? in function make_tarbar" |
1010 | return 1; | 1010 | return 1; |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | return 0; | 1013 | return 0; |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | function cmd_make_sdcard() { | 1016 | function cmd_make_sdcard() { |
1017 | make_sdcard ${PARAM_BLOCK_DEVICE} ${PARAM_OUTPUT_DIR} || { | 1017 | make_sdcard ${PARAM_BLOCK_DEVICE} ${PARAM_OUTPUT_DIR} || { |
1018 | pr_error "Failed #$? in function make_sdcard" | 1018 | pr_error "Failed #$? in function make_sdcard" |
1019 | return 1; | 1019 | return 1; |
1020 | }; | 1020 | }; |
1021 | 1021 | ||
1022 | return 0; | 1022 | return 0; |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | function cmd_make_clean() { | 1025 | function cmd_make_clean() { |
1026 | 1026 | ||
1027 | ## clean kernel, dtb, modules | 1027 | ## clean kernel, dtb, modules |
1028 | clean_kernel ${G_LINUX_KERNEL_SRC_DIR} || { | 1028 | clean_kernel ${G_LINUX_KERNEL_SRC_DIR} || { |
1029 | pr_error "Failed #$? in function clean_kernel" | 1029 | pr_error "Failed #$? in function clean_kernel" |
1030 | return 1; | 1030 | return 1; |
1031 | }; | 1031 | }; |
1032 | 1032 | ||
1033 | ## clean u-boot | 1033 | ## clean u-boot |
1034 | clean_uboot ${G_UBOOT_SRC_DIR} || { | 1034 | clean_uboot ${G_UBOOT_SRC_DIR} || { |
1035 | pr_error "Failed #$? in function clean_uboot" | 1035 | pr_error "Failed #$? in function clean_uboot" |
1036 | return 2; | 1036 | return 2; |
1037 | }; | 1037 | }; |
1038 | 1038 | ||
1039 | ## delete tmp dirs and etc | 1039 | ## delete tmp dirs and etc |
1040 | pr_info "Delete tmp dir ${G_TMP_DIR}" | 1040 | pr_info "Delete tmp dir ${G_TMP_DIR}" |
1041 | rm -rf ${G_TMP_DIR} && :; | 1041 | rm -rf ${G_TMP_DIR} && :; |
1042 | 1042 | ||
1043 | pr_info "Delete rootfs dir ${G_ROOTFS_DIR}" | 1043 | pr_info "Delete rootfs dir ${G_ROOTFS_DIR}" |
1044 | rm -rf ${G_ROOTFS_DIR} && :; | 1044 | rm -rf ${G_ROOTFS_DIR} && :; |
1045 | 1045 | ||
1046 | return 0; | 1046 | return 0; |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | #################### main function ####################### | 1049 | #################### main function ####################### |
1050 | 1050 | ||
1051 | ## test for root access support (msrc not allowed) | 1051 | ## test for root access support (msrc not allowed) |
1052 | [ "$PARAM_CMD" != "deploy" ] && [ "$PARAM_CMD" != "bootloader" ] && [ "$PARAM_CMD" != "kernel" ] && [ "$PARAM_CMD" != "modules" ] && [ ${EUID} -ne 0 ] && { | 1052 | [ "$PARAM_CMD" != "deploy" ] && [ "$PARAM_CMD" != "bootloader" ] && [ "$PARAM_CMD" != "kernel" ] && [ "$PARAM_CMD" != "modules" ] && [ ${EUID} -ne 0 ] && { |
1053 | pr_error "this command must be run as root (or sudo/su)" | 1053 | pr_error "this command must be run as root (or sudo/su)" |
1054 | exit 1; | 1054 | exit 1; |
1055 | }; | 1055 | }; |
1056 | 1056 | ||
1057 | V_RET_CODE=0; | 1057 | V_RET_CODE=0; |
1058 | 1058 | ||
1059 | pr_info "Command: \"$PARAM_CMD\" start..." | 1059 | pr_info "Command: \"$PARAM_CMD\" start..." |
1060 | 1060 | ||
1061 | case $PARAM_CMD in | 1061 | case $PARAM_CMD in |
1062 | deploy ) | 1062 | deploy ) |
1063 | cmd_make_deploy || { | 1063 | cmd_make_deploy || { |
1064 | V_RET_CODE=1; | 1064 | V_RET_CODE=1; |
1065 | }; | 1065 | }; |
1066 | ;; | 1066 | ;; |
1067 | rootfs ) | 1067 | rootfs ) |
1068 | cmd_make_rootfs || { | 1068 | cmd_make_rootfs || { |
1069 | V_RET_CODE=1; | 1069 | V_RET_CODE=1; |
1070 | }; | 1070 | }; |
1071 | ;; | 1071 | ;; |
1072 | bootloader ) | 1072 | bootloader ) |
1073 | cmd_make_uboot || { | 1073 | cmd_make_uboot || { |
1074 | V_RET_CODE=1; | 1074 | V_RET_CODE=1; |
1075 | } | 1075 | } |
1076 | ;; | 1076 | ;; |
1077 | kernel ) | 1077 | kernel ) |
1078 | cmd_make_kernel || { | 1078 | cmd_make_kernel || { |
1079 | V_RET_CODE=1; | 1079 | V_RET_CODE=1; |
1080 | }; | 1080 | }; |
1081 | ;; | 1081 | ;; |
1082 | modules ) | 1082 | modules ) |
1083 | cmd_make_kmodules || { | 1083 | cmd_make_kmodules || { |
1084 | V_RET_CODE=1; | 1084 | V_RET_CODE=1; |
1085 | }; | 1085 | }; |
1086 | ;; | 1086 | ;; |
1087 | sdcard ) | 1087 | sdcard ) |
1088 | cmd_make_sdcard || { | 1088 | cmd_make_sdcard || { |
1089 | V_RET_CODE=1; | 1089 | V_RET_CODE=1; |
1090 | }; | 1090 | }; |
1091 | ;; | 1091 | ;; |
1092 | rtar ) | 1092 | rtar ) |
1093 | cmd_make_rfs_tar || { | 1093 | cmd_make_rfs_tar || { |
1094 | V_RET_CODE=1; | 1094 | V_RET_CODE=1; |
1095 | }; | 1095 | }; |
1096 | ;; | 1096 | ;; |
1097 | all ) | 1097 | all ) |
1098 | (cmd_make_uboot && | 1098 | (cmd_make_uboot && |
1099 | cmd_make_kernel && | 1099 | cmd_make_kernel && |
1100 | cmd_make_kmodules && | 1100 | cmd_make_kmodules && |
1101 | cmd_make_rootfs) || { | 1101 | cmd_make_rootfs) || { |
1102 | V_RET_CODE=1; | 1102 | V_RET_CODE=1; |
1103 | }; | 1103 | }; |
1104 | ;; | 1104 | ;; |
1105 | clean ) | 1105 | clean ) |
1106 | cmd_make_clean || { | 1106 | cmd_make_clean || { |
1107 | V_RET_CODE=1; | 1107 | V_RET_CODE=1; |
1108 | }; | 1108 | }; |
1109 | ;; | 1109 | ;; |
1110 | * ) | 1110 | * ) |
1111 | pr_error "Invalid input command: \"${PARAM_CMD}\""; | 1111 | pr_error "Invalid input command: \"${PARAM_CMD}\""; |
1112 | V_RET_CODE=1; | 1112 | V_RET_CODE=1; |
1113 | ;; | 1113 | ;; |
1114 | esac | 1114 | esac |
1115 | 1115 | ||
1116 | pr_info "" | 1116 | pr_info "" |
1117 | pr_info "Command: \"$PARAM_CMD\" end. Exit code: ${V_RET_CODE}" | 1117 | pr_info "Command: \"$PARAM_CMD\" end. Exit code: ${V_RET_CODE}" |
1118 | pr_info "" | 1118 | pr_info "" |
1119 | 1119 | ||
1120 | 1120 | ||
1121 | exit ${V_RET_CODE}; | 1121 | exit ${V_RET_CODE}; |
1122 | 1122 |