YAFFS Debugging

How to control debugging in yaffs

YAFFS provides a debugging mechanism which can be controlled at runtime if you have access to /proc, normally via a shell. If you need to trace things before you get to a shell, then you can set default trace options at compile time.

Available Trace Flags

name C #define bitmask value
error YAFFS_TRACE_ERROR 0x00000001
os YAFFS_TRACE_OS 0x00000002
allocate YAFFS_TRACE_ALLOCATE 0x00000004
scan YAFFS_TRACE_SCAN 0x00000008
bad_blocks YAFFS_TRACE_BAD_BLOCKS 0x00000010
erase YAFFS_TRACE_ERASE 0x00000020
gc YAFFS_TRACE_GC 0x00000040
write YAFFS_TRACE_WRITE 0x00000080
tracing YAFFS_TRACE_TRACING 0x00000100
deletion YAFFS_TRACE_DELETION 0x00000200
buffers YAFFS_TRACE_BUFFERS 0x00000400
nandaccess YAFFS_TRACE_NANDACCESS 0x00000800
gc_detail YAFFS_TRACE_GC_DETAIL 0x00001000
scan_debug YAFFS_TRACE_SCAN_DEBUG 0x00002000
mtd YAFFS_TRACE_MTD 0x00004000
always YAFFS_TRACE_ALWAYS 0x40000000
bug YAFFS_TRACE_BUG 0x80000000

Flag meanings

The flags cover possible debugging messages from various aspects of the filesystem - initial scanning, mtd interface, writing, nand access, garbage collection, OS interaction etc. Turning on everything results an awful lot of trace info, so it is usually best to just enable a few relevant flags.

Setting flags at runtime

The flags can be set or cleared by echoing the name of the flag into /proc/yaffs with a '+' or '-':
echo +os-write > /proc/yaffs

It can be set to to all or none using '=', and then flags can be added or removed:
echo =none+os+write > /proc/yaffs

And you can use numerical values, if you are so inclined (using standard C format):
echo 0xf00001 > /proc/yaffs

So
echo all > /proc/yaffs
will turn all tracing on

Note that you only see the output showing you the current trace state if the 'always' (YAFFS_TRACE_ALWAYS) flag is set, so to see what you are doing do this:
echo +always > /proc/yaffs

Setting flags at compile time

Flags can be set in the code at compile-time by setting yaffs_traceMask in yaffs_fs.c (add new flags to always and bad_blocks which are set by default)