FreeCalypso > hg > fc-am-toolkit
comparison sh/c1xx-analyze-image @ 17:632d62e5efb4
c1xx-analyze-image: add bootloader analysis
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 10 Jun 2023 06:24:15 +0000 |
parents | 12810ff4aa92 |
children |
comparison
equal
deleted
inserted
replaced
16:6b0d533046e5 | 17:632d62e5efb4 |
---|---|
13 fi | 13 fi |
14 | 14 |
15 length=`wc -c $1 | cut -d ' ' -f 1` | 15 length=`wc -c $1 | cut -d ' ' -f 1` |
16 | 16 |
17 case "$length" in | 17 case "$length" in |
18 2097152) | 18 2097152) |
19 echo 'Flash dump file size is 2 MiB' | 19 echo 'Flash dump file size is 2 MiB' |
20 echo 'Is it a small-flash C11x/12x phone?' | 20 echo 'Is it a small-flash C11x/12x phone?' |
21 flash=2m | 21 flash=2m |
22 cal_offset=0x1FC000 | 22 cal_offset=0x1FC000 |
23 ;; | 23 ;; |
24 4194304) | 24 4194304) |
25 echo 'Flash dump file size is 4 MiB' | 25 echo 'Flash dump file size is 4 MiB' |
26 echo 'Possible Compal phones: C11x/12x, C139/140, SE J100' | 26 echo 'Possible Compal phones: C11x/12x, C139/140, SE J100' |
27 flash=4m | 27 flash=4m |
28 cal_offset=0x3FC000 | 28 cal_offset=0x3FC000 |
29 ;; | 29 ;; |
30 8388608) | 30 8388608) |
31 echo 'Flash dump file size is 8 MiB' | 31 echo 'Flash dump file size is 8 MiB' |
32 echo 'Is it a Motorola C155/156 phone?' | 32 echo 'Is it a Motorola C155/156 phone?' |
33 flash=8m | 33 flash=8m |
34 cal_offset=0x7E0000 | 34 cal_offset=0x7E0000 |
35 ;; | 35 ;; |
36 *) | 36 *) |
37 echo "Error: file length of $1 is not understood" 1>&2 | 37 echo "Error: file length of $1 is not understood" 1>&2 |
38 exit 1 | 38 exit 1 |
39 esac | 39 esac |
40 | 40 |
41 set -e | 41 set -e |
42 | 42 |
43 echo 'Parsing for RF calibration records' | 43 echo 'Parsing for RF calibration records' |
46 if [ ! -d rfbin/rx -o ! -d rfbin/tx ] | 46 if [ ! -d rfbin/rx -o ! -d rfbin/tx ] |
47 then | 47 then |
48 echo "Error: no RF calibration records found" 1>&2 | 48 echo "Error: no RF calibration records found" 1>&2 |
49 exit 1 | 49 exit 1 |
50 fi | 50 fi |
51 | |
52 case $flash in | |
53 2m|4m) | |
54 echo 'Analyzing bootloader' | |
55 boot=`c139-analyze-boot "$1"` | |
56 case "$boot" in | |
57 unlocked) | |
58 echo 'Found original Compal bootloader, unlocked' | |
59 echo 'Generating restore-flash script' | |
60 echo "flash erase-program-boot $1 0x10000" > restore-flash | |
61 echo "flash e-program-bin 0x10000 $1 0x10000" >> restore-flash | |
62 ;; | |
63 locked) | |
64 echo 'Found original Compal bootloader, LOCKED!' | |
65 u=unlocked-orig-fw.bin | |
66 echo "Generating unlocked version in $u" | |
67 cp "$1" $u | |
68 c139-patch-dmagic $u | |
69 echo 'Generating restore-flash script using this image' | |
70 echo "flash erase-program-boot $u 0x10000" > restore-flash | |
71 echo "flash e-program-bin 0x10000 $u 0x10000" >> restore-flash | |
72 ;; | |
73 fc) | |
74 echo 'Found FreeCalypso C11x/12x/139/140 bootloader' | |
75 echo 'It is a FreeCalypso C1xx flash image, not original,' | |
76 echo 'hence not generating restore-flash script.' | |
77 ;; | |
78 *) | |
79 echo 'Not found a good bootloader version - this flash image' | |
80 echo 'is UNSAFE! If you proceed with flashing FreeCalypso,' | |
81 echo 'you will not be able to restore the original fw without' | |
82 echo 'bricking the phone! Recommendation: please reflash your' | |
83 echo 'phone to a different, known-good official Motorola fw' | |
84 echo 'version before venturing into FreeCalypso fw.' | |
85 ;; | |
86 esac | |
87 ;; | |
88 8m) | |
89 echo 'Analyzing bootloader' | |
90 boot=`c155-analyze-boot "$1"` | |
91 case "$boot" in | |
92 ok) | |
93 echo 'Found classic C155/156 bootloader, all good' | |
94 echo 'Generating restore-flash script' | |
95 echo "flash e-program-bin 0x20000 $1 0x20000" > restore-flash | |
96 ;; | |
97 *) | |
98 echo 'Not found a good bootloader version - this flash image' | |
99 echo 'is UNSAFE! Please contact FreeCalypso and share your' | |
100 echo 'flash image before taking any further action.' | |
101 ;; | |
102 esac | |
103 ;; | |
104 esac |