Building Yaffs into Linux
This video shows you how to compile Yaffs into Linux. It’s just over 10 minutes long, and if you download it, it’s 325MB. After watching this video you should be able to include Yaffs in Linux. Once you have Yaffs available you will be able to mount a simulated NAND device, or if you have a Flash device attached, you will be able to use it. The demo was run in a Virtualbox system, and is available as a Vagrant box from our Downloads section with details of how to build and use a simulated NAND device.
The script for the video:
Hello, today I’m going to show you how to compile Yaffs into the linux kernel. Yaffs is the most widely used file system which is specialised for Flash memory. It’s used in millions of devices, both under Linux and other operatings systems. It’s available under the Gnu Public Licence – the GPL – and commercial terms. You can find out more about Yaffs at yaffs.net.
Today we’ll be targetting intel x86 but with some slight changes we could target another architecture – for instance ARM. This demo is being run in a Virtualbox machine, and the resulting system is available as a Vagrant box, so you can download the image and test it yourself. If you’ve never used vagrant, it provides a way to get a virtual system up and running in a few minutes.
We’re starting off with a stock Ubunutu Precise 12.04 386 server. We’re using 386 because it’s the lowest common demoninator, so the virtualbox will run on any system capable of running virtualbox, but this works just as well for 64 bit architecture.
Here we are at the command-line of a brand-new installation. To make a kernel with Yaffs you will need all the usual kernel-build tools for your distribution, the kernel source code, and the Yaffs source code.
If you skipped the first video, you won’t have seen how to download Yaffs. Here’s a brief clip of retrieving a GPL licenced copy of the Yaffs source.
git clone git://www.aleph1.co.uk/yaffs2
We’re starting off in the directory where I stored the kernel and Yaffs source.
The next step isn’t strictly necessary, but it’s useful to if you are going to be doing development: I’m going to make a branch for my changes to the kernel. Of course if you are using subversion, cvs or some other system for version control then you’ll want to skip this step or replace it
Let’s list the branches
Only one makes it easy.
Git checkout master -b yaffs-demo-x86
Okay, so we’ve created a branch.
And the star indicates that we are working in our new branch.
Now we have the kernel source, but we need to include Yaffs.
Luckily Yaffs comes with a script which automates the source changes necessary to include it.
It’s always a good idea to check the README file. Especially if you are doing this yourself.
So the script we use to patch the kernel is
./patch-ker.sh c m ~/kernel/source
The c tells the script to copy the changes rather than linking them, and the m indicates that we want the multiprocess option because more than one process might be using Yaffs at one time.
Right, Yaffs has been patched into the kernel. Now we need to configure the kernel build.
Because I’m working on a virtual machine, I don’t need to worry about different flavours of the kernel configuration. I can just go ahead and edit the default configuration. To avoid a long compile, I’m going to remove pretty much all of the non-essential drivers, and most of the hardware – remember this is running on a virtual machine.
To include Yaffs we need to enable two things.
The memory technology device support (MTD) and the caching block device access for MTD.
The MTD settings are in the Device drivers section. Usually it will be on. The caching should be on too. Once those are enabled, Yaffs becomes available as an optional file system.
Go into File systems, Miscellaneous and enable Yaffs.
Here’s a look at the various options.
I’ve set up Yaffs. Now I’m going to go ahead and turn off all the things that I don’t need in this kernel. There are a lot of them, and there’s no need to watch hundreds of items being unticked.
Once the config is suitable, we can exit and save.
Okay, we’re ready to build the kernel. Just to make sure that everything is fine..
fakeroot make-kpkg clean
and let’s kick the build off
fakeroot make-kpkg –initrd –append-to-version=yaffs kernel-image
and now, since this is running on a uniprocessor virtual machine, I’ll be going for some lunch. But there’s no need for you to wait…
So, the build is finished. It took about 1/2 hour. Your mileage will vary.
We have a Debian package, and I’m going to go ahead and install that.
sudo dpkg –install
We should have our new build in the grub. If we reboot, we’ll have Yaffs available. In the next video we’ll show you how to set up a Yaffs file system. You can download a copy of the virtual machine but you’ll need vagrant to use it. Details are on the site.
Thanks for watching.