OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
Line 8... | Line 8... | |||
8 | CI_KERNPART="${CI_KERNPART:-kernel}" |
8 | CI_KERNPART="${CI_KERNPART:-kernel}" |
|
Line 9... | Line 9... | |||
9 | |
9 | |
|
10 | # 'ubi' partition on NAND contains UBI |
10 | # 'ubi' partition on NAND contains UBI |
|
Line 11... | Line -... | |||
11 | CI_UBIPART="${CI_UBIPART:-ubi}" |
- | ||
12 | |
- | ||
13 | # 'rootfs' partition on NAND contains the rootfs |
- | ||
14 | CI_ROOTPART="${CI_ROOTPART:-rootfs}" |
11 | CI_UBIPART="${CI_UBIPART:-ubi}" |
|
15 | |
12 | |
|
16 | ubi_mknod() { |
13 | ubi_mknod() { |
|
Line 17... | Line 14... | |||
17 | local dir="$1" |
14 | local dir="$1" |
|
Line 100... | Line 97... | |||
100 | nand_restore_config() { |
97 | nand_restore_config() { |
|
101 | sync |
98 | sync |
|
102 | local ubidev=$( nand_find_ubi $CI_UBIPART ) |
99 | local ubidev=$( nand_find_ubi $CI_UBIPART ) |
|
103 | local ubivol="$( nand_find_volume $ubidev rootfs_data )" |
100 | local ubivol="$( nand_find_volume $ubidev rootfs_data )" |
|
104 | [ ! "$ubivol" ] && |
101 | [ ! "$ubivol" ] && |
|
105 | ubivol="$( nand_find_volume $ubidev $CI_ROOTPART )" |
102 | ubivol="$( nand_find_volume $ubidev rootfs )" |
|
106 | mkdir /tmp/new_root |
103 | mkdir /tmp/new_root |
|
107 | if ! mount -t ubifs /dev/$ubivol /tmp/new_root; then |
104 | if ! mount -t ubifs /dev/$ubivol /tmp/new_root; then |
|
108 | echo "mounting ubifs $ubivol failed" |
105 | echo "mounting ubifs $ubivol failed" |
|
109 | rmdir /tmp/new_root |
106 | rmdir /tmp/new_root |
|
110 | return 1 |
107 | return 1 |
|
Line 144... | Line 141... | |||
144 | ubimkvol /dev/$ubidev -n 1 -N ubootenv2 -s 1MiB |
141 | ubimkvol /dev/$ubidev -n 1 -N ubootenv2 -s 1MiB |
|
145 | } |
142 | } |
|
146 | fi |
143 | fi |
|
Line 147... | Line 144... | |||
147 | |
144 | |
|
148 | local kern_ubivol="$( nand_find_volume $ubidev $CI_KERNPART )" |
145 | local kern_ubivol="$( nand_find_volume $ubidev $CI_KERNPART )" |
|
149 | local root_ubivol="$( nand_find_volume $ubidev $CI_ROOTPART )" |
146 | local root_ubivol="$( nand_find_volume $ubidev rootfs )" |
|
Line 150... | Line 147... | |||
150 | local data_ubivol="$( nand_find_volume $ubidev rootfs_data )" |
147 | local data_ubivol="$( nand_find_volume $ubidev rootfs_data )" |
|
151 | |
148 | |
|
152 | # remove ubiblock device of rootfs |
149 | # remove ubiblock device of rootfs |
|
Line 159... | Line 156... | |||
159 | fi |
156 | fi |
|
160 | fi |
157 | fi |
|
Line 161... | Line 158... | |||
161 | |
158 | |
|
162 | # kill volumes |
159 | # kill volumes |
|
163 | [ "$kern_ubivol" ] && ubirmvol /dev/$ubidev -N $CI_KERNPART || true |
160 | [ "$kern_ubivol" ] && ubirmvol /dev/$ubidev -N $CI_KERNPART || true |
|
164 | [ "$root_ubivol" ] && ubirmvol /dev/$ubidev -N $CI_ROOTPART || true |
161 | [ "$root_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs || true |
|
Line 165... | Line 162... | |||
165 | [ "$data_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs_data || true |
162 | [ "$data_ubivol" ] && ubirmvol /dev/$ubidev -N rootfs_data || true |
|
166 | |
163 | |
|
167 | # update kernel |
164 | # update kernel |
|
Line 177... | Line 174... | |||
177 | if [ "$rootfs_type" = "ubifs" ]; then |
174 | if [ "$rootfs_type" = "ubifs" ]; then |
|
178 | root_size_param="-m" |
175 | root_size_param="-m" |
|
179 | else |
176 | else |
|
180 | root_size_param="-s $rootfs_length" |
177 | root_size_param="-s $rootfs_length" |
|
181 | fi |
178 | fi |
|
182 | if ! ubimkvol /dev/$ubidev -N $CI_ROOTPART $root_size_param; then |
179 | if ! ubimkvol /dev/$ubidev -N rootfs $root_size_param; then |
|
183 | echo "cannot create rootfs volume" |
180 | echo "cannot create rootfs volume" |
|
184 | return 1; |
181 | return 1; |
|
185 | fi |
182 | fi |
|
Line 186... | Line 183... | |||
186 | |
183 | |
|
Line 234... | Line 231... | |||
234 | local rootfs_length=`(cat $1 | wc -c) 2> /dev/null` |
231 | local rootfs_length=`(cat $1 | wc -c) 2> /dev/null` |
|
Line 235... | Line 232... | |||
235 | |
232 | |
|
Line 236... | Line 233... | |||
236 | nand_upgrade_prepare_ubi "$rootfs_length" "ubifs" "0" "0" |
233 | nand_upgrade_prepare_ubi "$rootfs_length" "ubifs" "0" "0" |
|
237 | |
234 | |
|
238 | local ubidev="$( nand_find_ubi "$CI_UBIPART" )" |
235 | local ubidev="$( nand_find_ubi "$CI_UBIPART" )" |
|
Line 239... | Line 236... | |||
239 | local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)" |
236 | local root_ubivol="$(nand_find_volume $ubidev rootfs)" |
|
240 | ubiupdatevol /dev/$root_ubivol -s $rootfs_length $1 |
237 | ubiupdatevol /dev/$root_ubivol -s $rootfs_length $1 |
|
Line 269... | Line 266... | |||
269 | local kern_ubivol="$(nand_find_volume $ubidev $CI_KERNPART)" |
266 | local kern_ubivol="$(nand_find_volume $ubidev $CI_KERNPART)" |
|
270 | tar xf $tar_file ${board_dir}/kernel -O | \ |
267 | tar xf $tar_file ${board_dir}/kernel -O | \ |
|
271 | ubiupdatevol /dev/$kern_ubivol -s $kernel_length - |
268 | ubiupdatevol /dev/$kern_ubivol -s $kernel_length - |
|
272 | } |
269 | } |
|
Line 273... | Line 270... | |||
273 | |
270 | |
|
274 | local root_ubivol="$(nand_find_volume $ubidev $CI_ROOTPART)" |
271 | local root_ubivol="$(nand_find_volume $ubidev rootfs)" |
|
275 | tar xf $tar_file ${board_dir}/root -O | \ |
272 | tar xf $tar_file ${board_dir}/root -O | \ |
|
Line 276... | Line 273... | |||
276 | ubiupdatevol /dev/$root_ubivol -s $rootfs_length - |
273 | ubiupdatevol /dev/$root_ubivol -s $rootfs_length - |
|
277 | |
274 | |