码迷,mamicode.com
首页 > 其他好文 > 详细

制作mkyaffs2image和mkyaffsimage

时间:2015-01-30 17:49:45      阅读:554      评论:0      收藏:0      [点我收藏+]

标签:

     我们转换文件系统到yaffs2或yaffs的时候,需要两个工具:mkyaffs2image和mkyaffsimage。


     mkyaffs2image:制作yaffs2镜像

     mkyaffsimage:制作yaffs镜像


    关于yaffs2与yaffs的区别:

    维基百科是这样说的:

YAFFS1和YAFFS2 主要差异还是在于PAGE 读写 size的大小,YAFFS2可支持到2K per page, 远高于YAFFS的512 Bytes, 因此对大容量NAND flash更具优势。其他与YAFFS1不同的是, YAFFS2不再写spare area, sequenceNumber 用29 bits 表示。Yaffs2还拥有YAFFS1所缺乏的SuperBlock, 因此YAFFS1严重依赖文件系统的read_super。

             

    1. Download Yaffs using Git

We now operate a GIT server for our active projects. Here we give details of the setup:-

If you just want to browse or download code then it’s easiest to access the repositoryover the web. This is also the best option if you are behind a firewall that does not allow direct GIT access(which is quite common).
To get a tarball of the top of the tree, just click ‘snapshot’ for the release that you want, or to quickly obtain a snapshot of the top of the tree you can use this URL.
You will be offered a freshly-squeezed gzipped tarball of your choice.

If you want to use GIT directly from the command line then public read-only access is available, using the(bash) command:

git clone git://www.aleph1.co.uk/yaffs2 

If you are a registered developer with a server account you can get read/write access using:

git clone ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2


Please contact jenny@aleph1.co.uk ifyou are having problems using the GIT server.

If you need more info on how to use GIT then this website is a useful start. Many other tutorials are also available on the internet.



    2. 解压缩

                   目前版本:yaffs2-HEAD-7e5cf0f.tar.gz

                   #tar zxvf yaffs2-HEAD-7e5cf0f.tar.gz


                   在解压缩后的目录里,有一个utils文件夹;这个就是我们需要的。

    3. 配置Makefile

                  (1) Linux kernel

                                       设置Linux kernel目录位置

                                       

## Change or override  KERNELDIR to your kernel

#KERNELDIR = /usr/src/kernel-headers-2.4.18
                                       在下面设置:

                                        KERNELDIR = /home/at91/linux-2.6.30


                 (2) CROSS_COMPILE

                                       设置交叉编译器

## Change if you are using a cross-compiler
MAKETOOLS = 
                                       在“MAKETOOLS=”后面,填写交叉编译器路径:/home/at91/x-tools/arm-softfp-linux-gnueabi/bin/arm-softfp-linux-gnueabi-


    4. 头文件

                   (1) 新建mytypes.h

                                         此头文件,主要解决u8,u16,s32等等的定义问题;


                   (2) 修改yutilsenv.h

                                       此头文件主要为工具环境而设,所以把我们新建的mytypes.h加进来。


    5. 生成

                       执行生成

make
技术分享





附录:

            1. Makefile

#Makefile for mkyaffs
#
# NB this is not yet suitable for putting into the kernel tree.
# YAFFS: Yet another Flash File System. A NAND-flash specific file system. 
#
# Copyright (C) 2002 Aleph One Ltd.
#   for Toby Churchill Ltd and Brightstar Engineering
#
# Created by Charles Manning <charles@aleph1.co.uk>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

## Change or override  KERNELDIR to your kernel

#KERNELDIR = /usr/src/kernel-headers-2.4.18
KERNELDIR = /home/at91/linux-2.6.30

CFLAGS =    -O2 -Wall -DCONFIG_YAFFS_UTIL
CFLAGS+=   -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations
CFLAGS+=   -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline

## Change if you are using a cross-compiler
MAKETOOLS = /home/at91/x-tools/arm-softfp-linux-gnueabi/bin/arm-softfp-linux-gnueabi-

CC=$(MAKETOOLS)gcc

COMMON_BASE_C_LINKS = yaffs_ecc.c
COMMON_BASE_LINKS = $(COMMON_BASE_C_LINKS) yaffs_ecc.h yaffs_guts.h yaffs_packedtags2.h yaffs_trace.h
COMMON_DIRECT_C_LINKS = yaffs_hweight.c
COMMON_C_LINKS = $(COMMON_DIRECT_C_LINKS) $(COMMON_BASE_C_LINKS)
COMMON_DIRECT_LINKS= $(COMMON_DIRECT_C_LINKS) yportenv.h yaffs_hweight.h yaffs_list.h
COMMONOBJS = $(COMMON_C_LINKS:.c=.o)

MKYAFFSSOURCES = mkyaffsimage.c
MKYAFFSIMAGEOBJS = $(MKYAFFSSOURCES:.c=.o)

MKYAFFS2SOURCES = mkyaffs2image.c
MKYAFFS2LINKS = yaffs_packedtags2.c
MKYAFFS2IMAGEOBJS = $(MKYAFFS2SOURCES:.c=.o) $(MKYAFFS2LINKS:.c=.o)

BASE_LINKS = $(MKYAFFSLINKS) $(MKYAFFS2LINKS) $(COMMON_BASE_LINKS)
DIRECT_LINKS = $(MKYAFFS_DIRECT_LINKS) $(MKYAFFS2_DIRECT_LINKS) $(COMMON_DIRECT_LINKS)
ALL_LINKS = $(BASE_LINKS) $(DIRECT_LINKS)

all: mkyaffsimage mkyaffs2image

$(BASE_LINKS):
	ln -s ../$@ $@

$(DIRECT_LINKS):
	ln -s ../direct/$@ $@

$(COMMONOBJS) $(MKYAFFSIMAGEOBJS) $(MKYAFFS2IMAGEOBJS) : $(ALL_LINKS)

$(COMMONOBJS) $(MKYAFFSIMAGEOBJS) $(MKYAFFS2IMAGEOBJS) : %.o: %.c
	$(CC) -c $(CFLAGS) $< -o $@

mkyaffsimage: $(MKYAFFSIMAGEOBJS) $(COMMONOBJS)
	$(CC) -o $@  $^

mkyaffs2image: $(MKYAFFS2IMAGEOBJS) $(COMMONOBJS)
	$(CC) -o $@ $^


clean:
	rm -f $(COMMONOBJS) $(MKYAFFSIMAGEOBJS) $(MKYAFFS2IMAGEOBJS) $(ALL_LINKS) mkyaffsimage mkyaffs2image core


            2. mytypes.h

#ifndef __MYTYPES_H
#define __MYTYPES_H

typedef unsigned char   u8;
typedef unsigned short  u16;
typedef unsigned int    u32;
typedef unsigned long   u64;
typedef char            s8;
typedef short           s16;
typedef int             s32;
typedef long            s64;

#endif

           3. yutilsenv.h

/*
 * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
 *
 * Copyright (C) 2002-2011 Aleph One Ltd.
 *   for Toby Churchill Ltd and Brightstar Engineering
 *
 * Created by Charles Manning <charles@aleph1.co.uk>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 2.1 as
 * published by the Free Software Foundation.
 *
 * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
 */


#ifndef __YAFFS_UTILSENV_H__
#define __YAFFS_UTILSENV_H__

#define YCHAR char
#define YUCHAR unsigned char

#include <sys/types.h>
#include <string.h>
#include "mytypes.h"
#include "yaffs_list.h"
#include "yaffs_hweight.h"

#define hweight8(x) yaffs_hweight8(x)
#define hweight32(x) yaffs_hweight32(x)

#define yaffs_trace(...) do {} while (0)
#endif



参考文章:

    1. 《YAFFS》 --- 维基百科



制作mkyaffs2image和mkyaffsimage

标签:

原文地址:http://blog.csdn.net/xiaobin_hlj80/article/details/43308107

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!