- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
Does anyone know how to read erase and program the AMD flash memory in ucLinux using C programs? (AM29LV065D or AM29LV128MH) I use this memory for store uClinux FPGA SOF and user’s data. Thanks in advance. Best regards,Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi posix6973,
> Does anyone know how to read erase and program the AMD flash memory in > ucLinux using C programs? Normally this is done with mtd-utils: http://cvs.uclinux.org/cgi-bin/cvsweb.cgi/....old/mtd-utils/ (http://cvs.uclinux.org/cgi-bin/cvsweb.cgi/userland.old/mtd-utils/) In your own applications if you use a JFFS2 filesystem, you can simply access the files with read, write, etc. system calls. If you don't use a filesystem, then you can directly access the device via the mtd device inodes (but your application is responsible for reading/writing the appropriate offsets in the flash). You can also just access the flash directly through a pointer since there's no MMU. But this is probably not good practice unless you have some compelling reasons not to use mtd. Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Scott,
I have re-built the kernel with JFFS2 filesystem selected and the system boot as below: uClinux/Nios II Altera Nios II support © 2004 Microtronix Datacom Ltd. Built 1 zonelists Kernel command line: root=/dev/mtdblock0 ro PID hash table entries: 256 (order: 8, 4096 bytes) Dentry cache hash table entries: 8192 (order: 3, 32768 bytes) Inode-cache hash table entries: 4096 (order: 2, 16384 bytes) Memory available: 30528k/32768k RAM, 0k/0k ROM (1567k kernel code, 302k data) Mount-cache hash table entries: 512 (order: 0, 4096 bytes) NET: Registered protocol family 16 JFFS2 version 2.2. © 2001-2003 Red Hat, Inc. JFFS2: default compression mode: priority NIOS serial driver version 0.0 ttyS0 (irq = 4) is a builtin NIOS UART io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize smc_probe: 85000 Khz Nios SMSC LAN91C111 Driver (v2.1), (Linux Kernel 2.6) eth0: SMC91C11xFD(rev:1) at 0x82210300 IRQ:6 MEMSIZE:8192b NOWAIT:0 ADDR: 00:07:ed:0f:63:08 smc_probe: 85000 Khz Nios Altera NDK flash (AMD): Found 1 x16 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 4 MTD partitions on "Altera NDK flash (AMD)": 0x00200000-0x00600000 : "romfs/jffs2" 0x00000000-0x00200000 : "loader/kernel" 0x00600000-0x00700000 : "User configuration" 0x00700000-0x00800000 : "safe configuration" microtronix[mtd]: RAM probe address=0x200000 size=0x3f8000 Creating 1 MTD partitions on "RAM": 0x00000000-0x003f8000 : "ROMfs" microtronix[mtd]: set ROMfs to be root filesystem NET: Registered protocol family 2 IP: routing cache hash table of 512 buckets, 4Kbytes TCP established hash table entries: 2048 (order: 2, 16384 bytes) TCP bind hash table entries: 2048 (order: 1, 8192 bytes) TCP: Hash tables configured (established 2048 bind 2048) NET: Registered protocol family 1 NET: Registered protocol family 17 VFS: Mounted root (romfs filesystem) readonly. Freeing unused kernel memory: 64k freed (0x41b2000 - 0x41c1000) expand: from=/ramfs.img to=/dev/ram0 expand: from=/ramfs.img to=/dev/ram1 eth0:PHY 100BaseT eth0:PHY Full Duplex /etc/issue www.microtronix.com June 2005 Welcome to Linux on the Nios II Nios2 login: root Password: # cat /proc/mtd dev: size erasesize name mtd0: 00400000 00010000 "romfs/jffs2" mtd1: 00200000 00010000 "loader/kernel" mtd2: 00100000 00010000 "User configuration" mtd3: 00100000 00010000 "safe configuration" mtd4: 003f8000 00001000 "ROMfs"# I have two questions: 1. I didn’t see any mtd device file create in /dev. Did I missing some procedures? 2. Need I create the mtd-utils with kernel? 3. What difference between ROMfs and romfs/jffs2 in boot report? Thanks in advance. Best regards,- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi posix6973,
> 1. I didn’t see any mtd device file create in /dev. Did I missing some procedures? You need to do this when you create the file system. You have two choices: (1) Create the device inodes by hand using mknod, then run mkfs.jffs2 (2) Create a device table file and use the -D, --devtable option to mkfs.jffs2 The second option is very convenient since you don't need to be root, and you basically have built-in documentation for /dev ;-) > 2. Need I create the mtd-utils with kernel? No. Just download and build the applications like any other linux apps. > 3. What difference between ROMfs and romfs/jffs2 in boot report? It looks like you are using two different mtd mapping drivers. Take a look at: drivers/mtd/maps/altera.c. drivers/mtd/maps/nios_romfs.c Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Scott,
As you mentioned: >(2) Create a device table file and use the -D, --devtable option to mkfs.jffs2 >The second option is very convenient since you don't need to be root, and you basically >have built-in documentation for /dev ;-) 1. I take the mkfs.jffs.c form mtd-util and compiler it as application project but it report too many error (incompatible types in assignment and crc32.h: No such file or directory) even I change the include file to <linux/crc32.h>. make -k all no emulation specific options. nios2-elf-gcc -nostdinc -D__linux__ -O2 -I"c:/altera/kits/nios2/bin/eclipse/plugins/com.microtronix.nios2linux.uClibc_1.4.0"/include -I/cygdrive/c/altera/kits/nios2/bin/nios2-gnutools/H-i686-pc-cygwin/bin/../lib/gcc/nios2-elf/3.4.1//include -fno-optimize-sibling-calls -mhw-mul -mhw-mulx -O0 -g -I"c:/altera/workspace/ep2c35Linux/build/include" -Wall -c -o mkfs.jffs2.o mkfs.jffs2.c mkfs.jffs2.c:45:19: crc32.h: No such file or directory mkfs.jffs2.c: In function `write_dirent': mkfs.jffs2.c:509: error: incompatible types in assignment mkfs.jffs2.c:510: error: incompatible types in assignment mkfs.jffs2.c:511: error: incompatible types in assignment 2. The /dev…. is read only filesystem how can I create the mtd device on it? Please give me some hints or show me how to do. Thanks again. Best regards,- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, scott
<div class='quotetop'>QUOTE </div> --- Quote Start --- If you don't use a filesystem, then you can directly access the device via the mtd device inodes (but your application is responsible for reading/writing the appropriate offsets in the flash).[/b] --- Quote End --- Can Flash(mtdblock1;kernel) be accessed directly by "open, read,write" routines If I want to update the kernel in runtime, then reboot.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
> Can Flash(mtdblock1;kernel) be accessed directly by "open, read,write" routines If I want to > update the kernel in runtime, then reboot. Yes, but use the character mode device (major 90 I think) -- which needs to be enabled in your kernel configuration. Then you can open, read, write, ioctl. To erase, use the MEMERASE ioctl. See the following: include/mtd/mtd-abi.h drivers/mtd/mtdchar.c You might want to review the mtd-utils code as well. Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi posix6973,
> I take the mkfs.jffs.c form mtd-util and compiler it as application project but it report > too many error It's not quite ready for cygwin ;-) You can get mkfs.jffs2 sources that build under cygwin at: http://www.psyent.com/download (http://www.psyent.com/download) > 2. The /dev…. is read only filesystem how can I create the mtd device on it? The mtd "partition" can be read-only or read-write ... this is controlled by your mapping driver. You can set the device "inode" attributes when you create the inode. If you want erase/write capability, both the partition and the inode attributes should be writeable. Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Scoot,
>The mtd "partition" can be read-only or read-write ....... Sorry, still don’t understand could you explain in detail or show me how to configure the system? If use directly access the AMD Flash memory which function be taken and how to specify the inode or name parameters? mtd_open(struct inode *inode, struct file *file) or. open(char *name, int flags, int perms) Thanks for help. Best regards,- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi posix6973,
> Sorry, still don’t understand could you explain in detail or show me how to > configure the system? You already did configure the system:<div class='quotetop'>QUOTE </div> --- Quote Start --- Creating 4 MTD partitions on "Altera NDK flash (AMD)": 0x00200000-0x00600000 : "romfs/jffs2" 0x00000000-0x00200000 : "loader/kernel" 0x00600000-0x00700000 : "User configuration" 0x00700000-0x00800000 : "safe configuration"[/b] --- Quote End --- And ... <div class='quotetop'>QUOTE </div> --- Quote Start --- It looks like you are using two different mtd mapping drivers. Take a look at: drivers/mtd/maps/altera.c. drivers/mtd/maps/nios_romfs.c[/b] --- Quote End --- Review the source code. Look at the partition maps with attention to the mask_flags field of the mtd_partition structures. This field should _not_ include MTD_WRITEABLE if you want the partition to be writeable. Make sure your map matches your actual hardware. Enable the character mode device driver (CONFIG_MTD_CHAR) in the kernel and create an inode for the character mode driver (major: 90, minor: partition number).<div class='quotetop'>QUOTE </div> --- Quote Start --- You have two choices: (1) Create the device inodes by hand using mknod, then run mkfs.jffs2 (2) Create a device table file and use the -D, --devtable option to mkfs.jffs2[/b] --- Quote End --- Then for example:int fd;
fd = open ("/dev/mtd0", O_RDWR);
etc.
If you need details, examples, info: <div class='quotetop'>QUOTE </div> --- Quote Start --- See the following: include/mtd/mtd-abi.h drivers/mtd/mtdchar.c You might want to review the mtd-utils code as well.[/b] --- Quote End --- Regards, --Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Scott,
I fixed my NiosII uClinux and the MTD partitions boot as below: uClinux/Nios II Altera Nios II support © 2004 Microtronix Datacom Ltd. Built 1 zonelists Kernel command line: root=/dev/mtdblock0 ro PID hash table entries: 256 (order: 8, 4096 bytes) Dentry cache hash table entries: 8192 (order: 3, 32768 bytes) Inode-cache hash table entries: 4096 (order: 2, 16384 bytes) Memory available: 30720k/32768k RAM, 0k/0k ROM (1416k kernel code, 298k data) Mount-cache hash table entries: 512 (order: 0, 4096 bytes) NET: Registered protocol family 16 NIOS serial driver version 0.0 ttyS0 (irq = 4) is a builtin NIOS UART io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize smc_probe: 85000 Khz Nios SMSC LAN91C111 Driver (v2.1), (Linux Kernel 2.6) eth0: SMC91C11xFD(rev:1) at 0x82210300 IRQ:6 MEMSIZE:8192b NOWAIT:0 ADDR: 00:07:ed:0f:63:08 smc_probe: 85000 Khz Nios Altera NDK flash (AMD): Found 1 x16 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 4 MTD partitions on "Altera NDK flash (AMD)": 0x00200000-0x00600000 : "romfs/jffs2" 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 established hash table entries: 2048 (order: 2, 16384 bytes) TCP bind hash table entries: 2048 (order: 1, 8192 bytes) TCP: Hash tables configured (established 2048 bind 2048) NET: Registered protocol family 1 NET: Registered protocol family 17 VFS: Mounted root (romfs filesystem) readonly. Freeing unused kernel memory: 60k freed (0x418c000 - 0x419a000) expand: from=/ramfs.img to=/dev/ram0 expand: from=/ramfs.img to=/dev/ram1 eth0:PHY 100BaseT eth0:PHY Half Duplex /etc/issue www.microtronix.com June 2005 Welcome to Linux on the Nios II Nios2 login: root Password: # cat /proc/devices Character devices: 1 mem 2 pty 3 ttyp 4 ttyS 5 /dev/tty 5 /dev/console 5 /dev/ptmx 10 misc 90 mtd 128 ptm 136 pts Block devices: 1 ramdisk 31 mtdblock# cat /proc/mtd dev: size erasesize name mtd0: 00400000 00010000 "romfs/jffs2" mtd1: 00200000 00010000 "loader/kernel" mtd2: 00100000 00010000 "User configuration" mtd3: 00100000 00010000 "safe configuration"# mknod /var/mtd0 c 90 0# mknod /var/mtd1 c 90 1# mknod /var/mtd2 c 90 2# mknod /var/mtd3 c 90 3# ls -la /var drwxr-xr-x 3 root root 1024 Nov 30 00:03 . drwxr-xr-x 1 root root 32 Jan 1 1970 .. drwxr-xr-x 2 root root 12288 Oct 8 1998 lost+found crw-r--r-- 1 root root 90, 0 Nov 30 00:02 mtd0 crw-r--r-- 1 root root 90, 1 Nov 30 00:02 mtd1 crw-r--r-- 1 root root 90, 2 Nov 30 00:03 mtd2 crw-r--r-- 1 root root 90, 3 Nov 30 00:03 mtd3 1. I make 4 MTD character devices on /var for character mode direct access FLASH using open, ioctl, read. This method is correct or not? int fd; fd = open ("/dev/mtd0", O_RDWR); etc. 2. >(2) Create a device table file and use the -D, --devtable option to mkfs.jffs2 Could you explain the -D, --devtable option and how to use? Thanks, Best Regards,- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi posix6973,
> This method is correct or not? > int fd; > fd = open ("/dev/mtd0", O_RDWR); > etc. Yes. The mtd-utils code has many examples. Take a look the erase utility for example. > Could you explain the -D, --devtable option and how to use? This is only for mkfs.jffs2 ... if you're not using jffs2, you won't need this. Regardless, when using mkfs.jffs2, a devtable file provides two advantages: 1. You don't have to su root. Without a devtable file, you would need to have root privileges on your development host to create device inodes in your jffs2 target tree -- which is a big hassle -- at least if you're concerned with security ;-) 2. The devtable file serves as a form of documentation that can be placed under version control just like any other source file. This is right out of an mtd-utils souce tree: <div class='quotetop'>QUOTE </div> --- Quote Start --- # This is a sample device table file for use with mkfs.jffs2. You can# do all sorts of interesting things with a device table file. For# example, if you want to adjust the permissions on a particular file# you can just add an entry like:# /sbin/foobar f 2755 0 0 - - - - -# and (assuming the file /sbin/foobar exists) it will be made setuid# root (regardless of what its permissions are on the host filesystem.# # Device table entries take the form of:# <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)# uid is the user id for the target file, gid is the group id for the# target file. The rest of the entried apply only to device special# file. # When building a target filesystem, it is desirable to not have to# become root and then run 'mknod' a thousand times. Using a device # table you can create device nodes and directories "on the fly".# Furthermore, you can use a single table entry to create a many device# minors. For example, if I wanted to create /dev/hda and /dev/hda[0-15]# I could just use the following two table entries:# /dev/hda b 640 0 0 3 0 0 0 -# /dev/hda b 640 0 0 3 1 1 1 16# # Have fun# -Erik Andersen <andersen@codepoet.org># # <name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count> # /dev d 755 0 0 - - - - - /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 640 0 0 5 0 0 0 - /dev/tty c 640 0 0 4 0 0 1 6 /dev/console c 640 0 0 5 1 0 0 - /dev/ram b 640 0 0 1 1 0 0 - /dev/ram b 640 0 0 1 0 0 1 4 /dev/loop b 640 0 0 7 0 0 1 2 /dev/ttyS c 640 0 0 4 64 0 1 4 [/b] --- Quote End --- Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
1. create these dev files in ROOTFS project in IDE: @mtd3,c,90,3 @mtdblock,b,31,0 @mtdblock,b,31,1 @mtdblock,b,31,2 @mtdblock,b,31,4 build,upload ROOTFS 2. config MTD, MTD_CHAR build kernel 3. download netflash from uClinux-dist-2005...tar.bz2 compile it, copy to NFS share dir. 4. after uClinux boot up, I test netflash# netflash -bfkn -r /dev/mtd3 192.168.168.0 testfile error: open("/dev/mtd3") permission denied Any suggestion , please? BTY, flash is AM29LV128 (16MB). My Altera maps is: Creating 5 MTD partitions on "Altera NDK flash (AMD)": 0x00200000-0x00c00000 : "romfs/root" 0x00000000-0x00200000 : "loader/kernel" 0x00c00000-0x00e00000 : "RW zone/jffs2" 0x00e00000-0x00f00000 : "User configuration" 0x00f00000-0x01000000 : "safe configuration" I'd like to test ACCESS mtdblock3(mtd3?).- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It worked!
I debuged mtdchar.c, and found open permission errror from:/* You can't open the RO devices RW */
if ((file->f_mode & 2) && (minor & 1))
return -EACCES;
and the minor = dev_minor >>1 , so should Dev's minor should 0, 2, 4, 8 ... to writable? why? however , I modify the mtd3,c,90,3->mtd3,c,90,4. And, It worked: <div class='quotetop'>QUOTE </div> --- Quote Start --- netflash: ftping file "Makefile" from 192.168.168.160 .. netflash: got "Makefile", length=9180 netflash: programming FLASH device /dev/mtd3 ................................[/b] --- Quote End --- but, i don't know which location(address) of flash did netflash programming?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've several days work invested in this jffs2 thing, but I'm not quite there yet. Below is a summary of what I've got so far. I'm diving into the mtd-utils stuff now...
# cat /proc/partitions major minor # blocks name 31 0 4064 mtdblock0 31 1 2048 mtdblock1 31 2 512 mtdblock2 31 3 8192 mtdblock3# cat /proc/mtd dev: size erasesize name mtd0: 003f8000 00010000 "ROMfs" mtd1: 00200000 00010000 "kernel" mtd2: 00080000 00010000 "Flash FS" mtd3: 00800000 00010000 "FPGA Cores"# ls -la /dev/mtdblock2 brw------- 1 root root 31, 2 Jan 1 1970 /dev/mtdblock2 [note I created the /dev entry in my ROMfs project as "@mtdblock2,b,31,2"] # cat /proc/partitions major minor # blocks name 31 0 4064 mtdblock0 31 1 2048 mtdblock1 31 2 512 mtdblock2 31 3 8192 mtdblock3# cat /proc/mtd dev: size erasesize name mtd0: 003f8000 00010000 "ROMfs" mtd1: 00200000 00010000 "kernel" mtd2: 00080000 00010000 "Flash FS" mtd3: 00800000 00010000 "FPGA Cores"# ls -la /var/flash drwxrwxrwx 2 root root 1024 Nov 30 18:57 . drwxr-xr-x 4 root root 1024 Nov 30 18:57 ..# mount -t jffs2 /dev/mtdblock2 /var/flash can't create lock file /etc/mtab~41: Read-only file system (use -n flag to overr ide)# mount -t jffs2 /dev/mtdblock2 /mnt -n Eep. No valid nodes for ino# 1 [the system locks up at this point...] I've created a file system image on a different machine and tried to cp it into /dev/mtdblock2, but it locks the system up as well. I compiled the mtd-tools erase program, and it's having issues as well:# cat /proc/mtd dev: size erasesize name mtd0: 003f8000 00010000 "ROMfs" mtd1: 00200000 00010000 "kernel" mtd2: 00080000 00010000 "Flash FS" mtd3: 00800000 00010000 "FPGA Cores"# cat /proc/partitions major minor # blocks name 31 0 4064 mtdblock0 31 1 2048 mtdblock1 31 2 512 mtdblock2 31 3 8192 mtdblock3# ./erase.exe /dev/mtd2 MTD_open File open error Any suggestions would be appreciated.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In my own case, You have done it ! Try to mkdir in the /var/flash for testing.
And , please refe to another post (http://www.niosforum.com/forum/index.php?act=st&f=18&t=2484)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi mikewest,
># ./erase.exe /dev/mtd2 > MTD_open > File open error Does /dev/mtd2 exist ... as a character mode device? And did you enable the char mode mtd driver in you kernel? Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
/dev/mtd2 shows up. I added it via my file system project (i.e., @mtd2,c,90,2). The CFI probe seems to work, and reports the partitions correction:
ISI flash device: 1000000 at 1000000 Probing for chip type phys_mapped_flash: Found 1 x16 devices at 0x0 in 16-bit bank Amd/Fujitsu Extended Query Table at 0x0040 Using buffer write method phys_mapped_flash: 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. Using ISI specific partition definition Creating 4 MTD partitions on "phys_mapped_flash": 0x00200000-0x005f8000 : "ROMfs" mtd: Giving out device 0 to ROMfs 0x00000000-0x00200000 : "kernel" mtd: Giving out device 1 to kernel 0x00700000-0x00800000 : "Flash FS" mtd: Giving out device 2 to Flash FS 0x00800000-0x01000000 : "FPGA Cores" mtd: Giving out device 3 to FPGA Cores Is it sufficient that the devices show up as follows?# ls -la /dev/mt* crw------- 1 root root 90, 0 Jan 1 1970 /dev/mtd0 crw------- 1 root root 90, 1 Jan 1 1970 /dev/mtd1 crw------- 1 root root 90, 2 Jan 1 1970 /dev/mtd2 crw------- 1 root root 90, 3 Jan 1 1970 /dev/mtd3 brw------- 1 root root 31, 2 Jan 1 1970 /dev/mtdblock2 I enabled the block and char mtd drivers in the kerel config...I just can't seem to nip this one. Mike --- Quote Start --- originally posted by smcnutt@Oct 17 2005, 08:22 AM hi mikewest,
># ./erase.exe /dev/mtd2
> mtd_open
> file open error
does /dev/mtd2 exist ... as a character mode device? and did you enable the char
mode mtd driver in you kernel?
regards,
--scott
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=10405)
--- quote end ---
--- Quote End ---
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've tracked it down a bit more...mtd_char.c thinks this mtd is not writable.
/* You can't open it RW if it's not a writeable device */ if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) { printk("Device not writable %x/%x\n", file->f_mode & 2, mtd->flags & MTD_WRITEABLE); put_mtd_device(mtd); return -EACCES; } With that printk added, I see the following:# ./mtd_debug.exe info /dev/mtd2 MTD_open Device not writable 2/0 open(): Permission denied I have _not_ included MTD_WRITEABLE in my partition definition, so there must be some other logic that's deciding this is the case. Partitions.h says writable partition be aligned: Note: writeable partitions require their size and offset be * erasesize aligned (e.g. use MTDPART_OFS_NEXTBLK). I'm asking for a 0x1000000 chunk at location 0x1000000. Seems like that shouldn't have any alignment issues...- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mike,
> I have _not_ included MTD_WRITEABLE in my partition definition, so there must > be some other logic that's deciding this is the case. I'm getting confused WRT the partition you are actually trying to access ... mtd partition 0: 0x00200000-0x005f8000 : "ROMfs" mtd partition 1: 0x00000000-0x00200000 : "kernel" mtd partition 2: 0x00700000-0x00800000 : "Flash FS" mtd partition 3: 0x00800000-0x01000000 : "FPGA Cores" Just to be sure ... you are try to access mtd partition 1 (the "kernel" partition, minor number 2), AND it does NOT have the MTD_WRITEABLE attribute set ... correct? Given a particular minor number for the char driver, the partition number is: minor >> 1. Basically: partition = minor >> 1 partition is read only = minor & 1 partition is read/write = ~(minor & 1) irrespective of your char mode device inode attributes. E.g.: crw------- 1 root root 90, 0 Jan 1 1970 /dev/mtd0 crw------- 1 root root 90, 1 Jan 1 1970 /dev/mtd0_ro crw------- 1 root root 90, 2 Jan 1 1970 /dev/mtd1 crw------- 1 root root 90, 3 Jan 1 1970 /dev/mtd1_ro crw------- 1 root root 90, 4 Jan 1 1970 /dev/mtd2 crw------- 1 root root 90, 5 Jan 1 1970 /dev/mtd2_ro crw------- 1 root root 90, 6 Jan 1 1970 /dev/mtd3 crw------- 1 root root 90, 7 Jan 1 1970 /dev/mtd3_ro Regards, --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bingo. I must have missed the class on partition<->minor device numbering... Based on other threads here and this (http://www.enseirb.fr/~kadionik/embedded/uclinux/mtd/howto_mtd.html)
I was under the distinct impression that partition N mapped directly to minor number N (aka mtdN/mtdblockN). I now see that when MTD says: 0x00700000-0x00800000 : "Flash FS" mtd: Giving out device 2 to Flash FS I should access the partition via /dev/mtd4 (rw) and /dev/mtd5 (ro). I've spent several days trying to access it as /dev/mtd2 (which refers to my MTD_WRITEABLE-flagged partition# 1). Now I can open the partition (via /dev/mtd4), but I can't do much with it:# mkdir /var/flash# mount -t jffs2 /dev/mtdblock4 /var/flash -n mount: wrong fs type, bad option, bad superblock on /dev/mtdblock4, or too many mounted file systems AND# cp jffs2.img /dev/mtd4 MTD_open MTD_write Badness in local_bh_enable at /cygdrive/c/altera/kits/nios2/bin/eclipse/plugins/ com.microtronix.nios2linux.kernel_1.4.0/linux-2.6.x/kernel/softirq.c:140 Stack from 00c53e54:<0> <0> 00166734<0> 0000ffc4<0> 000ec400<0> 00000000<0> 00000000<0> 00369e68... AND# erase /dev/mtd4 Trying to open /dev/mtd4 MTD_open Erase Total 1 Units MTD_ioctl MTD_ioctl Performing Flash Erase of length 65536 at offset 0x0MTD_ioctl (System hangs here...) Cheers! Mike --- Quote Start --- partition = minor >> 1 partition is read only = minor & 1 partition is read/write = ~(minor & 1) irrespective of your char mode device inode attributes. E.g.: crw------- 1 root root 90, 0 Jan 1 1970 /dev/mtd0 crw------- 1 root root 90, 1 Jan 1 1970 /dev/mtd0_ro crw------- 1 root root 90, 2 Jan 1 1970 /dev/mtd1 crw------- 1 root root 90, 3 Jan 1 1970 /dev/mtd1_ro crw------- 1 root root 90, 4 Jan 1 1970 /dev/mtd2 crw------- 1 root root 90, 5 Jan 1 1970 /dev/mtd2_ro crw------- 1 root root 90, 6 Jan 1 1970 /dev/mtd3 crw------- 1 root root 90, 7 Jan 1 1970 /dev/mtd3_ro Regards, --Scott <div align='right'><{post_snapback}> (index.php?act=findpost&pid=10416)</div> --- Quote End --- --- Quote End ---
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page