I got write the filesystem in my flash , but this method has some problems yet.
1) Download the mtd-utils (for mkfs.jffs2)
In my case (Ubuntu)
sudo apt-get install mtd-utils
2) Generate a romfs in a uClinux-dist
make romfs
3)Generate a device_table (like a romfs_list file in /vendor/Altera/nios)
In the romfs_list we have something like this# Device Name mode uid gid type major minor
/dev/tty 666 0 0 c 5 0
/dev/kmem 640 0 0 c 1 2
/dev/mtd0 640 0 0 c 90 0
/dev/mtd1 640 0 0 c 90 2
/dev/mtd2 640 0 0 c 90 4
In the device_table we need write in another mode like# <name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count># where name is the file name, type can be one of: # f A regular file# d Directory# c Character special device file# b Block special device file# p Fifo (named pipe)
/dev/mem c 640 0 0 1 1 0 0 -
/dev/kmem c 640 0 0 1 2 0 0 -
/dev/null c 640 0 0 1 3 0 0 -
/dev/zero c 640 0 0 1 5 0 0 -
/dev/random c 640 0 0 1 8 0 0 -
/dev/urandom c 640 0 0 1 9 0 0 -
/dev/tty c 666 0 0 5 0 0 0 -
You need change this file for your system and save with device_table.txt (this is normal for nios linux with mmu)
4) Creating a file system
We would create this file in nios2-linux/uClinux-dist/image
mkfs.jffs2 -l -e128KiB -p -d ../romfs -D device_table.txt -o rootfs.jffs2
This file is ready to write by bootloader
After this we have a rootfs.jffs2 file , but this process ins't ok, I having problem with erase_block size
Node at 0x0020ff20 with length 0x000008b1 would run over the end of the erase bk
Perhaps the file system was created with the wrong erase size?
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0020ff24: 0x08b1 id
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0020ff28: 0x4c30 id
5) Burning flash
In my case I'm using jtag
My CFI flash is partitioned:
Creating 2 MTD partitions on "physmap-flash.0":
0x000000200000-0x000000800000 : "romfs/jffs2"
0x000000000000-0x000000200000 : "loader/kernel"
For convert binary file to .srec file we need use a bin2flash tool:
bin2flash --input=rootfs.jffs2 --location=0x200000 --output=rootfs.flash
Now we need write the rootfs.flash in CFI flash using nios2-flash-programmer tool
nios2-flash-programmer --base=0x2000000 rootfs.flash
After this we boot with a kernel image monting a jffs2
When I get fix my problem with erase_block I return with another reply with the fix