小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

[daiq]用busybox-1.15.3制作FS2410的文件系統(tǒng)

 定慧圖書館 2012-02-11
分類: BusyBox

目標(biāo)板(FS2410)------------------------------
CPU:   S3C2410X
SDRAM: HY57V561620(64MB)
FLASH: K9F1208(64MB)
NET  : CS8900
-------------------------------------------

HOST---------------------------------------
Linux Version:        RedHat LINUX 9
CrossCompiler:        gcc-3.4.5-glibc-2.3.6
-------------------------------------------

移植步驟
 
1.建立root fs的文件系統(tǒng)所需的目錄和文件。
                               Mkdir /work/fs2410
                               Mkdir /work/fs2410/root
                           在work文件夾中建立基本的目錄
[daiq@localhost fs2410]$ tree root 5
root
|-- bin
|-- boot
|-- dev
|-- etc
|-- home
|-- lib
| `-- modules
|-- makedir
|-- mnt
| |-- data
| |-- etc
| |-- jffs2
| |-- temp
| `-- yaffs
|-- proc
|-- root
|-- sbin
|-- sys
|-- tmp
|-- usr
| |-- bin
| |-- lib
| `-- sbin
`-- var
|-- lib
|-- lock
|-- log
|-- run
`-- tmp
可以通過以下腳本文件來建立。
[daiq@localhost fs2410]$ vi makedir

#! /bin/sh

mkdir -p rootfs
cd rootfs

echo "making dir : bin dev etc lib proc sbin sys usr"
mkdir bin dev etc lib proc sbin sys usr #必備的8個(gè)目錄
mkdir usr/bin usr/lib usr/sbin lib/modules

# Don


運(yùn)行腳本文件makedir
[daiq@localhost fs2410]$ sh makedir
這樣在rootfs目錄下就會生成以上列出的文件。
 
2.準(zhǔn)備鏈接庫 (主要是拷貝交叉編譯環(huán)境下的一些文件)
[daiq@localhost fs2410]$ vi copelibs

#!/bin/sh

FSDIR=$PWD
OBJ_LIB=/work/cross/toolchain/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/arm-softfloat-linux-gnu/lib
cd ${OBJ_LIB}
for file in libc libcrypt libdl libm \
 libpthread libresolv libutil
do
 cp $file-*.so ${FSDIR}/rootfs/lib
 cp -d $file.so.[*0-9] ${FSDIR}/rootfs/lib
done
cp -d ld*.so* ${FSDIR}/rootfs/lib

[daiq@localhost fs2410]$ sh copelibs

3.使用busybox制作系統(tǒng)應(yīng)用程式
3.1 下載busybox-1.15.3(http://blog./link.php?url=http://www.busybox.net%2F)并解壓。
3.2 進(jìn)入解壓后的目錄,設(shè)置Busybox更改目錄下的Makefile文件。更改地方為:
 ARCH   ?= arm                      //根據(jù)需要設(shè)置不同的架構(gòu)
 CROSS_COMPILE ?=/work/cross/toolchain/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-  //就是交叉編譯工具
3.3 然后進(jìn)入下面的工作:
[daiq@localhost busybox-1.15.3]$ make defconfig
[daiq@localhost busybox-1.15.3]$ make menuconfig
在設(shè)置過程中要注意的是加載根文件系統(tǒng)的安裝路徑(Busybox Settings  ---> Installation Options  --->  BusyBox installation prefix:/work/fs/rootfs)
BusyBox Settings  ---> Build Options:  
Build BusyBox as a static binary (no shared libs) : 將BusyBox動態(tài)鏈接或靜態(tài)連接.(不勾選,動態(tài)鏈接)
選擇"Busybox Settings" ==> "Installation Options"選中"[*] Don't use /usr"
選擇"Additional CFLAGS"輸入如下一行參數(shù)(該行參數(shù)來源于2.6.30.4內(nèi)核)
 -DSYS_ioprio_get=0x90013b -DSYS_ioprio_set=0x90013a -DARPHRD_INFINIBAND=32 -DEV_SW=0x05 -DSW_LID=0x00
Network File Systems --->
<*> NFS file system support
[*] Provide NFSv3 client support
[*] Provide client support for the NFSv3 ACL protocol extension
[*] Provide NFSv4 client support (EXPERIMENTAL)
[*] Root file system on NFS
好了退出保存就ok了.
[daiq@localhost busybox-1.15.3]$ make
[daiq@localhost busybox-1.15.3]$ file busybox
busybox: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), stripped
[daiq@localhost busybox-1.15.3]$ make install

4.以root身份建立節(jié)點(diǎn)文件/dev/console, /dev/null
[root@localhost rootfs]# mknod -m 600 dev/console c 5 1
[root@localhost rootfs]# mknod -m 666 dev/null c 1 3

5. 為shell加入全局變量文件/etc/profile,內(nèi)容如下:
[daiq@localhost rootfs]$ vi etc/profile

# /etc/profile: system-wide .profile file for the Bourne shells
echo
echo -n "Processing /etc/profile...... "

# Set search library path
export LD_LIBRARY_PATH=/lib:/usr/lib

# Set user path
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH

# Set PS1
USER="`id -un`"
LOGNAME=$USER
PS1='[\u@\h \W]\$ '
PATH=$PATH

echo "Done ... "


6. 增加初始化文件inittab和fstab
[daiq@localhost rootfs]$ vi etc/fstab

#device mount-point type options dump fsck order
proc /proc proc defaults i 0 0
none /tmp ramfs defaults 0 0
mdev /dev ramfs defaults 0 0
sysfs /sys sysfs defaults 0 0


[daiq@localhost rootfs]$ vi etc/inittab

::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh

tty2::askfirst:-/bin/sh

::ctrlaltdel:/bin/umount -a -r
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a


7. 增加初始化腳本文件。
[daiq@localhost rootfs]$ mkdir etc/init.d
[daiq@localhost rootfs]$ vi etc/init.d/rcS

#! /bin/sh
# 設(shè)置主機(jī)名,需要在etc建立文件host
. /etc/host
hostname ${HOSTNAME}
# mount all filesystem defined in “fstab”
echo "# mount all..........."
/bin/mount -a
#+daiq
#/bin/chmod 0666 /dev/null
echo "# Starting mdev........."
/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
echo "*********************************************************"
echo " daiq Linux-2.6.24 nfs boot "
echo " 2010-01-12 "
echo "********************************************************"
echo

[daiq@localhost rootfs]$ chmod +x etc/init.d/rcS

8.建立主機(jī)名存儲文件/etc/host
[daiq@localhost rootfs]$ vi etc/host

#如果不指定主機(jī)名,默認(rèn)的為www。
HOSTNAME=daiq


9.建立文件/etc/mdev.conf,內(nèi)容為空
[daiq@localhost rootfs]$ vi etc/mdev.conf

10.復(fù)制主機(jī)/etc/下面的文件passwd, group, shadow文件到/etc
[daiq@localhost rootfs]$ su -
[root@localhost rootfs]# cp /etc/group  etc/
[root@localhost rootfs]# cp /etc/passwd etc/
[root@localhost rootfs]# cp /etc/shadow etc/
并修改用戶passwd中用戶使用的shell名稱。FC8上默認(rèn)的為bash,uboot中只支持ash。
root:x:0:0:root:/root:/bin/bash -->
root:x:0:0:root:/root:/bin/ash

daiq:x:500:500:daiq:/home/daiq:/bin/bash -->
daiq:x:500:500:daiq:/home/daiq:/bin/ash

ok,所需要的文件都已經(jīng)建立ok了
[daiq@localhost rootfs]$ ls etc/
fstab   group   host   init.d   inittab   mdev.conf   passwd   profile   shadow

11.yaffs文件系統(tǒng)映像的制作
使用mkyaffsimg程序可以把一個(gè)目錄做成一個(gè)yaffs映像文件,然后使用usb下載到
板子上。進(jìn)入文件系統(tǒng)目錄層,使用以下命令。
#mkyaffsimg rootfs rootfs.img (進(jìn)入yaffs2\utils后 make 可以生成這個(gè)工具)
這樣就會在該目錄下生成rootfs.img映像文件,下載到開發(fā)板運(yùn)行即可。
 
12.編譯linux內(nèi)核支持文件系統(tǒng)
12.1支持NFS掛載根文件系統(tǒng)
內(nèi)核支持NFS分區(qū)(即編譯時(shí)在File system中選中[*] Root file system on NFS), 以及支持內(nèi)核IP_PNP(即編譯時(shí)在Networking中選中[*] IP: kernel level autoconfiguration)
    File systems  --->
        Network File Systems  --->
            <*> NFS file system support                        ## 必選
                [*]   Provide NFSv3 client support             ## 可選
            [*] Root file system on NFS                        ## 必選
    Networking  --->
        [*] Networking support
            Networking options  --->
                [*]   IP: kernel level autoconfiguration       ## 必選
12.2支持cramfs、jffs、yaffs文件系統(tǒng)
在這里不詳細(xì)說明,請自行參考其他文檔資料。
 
13.uboot啟動引導(dǎo)文件系統(tǒng)
13.1支持NFS掛載根文件系統(tǒng)uboot環(huán)境變量設(shè)置

bootcmd=tftp 0x30008000 ${bootfile}; bootm 0x30008000
bootdelay=3
baudrate=115200
ethaddr=08:00:3e:26:0a:5b
ipaddr=192.168.4.130
serverip=192.168.4.110
rootpath="/work/nfs/rootfsln"
gatewayip=192.168.4.1
netmask=255.255.240.0
hostname="localhost.localdomain"
bootfile="uImage"
ethact=CS8900-0
bootargs=console=ttySAC0,115200 men=64M init=/linuxrc root=/dev/nfs nfsroot=192.168.4.110:/work/nfs/rootfsln ip=192.168.4.130:192.168.4.110:192.168.4.1:255.255.240.0:DaiQ:eth0:off
stdin=serial
stdout=serial
stderr=seria

tftp下載內(nèi)核NFS掛載根文件系統(tǒng)的串口信息(以供參考):

U-Boot 2009.11 ( 1月 12 2010 - 21:41:21)

DRAM: 64 MB
Flash: 512 kB
NAND: 64 MiB
In: serial
Out: serial
Err: serial
Net: CS8900-0
Hit any key to stop autoboot: 0
Using CS8900-0 device
TFTP from server 192.168.4.110; our IP address is 192.168.4.130
Filename 'uImage'.
Load address: 0x30008000
Loading:
#################################################################

    
#########################################

done
Bytes transferred = 1553840 (17b5b0 hex)
## Booting kernel from Legacy Image at 30008000 ...

   Image Name: fs2410_2.6.24
   Created: 2010-01-12 14:57:50 UTC
   Image Type: ARM Linux Kernel Image (uncompressed)
   Data Size: 1553776 Bytes = 1.5 MB
   Load Address: 30008000
   Entry Point: 30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux..................................................................................................... done, booting the kernel.
Linux version 2.6.24 (daiq@localhost.localdomain) (gcc version 3.4.5)
#6 Tue Jan 12 21:51:18 CST 2010

CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
Machine: SMDK2410
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410A (id 0x32410002)
S3C2410: core 200.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
S3C24XX Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: console=ttySAC0,115200 men=64M init=/linuxrc root=/dev/nfs nfsroot=192.168.4.110:/work/nfs/rootfsln ip=192.168.4.130:192.168.4.110:192.168.4.1:255.255.240.0:DaiQ:eth0:off
irq: clearing pending ext status 00001000
irq: clearing subpending status 00000002
PID hash table entries: 256 (order: 8, 1024 bytes)
timer tcon=00500000, tcnt a2c1, tcfg 00000200,00000000, usec 00001eb8
Console: colour dummy device 80x30
console [ttySAC0] enabled
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 61580KB available (2852K code, 309K data, 128K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 64 bytes
NET: Registered protocol family 16
S3C2410 Power Management, (c) 2004 Simtec Electronics
S3C2410: Initialising architecture
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4800000, irq 33
DMA channel 1 at c4800040, irq 34
DMA channel 2 at c4800080, irq 35
DMA channel 3 at c48000c0, irq 36
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
s3c2410-lcd s3c2410-lcd: no platform data for lcd, cannot attach
s3c2410-lcd: probe of s3c2410-lcd failed with error -22
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled
s3c2410-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410
s3c2410-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410
s3c2410-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
eth0: CS8900A rev E at 0xe0000300 irq=53, addr: 00: 0:3E:26:0A: 0
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2410-nand s3c2410-nand: Tacls=3, 30ns Twrph0=7 70ns, Twrph1=3 30ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
Scanning device for bad blocks
Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x00000000-0x00040000 : "Bootloader"
0x00040000-0x00200000 : "Kernel"
0x00200000-0x02000000 : "FS"
0x02000000-0x04000000 : "WinCE"
usbmon: debugfs is not available
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration
#1 chosen from 1 choice

hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
mice: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2410-i2c s3c2410-i2c: slave address 0x10
s3c2410-i2c s3c2410-i2c: bus frequency set to 390 KHz
s3c2410-i2c s3c2410-i2c: i2c-0: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
TCP cubic registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
IP-Config: Complete:
      device=eth0, addr=192.168.4.130, mask=255.255.240.0, gw=192.168.4.1,
     host=DaiQ, domain=, nis-domain=(none),
     bootserver=192.168.4.110, rootserver=192.168.4.110, rootpath=
Looking up port of RPC 100003/2 on 192.168.4.110
Looking up port of RPC 100005/1 on 192.168.4.110
VFS: Mounted root (nfs filesystem).
Freeing init memory: 128K
DaiQ
# mount all...........

# Starting mdev.........

*********************************************************
          daiq Linux-2.6.24 nfs boot
                  2010-01-12
********************************************************


Processing /etc/profile...... “Done ...
[root@DaiQ /]
# ls

bin etc linuxrc root sys var
boot home mnt rootfs tmp work
dev lib proc sbin usr

 
13.2支持cramfs、jffs、yaffs文件系統(tǒng)uboot環(huán)境變量設(shè)置
 
yaffs2:
 
修改制作yaffs映象文件的工具
 在 yaffs 源碼中有個(gè) utils 目錄,里面是工具 mkyaffsimage 和 mkyaffs2image的源代碼,前者用來制作 yaffs1 映象文件,后者用來制作 yaffs2 映象文件。目前 mkyaffsimage 工具只能生成老格式的yaffs1 映象文件,需要修改才能支持新格式。
(1)下載的yaffs2解壓出來是這樣的一個(gè)目錄/Development下面有兩個(gè)文件夾:yaffs  yaffs2,我們需要進(jìn)入yaffs2,然后再進(jìn)入utils,這個(gè)下面有3個(gè)文件,我們需要加兩個(gè)文件,nand-ecc.c  yaffs_packedtags1.c ,yaffs_packedtags1.c這個(gè)文件是從上一節(jié)目錄拷貝過來的,nand-ecc.c的原碼如下:

#include
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
static const u_char nand_ecc_precalc_table[] = {
    0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a, 0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00,
    0x65, 0x30, 0x33, 0x66, 0x3c, 0x69, 0x6a, 0x3f, 0x3f, 0x6a, 0x69, 0x3c, 0x66, 0x33, 0x30, 0x65,
    0x66, 0x33, 0x30, 0x65, 0x3f, 0x6a, 0x69, 0x3c, 0x3c, 0x69, 0x6a, 0x3f, 0x65, 0x30, 0x33, 0x66,
    0x03, 0x56, 0x55, 0x00, 0x5a, 0x0f, 0x0c, 0x59, 0x59, 0x0c, 0x0f, 0x5a, 0x00, 0x55, 0x56, 0x03,
    0x69, 0x3c, 0x3f, 0x6a, 0x30, 0x65, 0x66, 0x33, 0x33, 0x66, 0x65, 0x30, 0x6a, 0x3f, 0x3c, 0x69,
    0x0c, 0x59, 0x5a, 0x0f, 0x55, 0x00, 0x03, 0x56, 0x56, 0x03, 0x00, 0x55, 0x0f, 0x5a, 0x59, 0x0c,
    0x0f, 0x5a, 0x59, 0x0c, 0x56, 0x03, 0x00, 0x55, 0x55, 0x00, 0x03, 0x56, 0x0c, 0x59, 0x5a, 0x0f,
    0x6a, 0x3f, 0x3c, 0x69, 0x33, 0x66, 0x65, 0x30, 0x30, 0x65, 0x66, 0x33, 0x69, 0x3c, 0x3f, 0x6a,
    0x6a, 0x3f, 0x3c, 0x69, 0x33, 0x66, 0x65, 0x30, 0x30, 0x65, 0x66, 0x33, 0x69, 0x3c, 0x3f, 0x6a,
    0x0f, 0x5a, 0x59, 0x0c, 0x56, 0x03, 0x00, 0x55, 0x55, 0x00, 0x03, 0x56, 0x0c, 0x59, 0x5a, 0x0f
    0x0c, 0x59, 0x5a, 0x0f, 0x55, 0x00, 0x03, 0x56, 0x56, 0x03, 0x00, 0x55, 0x0f, 0x5a, 0x59, 0x0c,
    0x69, 0x3c, 0x3f, 0x6a, 0x30, 0x65, 0x66, 0x33, 0x33, 0x66, 0x65, 0x30, 0x6a, 0x3f, 0x3c, 0x69,
    0x03, 0x56, 0x55, 0x00, 0x5a, 0x0f, 0x0c, 0x59, 0x59, 0x0c, 0x0f, 0x5a, 0x00, 0x55, 0x56, 0x03,
    0x66, 0x33, 0x30, 0x65, 0x3f, 0x6a, 0x69, 0x3c, 0x3c, 0x69, 0x6a, 0x3f, 0x65, 0x30, 0x33, 0x66,
    0x65, 0x30, 0x33, 0x66, 0x3c, 0x69, 0x6a, 0x3f, 0x3f, 0x6a, 0x69, 0x3c, 0x66, 0x33, 0x30, 0x65,
    0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a, 0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00
};
int nand_calculate_ecc(const u_char *dat, u_char *ecc_code)
{
    uint8_t idx, reg1, reg2, reg3, tmp1, tmp2;
    int i;
    reg1 = reg2 = reg3 = 0;
    for(i = 0; i < 256; i++) {
        idx = nand_ecc_precalc_table[*dat++];
        reg1 ^= (idx & 0x3f);
        if (idx & 0x40) {
            reg3 ^= (uint8_t) i;
            reg2 ^= ~((uint8_t) i);
        }
    }
    tmp1 = (reg3 & 0x80) >> 0;
    tmp1 |= (reg2 & 0x80) >> 1;
    tmp1 |= (reg3 & 0x40) >> 1;
    tmp1 |= (reg2 & 0x40) >> 2;
    tmp1 |= (reg3 & 0x20) >> 2;
    tmp1 |= (reg2 & 0x20) >> 3;
    tmp1 |= (reg3 & 0x10) >> 3;
    tmp1 |= (reg2 & 0x10) >> 4;
    tmp2 = (reg3 & 0x08) << 4;
    tmp2 |= (reg2 & 0x08) << 3;
    tmp2 |= (reg3 & 0x04) << 3;
    tmp2 |= (reg2 & 0x04) << 2;
    tmp2 |= (reg3 & 0x02) << 2;
    tmp2 |= (reg2 & 0x02) << 1;
    tmp2 |= (reg3 & 0x01) << 1;
    tmp2 |= (reg2 & 0x01) << 0;
#ifdef CONFIG_MTD_NAND_ECC_SMC
     ecc_code[0] = ~tmp2;
    ecc_code[1] = ~tmp1;
#else
    ecc_code[0] = ~tmp1;
    ecc_code[1] = ~tmp2;
#endif

    ecc_code[2] = ((~reg1) << 2) | 0x03;
    return 0;
}
EXPORT_SYMBOL(nand_calculate_ecc);
static inline int countbits(uint32_t byte)
{
    int res = 0;
    for (;byte; byte >>= 1)
        res += byte & 0x01;
    return res;
}
int nand_correct_data(u_char *dat, u_char *read_ecc, u_char *calc_ecc)
{
    uint8_t s0, s1, s2;
#ifdef CONFIG_MTD_NAND_ECC_SMC
    s0 = calc_ecc[0] ^ read_ecc[0];
    s1 = calc_ecc[1] ^ read_ecc[1];
    s2 = calc_ecc[2] ^ read_ecc[2];
#else
    s1 = calc_ecc[0] ^ read_ecc[0];
    s0 = calc_ecc[1] ^ read_ecc[1];
    s2 = calc_ecc[2] ^ read_ecc[2];
#endif
    if ((s0 | s1 | s2) == 0)
        return 0;
    if( ((s0 ^ (s0 >> 1)) & 0x55) == 0x55 &&
        ((s1 ^ (s1 >> 1)) & 0x55) == 0x55 &&
        ((s2 ^ (s2 >> 1)) & 0x54) == 0x54) {
        uint32_t byteoffs, bitnum;
        byteoffs = (s1 << 0) & 0x80;
        byteoffs |= (s1 << 1) & 0x40;
        byteoffs |= (s1 << 2) & 0x20;
        byteoffs |= (s1 << 3) & 0x10;
        byteoffs |= (s0 >> 4) & 0x08;
        byteoffs |= (s0 >> 3) & 0x04;
        byteoffs |= (s0 >> 2) & 0x02;
        byteoffs |= (s0 >> 1) & 0x01;
        bitnum = (s2 >> 5) & 0x04;
        bitnum |= (s2 >> 4) & 0x02;
        bitnum |= (s2 >> 3) & 0x01;
        dat[byteoffs] ^= (1 << bitnum);
        return 1;
    }

    if(countbits(s0 | ((uint32_t)s1 << 8) | ((uint32_t)s2 <<16)) == 1)
        return 1;
    return -1;
}

在mkyaffsimage.c里邊修改原碼為:

加這個(gè)頭文件:#include "yaffs_packedtags1.h"
static int write_chunk(__u8 *data, __u32 objId, __u32 chunkId, __u32 nBytes)
{
       #ifdef CONFIG_YAFFS_9BYTE_TAGS
      yaffs_Tags t;
      yaffs_Spare s;

      error = write(outFile,data,512);
      if(error < 0) return error;

      memset(&t,0xff,sizeof (yaffs_Tags));
      memset(&s,0xff,sizeof (yaffs_Spare));
      
      t.chunkId = chunkId;
      t.serialNumber = 0;
      t.byteCount = nBytes;
      t.objectId = objId;

    if (convert_endian)
    {
        little_to_big_endian(&t);
    }
      
      yaffs_CalcTagsECC(&t);
      yaffs_LoadTagsIntoSpare(&s,&t);
      yaffs_CalcECC(data,&s);
      nPages++;
      return write(outFile,&s,sizeof(yaffs_Spare));
    #else
        yaffs_PackedTags1 pt1;
        yaffs_ExtendedTags etags;
        __u8 ecc_code[6];
        __u8 oobbuf[16];
        error = write(outFile,data,512);
        if(error < 0) return error;
        etags.chunkId = chunkId;
        etags.serialNumber = 0;
        etags.byteCount = nBytes;
        etags.objectId = objId;
        etags.chunkDeleted = 0;
        yaffs_PackTags1(&pt1, &etags);
        yaffs_CalcTagsECC((yaffs_Tags *)&pt1);
        memset(oobbuf, 0xff, 16);
        memcpy(oobbuf+8, &pt1, 8);
        nand_calculate_ecc(data, &ecc_code[0]);
        nand_calculate_ecc(data+256, &ecc_code[3]);
        oobbuf[0] = ecc_code[0];
        oobbuf[1] = ecc_code[1];
        oobbuf[2] = ecc_code[2];
        oobbuf[3] = ecc_code[3];
        oobbuf[6] = ecc_code[4];
        oobbuf[7] = ecc_code[5];
        nPages++;
        return write(outFile, oobbuf, 16);
#endif
}

修改Makefile文件:
MKYAFFSSOURCES = mkyaffsimage.c     yaffs_packedtags1.c nand-ecc.c
yaffs_packedtags1.c和nand-ecc.c是我們加上去的
這樣我們就可以用make命令來生成工具文件了:mkyaffsimage 和mkyaffs2image
現(xiàn)在我們來制作鏡象文件,把目錄轉(zhuǎn)到我們文件系統(tǒng)的文件夾上一個(gè)目錄,我是轉(zhuǎn)到根目錄,因?yàn)槲沂窃诟夸泟?chuàng)建了filesystem_install目錄,為了方便用mkyaffsimage命令,我們直接把mkyaffsimage拷貝到根目錄的bin里邊,這樣這個(gè)命令就可以用了,這樣我們就可以用下面的命令來生成鏡象文件了:mkyaffsimage filesystem_install (自己命個(gè)名字給鏡象文件,但是后綴一定是yaffs,比如:myyaffs.yaffs),
這樣我們就全部搞定了一個(gè)根文件系統(tǒng)yaffs,這樣我們就可以下載的板上面去測試,我這樣的做的,是完全成功的,在環(huán)境變量里邊還有設(shè)置個(gè)變量:bootargs=noinitrd console=ttySAC0 root=/dev/mtdblock2 rootfstype=yaffs到此為止,全部搞定。
 
 
 
附注
第2步中使用到的參數(shù)原始定義如下:

#define __NR_OABI_SYSCALL_BASE 0x900000 // 來自linux-2.6.30.4/arch/arm/include/asm/unistd.h

#define __NR_ioprio_set (__NR_SYSCALL_BASE+314)
// 0x90013a

#define __NR_ioprio_get (__NR_SYSCALL_BASE+315)
// 0x90013b


#define SYS_ioprio_get __NR_ioprio_get
// 來自/usr/include/bits/syscall.h

#define SYS_ioprio_set __NR_ioprio_set

#define ARPHRD_INFINIBAND 32
// 來自/usr/include和linux-2.6.30.4/include/linux/if_arp.h

#define EV_SW 0x05
// 來自/usr/include/linux/input.h和linux-2.6.30.4/include/linux/input.h

#define SW_LID 0x00
// 來自/usr/include/linux/input.h和linux-2.6.30.4/include/linux/input.h


#define __user
// 用于util-linux/mkfs_vfat.c


(未完待續(xù)。。。)
文章參考:
  http://blog./u3/108239/showart.php?id=2146079
  http://blog./u2/63560/showart_518011.html
  http://linux./techdoc/develop/2007/12/05/973747.shtml


    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多