Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

R/W Filesystem?

Altera_Forum
Honored Contributor II
1,737 Views

I'm currently running the stock FS, built following the instructions in the Getting Started manual.  

 

Is there any quick way to make this FS read/write? Changing the kernel command line string to 'root=/dev/mtdblock0 rw' didn't work. 

 

If this is possible, great -- my second problem is then how to 'save' FS changes back to flash (i.e. surviving a reboot/power cycle). 

If not, what do I need to do this? 

 

All I'd really like to do is be able to update config files and my userland apps via FTP instead of the oftentimes tedious (not to mention expensive) procedure of needing a ($$)Blaster cable and flashing the new FS image everytime I change a line of code. 

 

Thanks, 

 

Ryan 

Quantapoint
0 Kudos
23 Replies
Altera_Forum
Honored Contributor II
763 Views

Hi Ryan, 

 

> All I'd really like to do is be able to update config files and my userland apps via FTP .... 

 

Use jffs2 -- you can keep all of your "system stuff" as is ... and add a r/w jffs2 

partition for your config files & apps. You can mount the r/w partition under 

your ramfs during sysinit ... or add an entry in fstab. 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

Hi Scott, 

 

Thanks for your reply. I'm still confused as to how exactly to go about setting up a jffs2 partition in my flash. The instructions in the Microtronix Reference Guide assume an external flash card and IDE support. I have on-board flash and (currently) no IDE support in the kernel. I've included some (possibly) relevant information below. Any tips on how to get started? 

 

Thanks in advance, 

Ryan 

 

 

ls /dev button   console  cua0     cua1     cua2     cua3     cua4     cua5 cua6     cua7     cua8     cua9     fb0      fb1      hda      hda1 hda2     hda3     hda4     hda5     hda6     hda7     hda8     hdb hdb1     hdb2     hdb3     hdb4     hdb5     hdb6     hdb7     hdb8 i2c-0    i2c-1    input    kmem     mem      null     ptyp0    ptyp1 ptyp2    ptyp3    ptyp4    ptyp5    ptyp6    ptyp7    ptyp8    ptyp9 ptypa    ptypb    ptypc    ptypd    ptype    ptypf    ram0     ram1 ram2     ram3     spi      tty      tty0     tty1     tty2     tty3 tty4     tty5     tty6     tty7     tty8     tty9     ttyJ0    ttyS0 ttyS1    ttyS2    ttyS3    ttyS4    ttyS5    ttyS6    ttyS7    ttyS8 ttyS9    ttyp0    ttyp1    ttyp2    ttyp3    ttyp4    ttyp5    ttyp6 ttyp7    ttyp8    ttyp9    ttypa    ttypb    ttypc    ttypd    ttype ttypf    zero 

 

# cat /proc/mounts rootfs / rootfs rw 0 0 /dev/root / romfs ro 0 0 /dev/ram0 /var ext2 rw 0 0 /dev/ram1 /tmp ext2 rw 0 0 proc /proc proc rw,nodiratime 0 0 sysfs /sys sysfs rw 0 0 

 

Finally, my boot messages in case they help: 

setup_arch: No persistant network settings signature at 43FF0000 start_mem is 0x4017a000 virtual_end is 0x41000000 Built 1 zonelists Kernel command line: root=/dev/mtdblock0 rw PID hash table entries: 128 (order: 7, 2048 bytes) Dentry cache hash table entries: 4096 (order: 2, 16384 bytes) Inode-cache hash table entries: 2048 (order: 1, 8192 bytes) Mem_init: start=4017a000, end=41000000 Memory available: 14680k/16384k RAM, 0k/0k ROM (1227k kernel code, 280k data) Mount-cache hash table entries: 512 (order: 0, 4096 bytes) NET: Registered protocol family 16 Serial: JTAG UART driver $Revision: 1.3 $ ttyJ0 at MMIO 0xc4000808 (irq = 0) is a jtag_uart RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize smc_probe: 75000 Khz Nios SMSC LAN91C111 Driver (v2.1), (Linux Kernel 2.6) eth0: SMC91C11xFD(rev:1) at 0x4400a000 IRQ:2 MEMSIZE:8192b NOWAIT:0 ADDR: 00:07 ed:00:00:00 smc_probe: 75000 Khz Nios Using anticipatory io scheduler Microtronix map: Found 1 x16 devices at 0x0 in 16-bit bank Amd/Fujitsu Extended Query Table at 0x0040 Microtronix map: CFI does not contain boot bank location. Assuming top. number of CFI chips: 1 cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness. cmdlinepart partition parsing not available RedBoot partition parsing not available Using Microtronix development partition definition Creating 2 MTD partitions on "Microtronix map": 0x00200000-0x00800000 : "romfs" 0x00000000-0x00200000 : "loader/kernel" NET: Registered protocol family 2 IP: routing cache hash table of 512 buckets, 4Kbytes TCP: Hash tables configured (established 1024 bind 2048) NET: Registered protocol family 1 NET: Registered protocol family 17 VFS: Mounted root (romfs filesystem) readonly. Freeing unused kernel memory: 48k freed (0x40160000 - 0x4016b000) expand: from=/ramfs.img to=/dev/ram0 expand: from=/ramfs.img to=/dev/ram1
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

Hi Ryan, 

 

Take a look at the code in drivers/mtd/maps ... I don't have the source available 

right now, but I believe the file you want to look at is microtronix.c.  

 

Using Microtronix development partition definition Creating 2 MTD partitions on "Microtronix map": 0x00200000-0x00800000 : "romfs" 0x00000000-0x00200000 : "loader/kernel" 

 

I'm not sure which board you're using ... but you can add your own partition (if 

space allows). For testing purposes, a small partition is all you'll need ... you 

might be able to grab a meg from the "romfs" partition ;-) 

 

Enable JFFS2 in the kernel config. 

 

You can boot as you are already doing ... then mount your partition. 

 

You might want to add /mnt/flash (or something like that) to your filesystem to 

use as a mount point ... and you'll need a block device inode with the appropriate 

major/minor numbers as well. It would also be handy if you erase the appropriate 

sectors prior to first use ;-) 

 

Once the partition is mounted you can write whatever you want. 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

Thanks Scott, 

 

OK, I got all that -- now I'm assuming there's something along the lines of e2fsprogs for jffs? I get a multitude of errors when I try to mount the partition as jffs2 (not surprising). I guess I need to do some kind of formatting? 

 

Ryan
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

Hi Ryan, 

 

CONFIG_MTD_BLOCK should be defined. 

 

> I guess I need to do some kind of formatting? 

 

You should be able to mount a "blank: (erased) partition without any problems. 

 

Amd/Fujitsu Extended Query Table at 0x0040 Microtronix map: CFI does not contain boot bank location. Assuming top. 

 

What device is on your board? And where is your partition located? 

If you don't actually have a top boot device and your partition is at the 

top of the device you'll see erase/program errors at the offsets that 

are assumed to be boot sectors. 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

Hello Scott, 

 

I want to use jffs2 too, so I modified my "altera.c" in the drivers/mtd/maps since I use an Altera Eval Kit (Cyclone). I modified my mapping to add my partition. 

When I boot I get this messages, taht seems ok. 

 

Altera NDK flash (AMD): Found 1 x8 devices at 0x0 in 8-bit bank Amd/Fujitsu Extended Query Table at 0x0040 Altera NDK flash (AMD): CFI does not contain boot bank location. Assuming top. number of CFI chips: 1 cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness. cmdlinepart partition parsing not available RedBoot partition parsing not available Using Altera NDK partition definition Creating 5 MTD partitions on "Altera NDK flash (AMD)": 0x00200000-0x00500000 : "romfs/jffs2" 0x00500000-0x00600000 : "brolbrol" 0x00000000-0x00200000 : "loader/kernel" 0x00600000-0x00700000 : "User configuration" 0x00700000-0x00800000 : "safe configuration" 

 

My problem is that when I want to mount it, I don't see the partition in /dev or else... What is the argument I must use with mount ?  

Is this something like : 

 

mount -t jffs2 ??? /temp/flash_mount  

 

Thanks a lot 

 

Pierre-Olivier
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

mount -t jffs2 /dev/mtdblock0 /temp/flashmount -n 

should be fine. That partition shall be erased first, otherwise you may get a long train of messages.
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

Thank you for your answer, but my problem is that I dont have any device like mtdblock in /dev : 

 

button   console  cua0     cua1     cua2     cua3     cua4     cua5 cua6     cua7     cua8     cua9     fb0      fb1      hda      hda1 hda2     hda3     hda4     hda5     hda6     hda7     hda8     hdb hdb1     hdb2     hdb3     hdb4     hdb5     hdb6     hdb7     hdb8 i2c-0    i2c-1    input    kmem     mem      null     ptyp0    ptyp1 ptyp2    ptyp3    ptyp4    ptyp5    ptyp6    ptyp7    ptyp8    ptyp9 ptypa    ptypb    ptypc    ptypd    ptype    ptypf    ram0     ram1 ram2     ram3     spi      tty      tty0     tty1     tty2     tty3 tty4     tty5     tty6     tty7     tty8     tty9     ttyJ0    ttyS0 ttyS1    ttyS2    ttyS3    ttyS4    ttyS5    ttyS6    ttyS7    ttyS8 ttyS9    ttyp0    ttyp1    ttyp2    ttyp3    ttyp4    ttyp5    ttyp6 ttyp7    ttyp8    ttyp9    ttypa    ttypb    ttypc    ttypd    ttype ttypf    zero 

 

How can I have it appear ? 

 

Thanks 

 

Pierre-Olivier
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

How can I have it appear ?[/b] 

--- Quote End ---  

 

 

I did this by adding a node to the filesystem in the IDE. Node names look like "@<name>,<type>,<major#>,<minor#>. You can get minor/major# s via  

cat /proc/partitions 

 

for example, mine is: 

 

# cat /proc/partitions major minor # blocks  name  31     0       6144 mtdblock0  31     1       2048 mtdblock1  31     2       2048 mtdblock2 

 

then mount as you mentioned previously (mount -n -t /dev/mtdblock0 /mnt/whatever) 

 

 

Ryan
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

You mean I just have to create a file named "@mtdblock0,???,major,minor" in the target/dev of my Filesystem project directory ? 

 

What does the type mean, I only see c or b, what do I have to set ? 

 

Thanks 

 

Pierre-Olivier
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

What does the type mean, I only see c or b, what do I have to set ?[/b] 

--- Quote End ---  

 

 

b = Block Device, c = Char Device 

 

Use B. 

 

Ryan
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

Thanks a lot, it works fine 

 

Regards 

 

 

Pierre-Olivier
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

 

--- Quote Start ---  

originally posted by wentao@Mar 31 2005, 09:14 AM 

mount -t jffs2 /dev/mtdblock0 /temp/flashmount -n 

should be fine.  that partition shall be erased first, otherwise you may get a long train of messages. 

--- Quote End ---  

 

Hi, 

 

After giving the following command 

"mount -t jffs2 /dev/mtdblock0 /mnt/rwfs -n" 

i&#39;m getting a long train of messages. 

How to erase that partition? 

 

Thanks, 

Pankaj.
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

Hi Pankaj, 

 

to erase it, you have to do it directly, whithout any OS. a simple program like this should be enough : 

#include <stdio.h># include "system.h"# include "sys/alt_flash.h" int main() {      alt_flash_fd* flash;      int i;      flash=alt_flash_open_dev(EXT_FLASH_NAME);      for (i=0x500000;i<0x600000;i=i+0x10000)      {    printf("Erase %08x\n",i);        alt_erase_flash_block(flash,i,0x10000);      }      return 0; } 

 

This erases from address 0x500000 to 0x600000 according the erase block size is 0x10000. 

 

Regards 

 

Pod
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

Hi Pankaj, 

 

You might also want to use the u-boot or Redboot monitors ... 

even if you __don&#39;t__ plan on using these as part of your product, 

they can be quite useful for such tasks during development. 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

After erasing that partition also i&#39;m getting the same errors. 

My boot messages are: 

uClinux/Nios II Altera Nios II support (C) 2004 Microtronix Datacom Ltd. setup_arch: No persistant network settings signature at 007F0000 Built 1 zonelists Kernel command line: root=/dev/mtdblock0 ro PID hash table entries: 128 (order: 7, 2048 bytes) Dentry cache hash table entries: 4096 (order: 2, 16384 bytes) Inode-cache hash table entries: 2048 (order: 1, 8192 bytes) Memory available: 14364k/16384k RAM, 0k/0k ROM (1506k kernel code, 317k data) Mount-cache hash table entries: 512 (order: 0, 4096 bytes) NET: Registered protocol family 16 JFFS2 version 2.2. (C) 2001-2003 Red Hat, Inc. Serial: JTAG UART driver $Revision: 1.3 $ ttyJ0 at MMIO 0x821208b0 (irq = 1) is a jtag_uart RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize smc_probe: 50000 Khz Nios SMSC LAN91C111 Driver (v2.1), (Linux Kernel 2.6) eth0: SMC91C11xFD(rev:1) at 0x82110300 IRQ:6 MEMSIZE:8192b NOWAIT:0 ADDR: 00:07: ed:00:00:00 smc_probe: 50000 Khz Nios Using anticipatory io scheduler Altera NDK flash (AMD): Found 1 x8 devices at 0x0 in 8-bit bank Amd/Fujitsu Extended Query Table at 0x0040 Altera NDK flash (AMD): CFI does not contain boot bank location. Assuming top. number of CFI chips: 1 cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness. cmdlinepart partition parsing not available RedBoot partition parsing not available Using Altera NDK partition definition Creating 5 MTD partitions on "Altera NDK flash (AMD)": 0x00200000-0x00500000 : "romfs/jffs2" 0x00500000-0x00600000 : "rwfs" 0x00000000-0x00200000 : "loader/kernel" 0x00600000-0x00700000 : "User configuration" 0x00700000-0x00800000 : "safe configuration" NET: Registered protocol family 2 IP: routing cache hash table of 512 buckets, 4Kbytes TCP: Hash tables configured (established 1024 bind 2048) NET: Registered protocol family 1 NET: Registered protocol family 17 VFS: Mounted root (romfs filesystem) readonly. Freeing unused kernel memory: 48k freed (0x11aa000 - 0x11b5000) expand: from=/ramfs.img to=/dev/ram0 expand: from=/ramfs.img to=/dev/ram1 /etc/issue              www.microtronix.com               July 2004                   Welcome to Linux on the Nios II      Nios2 login: nios Password: 

 

The error messages after giving mount command (which keep on appearing) are: 

 

# mount -t jffs2 /dev/mtdblock0 /mnt/rwfs -n jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000000: 0x722d in stead jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000004: 0x6631 in stead jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000008: 0x2b00 in stead jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000000c: 0xe310 in stead jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000010: 0x6966 in stead jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000014: 0x7973 in stead jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000018: 0x6d65 in stead jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000001c: 0x6d6f in stead jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000003c: 0xffd1 in stead jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000040: 0x002e in stead Further such events for this erase block will not be printed Old JFFS2 bitmask found at 0x00004434 You cannot use older JFFS2 filesystems with newer kernels Old JFFS2 bitmask found at 0x00004504 You cannot use older JFFS2 filesystems with newer kernels Old JFFS2 bitmask found at 0x00004514 You cannot use older JFFS2 filesystems with newer kernels Old JFFS2 bitmask found at 0x000046b4 You cannot use older JFFS2 filesystems with newer kernels Old JFFS2 bitmask found at 0x00006398 You cannot use older JFFS2 filesystems with newer kernels Empty flash at 0x00009a20 ends at 0x00009a24 Empty flash at 0x0000b7c8 ends at 0x0000b7cc Empty flash at 0x0000b7e0 ends at 0x0000b7e4 Old JFFS2 bitmask found at 0x0000f55c You cannot use older JFFS2 filesystems with newer kernels Old JFFS2 bitmask found at 0x0000f62c You cannot use older JFFS2 filesystems with newer kernels Old JFFS2 bitmask found at 0x0000f63c You cannot use older JFFS2 filesystems with newer kernels Old JFFS2 bitmask found at 0x0000f7dc You cannot use older JFFS2 filesystems with newer kernels 

How to solve this problem? 

Thanks in anticipation, 

 

Regards, 

Pankaj.
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

I had the same problem, but it was solved when I erased the flash... 

Can you verify that the zone you erased is actually empty (all 1&#39;s) ? 

 

 

pod
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

I&#39;m facing the same problems again.  

 

0. Why does the kernel accesses memory location - 0x00000000, after giving mount command : 

# mount -t jffs2 /dev/mtdblock0 /mnt/rwfs -n jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000000: 0x722d in stead 

I&#39;ve checked the data at 0x00000000, it is not 0x722d as declared by error message. 

 

1. I had only created new partition by allocating size and offset in "altera.c" file. 

Do I need to do something extra to make that partition compatible for jffs2? 

 

Regards, 

Pankaj
0 Kudos
Altera_Forum
Honored Contributor II
763 Views

Hi Pankajsharma, 

 

> Why does the kernel accesses memory location - 0x00000000, after 

> giving mount command 

 

It is scanning the jffs2 file system ... but I believe the value is an offset 

in the flash ... not the physical address. You can check this yourself ... 

use the force ;-) 

 

> I had only created new partition by allocating size and offset in "altera.c" file. 

> Do I need to do something extra to make that partition compatible for jffs2? 

 

Did you erase the partition? 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
705 Views

Hi, 

 

I am now able to mount jffs2 http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif  

The only change i made was : using mtdblock1 instead of mtdblock0. 

I still don&#39;t know why it is so, but it is working. 

Thanks for the replies, 

 

Regards, 

Pankaj.
0 Kudos
Reply