打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
[daiq]用busybox-1.15.3制作FS2410的文件系统
分类: BusyBox

目标板(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的文件系统所需的目录和文件。
                               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个目录
mkdir usr/bin usr/lib usr/sbin lib/modules

# Don


运行脚本文件makedir
[daiq@localhost fs2410]$ sh makedir
这样在rootfs目录下就会生成以上列出的文件。
 
2.准备链接库 (主要是拷贝交叉编译环境下的一些文件)
[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制作系统应用程式
3.1 下载busybox-1.15.3(http://blog.chinaunix.net/link.php?url=http://www.busybox.net%2F)并解压。
3.2 进入解压后的目录,设置Busybox更改目录下的Makefile文件。更改地方为:
 ARCH   ?= arm                      //根据需要设置不同的架构
 CROSS_COMPILE ?=/work/cross/toolchain/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-  //就是交叉编译工具
3.3 然后进入下面的工作:
[daiq@localhost busybox-1.15.3]$ make defconfig
[daiq@localhost busybox-1.15.3]$ make menuconfig
在设置过程中要注意的是加载根文件系统的安装路径(Busybox Settings  ---> Installation Options  --->  BusyBox installation prefix:/work/fs/rootfs)
BusyBox Settings  ---> Build Options:  
Build BusyBox as a static binary (no shared libs) : 将BusyBox动态链接或静态连接.(不勾选,动态链接)
选择"Busybox Settings" ==> "Installation Options"选中"[*] Don't use /usr"
选择"Additional CFLAGS"输入如下一行参数(该行参数来源于2.6.30.4内核)
 -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身份建立节点文件/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,内容如下:
[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
# 设置主机名,需要在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.建立主机名存储文件/etc/host
[daiq@localhost rootfs]$ vi etc/host

#如果不指定主机名,默认的为www。
HOSTNAME=daiq


9.建立文件/etc/mdev.conf,内容为空
[daiq@localhost rootfs]$ vi etc/mdev.conf

10.复制主机/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上默认的为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,所需要的文件都已经建立ok了
[daiq@localhost rootfs]$ ls etc/
fstab   group   host   init.d   inittab   mdev.conf   passwd   profile   shadow

11.yaffs文件系统映像的制作
使用mkyaffsimg程序可以把一个目录做成一个yaffs映像文件,然后使用usb下载到
板子上。进入文件系统目录层,使用以下命令。
#mkyaffsimg rootfs rootfs.img (进入yaffs2\utils后 make 可以生成这个工具)
这样就会在该目录下生成rootfs.img映像文件,下载到开发板运行即可。
 
12.编译linux内核支持文件系统
12.1支持NFS挂载根文件系统
内核支持NFS分区(即编译时在File system中选中[*] Root file system on NFS), 以及支持内核IP_PNP(即编译时在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文件系统
在这里不详细说明,请自行参考其他文档资料。
 
13.uboot启动引导文件系统
13.1支持NFS挂载根文件系统uboot环境变量设置

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下载内核NFS挂载根文件系统的串口信息(以供参考):

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文件系统uboot环境变量设置
 
yaffs2:
 
修改制作yaffs映象文件的工具
 在 yaffs 源码中有个 utils 目录,里面是工具 mkyaffsimage 和 mkyaffs2image的源代码,前者用来制作 yaffs1 映象文件,后者用来制作 yaffs2 映象文件。目前 mkyaffsimage 工具只能生成老格式的yaffs1 映象文件,需要修改才能支持新格式。
(1)下载的yaffs2解压出来是这样的一个目录/Development下面有两个文件夹:yaffs  yaffs2,我们需要进入yaffs2,然后再进入utils,这个下面有3个文件,我们需要加两个文件,nand-ecc.c  yaffs_packedtags1.c ,yaffs_packedtags1.c这个文件是从上一节目录拷贝过来的,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里边修改原码为:

加这个头文件:#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
现在我们来制作镜象文件,把目录转到我们文件系统的文件夹上一个目录,我是转到根目录,因为我是在根目录创建了filesystem_install目录,为了方便用mkyaffsimage命令,我们直接把mkyaffsimage拷贝到根目录的bin里边,这样这个命令就可以用了,这样我们就可以用下面的命令来生成镜象文件了:mkyaffsimage filesystem_install (自己命个名字给镜象文件,但是后缀一定是yaffs,比如:myyaffs.yaffs),
这样我们就全部搞定了一个根文件系统yaffs,这样我们就可以下载的板上面去测试,我这样的做的,是完全成功的,在环境变量里边还有设置个变量:bootargs=noinitrd console=ttySAC0 root=/dev/mtdblock2 rootfstype=yaffs到此为止,全部搞定。
 
 
 
附注
第2步中使用到的参数原始定义如下:

#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


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


本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
cramfs+yaffs2文件系统制作
linux2.6.33内核移植(1)
转 在s3c2410板上移植2.6 kernel_mmeelv
嵌入式Linux系列第5篇:Nand Flash根文件系统制作
移植Linux内核2.6.32.2到QQ2440开发板
Linux 内核移植和根文件系统制作
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服