Kernel transplantation and file system production (4): Summary of UBIFS root file system production

Publisher:rho27Latest update time:2024-07-24 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere


set -x

echo ""
echo "Generating $image_name file by mkfs.ubifs..."
/usr/bin/mkfs.ubifs -x lzo -m $page_size_in_bytes -e $logical_erase_block_size -c $patition_logical_blocks -r
$rootfs_dir -o $image_tmp
set +x


echo
echo "Generating configuration file..."
echo "[ubifs-volume]" > $config_file
echo "mode=ubi" >> $config_file
echo "image=$image_tmp" >> $config_file
echo "vol_id=0" >> $config_file
echo "vol_size=$fs_vol_size" >> $config_file
echo "vol_type=dynamic" >> $config_file
echo "vol_name=rootfs" >> $config_file
echo "vol_flags=autoresize" >> $config_file
echo "vol_alignment=1" >> $config_file
echo


set -x
/usr/bin/ubinize -o $image_name -m $page_size_in_bytes -p $block_size_in_bytes -s $sub_page_size  -O    $vid_head_offset
$config_file

rm -f $image_tmp $config_file
cp $image_name /tftp

set +x

[zhouguangfeng@localhost ubifs]$ sh build_ubifs.sh

[zhouguangfeng@localhost ubifs]$ ls
build_ubifs.sh  rootfs_zhou.ubifs
[zhouguangfeng@localhost ubifs]$ OK!


The Linux server used has TFTP enabled, and the IP address is 192.168.1.3. Finally, the script directly copies the image file to the /tftp directory and sets the server IP address to 192.168.1.3 under uboot.


3. Add support for UBIFS in uboot

The nandflash partitions are as follows:


Creating 9 MTDpartitions on "NAND":

0x000000000000-0x000000100000: "mtdblock0_u-Boot 1MB "

0x000000100000-0x000001000000 : "mtdbolck1_kernel 15MB"

0x000001000000-0x000002400000: "mtdbolck2_ramdisk 20MB"

0x000002400000-0x000003800000: "mtdblock3_cramfs 20MB"

0x000003800000-0x000006000000: "mtdblock4_jffs2 40MB"

0x000006000000-0x000008800000: "mtdblock5_yaffs2 40MB"

0x000008800000-0x00000b000000: "mtdblock6_ubifs 40MB"

0x00000b000000-0x00000d800000: "mtdblock7_apps 40MB"

0x00000d800000-0x000010000000: "mtdblock8_data 40MB"

The addresses of kernel and UBIFS image file systems must correspond to the partitions. Partition mtdbolck1 stores the kernel and partition mtdblock6 stores UBIFS. The offsets are 100000 and 8800000 respectively.


[ s3c2440@zhou ]# set serverip 192.168.1.3

[ s3c2440@zhou ]# set bubifs 'tftp 30008000 rootfs_zhou.ubifs;nand erase 8800000 2800000;nand write 30008000 8800000 800000'

[ s3c2440@zhou ]# set bootargs_ubifs 'console=ttyS0,115200 mem=64Mubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw'

[ s3c2440@zhou ]# set bootargs  'console=ttyS0,115200 mem=64Mubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw'


[ s3c2440@zhou ]# set bootcmd_rootfs 'nand read 30008000 100000 800000;bootm 30008000'


[ s3c2440@zhou ]# set bootcmd 'run bootcmd_rootfs'

[ s3c2440@zhou ]# save
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done
[ s3c2440@zhou ]# pri
cpu=s3c2440
bbl=tftp 30008000 u-boot-$cpu.bin;nand erase 0 100000;nand write 30008000 0 $filesize
norbbl=erase bank 1; tftp 30008000 u-boot-$cpu.bin;cp.b 30008000 0 $filesize
blx=tftp 30008000 linuxrom-$cpu.bin;nand erase 100000 F00000;nand write 30008000 100000 $filesize
bcramfs=tftp 30800000 cramfs-$cpu.rootfs;nand erase 2400000 1400000;nand write 30800000 2400000 $filesize
tb=tftp 30008000 linuxrom-$cpu.bin;bootm 30008000
bootargs_initamfs=console=ttyS0,115200 mem=64M rw loglevel=7
bootargs_ramdisk=console=ttyS0,115200 root=/dev/ram0 initrd=0x30800000,16M init=/linuxrc mem=64M rw loglevel=7
bootargs_cramfs=console=ttyS0,115200 root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc mem=64M noinitrd        loglevel=7
bootargs_jffs2=console=ttyS0,115200 root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc mem=64M rw noinitrd         loglevel=7
mtdparts=mtdparts=nand0:1m(uboot),15m(kernel),20m(ramdisk),20m(cramfs),20m(jffs2),20m(yaffs2),20m(ubifs),-(users)
baudrate=115200
ethaddr=08:08:11:18:12:27
ethact=dm9000
bootdelay=1
bkr=tftp 30008000 linuxrom-s3c2440_zhou.bin;nand erase 100000 800000;nand write 30008000 100000 800000
bootargs_ubifs=console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw
bootcmd_rootfs=nand read 30008000 100000 800000;bootm 30008000
bubifs=tftp 30008000 rootfs_zhou.ubifs;nand erase 8800000 2800000;nand write 30008000 8800000 800000
brdfs=tftp 30008000 ramdisk_zhou.gz;nand erase 1000000 1400000;nand write 30008000 1000000 800000
bootcmd_ramdisk=nand read 30008000 100000 800000;nand read 30800000 1000000 800000;bootm 30008000
bootcmd=run bootcmd_rootfs
bootargs_nfs=noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/ ip=192.168.1.224:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
filesize=2F8910
fileaddr=30008000
gatewayip=192.168.1.1
netmask=255.255.255.0
serverip=192.168.1.3
bootargs=console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw
ipaddr=192.168.1.220
stdin=serial
stdout=serial
stderr=serial


Environment size: 2076/131068 bytes

[ s3c2440@zhou ]# run bkr
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.220
Filename 'linuxrom-s3c2440_zhou.bin'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#################################################################
###############################
done
Bytes transferred = 3304240 (326b30 hex)


NAND erase: device 0 offset 0x100000, size 0x800000
Erasing at 0x8e0000 -- 100% complete.
OK


NAND write: device 0 offset 0x100000, size 0x800000
8388608 bytes written: OK
[ s3c2440@zhou ]# run bubifs
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.3; our IP address is 192.168.1.220
Filename 'rootfs_zhou.ubifs'.
Load address: 0x30008000
Loading: #################################################################
#################################################################
#################################################################
######################################
done
Bytes transferred = 3407872 (340000 hex)


NAND erase: device 0 offset 0x8800000, size 0x2800000
Skipping bad block at  0x09c60000
Erasing at 0xafe0000 -- 100% complete.
OK


NAND write: device 0 offset 0x8800000, size 0x800000
8388608 bytes written: OK
[ s3c2440@zhou ]#    boot



NAND read: device 0 offset 0x100000, size 0x800000
8388608 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
Image Name:   Linux Kernel
Created:      2014-08-22  11:27:56 UTC
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    3304176 Bytes = 3.2 MiB
Load Address: 30008000
Entry Point:  30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
OS entry point: 30008040
Image entry point=30008040


Starting kernel ...

......

UBI: attaching mtd6 to ubi0
UBI: scanning is finished
UBI: attached mtd6 (name "mtdblock6_ubifs 40MB", size 40 MiB) to ubi0
UBI: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 512
UBI: VID header offset: 512 (aligned 512), data offset: 2048
UBI: good PEBs: 319, bad PEBs: 1, corrupted PEBs: 0
UBI: user volume: 1, internal volumes: 1, max. volumes count: 128
UBI: max/mean erase counter: 2/0, WL threshold: 4096, image sequence number: 1940096911
UBI: available PEBs: 0, total reserved PEBs: 319, PEBs reserved for bad PEB handling: 1
UBI: background thread "ubi_bgt0d" started, PID 501
s3c-rtc s3c2410-rtc: setting system clock to 2014-08-22 20:58:16 UTC (1408741096)
ALSA device list:
No soundcards found.
UBIFS: background thread "ubifs_bgt0_0" started, PID 503
usb 1-1: new full-speed USB device number 2 using s3c2410-ohci
UBIFS: mounted UBI device 0, volume 0, name "rootfs"(null)
UBIFS: LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
UBIFS: FS size: 37416960 bytes (35 MiB, 290 LEBs), journal size 5160960 bytes (4 MiB, 40 LEBs)
UBIFS: reserved for root: 0 bytes (0 KiB)
UBIFS: media format: w4/r0 (latest is w4/r0), UUID 8F308069-E353-4739-8E3A-5CB1967E7A24, small LPT model
VFS: Mounted root (ubifs filesystem) on device 0:11.
devtmpfs: mounted
Freeing init memory: 156K
usb 1-1: New USB device found, idVendor=05e3, idProduct=0606
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Hub 2.0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
dm9000 dm9000 eth0: link down
dm9000 dm9000 eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1



Copyright (C) 2014 zhouguangfeng
root login: root
Password:
[root@root /]# OK


[1] [2]
Reference address:Kernel transplantation and file system production (4): Summary of UBIFS root file system production

Previous article:FL2440 driver addition (3) LCD driver addition study notes
Next article:Use of Linux 2.4.18 kernel timer

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号