Project

General

Profile

SciphoneDreamG2 » History » Version 22

Anonymous, 02/19/2016 10:49 PM

1 1 laforge
2 22 laforge
h1. Sciphone Dream G2
3 1 laforge
4 22 laforge
5
The Sciphone Dream G2 is a [[MT6235]] based phone running UI software to mimic the look+feel of Android.
6
7 1 laforge
There is currently an u-boot and Linux port for the MT6235 underway, the primary development platform is the Sciphone G2.
8
9 22 laforge
[[OsmocomBB]] does not yet support any Mediatek chipsets, so this phone is not supported by [[OsmocomBB]].  Nonetheless, we
10 1 laforge
expect to have support for it at some point in the future.
11
12 22 laforge
More information on the hardware of the device can be found at "[[BR":http://en.qi-hardware.com/wiki/Sciphone_Dream_G2]]
13 1 laforge
The phone has a engineering menu which can be activated by dialing *#36466331#
14 16 steve-m
15
16 22 laforge
h2. Serial Cable
17
18
19 16 steve-m
You can make a serial cable by sacrificing the headset that comes with the phone, and swapping the pins inside the connector.
20 2 steve-m
21
Serial pinout:
22 9 laforge
23 2 steve-m
||Pin||signal||comment||
24 9 laforge
||1||GND||
25
||2||GND||
26 1 laforge
||5||Rx||(From PC to Phone)||
27
||7||Tx||(From Phone to PC)||
28
29
[[Image(sciphone_serial.jpg,20%)]]
30 2 steve-m
31 1 laforge
32 22 laforge
h2. JTAG
33
34
35 4 steve-m
The JTAG port of the MT6235 is accessible on the phone PCB, see the attached picture.
36 22 laforge
You can use "OpenOCD":http://openocd.berlios.de/web/ along with the attached configuration file ([raw-attachment:openocd_mt6235.cfg]) for debugging.
37 1 laforge
38
[[Image(scig2_front.JPG,20%)]]
39
[[Image(scig2_jtag.jpg,20%)]]
40
41 11 steve-m
42 22 laforge
h2. Serial Bootloader
43
 
44 1 laforge
45 22 laforge
Like all Mediatek MT62xx SoCs, the phone uses the [[MTKRomloader]].
46
47 10 steve-m
For executing U-Boot and Linux using the MTK romloader, proceed as follows:
48 1 laforge
49 22 laforge
* clone osmocom-bb.git and checkout the branch 'steve-m/loader_sciphone'
50
* compile the code, connect the phone and run osmocon:
51
<pre>
52 1 laforge
$ ./osmocon -p /dev/ttyUSB0 -m mtk ../../target/firmware/board/mt62xx/loader.mtkram.bin
53 22 laforge
</pre>
54
* press and *hold* the powerbutton of the phone, until the loading has finished and you see the following:
55
<pre>
56 1 laforge
[...]
57
Received branch address ack, code should run now
58 10 steve-m
59 1 laforge
Running on mt62xx in environment mtkram
60
HW_CODE = 0x6235
61 22 laforge
</pre>
62 1 laforge
63 22 laforge
*Uploading U-Boot*
64
* *don't* terminate osmocon and execute:
65
<pre>
66 10 steve-m
$ ./osmoload memload 0x500000 u-boot.bin
67
$ ./osmoload jump 0x500000
68 22 laforge
</pre>
69 13 laforge
70 22 laforge
* now terminate osmocon and open a serial terminal of your choice (115200-8N1)
71
* see below for loading Linux with U-Boot
72 13 laforge
73
74 22 laforge
h2. MTK boot process
75
76
77 1 laforge
[[Image(mt62xx_boot.jpg,20%)]]
78
79 22 laforge
MT62xx chips have IPL (Initial Program Loader) saved in ROM.
80 1 laforge
81
82 22 laforge
This is first code executed after power up.
83 1 laforge
84
85 22 laforge
It configures basic functionality of CPU (serial port 19200n8) and waits on 0xA beacon.
86 1 laforge
87 22 laforge
88
If beacon won't be received, it jumps to NAND memory read procedure.
89
90
91
At NAND 0x0 address Boot Header is placed which holds informations about NAND memory and parameters of image which is going to be loaded.
92
93
94 1 laforge
NAND memory read procedure tries to read NAND memory from 0x0 address with following NFI controller settings:
95
96 13 laforge
||Bus width||Address bytes||Page size||Column shift||Used in Sciphone G2||
97 1 laforge
||1||3||512||8||||
98 13 laforge
||0||3||512||8||||
99 14 laforge
||1||4||512||8||||
100 13 laforge
||0||4||512||8||yes||
101 1 laforge
||1||4||2048||16||||
102
||0||4||2048||16||yes||
103
||1||5||2048||16||||
104
||0||4||2048||16||||
105 15 laforge
106 22 laforge
If Boot Header read from NAND memory will match to currently used NFI configuration, bootloader will start to read data from NAND to internal SRAM. Internal SRAM size is 64kB, which means that code loaded by IPL can't be bigger than that.
107 1 laforge
108
109 22 laforge
*Note:* IPL doesn't configure PLL and SDRAM controller, so there is no possibility to load code to external RAM. Here is where SPL (Secondary Program Loader) comes into the game.
110 1 laforge
111 13 laforge
112 22 laforge
h2. SPL - Runing U-Boot from NAND
113 1 laforge
114 15 laforge
115 22 laforge
SPL (Second Program Loader) is just small U-Boot loader which includes low level CPU initialization (PLL, SDRAM) and NAND driver.
116 1 laforge
117 15 laforge
118 22 laforge
Using default build it occupies less than 4kB, but it lacks NAND memory detection. All the NAND memory types can be specified using preprocessor which is not comfortable. We already identified three different NAND memories and that would be bad to create seperate builds for them.
119 1 laforge
120 22 laforge
121
Fortunatelly there is no need to strip down SPL size to 4kB, so SPL code has been reworked and new functionalities are added. It detects NAND memory at startup and configures NFI controller automatically. New implementation can be found at "nand_spl/nand_boot_detect.c".
122
123
124
SPL also automatically configures SDRAM controler according to RAM you have on your device (currently it tries two configurations).
125
126
127
SPL is generated on every U-Boot build and binary can be found at "nand_spl/u-boot-spl.bin".
128
129
130
SPL will be loaded and executed by IPL only if Boot Header will contain valid data (in this case checksum and length is most important).
131
132
133 6 laforge
To generate Boot Header and place it at the begining of binary you should use mtk_image tool. MTK Boot Header generator can be found at "tools/mtk_image.c".
134
135 22 laforge
<pre>
136 1 laforge
Usage ./mtk_image [ -s size ] [ -o file ] mtk_dump.bin image.bin
137
	[ -s size ]	- size of image, if not specified file size will be taken
138 6 laforge
	[ -o file ]	- name of output file
139 1 laforge
	mtk_dump.bin	- dump of NAND memory from address 0 (at least 64 bytes)
140 6 laforge
	image.bin	- image to be loaded by MTK bootloader
141 22 laforge
</pre>
142 1 laforge
143 22 laforge
mtk_image tool needs dump file from your device (at least 64 bytes read from NAND 0x0 address) as there are different NAND memory configurations. Thanks to that Boot Header will be properly generated for your device.
144 6 laforge
145 1 laforge
146 22 laforge
*Note! Before flashing U-Boot to NAND, create full dump of your NAND, otherwise you'll be not able to restore phone's original software.*
147 1 laforge
148 6 laforge
149 22 laforge
h2. U-Boot
150
151
152
Port of U-Boot for Sciphone G2 can be found at "U-Boot":http://git.osmocom.org/gitweb?p=uboot-mt623x.git;a=summary
153
154 1 laforge
Building U-Boot:
155
156 22 laforge
<pre>
157 1 laforge
export CROSS_COMPILE=arm-linux-gnueabi-
158
make sciphone_g2_config
159 8 laforge
make
160 22 laforge
</pre>
161 1 laforge
162
163 22 laforge
h2. Linux kernel
164 1 laforge
165 22 laforge
166
Port of Linux kernel for Sciphone G2 can be found at "Linux kernel":http://git.osmocom.org/gitweb?p=linux-mt623x.git;a=summary
167
168 1 laforge
Building Linux:
169
170 22 laforge
<pre>
171 8 laforge
export CROSS_COMPILE=arm-linux-gnueabi-
172
make ARCH=arm sciphone_g2_defconfig
173 1 laforge
make ARCH=arm uImage
174 22 laforge
</pre>
175 1 laforge
176 8 laforge
177 22 laforge
h2. Building initramfs file system
178 1 laforge
179 8 laforge
180 22 laforge
The easiest way to have file system in Linux kernel is to build "Initramfs image":http://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt.
181
182
183
You need to download "Busybox":http://www.busybox.net/, configure it and build it.
184
185
<pre>
186 8 laforge
export CROSS_COMPILE=arm-linux-gnueabi-
187
make menuconfig
188
make
189
make install
190 22 laforge
</pre>
191 1 laforge
192 22 laforge
Generated file system by default installs in _install directory.
193 1 laforge
194 22 laforge
195 1 laforge
Additional to that you'll need to create console device in already built filesystem.
196
197 22 laforge
<pre>
198 1 laforge
sudo mknod dev/console c 5 1
199 22 laforge
</pre>
200 1 laforge
201
Now you can create CPIO archive:
202
203 22 laforge
<pre>
204 1 laforge
find . | cpio -o -H newc > rootfs.cpio
205 22 laforge
</pre>
206 7 laforge
207 22 laforge
Next step is to point to Linux kernel where initramfs image is located.
208 7 laforge
209 22 laforge
210 1 laforge
In menuconfig of Linux kernel you should modify following option:
211
212 22 laforge
<pre>
213 1 laforge
CONFIG_INITRAMFS_SOURCE=<path_to_cpio>
214
General setup -> Initial RAM filesystem and RAM disk -> Initramfs source file(s)
215 22 laforge
</pre>
216 1 laforge
217 22 laforge
After these steps Linux kernel image will have initramfs built in.
218 1 laforge
219 14 laforge
220 22 laforge
*Important note:* Initramfs ignores 'init=' variable given in kernel boot parameters list. It always executes /init command at startup and you can't change it. Check if you have /init in your file system (BusyBox has /linuxrc by default, so just change its name to init).
221
Every time you change initramfs file system you have to rebuild also Linux kernel.
222
223
224 13 laforge
To unpack CPIO archive you can use following command:
225
226 22 laforge
<pre>
227 1 laforge
cpio -i -d -H newc -F <path_to_cpio_archive> --no-absolute-filenames
228 22 laforge
</pre>
229 13 laforge
230 1 laforge
231 22 laforge
h2. Reading data files in U-Boot
232 1 laforge
233 22 laforge
234
*NAND*
235
236 1 laforge
Following command will read 256 bytes from NAND address 0 at address 0x800000.
237 13 laforge
238 22 laforge
<pre>
239 1 laforge
nand read 0x800000 0 0x100
240 22 laforge
</pre>
241 13 laforge
242 22 laforge
*Serial*
243 1 laforge
244
Following command will read data at address 0x800000 from serial at baudrate 115200 (using kermit protocol).
245
246 22 laforge
<pre>
247 1 laforge
loadb 0x800000 115200
248 22 laforge
</pre>
249 1 laforge
250 22 laforge
*SD/MMC*
251 1 laforge
252 13 laforge
Following command will read uImage file at address 0x800000 from MMC card.
253 1 laforge
254 22 laforge
<pre>
255 1 laforge
mmcinfo
256 13 laforge
fatload mmc 0 0x800000 uImage
257 22 laforge
</pre>
258 13 laforge
259
260 22 laforge
h2. NAND memory
261
262
263 13 laforge
So far three types of NAND memories has been identified:
264 1 laforge
265
||Chip||Size||
266
||HY27XS08121M||512Mb (64MB) NAND||
267 13 laforge
||HY27XA081G1M||1Gb (128MB) NAND||
268 1 laforge
||TC58NVG0S3AFT||1Gb (128MB) NAND||
269
270 22 laforge
All of them are supported by "mt62xx_nand.c" NAND driver in U-Boot.
271 1 laforge
272
273 22 laforge
This driver has also support for ECC hardware decoding and encoding.
274
275
276 1 laforge
ECC layout which is used by MTK looks as follows:
277 13 laforge
278 22 laforge
<pre>
279 13 laforge
/*
280 22 laforge
* For small and large page NAND devices ecc block size is the same:
281 13 laforge
 *
282 22 laforge
*      ecc_block_size = 256
283 13 laforge
 *
284 22 laforge
* Placement of ecc bytes in spare area is as follows:
285 1 laforge
 *
286 22 laforge
* --------------------------------------------------------------
287
* |                            SPARE                           |
288
* --------------------------------------------------------------
289
* |    | ECC0  |       | ECC1  |       | ECC2  |       | ECC3  |
290
* --------------------------------------------------------------
291
* 0    8       16      24      32      40      48      56      64
292 1 laforge
 *
293 22 laforge
* ECC0 = 12 bits (from 1st ECC block) + 12 bits (from 2nd ECC block)
294
* ECC1 = 12 bits (from 3rd ECC block) + 12 bits (from 4th ECC block)
295
* ECC2 = 12 bits (from 5th ECC block) + 12 bits (from 6th ECC block)
296
* ECC2 = 12 bits (from 7th ECC block) + 12 bits (from 8th ECC block)
297 1 laforge
 */
298
299 22 laforge
</pre>
300 1 laforge
301 13 laforge
ECC layout information is pretty important as built-in bootloader in MT62xx chips
302
has hardware ECC enabled and it won't load code from NAND if ECC layout will
303 22 laforge
not match.
304 13 laforge
305 1 laforge
306 22 laforge
This layout is also important to properly dump or restore existing firmware.
307
308
309 1 laforge
NAND driver for Linux is under development.
310
311
312 22 laforge
h2. LCD
313
314
Sciphone G2 has LCD with 240x320 resolution.
315
316
317 1 laforge
Currently two different LCD controllers has been identified (on Sciphone G2):
318 22 laforge
* ILI9331
319
* ILI9325
320
These controllers are already supported in U-Boot.
321 1 laforge
322 22 laforge
323 1 laforge
To identify what kind of controller is in your device, just check U-Boot prints.
324
325 22 laforge
<pre>
326 13 laforge
DRAM:  32 MiB
327
NAND:  64 MiB
328
MMC:   msdc_mmc: 0
329 1 laforge
mtk_lcd INFO: Read LCD device code: 9331.
330 22 laforge
</pre>
331 1 laforge
332 22 laforge
U-Boot supports displaying bitmap on the screen, you just have to create bitmap in proper format.
333 1 laforge
334
335 22 laforge
By default U-Boot will build osmocomBB bitmap.
336 13 laforge
337
338 22 laforge
To convert your customized bitmap change type of bitmap to indexed.
339
340
341
Using GIMP, select "Image -> Mode -> Indexed...". Maximum number of colours is 240 (16 is used by internal U-Boot CMAP).
342
343
344 13 laforge
In existing U-Boot bmp logo converting tool (tools/bmp_logo.c) there are two issues:
345 22 laforge
* width of bitmap has to be aligned to 4 (otherwise padding bytes will be added and bitmap will be not properly displayed)
346
* size of bitmap can't be bigger than 65535 (LCD on Sciphone G2 is 240x320 = 76800)
347
Both issues are fixed on "uboot-mt623x":http://git.osmocom.org/gitweb?p=uboot-mt623x.git;a=summary.
348 13 laforge
349
350 22 laforge
MT6235 LCD controller shares data lines with NFI (NAND) controller. Currently there is no possibility to use NAND when LCD is used.
351
352
353 1 laforge
Frame buffer driver for Linux is under development.
354 13 laforge
355
356 22 laforge
h2. BBT handling
357
358
359 13 laforge
Comment from "sciphone_g2.h" configuration file explains how BBT is handled.
360
361 22 laforge
<pre>
362 13 laforge
/*
363 22 laforge
* Below option allows U-Boot to save BBT table in NAND.
364
* Without this option BBT table is created everytime when first nand
365
* command is executed (except "nand dump"). Full scanning of NAND
366
* takes long time and unnecessarily delays first command execution.
367 13 laforge
 *
368 22 laforge
* NOTE! This option is disabled by defaut as at startup it deletes last
369
* two blocks of NAND. Most of people run code from RAM and don't have
370
* NAND memory dumped yet. If you don't like to wait on first nand
371
* command, you should enable below option.
372 13 laforge
 */
373
#define MT62XX_NAND_BBT_IN_NAND
374 22 laforge
</pre>
375 13 laforge
376
377 22 laforge
h2. MTD partitions
378
379
380 13 laforge
Layout of MTD partitions is following:
381
382 22 laforge
<pre>
383 13 laforge
device nand0 <mt62xx_nand.0>, # parts = 5
384
 #: name                size            offset          mask_flags
385
 0: sbl                 0x00020000      0x00000000      0
386
 1: env                 0x00020000      0x00020000      0
387
 2: u-boot              0x00200000      0x00040000      0
388
 3: kernel              0x00200000      0x00240000      0
389 6 laforge
 4: root                0x03bc0000      0x00440000      0
390 22 laforge
</pre>
391 17 laforge
392
393 22 laforge
h2. Building images with [[OpenEmbedded]]
394 17 laforge
395
396 22 laforge
Currently the easiest way to build your own Linux distribution for Sciphone G2 is to use OE.
397 17 laforge
398
399 22 laforge
Setting up of OE is described "here":http://www.openembedded.org/index.php/Getting_started.
400
401
402
To have Sciphone G2 target and Linux kernel with U-Boot from [[OsmocomBB]] repositories, you need to apply patch from "here":http://downloads.qi-hardware.com/people/marcin/.
403
404
405
Under above link you can also find example config file for OE build.
406
407
408 17 laforge
So far following images has been successfully run on Sciphone G2:
409
410 22 laforge
<pre>
411 17 laforge
minimal-image
412
opie-image-16mb
413
opie-image
414
x11-image
415 22 laforge
</pre>
416 17 laforge
After successfull build of image, following directory will contain U-Boot, Linux kernel and file system image:
417
418 22 laforge
<pre>
419 18 laforge
/YOUR_BUILD_DIRECTORY/deploy/images/sciphone_g2/
420 22 laforge
</pre>
421 17 laforge
422 22 laforge
U-Boot and Linux kernel are built from latest sources found in [[OsmocomBB]] repositories.
423 17 laforge
424
425 22 laforge
h2. Running Linux distro
426
427
428 17 laforge
[[Image(scig2_opie.jpg,20%)]]
429
430 22 laforge
It's possible to run any Linux distribution without flashing Sciphone's original firmware.
431 17 laforge
432
433 22 laforge
To do this, you need to prepare microSD card and use osmocon loader to load u-Boot image to RAM.
434 17 laforge
435
436 22 laforge
Current images for U-Boot and Root File Systems can be found "here":http://downloads.qi-hardware.com/people/marcin/.
437 17 laforge
438 22 laforge
First of all ext3 partition has to be created on SD card.
439
440
441
*Note!!! Followig method will erase all data on your SD card.*
442
443
<pre>
444 17 laforge
sudo fdisk /dev/sdbX
445
press p (prints partition table)
446
press d (deletes partition table)
447
press n (adds new partition)
448
sudo mkfs.ext3 /dev/sdbX
449 22 laforge
</pre>
450 17 laforge
451
Next step is to copy built image to SD card:
452
453 22 laforge
<pre>
454 17 laforge
sudo dd if=<path_to_ext3_image_file> of=/dev/sdbx
455 22 laforge
</pre>
456 19 laforge
457 22 laforge
When operation is finished, you can pull out SD card from PC and insert it to Sciphone.
458 20 laforge
459
460 22 laforge
Now you can load U-Boot image using osmocon tool.
461 20 laforge
462
463 22 laforge
When U-Boot starts, it loads /boot/uImage kernel file from SD card to RAM and boots it (OE automatically copies built kernel to /boot directory).
464 21 laforge
465 20 laforge
466 22 laforge
After that you should see [[OsmocomBB]] splash screen with "Please wait ..." text and after few moments an OPIE welcome screen should appear.
467 19 laforge
468 22 laforge
469
*Note!!! Initial boot takes much longer time than next ones.*
470
471
If your screen is not properly calibrated, execute *ts_calibrate* command from shell which will recalibrate your touchscreen.
472
473
474
h2. Additional equipment
475
476
477
Sciphone G2 has microSD card slot in hardly available place.
478
479
During development process you'll waste a lot of time to pull out and put in microSD card with new software.
480
481 1 laforge
Below picture shows home made microSD card extension cable which makes SD card changes much faster.
482
483
[[Image(microsd_extension.jpg,20%)]]
484
[[Image(scig2_microsd.jpg,35%)]]
485
486
487 22 laforge
h2. Links
488 1 laforge
489 22 laforge
"- video showing Sciphone G2 running Angstrom Linux with OPIE[[BR":http://www.youtube.com/watch?v=-_guRruQi0I]]
490
491
"- video showing Sciphone G2 running Linux kernel[[BR":http://www.youtube.com/watch?v=w_Iwsckm7Ko]]
492
493
"- Sciphone G2 binary images and patches[[BR":http://downloads.qi-hardware.com/people/marcin/]]
Add picture from clipboard (Maximum size: 48.8 MB)