Skip to content

Commit

Permalink
Incorporate yaffs2 into U-boot
Browse files Browse the repository at this point in the history
To use YAFFS2 define CONFIG_YAFFS2

Signed-off-by: William Juul <[email protected]>
Signed-off-by: Scott Wood <[email protected]>
  • Loading branch information
William Juul authored and Scott Wood committed Aug 12, 2008
1 parent 0e8cc8b commit 90ef117
Show file tree
Hide file tree
Showing 31 changed files with 666 additions and 89 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ LIBS += cpu/ixp/npe/libnpe.a
endif
LIBS += lib_$(ARCH)/lib$(ARCH).a
LIBS += fs/cramfs/libcramfs.a fs/fat/libfat.a fs/fdos/libfdos.a fs/jffs2/libjffs2.a \
fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a
fs/reiserfs/libreiserfs.a fs/ext2/libext2fs.a fs/yaffs2/direct/libyaffs2.a
LIBS += net/libnet.a
LIBS += disk/libdisk.a
LIBS += drivers/bios_emulator/libatibiosemu.a
Expand Down Expand Up @@ -378,6 +378,7 @@ TAG_SUBDIRS += fs/cramfs
TAG_SUBDIRS += fs/fat
TAG_SUBDIRS += fs/fdos
TAG_SUBDIRS += fs/jffs2
TAG_SUBDIRS += fs/yaffs2/direct
TAG_SUBDIRS += net
TAG_SUBDIRS += disk
TAG_SUBDIRS += common
Expand Down
1 change: 1 addition & 0 deletions common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ COBJS-$(CONFIG_CMD_TERMINAL) += cmd_terminal.o
COBJS-$(CONFIG_CMD_UNIVERSE) += cmd_universe.o
COBJS-$(CONFIG_CMD_USB) += cmd_usb.o
COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o
COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o
COBJS-y += cmd_vfd.o
COBJS-y += command.o
COBJS-y += console.o
Expand Down
215 changes: 215 additions & 0 deletions common/cmd_yaffs2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
#include <common.h>

#include <config.h>
#include <command.h>

#ifdef YAFFS2_DEBUG
#define PRINTF(fmt,args...) printf (fmt ,##args)
#else
#define PRINTF(fmt,args...)
#endif

extern void cmd_yaffs_mount(char *mp);
extern void cmd_yaffs_umount(char *mp);
extern void cmd_yaffs_read_file(char *fn);
extern void cmd_yaffs_write_file(char *fn,char bval,int sizeOfFile);
extern void cmd_yaffs_ls(const char *mountpt, int longlist);
extern void cmd_yaffs_mwrite_file(char *fn, char *addr, int size);
extern void cmd_yaffs_mread_file(char *fn, char *addr);
extern void cmd_yaffs_mkdir(const char *dir);
extern void cmd_yaffs_rmdir(const char *dir);
extern void cmd_yaffs_rm(const char *path);
extern void cmd_yaffs_mv(const char *oldPath, const char *newPath);

extern int yaffs_DumpDevStruct(const char *path);


int do_ymount (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *mtpoint = argv[1];
cmd_yaffs_mount(mtpoint);

return(0);
}

int do_yumount (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *mtpoint = argv[1];
cmd_yaffs_umount(mtpoint);

return(0);
}

int do_yls (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *dirname = argv[argc-1];

cmd_yaffs_ls(dirname, (argc>2)?1:0);

return(0);
}

int do_yrd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *filename = argv[1];
printf ("Reading file %s ", filename);

cmd_yaffs_read_file(filename);

printf ("done\n");
return(0);
}

int do_ywr (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *filename = argv[1];
ulong value = simple_strtoul(argv[2], NULL, 16);
ulong numValues = simple_strtoul(argv[3], NULL, 16);

printf ("Writing value (%x) %x times to %s... ", value, numValues, filename);

cmd_yaffs_write_file(filename,value,numValues);

printf ("done\n");
return(0);
}

int do_yrdm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *filename = argv[1];
ulong addr = simple_strtoul(argv[2], NULL, 16);

cmd_yaffs_mread_file(filename, (char *)addr);

return(0);
}

int do_ywrm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *filename = argv[1];
ulong addr = simple_strtoul(argv[2], NULL, 16);
ulong size = simple_strtoul(argv[3], NULL, 16);

cmd_yaffs_mwrite_file(filename, (char *)addr, size);

return(0);
}

int do_ymkdir (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *dirname = argv[1];

cmd_yaffs_mkdir(dirname);

return(0);
}

int do_yrmdir (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *dirname = argv[1];

cmd_yaffs_rmdir(dirname);

return(0);
}

int do_yrm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *path = argv[1];

cmd_yaffs_rm(path);

return(0);
}

int do_ymv (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *oldPath = argv[1];
char *newPath = argv[2];

cmd_yaffs_mv(newPath, oldPath);

return(0);
}

int do_ydump (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
char *dirname = argv[1];
if (yaffs_DumpDevStruct(dirname) != 0)
printf("yaffs_DumpDevStruct returning error when dumping path: , %s\n", dirname);
return 0;
}



U_BOOT_CMD(
ymount, 3, 0, do_ymount,
"ymount\t- mount yaffs\n",
"\n"
);

U_BOOT_CMD(
yumount, 3, 0, do_yumount,
"yumount\t- unmount yaffs\n",
"\n"
);

U_BOOT_CMD(
yls, 4, 0, do_yls,
"yls\t- yaffs ls\n",
"[-l] name\n"
);

U_BOOT_CMD(
yrd, 2, 0, do_yrd,
"yrd\t- read file from yaffs\n",
"filename\n"
);

U_BOOT_CMD(
ywr, 4, 0, do_ywr,
"ywr\t- write file to yaffs\n",
"filename value num_vlues\n"
);

U_BOOT_CMD(
yrdm, 3, 0, do_yrdm,
"yrdm\t- read file to memory from yaffs\n",
"filename offset\n"
);

U_BOOT_CMD(
ywrm, 4, 0, do_ywrm,
"ywrm\t- write file from memory to yaffs\n",
"filename offset size\n"
);

U_BOOT_CMD(
ymkdir, 2, 0, do_ymkdir,
"ymkdir\t- YAFFS mkdir\n",
"dirname\n"
);

U_BOOT_CMD(
yrmdir, 2, 0, do_yrmdir,
"yrmdir\t- YAFFS rmdir\n",
"dirname\n"
);

U_BOOT_CMD(
yrm, 2, 0, do_yrm,
"yrm\t- YAFFS rm\n",
"path\n"
);

U_BOOT_CMD(
ymv, 4, 0, do_ymv,
"ymv\t- YAFFS mv\n",
"oldPath newPath\n"
);

U_BOOT_CMD(
ydump, 2, 0, do_ydump,
"ydump\t- YAFFS device struct\n",
"dirname\n"
);
2 changes: 1 addition & 1 deletion fs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#
#

SUBDIRS := jffs2 cramfs fdos fat reiserfs ext2
SUBDIRS := jffs2 cramfs fdos fat reiserfs ext2 yaffs2/direct

$(obj).depend all:
@for dir in $(SUBDIRS) ; do \
Expand Down
13 changes: 12 additions & 1 deletion fs/yaffs2/devextras.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@
#define new newHack
#endif

#if !(defined __KERNEL__) || (defined WIN32)
/* XXX U-BOOT XXX */
#if 1 /* !(defined __KERNEL__) || (defined WIN32) */

/* User space defines */

/* XXX U-BOOT XXX */
#if 0
typedef unsigned char __u8;
typedef unsigned short __u16;
typedef unsigned __u32;
#endif

#include <asm/types.h>

/*
* Simple doubly linked list implementation.
Expand Down Expand Up @@ -213,7 +219,12 @@ static __inline__ void list_splice(struct list_head *list,
#define DT_WHT 14

#ifndef WIN32
/* XXX U-BOOT XXX */
#if 0
#include <sys/stat.h>
#else
#include "common.h"
#endif
#endif

/*
Expand Down
58 changes: 27 additions & 31 deletions fs/yaffs2/direct/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,46 @@
# $Id: Makefile,v 1.15 2007/07/18 19:40:38 charles Exp $

#EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC
include $(TOPDIR)/config.mk

CFLAGS = -Wall -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -DCONFIG_YAFFS_YAFFS2 -g $(EXTRA_COMPILE_FLAGS) -DNO_Y_INLINE
CFLAGS+= -fstack-check -O0
LIB = $(obj)libyaffs2.a

#CFLAGS+= -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Wmissing-declarations
#CFLAGS+= -Wmissing-prototypes -Wredundant-decls -Wnested-externs -Winline
COBJS-$(CONFIG_YAFFS2) := \
yaffscfg.o yaffs_ecc.o yaffsfs.o yaffs_guts.o yaffs_packedtags1.o \
yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o \
yaffs_nand.o yaffs_checkptrw.o yaffs_qsort.o yaffs_mtdif.o \
yaffs_mtdif2.o


DIRECTTESTOBJS = dtest.o yaffscfg2k.o yaffs_ecc.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
yaffs_checkptrw.o yaffs_qsort.o \
# yaffs_checkptrwtest.o\

BOOTTESTOBJS = bootldtst.o yboot.o yaffs_fileem.o nand_ecc.o

#ALLOBJS = dtest.o nand_ecc.o yaffscfg.o yaffs_fileem.o yaffsfs.o yaffs_ramdisk.o bootldtst.o yboot.o yaffs_ramem2k.o

ALLOBJS = $(DIRECTTESTOBJS) $(BOOTTESTOBJS)
SRCS := $(COBJS-y:.o=.c)
OBJS := $(addprefix $(obj),$(COBJS-y))

SYMLINKS = devextras.h yaffs_ecc.c yaffs_ecc.h yaffs_guts.c yaffs_guts.h yaffsinterface.h yportenv.h yaffs_tagscompat.c yaffs_tagscompat.h \
yaffs_packedtags1.c yaffs_packedtags1.h yaffs_packedtags2.c yaffs_packedtags2.h yaffs_nandemul2k.h \
yaffs_nand.c yaffs_nand.h \
yaffs_nand.c yaffs_nand.h yaffs_mtdif.c yaffs_mtdif.h \
yaffs_tagsvalidity.c yaffs_tagsvalidity.h yaffs_checkptrw.h yaffs_checkptrw.c \
yaffs_qsort.c yaffs_qsort.h
yaffs_qsort.c yaffs_qsort.h yaffs_mtdif2.c yaffs_mtdif2.h

#all: directtest2k boottest
# -DCONFIG_YAFFS_NO_YAFFS1
CFLAGS += -DCONFIG_YAFFS_DIRECT -DCONFIG_YAFFS_SHORT_NAMES_IN_RAM -DCONFIG_YAFFS_YAFFS2 -DNO_Y_INLINE -DLINUX_VERSION_CODE=0x20616

all: directtest2k
all: $(LIB)

$(ALLOBJS): %.o: %.c
gcc -c $(CFLAGS) $< -o $@
$(LIB): $(obj).depend $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)

$(SYMLINKS):
ln -s ../$@ $@
.PHONY: clean distclean
clean:
rm -f $(OBJS)

directtest2k: $(SYMLINKS) $(DIRECTTESTOBJS)
gcc -o $@ $(DIRECTTESTOBJS)
distclean: clean
rm -f $(LIB) core *.bak .depend

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

boottest: $(SYMLINKS) $(BOOTTESTOBJS)
gcc -o $@ $(BOOTTESTOBJS)
# defines $(obj).depend target
include $(SRCTREE)/rules.mk

sinclude $(obj).depend

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

clean:
rm -f $(ALLOBJS) core
2 changes: 2 additions & 0 deletions fs/yaffs2/direct/dtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Test code for the "direct" interface.
*/

/* XXX U-BOOT XXX */
#include <common.h>

#include <stdio.h>
#include <string.h>
Expand Down
5 changes: 3 additions & 2 deletions fs/yaffs2/direct/yaffs_fileem.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* This is only intended as test code to test persistence etc.
*/

/* XXX U-BOOT XXX */
#include <common.h>

const char *yaffs_flashif_c_version = "$Id: yaffs_fileem.c,v 1.3 2007/02/14 01:09:06 wookey Exp $";


Expand Down Expand Up @@ -214,5 +217,3 @@ int yflash_InitialiseNAND(yaffs_Device *dev)

return YAFFS_OK;
}


Loading

0 comments on commit 90ef117

Please sign in to comment.