Project

General

Profile

Flashing » History » Version 11

fixeria, 07/11/2018 11:12 AM

1 10 fixeria
h1. Flashing application(s) into a Motorola C123 phone
2 8 jolly
3 9 fixeria
{{>toc}}
4 8 jolly
5 10 fixeria
This tutorial explains how to flash one or multiple application(s) into C123 phone. Read carefully, otherwise you might brick your phone. Even if you follow this tutorial, you may brick your phone if you run into cable problem, weak battery or software fault.
6 1 jolly
7 10 fixeria
h2. DISCLAIMER
8
9
Please note that *flashing is optional*, i.e. it is not required for normal OsmocomBB operation! Moreover, it is strongly recommended to avoid flashing, since the *code is experimental*, and many lucky *users reported that a phone was bricked* during / after the flashing process. You were warned, don't expect to get help at #osmocom or in the "mailing list":https://lists.osmocom.org/mailman/listinfo/baseband-devel.
10
11
Also be sure to have another phone for unattended charging. The charger is supported, but if firmware crashes, *battery might get overloaded*. Never charge unattended! After flashing, the original firmware is gone, so be sure to save complete flash memory, if you want to restore original firmware in the future.
12
13
h2. Flashing details
14
15 1 jolly
There will be three parts to be flashed:
16 8 jolly
17 1 jolly
* the original Compal loader
18
* the OSMOCOM menu (loads applications from flash into ram)
19
* the application
20
21
Without the Compal loader, the phone is bricked.
22
23
The OSMOCOM menu will allow to start the application from any flash page other than page 0. It displays all applications it finds in flash (using a header, as described below). The cursor keys will select the application, the green button will start the application, the menu button (black button) will display flash location.
24 8 jolly
25 10 fixeria
h2. Memory layout
26 8 jolly
27 1 jolly
The memory is mapped as follows:
28
29 8 jolly
* 0x000000-0x00ffff: Flash page 0
30
* 0x010000-0x01ffff: Flash page 1
31
* ... more Flash pages ...
32 1 jolly
* 0x800000-0x83ffff: Ram
33 8 jolly
34
Our flash layout is:
35 1 jolly
36
* 0x000000-0x001fff: Compal loader
37
* 0x002000-0x00ffff: OSMOCOM menu
38
* 0x010000-........: OSMOCOM application and storage
39 8 jolly
40 1 jolly
Note: The Compal loader and the OSMOCOM menu will be located in the same flash page!
41 8 jolly
42 11 fixeria
h2. Preparations
43 8 jolly
44
h3. Unlocking flash write of Osmocom loader
45
46
<pre>
47 1 jolly
$ cd src/target/firmware/
48
$ edit Makefile
49 8 jolly
</pre>
50 1 jolly
51
Enable the following compiler flags: (They are located at the bottom of the file.)
52
53 8 jolly
<pre>
54 1 jolly
CFLAGS += -DCONFIG_FLASH_WRITE
55
CFLAGS += -DCONFIG_FLASH_WRITE_LOADER
56 8 jolly
</pre>
57 1 jolly
58
Also you may want to allow the application to transmit, so enable TX supprt:
59
60 8 jolly
<pre>
61 3 jolly
CFLAGS += -DCONFIG_TX_ENABLE
62 8 jolly
</pre>
63 3 jolly
64
65 11 fixeria
h3. Rebuilding the firmware
66 8 jolly
67
68 1 jolly
Now rebuild the firmware with write support enabled:
69
70 8 jolly
<pre>
71 1 jolly
$ make clean
72 8 jolly
$ make
73 1 jolly
</pre>
74
75 8 jolly
h2. actual installation
76 1 jolly
77 8 jolly
78
79
h3. Booting the phone / downloading loader to ram
80
81
82
<pre>
83 1 jolly
$ cd src
84
$ host/osmocon/osmocon -p /dev/ttyUSB0 -m c123xor target/firmware/board/compal_e88/loader.compalram.bin
85 8 jolly
</pre>
86 1 jolly
87
Briefly press the power-on button of your phone (short push, not like a regular phone boot!).
88 8 jolly
See [[osmocon]] for more informations.
89 1 jolly
90
You will get the following output:
91
92 8 jolly
<pre>
93 1 jolly
Received PROMPT1 from phone, responding with CMD
94
read_file(target/firmware/board/compal_e88/loader.compalram.bin): file_size=18436, hdr_len=4, dnload_len=18443
95
Received PROMPT2 from phone, starting download
96
handle_write(): 4096 bytes (4096/18443)
97
handle_write(): 4096 bytes (8192/18443)
98
handle_write(): 4096 bytes (12288/18443)
99
handle_write(): 4096 bytes (16384/18443)
100
handle_write(): 2059 bytes (18443/18443)
101
handle_write(): finished
102
Received DOWNLOAD ACK from phone, your code is running now!
103
Received DOWNLOAD ACK from phone, your code is running now!
104
105
106
OSMOCOM Loader (revision osmocon_v0.0.0-1322-g43c588b-modified)
107
======================================================================
108
Running on compal_e88 in environment compalram
109
Found flash of 2097152 bytes at 0x0 with 2 regions
110 8 jolly
</pre>
111 1 jolly
112
Now open another console and talk to the loader as described below:
113
114
115
116 8 jolly
h3. Flashing the loader + menu
117
118
119 1 jolly
The OSMOCOM loader is located in ram. (see above) It will be used to write to flash. Because it runs in ram, it will allow accessing the flash.
120
121
The OSMOCOM menu cannot be flashed without erasing the original Compal loader, because both are located in the same flash page. We can only erase the complete page, not parts of it. The first thing we must do is save the original loader:
122
123 8 jolly
<pre>
124 1 jolly
$ cd src
125
$ host/osmocon/osmoload memdump 0x000000 0x2000 compal_loader.bin
126 8 jolly
</pre>
127 1 jolly
128
To test if flashing works, we will first flash the Compal and OSMOCOM menu to a wrong location. If flashing fails, we still have the Compal loader working on it's original location, and the phone is not bricked.
129
130
First erase page at 0x010000 and program the just saved compal_loader.bin and the OSMOCOM menu:
131
132 8 jolly
<pre>
133 1 jolly
$ host/osmocon/osmoload funlock 0x010000 0x10000
134
$ host/osmocon/osmoload ferase 0x010000 0x10000
135
$ host/osmocon/osmoload fprogram 0 0x010000 compal_loader.bin
136
$ host/osmocon/osmoload fprogram 0 0x012000 target/firmware/board/compal_e88/menu.e88loader.bin
137 8 jolly
</pre>
138 1 jolly
139
If all these steps will not produce any error output, you can start flashing the Osmocom loader to it's right place at page 0x000000:
140
141 8 jolly
<pre>
142 1 jolly
$ host/osmocon/osmoload funlock 0x000000 0x10000
143
$ host/osmocon/osmoload ferase 0x000000 0x10000
144
$ host/osmocon/osmoload fprogram 0 0x000000 compal_loader.bin
145
$ host/osmocon/osmoload fprogram 0 0x002000 target/firmware/board/compal_e88/menu.e88loader.bin
146 8 jolly
</pre>
147 1 jolly
148
149 8 jolly
h3. Preparing an application
150
151
152 1 jolly
The OSMOCOM menu will search for applications starting at any flash page. In order to detect an application, a header is used. create the header as follows:
153
154 8 jolly
<pre>
155 1 jolly
$ echo "highram:RSSI" >temp
156 8 jolly
</pre>
157 1 jolly
158
In this case we created a header for the RSSI application and call that "RSSI". Now we append the highram image to be loaded by the OSMOCOM menu:
159
160 8 jolly
<pre>
161 1 jolly
$ cat target/firmware/board/compal_e88/rssi.highram.bin >>temp
162 8 jolly
</pre>
163 1 jolly
164
Flashing the "temp" file is only possible, if the number of byte are even. In case they are odd, add one byte:
165
166 8 jolly
<pre>
167 1 jolly
$ ls -la temp
168
-rw-r--r-- 1 root root 83761 Sep 27 10:08 temp
169 2 jolly
$ echo >>temp
170
$ ls -la temp
171
-rw-r--r-- 1 root root 83762 Sep 27 10:08 temp
172 8 jolly
</pre>
173 2 jolly
174 1 jolly
Now the application is ready to be flashed to any flash page. In case of RSSI application, it requires two pages of flash memory. 
175 2 jolly
176 1 jolly
177 2 jolly
178 8 jolly
h3. Flasing an application
179
180
181 1 jolly
In order to flash an application, you must check how large it is. You need to erase the amount of pages the firmware requires. You need to round it up to a multiple of 64k (one flash page).
182 2 jolly
183 1 jolly
In this example we will flash the RSSI firmware. It is between 64k and 128k, so we need at least two pages to erase:
184
185 8 jolly
<pre>
186 1 jolly
$ host/osmocon/osmoload funlock 0x010000 0x20000
187 2 jolly
$ host/osmocon/osmoload ferase 0x010000 0x20000
188 1 jolly
$ host/osmocon/osmoload fprogram 0 0x010000 temp
189 8 jolly
</pre>
190 2 jolly
191 1 jolly
Now we have flashed page 1 and page 2. In order to flash another application, you need to erase and flash page 3 or higher. 
192 2 jolly
193 1 jolly
194
195 8 jolly
h2. Testing
196
197
198
* Power off your phone.
199
* Disconnect the serial cable.
200
* Turn it on (push power button), the OSMOCOM menu will appear and show available applications.
201
* Use up/down keys or digits to select the application.
202
* Press the green off-hook button, the application will be loaded to ram and is started.
203
** Alternatively press the digit as shown in front of the application's name.
Add picture from clipboard (Maximum size: 48.8 MB)