FreeCalypso > hg > freecalypso-reveng
annotate compal/boot/code-deriv @ 408:14302e075f37 default tip
hr-bits: further conditionalize SID-1-diff
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 22 Jul 2024 10:06:38 +0000 |
parents | 4b6b595ae0a0 |
children |
rev | line source |
---|---|
401
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 It is apparent that Compal's bootloader was genealogically derived from TI's |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 original FRBL (flash-resident bootloader) built into TCS211 reference fw. The |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 most "basic" or "pristine" version of Compal's bootloader is the one analyzed |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 in c123-boot.disasm, aided by symbolic information from R87.2.1.03.map; here we |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 shall analyze the diffs between this code and the original TCS211 version in |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 the ../../leo-obj/bootloader directory. |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 0x830: serial.obj .const section |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 Exact match to TCS211-20070608! |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 0x86c: bootloader.obj .text section |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 The only diffs from TCS211 are: |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 1) The addition of these instructions (right at _INT_Bootloader_Start) to set |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 VCLKOUT_DIV2 bit in the FFFF:FD02 register: |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 89c: e51f1020 ldr r1, =0xfffffd00 ; via 0x884 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 8a0: e1d120b2 ldrh r2, [r1, #2] |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 8a4: e51f002c ldr r0, =0x40 ; via 0x880 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 8a8: e1800002 orr r0, r0, r2 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 8ac: e1c100b2 strh r0, [r1, #2] |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 2) The addition of 32-bit word 0x40 to the literal at the beginning of this |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 .text section, before _INT_Bootloader_Start entry point. |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 0x968: start.obj .text section |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 Static function 0 (0x0 in reference object, 0x968 in Compal's bl) matches |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 exactly. |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 Static function 1 (0x2c in reference object, 0x994 in Compal's bl) matches |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 exactly. |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 Static function 2 (0xe0 in reference object, 0xa48 in Compal's bl) matches |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 exactly. |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 Final function sta_select_application(): |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 * The beginning of the function is the same between TI and Compal versions: |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 - call to static function 0 (hw init) |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 - call to ser_initialize_serial_link() |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 - call to con_initialize_conversion() |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 * The remainder of the function differs fundamentally: |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 - TI's version calls cmd_check_application_in_flash(), followed by static |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 functions 1 and 2 that implement FRBL1 interrupt-boot window provision. |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 - Compal's version calls their heavily modified version of fluid_bootloader(), |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 which is where Compal's serial boot entry protocol is implemented, followed |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 by FTM_Tool_check() where the "ftmtool - (yes) - (modem)error" business |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 happens. |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 0xb10: boot.obj .text section |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 The dead code preamble before fluid_bootloader() function (5 32-bit ARM |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 instructions) is the same between TI and Compal versions. |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 The body of fluid_bootloader() is completely different, leaving only the now- |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 misleading function name: all FRBL2 code has been ripped out, replaced with |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 Compal's serial boot entry protocol. |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 The following functions from TI's original boot.c survive in Compal's version: |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 jump() |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 putchar() |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 getchar() |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 hardware_init() -- already a mostly-do-nothing in TCS211 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 uart_init() |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 The following functions in this module are entirely new in Compal's version: |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 SeekMsg() |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 FTM_Tool_check() |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 getchar_timeout() |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 UartTimeout() -- unused! |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 CheckFTMtoolMode() |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 putchar__() -- unused! |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 getchar__() -- unused! |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 0xfb4: branch_in_RAM.obj .text section |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 Exact match to TCS211-20070608, but then it's a trivial assembly module. |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 0xfb8: command.obj .text section |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 Exact match to TCS211-20070608! |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 0x13d0: convert.obj .text section |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 Exact match to TCS211-20070608, including the call to fluid_bootloader() in |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 con_get_command_from_string() which is now a complete bogon. |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 0x1594: optboot.obj .text section |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 Exact match to TCS211-20070608, except for one byte change in the ID returned |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 by opt_get_monitor_id(). |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 0x165c: serial.obj .text section |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 Exact match to TCS211-20070608! |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 0x1cec: cmdboot.obj .text section |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 Exact match to TCS211-20070608! |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 0x1dd8: start.obj .text:v$3 section |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 |
4b6b595ae0a0
compal/boot/code-deriv: new analysis
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 Exact match to TCS211-20070608! |