【CHICHI ETUTOR@ARM/MIPS/PPC】FILE SYSTEM 6 _ create Partitions on FLASH
1. planned partition formation
2. modification of kernel code (partition.h) to let kernel recongnize the partition
drivers/mtd/nand$ vim s3c_nand.c
*edit/add the partition_info as below
=========================================================
{
.name = "Bootloader",
.offset = 0,
.size = 0x00100000,
},
{
.name = "Kernel",
.offset = 0x00600000,
.size = 0x00500000,
},
{
.name = "cramfs",
.offset = 0x00B00000,
.size = 0x00300000,
},
{
.name = "DATA",
.offset = 0x00E00000,
.size = 0x04000000,
},
{
.name = "Jffs2",
.offset = 0x04E00000,
.size = 0x00f00000,
},
{
.name = "RAMDISK",
.offset = 0x0C640000,
.size = 0x00300000,
},
{
.name = "UBIFS",
.offset = 0x0CA00000,
.size = MTDPART_SIZ_FULL,
}
============================================================
3. check the necessary option items in kernel menuconfig
Device Drivers --->
<*> Memory Technology Device (MTD) support --->
[*] MTD partitioning support
File systems --->
Miscellaneous filesystems --->
<*> YAFFS2 file system support
<*> Journalling Flash File System v2 (JFFS2) support
<*> Compressed ROM file system support (cramfs)
4. make , upload zImage to QT210 and check the KERNEL POST message
$make -j4
$cd ../arch/arm/boot
$sudo dnw zImage
*There should be a message during POST show you the MTD partition formation
===============================================================
[ 0.735000] Creating 7 MTD partitions on "s5pv210-nand":
[ 0.740000] 0x000000000000-0x000000100000 : "Bootloader"
[ 0.745000] 0x000000600000-0x000000b00000 : "Kernel"
[ 0.750000] 0x000000b00000-0x000000e00000 : "cramfs"
[ 0.755000] 0x000000e00000-0x000004e00000 : "DATA"
[ 0.770000] 0x000004e00000-0x000005d00000 : "Jffs2"
[ 0.775000] 0x00000c640000-0x00000c940000 : "RAMDISK"
[ 0.775000] 0x00000ca00000-0x000010000000 : "UBIFS"
==============================================================
*boot NFS and check the /dev have added these MTD device
[root@QT210 /]# ls /dev/mtd*
/dev/mtd0 /dev/mtd2ro /dev/mtd5 /dev/mtdblock1 /dev/mtdblock6
/dev/mtd0ro /dev/mtd3 /dev/mtd5ro /dev/mtdblock2
/dev/mtd1 /dev/mtd3ro /dev/mtd6 /dev/mtdblock3
/dev/mtd1ro /dev/mtd4 /dev/mtd6ro /dev/mtdblock4
/dev/mtd2 /dev/mtd4ro /dev/mtdblock0 /dev/mtdblock5
5. upload the cramfs/data/jffs2/ramdisc image you made earlier to QT210 flash rom (refer to NOTE_fs_rootfs_build)
*cramfs
*QT210 side
==============================
LARRY6410>>set cramfs dnw\;nand erase b00000 300000\;nand write c0008000 b00000 300000
//update20151030 for tftpboot
set cramfs tftpboot 0xc0008000 192.168.10.59:rootfs.cramfs\;nand erase b00000 300000\;nand write c0008000 b00000 300000
LARRY6410>>run cramfs
*HOST side
==============================
$sudo dnw rootfs.cramfs
*QT210 side
==============================
LARRY6410>>set cramfs_boot set bootargs root=/dev/mtdblock2 rootfstype=cramfs console=ttySAC0 mem=512M
LARRY6410>>run cramfs_boot
*There should a boot message shown that cramfs work correctlly
==============================
[ 3.530000] VFS: Mounted root (cramfs filesystem) readonly on device 31:2.
[ 3.530000] Freeing init memory: 148K
[ 5.680000] smdkc110-rtc smdkc110-rtc: rtc disabled, re-enabling
Please press Enter to activate this console.
==============================
*DATA ,create a data area for storage purpose or so.....
*boot to NFS.
*to make sure the device name of "data"
[root@QT210 /]# cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00020000 "Bootloader"
mtd1: 00500000 00020000 "Kernel"
mtd2: 00300000 00020000 "cramfs"
mtd3: 04000000 00020000 "DATA"
mtd4: 00f00000 00020000 "Jffs2"
mtd5: 00300000 00020000 "RAMDISK"
mtd6: 03600000 00020000 "UBIFS"
*format "DATA" as FS Jfss2
[root@QT210 /]# flash_eraseall -j /dev/mtd3
Erasing 128 Kibyte @ 1260000 -- 28 % complete. Cleanmarker written at 1260000.
Skipping bad block at 0x01280000
Erasing 128 Kibyte @ 3e80000 -- 97 % complete. Cleanmarker written at 3e80000.
Skipping bad block at 0x03ea0000
Erasing 128 Kibyte @ 3fe0000 -- 99 % complete. Cleanmarker written at 3fe0000.
*create a folder "/mnt/datatmp" for DATA to mount
[root@QT210 /]# mkdir /mnt/datatmp
*mount the FS to 6410 /mnt
[root@QT210 /]# mount -t jffs2 /dev/mtdblock3 /mnt/datatmp
[root@QT210 /]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 26651712 24847996 449888 98% /
/dev/mmcblk0p1 3139600 72 3139528 0% /mnt/sdcard
tmpfs 337028 0 337028 0% /dev/shm
/dev/mtdblock3 65536 1920 63616 3% /mnt/datatmp
*then you can try to access data via /mnt
*you might meet problem like these
[root@QT210 /]# mount -t jffs2 /dev/mtdblock3 /mnt/datatmp
mount: mounting /dev/mtdblock3 on /mnt failed: No such device
*check the item of jffs2 support in kernel has checked or not
File systems --->
Miscellaneous filesystems --->
<*> Journalling Flash File System v2 (JFFS2) support
*you can add these action into /etc/init.d/rcS let the system do it earilyand automatically..
*add these to rcS
=================================
flash_eraseall -j /dev/mtd3
mkdir /mnt/datatmp
mount -t jffs2 /dev/mtdblock3 /mnt/datatmp
*JFSS2
*boot NFS
*to make sure the device name of "JFSS2"
[root@QT210 /]# cat /proc/mtd*
dev: size erasesize name
mtd0: 00100000 00020000 "Bootloader"
mtd1: 00500000 00020000 "Kernel"
mtd2: 00300000 00020000 "cramfs"
mtd3: 04000000 00020000 "DATA"
mtd4: 00f00000 00020000 "Jffs2"
mtd5: 00300000 00020000 "RAMDISK"
mtd6: 03600000 00020000 "UBIFS"
*format "mtd4" in which we will upload JFSS2 FS
[root@QT210 /]# flash_eraseall -j /dev/mtd4
Erasing 128 Kibyte @ ee0000 -- 99 % complete. Cleanmarker written at ee0000.
*upload the jffs2 image to mtd4
*QT210 side
==============================
SMDKV210#set jffs2 dnw\;nand erase 4e00000 f00000\;nand write c0008000 4e00000 f00000
//update20151030 for tftpboot
set jffs2 tftpboot 0xc0008000 192.168.10.59:rootfs.jffs2\;nand erase 4e00000 f00000\;nand write c0008000 4e00000 f00000
SMDKV210#run jffs2
*HOST side
==============================
$sudo dnw rootfs.jffs2
*QT210 side
==============================
SMDKV210#set jffs2_boot set bootargs root=/dev/mtdblock4 rootfstype=jffs2 console=ttySAC0 mem=512M
SMDKV210#run jffs2_boot
*There might be a boot message shown like these.
* the "Empty xxxxx" message is not a problem .
This message is generated if a block of data is partially written.
It is generally not a sign of any problem.
==============================
[ 9.225000] Empty flash at 0x00297ffc ends at 0x00298000
[ 9.235000] Empty flash at 0x0029bffc ends at 0x0029c000
[ 9.355000] Empty flash at 0x002a3fec ends at 0x002a4000
[ 9.405000] Empty flash at 0x002a7fc0 ends at 0x002a8000
[ 9.565000] VFS: Mounted root (jffs2 filesystem) on device 31:4.
[ 9.565000] Freeing init memory: 148K
[ 13.250000] smdkc110-rtc smdkc110-rtc: rtc disabled, re-enabling
Please press Enter to activate this console.
==============================
*RAMdisc
*make sure the relavent items in kernel have been choosen
General setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
Device Drivers --->
[*] Block devices --->
(8192) Default RAM disk size (kbytes)
File systems --->
<*> Second extended fs support
*edit the file "mk_ramdisk.sh" to change the disk size match the setting in kernel
$ vim mk_ramdisk.sh
change to
===============
RAMDISKSIZE=8192
==============
*Qt210 side (older tigerboard)
==============================
SMDKV210#set ramdisk dnw\;nand erase c640000 300000\;nand write c0008000 c640000 300000
//update20151030 for tftpboot
set ramdisk tftpboot 0xc0008000 192.168.10.59:initrd.gz\;nand erase c640000 300000\;nand write c0008000 c640000 300000
SMDKV210#run ramdisk
*HOST side
==============================
$sudo dnw initrd.img
*QT210 side (for previous vesion tigerboard which with the black/white keypad)
==============================
SMDKV210#nand read 30a00000 c640000 300000
*QT210 side (for the new board tigerboard2 ramdisk corrupt issue, only find the address that wont
be corrupt by kernel would fixed that issue which is why 3C00_0000)
==============================
SMDKV210#nand read 3C000000 c640000 300000
*for older tigerboard
SMDKV210#set ramdisk_boot set bootargs root=/dev/ram0 rootfstype=ext2 ramdisk=8192 initrd=0x30a00000,8M console=ttySAC0 mem=512M
*for new tigerboard 2
SMDKV210#set ramdisk_boot set bootargs root=/dev/ram0 rootfstype=ext2 ramdisk=8192 initrd=0x3c000000,8M console=ttySAC0 mem=512M
SMDKV210#run ramdisk_boot
*There should a boot message shown that ramdisk work correctlly
==============================
[ 0.370000] Trying to unpack rootfs image as initramfs...
[ 0.375000] rootfs image is not initramfs (no cpio magic); looks like an initrd
[ 0.400000] Freeing initrd memory: 8192K
[ 3.535000] s5p-tvout s5p-tvout: hpd status is cable removed
[ 3.545000] DBUG_PORT must not use AFC!
[ 3.545000] RAMDISK: gzip image found at block 0
[ 3.740000] EXT2-fs (ram0): warning: checktime reached, running e2fsck is recommended
[ 3.740000] VFS: Mounted root (ext2 filesystem) on device 1:0.
[ 3.740000] Freeing init memory: 148K
[ 5.085000] smdkc110-rtc smdkc110-rtc: rtc disabled, re-enabling
[ 5.105000] net eth0: SMSC911x/921x identified at 0xf48e2000, IRQ: 41
Please press Enter to activate this console.
==============================
*UBIFS
*boot NFS
**make sure the relavent items in kernel have been choosen
Device Drivers -->
Memory Technology Device (MTD) support--->
UBI - Unsorted block images-->
<*> Enable UBI
File systems --->
Miscellaneous filesystems -->
<*> UBIFS file system support
[*] Extended attributes support
[*] Advanced compression options
[*] LZO compression support
[*] ZLIB compression support
*to make sure the device name of "UBIFS"
[root@QT210 /]# cat /proc/mtd*
dev: size erasesize name
mtd0: 00100000 00020000 "Bootloader"
mtd1: 00500000 00020000 "Kernel"
mtd2: 00300000 00020000 "cramfs"
mtd3: 04000000 00020000 "DATA"
mtd4: 00f00000 00020000 "Jffs2"
mtd5: 00300000 00020000 "RAMDISK"
mtd6: 03600000 00020000 "UBIFS"
*format "mtd6" in which we will upload UBI FS
[root@QT210 /]# flash_eraseall /dev/mtd6
Erasing 128 Kibyte @ 35e0000 -- 99 % complete.
*ubi_ctrl
[root@QT210 /]# ls /dev/ubi*
/dev/ubi_ctr
*attach ubi_ctrl with mtd6
[root@QT210 /]# ubiattach /dev/ubi_ctrl -m 6
[ 169.115000] UBI: attaching mtd6 to ubi0
[ 169.115000] UBI: physical eraseblock size: 131072 bytes (128 KiB)
[ 169.115000] UBI: logical eraseblock size: 129024 bytes
[ 169.115000] UBI: smallest flash I/O unit: 2048
[ 169.115000] UBI: sub-page size: 512
[ 169.115000] UBI: VID header offset: 512 (aligned 512)
[ 169.120000] UBI: data offset: 2048
[ 169.580000] UBI: empty MTD device detected
[ 169.580000] UBI: create volume table (copy #1)
[ 169.590000] UBI: create volume table (copy #2)
[ 169.610000] UBI: attached mtd6 to ubi0
[ 169.610000] UBI: MTD device name: "UBIFS"
[ 169.610000] UBI: MTD device size: 54 MiB
[ 169.610000] UBI: number of good PEBs: 432
[ 169.610000] UBI: number of bad PEBs: 0
[ 169.610000] UBI: max. allowed volumes: 128
[ 169.615000] UBI: wear-leveling threshold: 4096
[ 169.620000] UBI: number of internal volumes: 1
[ 169.625000] UBI: number of user volumes: 0
[ 169.625000] UBI: available PEBs: 424
[ 169.635000] UBI: total number of reserved PEBs: 8
[ 169.635000] UBI: number of PEBs reserved for bad PEB handling: 4
[ 169.645000] UBI: max/mean erase counter: 0/0
[ 169.645000] UBI: image sequence number: 0
[ 169.650000] UBI: background thread "ubi_bgt0d" started, PID 92
UBI device number 0, total 432 LEBs (55738368 bytes, 53.2 MiB), available 424 LEBs (54706176 bytes, 52.2 MiB), LEB size 129024 bytes (126.0 KiB)
*there is a ubi0 generated and connected to /dev/mtd6
[root@QT210 /]# ls /dev/ubi*
/dev/ubi0 /dev/ubi_ctr
*give a label to ubi0 and ubi0_0 generate
[root@QT210 /]# ubimkvol /dev/ubi0 -N larryubifs -m
Set volume size to 54706176
Volume ID 0, size 424 LEBs (54706176 bytes, 52.2 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "larryubifs", alignment 1
*there is a ubi0_0 generated and this is exactly one we used to mount to /mnt
[root@QT210 /]# ls /dev/ubi*
/dev/ubi0 /dev/ubi0_0 /dev/ubi_ctrl
*create a folder "ubitmp" for ubi device to mount
[root@QT210 /]# mkdir /mnt/ubitmp
*mount the ubifs to /mnt
[root@QT210 /]# mount -t ubifs ubi0_0 /mnt/ubitmp
[ 371.920000] UBIFS: default file-system created
[ 372.115000] UBIFS: mounted UBI device 0, volume 0, name "larryubifs"
[ 372.115000] UBIFS: file system size: 53544960 bytes (52290 KiB, 51 MiB, 415 LEBs)
[ 372.115000] UBIFS: journal size: 2709504 bytes (2646 KiB, 2 MiB, 21 LEBs)
[ 372.115000] UBIFS: media format: w4/r0 (latest is w4/r0)
[ 372.120000] UBIFS: default compressor: lzo
[ 372.125000] UBIFS: reserved for root: 2529060 bytes (2469 KiB)
*setup a file system (/day7/root_mkfs.tar.gz) on mtd6
$cp root_mkfs20120215.tar.gz ~/root_mkfs
*then decompress it on 6410 to /mnt
[root@QT210 /]# tar zxvf root_mkfs20120215.tar.gz -C /mnt/ubitmp
*umount device
[root@QT210 /]# umount /mnt/ubitmp/
[ 569.885000] UBIFS: un-mount UBI device 0, volume 0
*reboot qt210 and set bootargs to boot from mtd6
SMDKV210# set ubi_boot set bootargs ubi.mtd=6 root=ubi0:larryubifs rootfstype=ubifs console=ttySAC0 mem=512M
*There should be message shown as below
UBIFS: recovery needed
UBIFS: recovery completed
UBIFS: mounted UBI device 0, volume 0, name "larryubifs"
UBIFS: file system size: 303206400 bytes (296100 KiB, 289 MiB, 1175 LEBs)
UBIFS: journal size: 15224832 bytes (14868 KiB, 14 MiB, 59 LEBs)
UBIFS: media format: 4 (latest is 4)
UBIFS: default compressor: LZO
UBIFS: reserved for root: 5182151 bytes (5060 KiB)
VFS: Mounted root (ubifs filesystem).
Freeing init memory: 280K
eth0: link down
Please press Enter to activate this console.
*setup QTOPIA (day7/qtopia.tar.gz) as a FS into mtd6 and then boot to it
*re-compile the kernel coz the capacity of flash is not bigger enough for the segments we made earlier
/drivers/mtd/nand/s3c_nand.h
{
.name = "Bootloader",
.offset = 0,
.size = 0x00100000,
},
{
.name = "Kernel",
.offset = 0x00100000,
.size = 0x00500000,
},
{
.name = "UBIFS",
.offset = 0x00600000,
.size = MTDPART_SIZ_FULL,
}
QT210 side
==========
SMDKV210# set bootargs noinitrd root=/dev/nfs nfsroot=192.168.0.1:/home/cdpda/root_mkfs,proto=tcp,nfsvers=3 ip=192.168.0.20::192.168.0.1:255.255.255.0:hello.com.tw:eth0:off console=ttySAC0
QT210 side
===========
SMDKV210# dnw
OTG cable Connected!
Now, Waiting for DNW to transmit data
Download Done!! Download Address: 0xc0008000, Download Filesize:0x35b1e8
Checksum is being calculated....
Checksum O.K.
HOST side
==========
dnw zImage
QT210 side (boot kernel that store in 0xc0008000)
==========
SMDKV210# bootm c0008000
*then boot NFS to console
*repeated the step as above
*flash_eraseall /dev/mtd2
*ubiattach /dev/ubi_ctrl -m 2
*ubimkvol /dev/ubi0 -N larryubifs -m
*mkdir /mnt/ubitmp
*mount -t ubifs ubi0_0 /mnt/ubitmp
$cp qtopia10.tar.gz ~/root_mkfs
*then decompress it on 6410 to /mnt
[root@QT210 /]#tar zxvf qtopia10.tar.gz -C /mnt/ubitmp
*umount /mnt/ubitmp
*reboot QT210
QT210 side (set bootargs to boot from mtd6)
==========
SMDKV210#set bootargs ubi.mtd=2 root=ubi0:larryubifs rootfstype=ubifs console=ttySAC0 mem=512M
QT210 side
===========
SMDKV210# dnw
OTG cable Connected!
Now, Waiting for DNW to transmit data
Download Done!! Download Address: 0xc0008000, Download Filesize:0x35b1e8
Checksum is being calculated....
Checksum O.K.
HOST side
==========
dnw zImage
QT210 side (boot kernel that store in 0xc0008000)
==========
SMDKV210# bootm c0008000
*then boot to QTOPIA you should see the "windows" on the LCD
===================================
[ 5.950000] UBIFS: reserved for root: 4952683 bytes (4836 KiB)
[ 5.960000] VFS: Mounted root (ubifs filesystem) on device 0:13.
[ 5.960000] Freeing init memory: 152K
mount: mounting /dev/mmcblk0p1 on /mnt/sdcard failed: Device or resource busy
[ 8.550000] smdkc110-rtc smdkc110-rtc: rtc disabled, re-enabling
hwclock: settimeofday() failed: Invalid argument
Try to bring eth0 interface up......[ 8.615000] net eth0: MAC Address: 00:22:12:34:56:90
[ 8.630000] net eth0: SMSC911x/921x identified at 0xf4948000, IRQ: 41
Done
Starting Qtopia, please waiting...
Please press Enter to activate this console.
====================================
*Andoird (FASTBOOT)
Host side
--------
1. download "fastboot.tar.gz from /day7 and decompressed it.
#tar zxvf fastboot_image.tar.gz
QT210 side (with the USB cable connected between QT210 and HOST)
-------
2. Stop at uboot console and run "fastboot"
SMDKV210 # fastboot
Fastboot: employ default partition information
[Partition table on NAND]
ptn 0 name='bootloader' start=0x0 len=0x100000(~1024KB)
ptn 1 name='recovery' start=0x100000 len=0x500000(~5120KB)
ptn 2 name='kernel' start=0x600000 len=0x500000(~5120KB)
ptn 3 name='ramdisk' start=0xB00000 len=0x300000(~3072KB)
ptn 4 name='system' start=0xE00000 len=0x6E00000(~112640KB) (Yaffs)
ptn 5 name='cache' start=0x7C00000 len=0x5000000(~81920KB) (Yaffs)
ptn 6 name='userdata' start=0xCC00000 len=N/A (Yaffs)
Host side
---------
3. run the fastboot.sh in the fastboot folder (the while process might take 2~3 minutes)
fastboot_image#sudo ./fastboot.sh
sending 'bootloader' (272 KB)...
OKAY [ 0.215s]
writing 'bootloader'...
OKAY [ 0.476s]
finished. total time: 0.691s
sending 'kernel' (3011 KB)...
OKAY [ 0.939s]
writing 'kernel'...
OKAY [ 2.583s]
finished. total time: 3.522s
sending 'system' (110077 KB)...
OKAY [ 31.147s]
writing 'system'...
OKAY [ 94.093s]
finished. total time: 125.241s
sending 'userdata' (1470 KB)...
OKAY [ 0.529s]
writing 'userdata'...
OKAY [ 2.358s]
finished. total time: 2.887s
sending 'ramdisk' (1314 KB)...
OKAY [ 0.502s]
writing 'ramdisk'...
OKAY [ 1.303s]
finished. total time: 1.805s
erasing 'cache'...
OKAY [ 0.591s]
finished. total time: 0.591s
QT210 side
---------
4. reset the system and let it go freely unitl enter "android 2.3"
5. copy the "pointercal" in your sdcard to system /data (conduct this when the full android screen is displayed)
cp /mnt/sdcard/pointercal /data/
6.enjoy your first android system
0 意見:
張貼留言