89
mtdfis=$(mtdblock "FIS directory")
90
if [ -z "$mtdfis" ]; then
102
fismtd=$(mtdblock "FIS directory")
103
if [ -z "$fismtd" ]; then
91
104
error "Cannot find mtd FIS directory"
93
mtdkernel=$(mtdblock Kernel)
94
if [ -z "$mtdkernel" ]; then
106
kmtd=$(mtdblock Kernel)
107
if [ -z "$kmtd" ]; then
95
108
error "Cannot find mtd partition 'Kernel'"
97
mtdramdisk=$(mtdblock Ramdisk)
98
if [ -z "$mtdramdisk" ]; then
110
kmtdsize=$(mtdsize "Kernel")
111
check_size "kernel" $(($kfilesize + 16 + 16)) $kmtdsize
112
imtd=$(mtdblock Ramdisk)
113
if [ -z "$imtd" ]; then
99
114
error "Cannot find mtd partition 'Ramdisk'"
116
imtdsize=$(mtdsize "Ramdisk")
117
check_size "ramdisk" $(($ifilesize + 16)) $imtdsize
101
118
# The following devio magic parses the FIS directory to
102
119
# obtain the size, offset and name of each partition. This
103
120
# used used to obtain the offset of the Kernel partition.
104
offset=$(echo "$(devio "<<$mtdfis" '
121
offset=$(echo "$(devio "<<$fismtd" '
129
146
# kernel into two and write them to flash with two Sercomm
131
148
boundary=1441792 # 0x00160000
132
ksize=$(wc -c $kfile | awk '{print $1}')
133
149
ksize1=$(expr $boundary - $offset - 16)
135
151
printf "Flashing kernel: " >&2
137
sercomm_header $(expr $ksize + 16)
153
sercomm_header $(expr $kfilesize + 16)
138
154
dd if=$kfile of=$tmp bs=$ksize1 count=1 2>/dev/null
140
156
sercomm_header 131072
141
157
dd if=$kfile of=$tmp ibs=$ksize1 skip=1 2>/dev/null
144
) > "$mtdkernel" || error "failed."
160
) > "$kmtd" || error "failed."
146
162
printf "Flashing initramfs: " >&2
147
size=$(grep "\"Ramdisk\"" /proc/mtd | cut -d " " -f 2)
148
size=$(printf "%d" 0x$size)
149
isize=$(wc -c $ifile | awk '{print $1}')
150
pad=$(expr $size - $isize - 16)
151
if [ "$pad" -gt 0 ]; then
152
dd if=$ifile of=$tmp ibs=4M conv=sync 2>/dev/null
163
dd if=$ifile of=$tmp ibs=$(($imtdsize - 16)) conv=sync 2>/dev/null
155
sercomm_header $isize
165
sercomm_header $ifilesize
158
) > $mtdramdisk || error "failed."
162
check_subarch "ixp4xx"
164
mtdramdisk=$(mtdblock filesystem)
165
if [ -z "$mtdramdisk" ]; then
166
error "Cannot find mtd partition 'filesystem'"
168
mtdkernel=$(mtdblock kernel)
169
if [ -z "$mtdkernel" ]; then
170
error "Cannot find mtd partition 'kernel'"
172
printf "Flashing kernel: " >&2
173
cat $kfile > "$mtdkernel" || error "failed."
175
printf "Flashing initramfs: " >&2
176
size=$(grep "\"filesystem\"" /proc/mtd | cut -d " " -f 2)
177
size=$(printf "%d" 0x$size)
178
isize=$(wc -c $ifile | awk '{print $1}')
179
pad=$(expr $size - $isize)
182
dd if=/dev/zero bs=$pad count=1 2>/dev/null
183
) > $mtdramdisk || error "failed."
168
) > $imtd || error "failed."
187
172
check_subarch "iop32x"
189
mtdramdisk=$(mtdblock ramdisk)
190
if [ -z "$mtdramdisk" ]; then
174
imtd=$(mtdblock ramdisk)
175
if [ -z "$imtd" ]; then
191
176
error "Cannot find mtd partition 'ramdisk'"
193
mtdkernel=$(mtdblock kernel)
194
if [ -z "$mtdkernel" ]; then
178
imtdsize=$(mtdsize "ramdisk")
179
check_size "ramdisk" $ifilesize $imtdsize
180
kmtd=$(mtdblock kernel)
181
if [ -z "$kmtd" ]; then
195
182
error "Cannot find mtd partition 'kernel'"
184
kmtdsize=$(mtdsize "kernel")
185
check_size "kernel" $(($kfilesize + 8)) $kmtdsize
197
186
printf "Flashing kernel... " >&2
199
188
devio 'wl 0xe3a01c04,4' 'wl 0xe381104d,4'
201
) > $mtdkernel || error "failed."
190
) > $kmtd || error "failed."
203
192
printf "Flashing initramfs... " >&2
204
size=$(grep "\"ramdisk\"" /proc/mtd | cut -d " " -f 2)
205
size=$(printf "%d" 0x$size)
206
isize=$(wc -c $ifile | awk '{print $1}')
207
pad=$(expr $size - $isize)
193
pad=$(expr $imtdsize - $ifilesize)
210
196
dd if=/dev/zero bs=$pad count=1 2>/dev/null
211
) > $mtdramdisk || error "failed."
197
) > $imtd || error "failed."