-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathREADME-JZ
1181 lines (911 loc) · 35.7 KB
/
README-JZ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Linux 2.6 Kernel Release for Ingenic
(Updated: 2008-12-29)
-------------
** Content **
-------------
** Quick start **
** Supported SOC and Platforms **
** Overview of source tree **
** NAND Flash Filesystem **
** UBI, UBIFS and UBI Block Layer **
** UBI and UBIFS images **
** YAFFS2 **
** MTD Block Layer **
** About Bad Blocks of NAND **
** SLC and MLC NAND Flash **
** Initramfs **
** Audio full duplex mode **
** Support **
-----------------
** Quick Start **
-----------------
To build linux 2.6, you needs a mipsel-linux-gcc version 4. Please
download it from Ingenic website http://www.ingenic.cn.
You should have downloaded the linux-2.6.24.3.tar.bz2 and the latest kernel
patch. The patch file was named as "linux-2.6.24.3-jz-yyyymmdd.patch.gz".
Follow next steps to install the full kernel source:
$ tar -xjf linux-2.6.24.3.tar.bz2
$ cd linux-2.6.24.3
$ gzip -cd ../linux-2.6.24.3-jz-yyyymmdd.patch.gz | patch -p1
Now you can configure and build the kernel.
First, you need to do a 'make board_defconfig' to select a board.
For example:
- make pavo_defconfig # JZ4740 PAVO board default configuration
- make pmp_defconfig # JZ4730 PMP ver 2.x board default configuration
- make dipper_defconfig # JZ4725 PMP ver 1.x board default configuration
Then, configure and compile the kernel:
- make xconfig or make menuconfig, if you want to change the configuration.
- make, make uImage, or make zImage, to build the kernel.
The ELF format kernel image is linux-2.6.24.3/vmlinux.
The U-Boot format kernel image is linux-2.6.24.3/arch/mips/boot/uImage.
The compressed raw kernel image is linux-2.6.24.3/arch/mips/boot/compressed/zImage.
---------------------------------
** Supported SOC and Platforms **
---------------------------------
This release supports several platforms based on JZ4730, JZ4740 and JZ4750.
JZ4750 based platforms:
- apus: JZ4750 development board
JZ4740 based platforms:
- pavo: JZ4740 reference board
- leo: JZ4740 development board
JZ4730 based platforms:
- pmp: JZ4730 reference board version 2.x
JZ4725 based platforms:
- dipper: JZ4725 reference board version 1.x
-----------------------------
** Overview of source tree **
-----------------------------
- Changelog : Revision history
- README-JZ : This file
- arch/mips/
- kernel/ : MIPS kernel common code
- mm/ : MIPS memory common code
- jz4730/ : JZ4730 code
- jz4740/ : JZ4740 JZ4725 JZ4720 code
- jz4750/ : JZ4750 code
- configs/
- apus_defconfig : jz4750 based apus default configuration
- pavo_defconfig : jz4740 based pavo default configuration
- pmp_defconfig : jz4730 based pmp default configuration
- dipper_defconfig : jz4725 based dipper default configuration
- include/asm-mips/ : MIPS asm common include
- jzsoc.h : JZ SoC common include
- mach-jz4730/ : JZ4730 SoC headers
- mach-jz4740/ : JZ4740 JZ4725 JZ4720 SoC headers
- mach-jz4750/ : JZ4750 SoC headers
- fs/
- jffs2/ : JFFS2 file system
- yaffs2/ : YAFFS2 file system
- utils/ : YAFFS2 utilities, like mkyaffs2image
- ubifs/ : ubifs file system
- mkfs.ubifs/ : mkfs.ubifs util to create UBIFS
- sound/
oss/ : OSS audio driver
soc/jz4740/ : JZ4740 ALSA audio driver
- drivers/
- char/
- serial.c : serial port driver
- rtc_pcf8563.c : PCF8563 RTC driver
- rtc_jz.c : JZSOC On-Chip RTC driver
- jzchar/ : jzchar devices
- jz_ts.c : generic touch screen driver
- sadc.c : JZ4740 SADC driver
- ak4182.c : AK4182 touch driver
- udc_hotplug.c : UDC hotplug management
- poweroff.c : suspend/poweroff management
- input/keyboard/
- jz_keypad.c : scan keypad driver
- gpio_keys.c : gpio keypad driver
- media/video/
- jz_cim.c : generic camera driver
- jz_sensor.c : generic sensor driver
- mmc/host/
- jz_mmc.c : jz mmc/sd card driver
- mtd/
- mtdblock-jz.c : NAND Flash translation layer driver
- nand/
- nand_base.c : NAND flash interface to MTD
- jz4730_nand.c : NAND flash definition on JZ4730 boards
- jz4740_nand.c : NAND flash definition on JZ4740 boards
- jz4750_nand.c : NAND flash definition on JZ4750 boards
- ubi/ : MTD utilities like flash_eraseall, nandwrite etc.
- ubiblk.c : UBI block layer driver on top of UBI
- mtd-utils/ : MTD and UBI utilities, like flash_eraseall, nandwrite and ubimkvol etc.
- ubi-utils : UBI utils like ubimkvol/ubirmvol/ubinize etc.
- net/
- jz_eth.c : JZ4730 On-Chip ethernet driver
- jzcs8900a.c : cs8900a ethernet driver
- serial/
- 8250.c : standard 16550A serial driver
- usb/ : USB OHCI host driver
- usb/host/
ohci-jz.c : JZ OHCI driver
- usb/gadget/
- jz4730_udc.c : JZ4730 UDC low-level driver
- jz4740_udc.c : JZ4740 and JZ4750 UDC low-level driver
- file_storage.c : USB mass storage class driver
- serial.c : USB serial class driver
- video/
- jzlcd.c : JZ LCD controller framebuffer driver for JZ4730 and JZ4740
- jz4740_slcd.c : JZ Smart LCD controller framebuffer driver for JZ4740
- jz4750_lcd.c : JZ LCD and Smart LCD controller driver for JZ4750
- jz4750_tve.c : JZ TV encoder controller driver for JZ4750
- watchdog/
- jz_wdt.c : JZ On-Chip watchdog driver
---------------------------
** NAND Flash Filesystem **
---------------------------
NAND Flash is the main non-volatile storage for most embedded devices.
So, it's very important to implement a stable and reasonable filesystem on
NAND flash.
In Linux, the MTD subsystem provides a common interface for operating with
many flash devices, such as NOR, NAND etc. And the MTD subsystem was modified
by Ingenic to support the NAND larger than 2GB.
Above MTD layer, we can implement the YAFFS2 filesystem. Or we can implement
a MTD block device, on top of it we can implement the general filesystem
such as FAT and EXT2.
The Linux 2.6 kernel also implements the UBI (Unsorted Block Images). UBI
is a software layer above MTD layer which admits of LVM-like logical volumes
on top of MTD devices, hides some complexities of flash chips like wear
and bad blocks and provides some other useful capabilities. Please, consult
the MTD web site for more details (www.linux-mtd.infradead.org).
On top of UBI, we can implement the UBIFS filesystem. We can also emulate
block devices above UBI, such that we can use the general filesystem such as
FAT and EXT2 on it.
The architecture of the NAND flash filesystem is illustrated as below:
+-----------+ +-------------+ +-------------+
| YAFFS2 | | UBIFS | | FAT or EXT2 | Filesystems
+-----------+ +-------------+ +-------------+
\ | / \
\ | / \
\ | / \
\ | +-----------------+ +-----------------+
\ | | UBI Block Layer | | MTD Block Layer |
\ | +-----------------+ +-----------------+
\ | / /
\ | / /
\ +-------------+ /
\ | UBI | /
\ +-------------+ /
\ | /
+-------------------------------------------+
| MTD |
+-------------------------------------------+
|
+--------------------+
| nand_base.c |
+--------------------+
|
+--------------------+
| jz4740_nand.c |
+--------------------+
The related source codes are listed below:
fs/yaffs2: YAFFS2
fs/ubifs: UBIFS
fs/fat: FAT
fs/ext2: EXT2
drivers/mtd: MTD
drivers/mtd/ubi: UBI
drivers/mtd/ubi/ubiblk.c: UBI Block Layer
drivers/mtd/mtdblock-jz.c: MTD Block Layer
drivers/mtd/mtd-utils: MTD and UBI utils (flash_eraseall/ubimkvol/ubinfo/ubinize etc.)
fs/ubifs/mkfs.ubifs: UBIFS util to create ubifs image (mkfs.ubifs)
fs/yaffs2/util: YAFFS2 util (mkyaffs2image)
To build mtd utils, go to drivers/mtd/mtd-utils, type 'make' and
'make install DESTDIR=/nfsroot/root26'.
To build yaffs2 util, go to fs/yaffs2/utils and type 'make'.
To build ubifs util, go to fs/ubifs/mkfs.ubifs and type 'make'.
Except 'UBI Block Layer' and 'MTD Block Layer', which are implement by Ingenic
ourself, the others are general in the linux kernel tree.
User can select any one of these drivers to implement the filesystem. It all
depends on yourself.
Following sections will describe how to use these drivers in details.
------------------------------------
** UBI, UBIFS and UBI Block Layer **
------------------------------------
UBIFS is a new flash file system which is designed to work on top of UBI.
Here is a short and unsorted list of some of UBIFS features:
* write-back support - This dramatically improves the throughput of the
file-system comparing to JFFS2, which is write-through;
* fast mount time
* tolerance to unclean reboots - UBIFS is a journaling file system and it
tolerates sudden crashes and unclean reboots;
* fast I/O - even with write-back disabled;
* on-the-flight compression - the data is stored in compressed form on
the flash media, which makes it possible to put considerably more data to
the flash as if the data would not be compressed;
Please, consult the MTD web site for more details (www.linux-mtd.infradead.org).
The UBI and UBIFS can be compiled as modules or built into the kernel.
To enable UBI, you need to select following configurations:
CONFIG_MTD_UBI: Enable UBI
CONFIG_MTD_UBI_WL_THRESHOLD: UBI wear-leveling threshold
CONFIG_MTD_UBI_BEB_RESERVE: Percentage of reserved eraseblocks for bad eraseblocks handling
To enable 'UBI Block Layer', you need to select following configurations:
CONFIG_MTD_UBI_BLKDEVS: Common interface to block layer for UBI
CONFIG_MTD_UBI_BLOCK: Emulate block devices
To enable UBIFS, you need to select following configurations:
CONFIG_UBIFS_FS: UBIFS file system support
CONFIG_UBIFS_COMPRESSION_OPTIONS: Advanced compression options for UBIFS
CONFIG_UBIFS_LZO: UBIFS LZO compression support
CONFIG_UBIFS_ZLIB: UBIFS ZLIB compression support
CONFIG_UBIFS_FS_DEBUG: UBIFS debugging
If you want to compile as modules, take next steps:
Type 'make modules' to compile the modules.
Type 'make modules_install INSTALL_MOD_PATH=/nfsroot/root26' to install the
modules to the target root.
You also need to compile the MTD and UBIFS utilities and install them to the
target root.
Now boot your board and mounted root FS with these modules, and below is a
simple guide to test and use the UBIFS and 'UBI Block Layer':
Here we will create UBI volumes on mtd5.
First, format mtd5:
# flash_eraseall /dev/mtd5
Erasing 256 Kibyte @ 1ffc0000 -- 99 % complete.
Install UBI module, attached it to mtd5:
# modprobe ubi mtd=5
UBI: empty MTD device detected
UBI: create volume table (copy #1)
UBI: create volume table (copy #2)
UBI: attached mtd5 to ubi0
UBI: MTD device name: "NAND VFAT partition"
UBI: MTD device size: 512 MiB
UBI: physical eraseblock size: 262144 bytes (256 KiB)
UBI: logical eraseblock size: 258048 bytes
UBI: number of good PEBs: 2048
UBI: number of bad PEBs: 0
UBI: smallest flash I/O unit: 2048
UBI: VID header offset: 2048 (aligned 2048)
UBI: data offset: 4096
UBI: max. allowed volumes: 128
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 0
UBI: available PEBs: 2024
UBI: total number of reserved PEBs: 24
UBI: number of PEBs reserved for bad PEB handling: 20
UBI: max/mean erase counter: 0/0
UBI: background thread "ubi_bgt0d" started, PID 241
Now, create two UBI volumes, one is called ubifs and size is 200MB, the
other is called vfat and size is 298MB.
# ubimkvol /dev/ubi0 -s 200MiB -N ubifs
Volume ID 0, size 813 LEBs (209793024 bytes, 200.1 MiB), LEB size 258048 bytes (252.0 KiB), dynamic, name "ubifs", alignment 1
# ubimkvol /dev/ubi0 -s 298MiB -N vfat
Volume ID 1, size 1211 LEBs (312496128 bytes, 298.0 MiB), LEB size 258048 bytes (252.0 KiB), dynamic, name "vfat", alignment 1
Then you can use 'ubinfo' to query the UBI volume info:
# ubinfo -a
UBI version: 1
Count of UBI devices: 1
UBI control device major/minor: 10:63
Present UBI devices: ubi0
ubi0:
Volumes count: 2
Logical eraseblock size: 258048
Total amount of logical eraseblocks: 2048 (528482304 bytes, 504.0 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 20
Current maximum erase counter value: 3
Minimum input/output unit size: 2048 bytes
Character device major/minor: 252:0
Present volumes: 0, 1
Volume ID: 0 (on ubi0)
Type: dynamic
Alignment: 1
Size: 813 LEBs (209793024 bytes, 200.1 MiB)
State: OK
Name: ubifs
Character device major/minor: 252:1
-----------------------------------
Volume ID: 1 (on ubi0)
Type: dynamic
Alignment: 1
Size: 1211 LEBs (312496128 bytes, 298.0 MiB)
State: OK
Name: vfat
Character device major/minor: 252:2
It shows that we have successfully created two UBI volumes (Volume ID 0 and 1)
on ubi0.
Now you can install the UBIFS and 'UBI Block Layer' modules and create
UBIFS and FAT on UBI volume 0 and 1 respectively.
# modprobe ubifs
# modprobe ubiblk
# lsmod
Module Size Used by Not tainted
ubiblk 7696 0
bdev 10016 1 ubiblk
deflate 4256 1
zlib_deflate 22256 1 deflate
zlib_inflate 16992 1 deflate
lzo 2400 1
lzo_decompress 2816 1 lzo
lzo_compress 2848 1 lzo
ubifs 208560 0
crc16 2048 1 ubifs
ubi 103664 4 ubiblk,bdev,ubifs
Mount UBI volume 0 (the name is "ubifs") on ubi0 with type ubifs:
# mount -t ubifs ubi0:ubifs /mnt/ubifs/
UBIFS: mounted UBI device 0, volume 0
UBIFS: minimal I/O unit size: 2048 bytes
UBIFS: logical eraseblock size: 258048 bytes (252 KiB)
UBIFS: file system size: 207212544 bytes (202356 KiB, 197 MiB, 803 LEBs)
UBIFS: journal size: 9420800 bytes (9200 KiB, 8 MiB, 37 LEBs)
UBIFS: data journal heads: 1
UBIFS: default compressor: LZO
It shows that we have mounted it sucessfully.
Format /dev/ubiblock1 (the block device for UBI volume 1) and mount it with
type vfat:
# mkfs.vfat /dev/ubiblock1
# mount -t vfat /dev/ubiblock1 /mnt/ubiblock1
Please refer to the linux26_developer_guide.pdf for more details about
the UBI and UBIFS.
--------------------------
** UBI and UBIFS images **
--------------------------
Generally, you want to create UBIFS and VFAT images respectively and combine
these two images into one single image, and then use the nandwrite command
to write this image to the MTD partition.
First of all, you need to compile the mkfs.ubifs utility. We use mkfs.ubifs
to create the UBIFS image, like this:
Note: download the linux-nand-utils.tar.gz package from www.ingenic.cn and
follows the guide to compile and run the mkfs.ubifs.
On the PC host:
$ mkfs.ubifs -h
Usage: mkfs.ubifs [OPTIONS]
Make a UBIFS file system image from an existing directory tree
Options:
-r, -d, --root=DIR Build file system from directory DIR
-m, --min-io-size=SIZE Minimum I/O size SIZE
-e, --leb-size=SIZE Use logical erase block size SIZE
-c, --max-leb-cnt=COUNT Use maximum logical erase block count COUNT
-o, --output=FILE Output to FILE
-j, --jrn-size=SIZE Use journal size SIZE bytes
-x, --compr=TYPE Use compression type TYPE (lzo, zlib or none) (default: lzo)
-f, --fanout=NUM Use fanout NUM (default: 8)
-k, --keyhash=TYPE Use key hash type TYPE (r5 or test) (default: r5)
-l, --log-lebs=COUNT Use COUNT erase blocks for the log
-p, --orph-lebs=COUNT Use COUNT erase blocks for orphans (default: 1)
-v, --verbose Verbose operation
-V, --version Display version information
-g, --debug=LEVEL Display debug information
-h, --help Display this help text
$ mkfs.ubifs -r /nfsroot/root26 -m 2048 -e 258048 -c 813 -o ubifs.img
This will create an UBIFS image called ubifs.img. The argument values
can be obtained from the 'ubinfo -a' command.
Follow next steps to create a 30MB FAT32 image called vfat.img:
# dd if=/dev/zero of=vfat.img bs=1M count=30
# losetup /dev/loop0 vfat.img
# mkfs.vfat /dev/loop0
# mount -t vfat /dev/loop0 /mnt/vfat
# cp * /mnt/vfat
# umount /mnt/vfat
# losetup -d /dev/loop0
Now the two images ubifs.img and vfat.img are ready, and we want to
create two UBI volumes and write these two images to the two UBI volumes
respectively. We can do like this:
First, use 'ubinize' command to combine ubifs.img and vfat.img into one
UBI image called ubi.img.
Second, use 'nandwrite_mlc_ubi' command to write the ubi.img to the
MTD partition.
To use 'ubinize' command, you should prepare an INI file for it. The
content of the INI file are as below:
# cat ubinize.cfg
[ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=200MiB
vol_type=dynamic
vol_name=ubifs
vol_alignment=1
vol_flag=autoresize
[vfat]
mode=ubi
image=vfat.img
vol_id=1
vol_size=298MiB
vol_type=dynamic
vol_name=vfat
vol_alignment=1
vol_flag=autoresize
Now you can boot your board and follow next guides to create the UBI
image and burn the UBI image.
On the target board side:
# ubinize -o ubi.img ubinize.cfg -p 262144 -m 2048
If things go well, you can get the UBI image ubi.img.
Then use 'nandwrite_ubi' command to write it to the MTD partition.
# flash_eraseall /dev/mtd5
# nandwrite_ubi -a -q -m /dev/mtd5 ubi.img
Now the UBI image has been written to the NAND mtd5 partition.
Use next commands to test it.
# modprobe ubi mtd=5
# ubinfo -a
UBI version: 1
Count of UBI devices: 1
UBI control device major/minor: 10:63
Present UBI devices: ubi0
ubi0:
Volumes count: 2
Logical eraseblock size: 258048
Total amount of logical eraseblocks: 2048 (528482304 bytes, 504.0 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 20
Current maximum erase counter value: 1
Minimum input/output unit size: 2048 bytes
Character device major/minor: 252:0
Present volumes: 0, 1
Volume ID: 0 (on ubi0)
Type: dynamic
Alignment: 1
Size: 813 LEBs (209793024 bytes, 200.1 MiB)
State: OK
Name: ubifs
Character device major/minor: 252:1
-----------------------------------
Volume ID: 1 (on ubi0)
Type: dynamic
Alignment: 1
Size: 1211 LEBs (312496128 bytes, 298.0 MiB)
State: OK
Name: vfat
Character device major/minor: 252:2
This shows that two UBI volumes are present on ubi0.
# modprobe ubifs
# mount -t ubifs ubi0:ubifs /mnt/ubifs/
UBIFS: mounted UBI device 0, volume 0
UBIFS: minimal I/O unit size: 2048 bytes
UBIFS: logical eraseblock size: 258048 bytes (252 KiB)
UBIFS: file system size: 207212544 bytes (202356 KiB, 197 MiB, 803 LEBs)
UBIFS: journal size: 9420800 bytes (9200 KiB, 8 MiB, 37 LEBs)
UBIFS: data journal heads: 1
UBIFS: default compressor: LZO
# modprobe ubiblk
# mount -t vfat /dev/ubiblock1 /mnt/ubiblock1
# df
Filesystem 1k-blocks Used Available Use% Mounted on
tmpfs 30196 56 30140 0% /dev
ubi0:ubifs 197536 48228 149308 24% /mnt/ubifs
/dev/ubiblock1 30642 5762 24880 19% /mnt/ubiblock1
It shows that the UBIFS and VFAT are all mounted successfully.
------------
** YAFFS2 **
------------
YAFFS (Yet Another Flash File System) was written to satisfy the
special needs of NAND flash. The second release of YAFFS especially
points to supporting newer NAND flash chips with 2k page size and
up to 128MB capacity.
YAFFS2 is supported in this kernel. It's built on top of MTD directly.
Go to fs/yaffs2 for more details.
To build the utility of YAFFS2, change to directory fs/yaffs2/utils/
and type 'make'.
To create a YAFFS2 image, mkyaffs2image command is used On PC host:
usage: mkyaffs2image layout# dir image_file [convert]
layout# NAND OOB layout:
0 - nand_oob_raw, no used,
1 - nand_oob_64, for 2KB pagesize,
2 - nand_oob_128, for 2KB pagesize using multiple planes or 4KB pagesize,
3 - nand_oob_256, for 4KB pagesize using multiple planes
dir the directory tree to be converted
image_file the output file to hold the image
e.g., for 2KB page size NAND not using multi-plane:
$ mkyaffs2image 1 /nfsroot/root26 root26.yaffs2
To burn the yaffs2 image to the NAND, use next command (On target board):
# nandwrite -a -o /dev/mtd2 root26.yaffs2
To format and mount YAFFS2 (On target board):
# flash_eraseall /dev/mtd2
# mount -t yaffs2 /dev/mtdblock2 /mnt/mtdblock2
---------------------
** MTD Block Layer **
---------------------
Ingenic implement the 'MTD Block Layer' by ourself. This gives you a choice
to implement a general filesystem such as FAT and ext2 on NAND flash.
Which partition used for VFAT should be set in bootargs of u-boot for kernel cmdline,
so the kernel kowns other partitions aren't base on MTD Block Layer, and their mounting
speed will be faster. For example, if mtdblock5 is used for VFAT, you can
set bootargs mem=64M console=ttyS1,57600n8 ip=dhcp root=/dev/mtdblock2 rw mtdblk=5
and the mounting speed of mtdblock2 which is not based on MTD Block Layer will be faster.
Features of the 'MTD Block Layer' include:
1. Block unit management (address mapping & block cache operations)
2. Wear-leveling
3. Bad block management
4. Write verify enable
5. mutiple choice of ECC algorithms (hardware Hamming ECC & Reed Solomon ECC,
software Hamming ECC)
Kernel configurations related to the 'MTD Block Layer':
* CONFIG_MTD_OOB_COPIES: defines how many copies of the critical oob data for
each block. Since the page data can be corrected by the ECC algorithm but
the oob data can't, we want to ensure the correction of the oob data by this
way. The mtdblock-jz translation layer driver uses block mode to manipulate
the NAND flash. It makes several copies of the oobinfo data for each block,
so that it can get a correct copy even there is an error in one of them.
* CONFIG_MTD_MTDBLOCK_WRITE_VERIFY_ENABLE: defines this to enable the write
verification function, which will read back data to verify during a write
operation.
Take following steps to use the 'MTD Block Layer':
# flash_eraseall /dev/mtd3
# mkfs.vfat /dev/mtdblock3
# mount -t vfat /dev/mtdblock3 /mnt/vfat
NOTICE:
You can define mutiple VFAT partitions, all the VFAT partitions share
the same above configurations.
Each VFAT partition have its own block cache which resides only in RAM.
Generally, the block cache flush operation is triggered when the access
address exceeds block boundary. The last block cache usually will be
flushed to NAND device when the device is closed (eg: umount /mnt/vfat;
use system call close(fd)).
Abrupt poweroff without flushing the last block cache will cause the
VFAT partition to lose the most significant data which records the
information of the file system management such as FAT table, inodes ...
To avoid this bad thing, you have to flush block cache as soon as possible.
Please do remember to flush block cache manually when you finish
a write operation.
The MTD block layer driver supplys an ioctl for triggering flush block cache
operation. The code attached behind is a reference for you to use.
eg:
# cp * /mnt/vfat
# sync ; this step is necessary to flush the FS cache
# flushcache /dev/mtdblock3 ; this step is necessary to flush the NFTL block cache
/* flushcache.c */
#include <sys/ioctl.h>
#include <linux/fs.h>
#include <fcntl.h>
#include <stdio.h>
int main(int argc,char **argv)
{
int fd;
if( argc != 2 ){
printf( "Usage:%s device name(full path)\n", argv[0] );
return -1;
}
if( (fd = open( argv[1], O_RDONLY ) ) == -1) {
printf( "Open %s failed\n", argv[1] );
return -1;
}
if( ioctl( fd, BLKFLSBUF) == -1)
printf("flush catche failed\n");
close(fd);
return 0;
}
------------------------------
** About Bad Blocks of NAND **
------------------------------
NAND is a special flash type which there are new bad blocks generated during
the whole period of using it. So the NAND driver should know how to detect
a bad block and how to mark a new block bad.
Some types of NAND flash mark the bad block in the spare area of the first
page but others in the last page. So we define a kernel configuration called
CONFIG_MTD_BADBLOCK_FLAG_PAGE and use it to decide the bad block.
CONFIG_MTD_BADBLOCK_FLAG_PAGE: page in a block to store the badblock mark
Following functions should be cared:
nand_base.c:
- nand_block_bad()
- nand_default_block_markbad()
nand_bbt.c:
- create_bbt()
---------------------------------------
** Multiple plane operation for NAND **
---------------------------------------
NAND multiple plane is a feature enabling support of simultaneous write/erase
operations for NAND devices with multiplane architecture. This feature
significantly increases write performance. It could give performance benefits
if NAND device supports ultiple plane architecture only. If NAND device does
not support multiple plane and CONFIG_MTD_NAND_MULTI_PLANE was set to yes when
compiling kernel, code will parse device capabilities and NAND device will work
in single plane mode. For safe, you'd better set CONFIG_MTD_NAND_MULTI_PLANE to
no if NAND device does not support multiple plane.
If the NAND device support multiple plane, you could determine which partitions
use multiple plane and which use single plane by setting the value of
partition_info[] in driver/mtd/nand/jz47xx_nand.c, if the value of use_planes
for a partition is 0, then the partition uses single plane, or else it uses
multiple plane. e.g.
static struct mtd_partition partition_info[] = {
{name:"NAND BOOT partition",
offset:0 * 0x100000,
size:4 * 0x100000,
use_planes: 0},
{name:"NAND KERNEL partition",
offset:4 * 0x100000,
size:4 * 0x100000,
use_planes: 0},
{name:"NAND ROOTFS partition",
offset:8 * 0x100000,
size:120 * 0x100000,
use_planes: 1},
{name:"NAND DATA1 partition",
offset:128 * 0x100000,
size:128 * 0x100000,
use_planes: 1},
{name:"NAND DATA2 partition",
offset:256 * 0x100000,
size:256 * 0x100000,
use_planes: 1},
{name:"NAND VFAT partition",
offset:512 * 0x100000,
size:512 * 0x100000,
use_planes: 1},
};
---------------------------------------
** Multiple chip selecting for NAND **
---------------------------------------
CS1_N pin on Jz4740 or Jz4750 will be used for NAND defaultly; besides CS2_N,
CS3_N, and CS4_N pins could be used for NAND, too. You can configure the kernel
and select the configuration at:
[Memory Technology Devices (MTD)] --> [NAND Device Support]
--> [ECC Type] --> [Use NAND on CS2_N of JZSOC]
[Use NAND on CS3_N of JZSOC]
[Use NAND on CS4_N of JZSOC]
----------------------------
** SLC and MLC NAND Flash **
----------------------------
Single-Level Cell (SLC) and Multi-Level Cell (MLC) are both NAND-based
non-volatile memory technologies. MLC NAND Flash allows each memory cell
to store two bits of information, compared to the one bit-per-cell SLC
NAND Flash allows. As a result, 90 nanometer (nm) MLC NAND offers a
larger capacity (typically twice the density of SLC) and at a cost point
appropriate for consumer products.
Though SLC NAND offers a lower density, it also provides an enhanced
level of performance in the form of faster write speeds. Because SLC
stores only one bit per cell, the likelihood for error is reduced.
At 90 nanometer process, it is recommended to implement a 1 to 2-bit
ECC for SLC, whereas 4-bit ECC is recommended on the MLC architecture.
The linux kernel from ingenic provides MLC NAND support through Hardware
ECC algorithm. Jz4740 supports Reed-Solomon (RS) ECC algorithm, which can
detect and correct 4-bit errors per 512 bytes at least. Jz4750 supports
4-bit and 8-bit BCH ECC algorithm, 4-bit BCH ECC can detect and correct
4 bits for up to 1010 bytes and 8-bit BCH ECC can detect and correct
8 bits errors for up to 1016 bytes.
To include MLC NAND support, you are required to configure the kernel
and select the configuration CONFIG_MTD_HW_RS_ECC for Jz4740, and
CONFIG_MTD_HW_BCH_ECC for Jz4750, which can be found at:
[Memory Technology Devices (MTD)] --> [NAND Device Support]
--> [ECC Type] --> [Select hardware RS ECC]
[Select hardware BCH ECC]
---------------
** Initramfs **
---------------
Please read Documentation/filesystems/ramfs-rootfs-initramfs.txt for
more information about how to use initramfs.
Following are some steps to help you to create root fs by using initramfs:
# cd /rootfs/
# find . | cpio -c -o | gzip -9 > ../rootfs.cpio.gz
Reconfigure the Linux kernel and select next configurations:
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="/rootfs.cpio.gz"
CONFIG_INITRAMFS_ROOT_UID=0
CONFIG_INITRAMFS_ROOT_GID=0
Rebuild the kernel and boot the kernel with next command lines:
"root=/dev/ram0 rw rdinit=/sbin/init"
----------------------------
** Audio full duplex mode **
----------------------------
OSS audio driver supports full duplex mode, that is to say, you can
record while replaying.
The user application want to do some jobs to enable the full duplex mode
of the OSS driver. The following are two examples:
One is:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/soundcard.h>
#include <sys/time.h>
#include <signal.h>
#include <sys/wait.h>
#define AUDIO_FILE "/dev/dsp"
#define FREQS 48000
#define CHANNELS 2
#define TEST_TIME 10
#define SAMPLES 16
#define BUF_SIZE 8192
#define MAX_LEN (FREQS * CHANNELS * TEST_TIME * SAMPLES / 8)
int main(int argc, char *argv[])
{
FILE *fp;
pid_t pid;
int audio_fd, i;
char *play_name;
char *rec_name;
int play_count, play_cnt, played;
int rec_count, rec_cnt, recorded;
u_char play_arr[MAX_LEN];
u_char rec_arr[MAX_LEN];
int err = 0;
play_name = argv[1];
rec_name = argv[2];
if ((audio_fd = open("/dev/dsp", O_RDWR)) < 0) {
printf(" Can't open sound device!\n");
exit(-1);
}
i = BUF_SIZE;
ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &i);
ioctl(audio_fd, SNDCTL_DSP_SYNC, NULL);
i = CHANNELS;
ioctl(audio_fd, SNDCTL_DSP_STEREO, (u_char *) &i);
i = SAMPLES;
ioctl(audio_fd, SNDCTL_DSP_SAMPLESIZE, (u_char *) &i);
i = FREQS;
ioctl(audio_fd, SNDCTL_DSP_SPEED, (u_char *) &i);
fp=fopen(play_name, "r");
fread(play_arr, 1, MAX_LEN, fp);
fclose(fp);
play_count = MAX_LEN;
played = 0;
rec_count = MAX_LEN;
recorded = 0;
switch(pid = fork()) {
case -1:
printf("error\n");
break;
case 0:
printf(" playing\n");
while (play_count) {
play_cnt = play_count;
if (play_cnt > BUF_SIZE)
play_cnt = BUF_SIZE;
write (audio_fd, (char *)play_arr+played, play_cnt);
played += play_cnt;
play_count -= play_cnt;
}/* while (count) */
exit(0);
break;
default:
printf(" recording\n");
while (rec_count) {
rec_cnt = rec_count;
if (rec_cnt > BUF_SIZE)
rec_cnt = BUF_SIZE;
read (audio_fd, (char *)rec_arr+recorded, rec_cnt);