Letux 400 Kernel 2.6.24.3

Letux 400 Kernel 2.6.24.3 Git Source Tree

Root/README-JZ

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

Archive Download this file

Branches

Tags