Project

General

Profile

SciphoneDreamG2 » History » Version 28

osmith, 03/29/2019 09:43 AM
fix link formatting

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