Project

General

Profile

SciphoneDreamG2 » History » Version 21

Anonymous, 02/19/2016 10:49 PM

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