xilmfs on flash

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hello all,

I am using Xilinx fpga in my project. The board is ML403 and it
contains an 8MB flash.
I need to store few data files onto the flash and read these files
during the execution of my program on powerpc.
i have to use xilmfs as the filesystem on the flash and therefore i
created a mfs image of the files by using mfsgen utility according to
the xilinx reference manuals (oslib_rm, ps_ug).

for downloading this mfs image, the manual says
"Load this image file into memory at a suitable address, such as
0x10000000. You can
use XMD to download data, or you can use another tool to copy this data
to memory."

i tried to download using XMD command: dow -data image.mfs 0x22000000
where
   dow : command
   -data : option to indicate data file and not executable
  image.mfs : mfs filesystem image
  0x22000000 : flash memory starting address in my design where the mfs
image has to be downloaded.

in the design, i have included the flash drive on the hardware side and
enabled the xilmfs libary with the parameters set appropriately. i.e.,
baseaddress = 0x22000000, init_type = rom_image and size = 15960 bytes

in the code
#include "mfs_config.h"

main()
{
....
    mfs_init_fs(MFS_NUMBYTES, MFS_BASE_ADDRESS, MFSINIT_ROM_IMAGE);

    mnt1 = mfs_file_open("1_1_0.mnt", MFS_MODE_READ);
    xil_printf("\n%d\n",mnt1); // receiving -1 for mnt1 : the file opening
was unsuccessful.

...
}

and still not able to open the file and read from it.

i have crosschecked all the steps suggested in the manual many times
but found that i have done everything according to the manuals.

(i also tried to load the flash with the image.mfs using "Program Flash
Memory" option in the Menu but with no change in the result)

Any help in resolving the problem is deeply appreciated.

Thanks in advance,
Rajashekar


Re: xilmfs on flash
I used xilmfs once...

Did you use the mfsgen utility to make your file system?  If so you
probably need to use mfs_init_genimage instead of mfs_init_fs.
Essentially they vary by adjusting some pointer a byte or two (or four
or whatever).  I used mfsgen and then downloaded like you mentioned and
then did this in my main:

/* Set up the file system and cd to correct dir */
 mfs_init_genimage(53200, (char *) MFS_BASE_ADDRESS, MFS_INIT_TYPE);
 xilmfs_result = mfs_change_dir("my_fs");
 xilmfs_result = mfs_get_current_dir_name(dirname);
 if(xilmfs_result == 0) {
     printf("Couldn't get current_dir_name.\r\n");
     printf("Exiting...\n");
     exit(1);
 }

I don't recall if the 53200 is the value I got directly from mfsgen or
not... maybe have to adjust it a little?  Like it could have been 53204
or something (again with the pointer adjustment).  Sorry if I am a
little vague, it was a while ago that I set this up. The moral of this
story is try mfs_init_genimage.

Joey


Re: xilmfs on flash
hi joey,
 thank you for your response.

i tried using mfs_init_genimage as you suggested. and am able to change
to the directory and also able to read the name of the directory using
mfs_get_current_dir_name funtion. but when i try to open the file i am
not able to. i used the mfs_ls() funtion to get the directory contents
but am getting a lot of garbage like

...
mnt 0
 00000000
 00000000
 00000000
 00000000
 00000000
 00000000
 00000000
 00000000
 00000000
 00000000
 00000000
.. 00000000
 00
. 00000000
 0000
mnt 00000000
.. 00000000
 00000000
. 00000
 00000000
.....

but the image of the filesystem generated using mfsgen on my host
system is proper which i checked using the command below in the XMD:
$ mfsgen -tfv image.mfs
mfsgen
Xilinx EDK 7.1.2 EDK_H.12.5.1
Copyright (c) 2004 Xilinx, Inc.  All rights reserved.

Directory mnt 4
1_1_0.mnt 3072
1_1_0d.mnt 3072
cd..
mfsgen done!

any suggestions/ideas where i might be going wrong.

Thank you,
Rajashekar

Joseph wrote:

Quoted text here. Click to load it


Re: xilmfs on flash
When you say "when i try to open the file i am not able to", what
happens? How are you opening the files?  What flags are you using to
generate image.mfs? It may be necessary to use the -s flag (see Answer
Record:19867 on the xilinx site).  That flag switches the endianess.

Are you using a PPC or microblaze?  My only experience is with the PPC.

One more thing to try is sticking a small (few chars) txt file in your
file system and see if you can peek at it with XMD to see the correct
values.

Let me know how it goes...  I know it took me a while to get my file
system working like I wanted it to.

Joey


Re: xilmfs on flash
hi joey,

Quoted text here. Click to load it
the function returns -1 indicating failure to open the file.

Quoted text here. Click to load it
using the mfs_file_open("src.mnt", MFS_MODE_READ);

Quoted text here. Click to load it
$ mfsgen -cvbfs imagemnt.mfs 30 mnt
mfsgen
Xilinx EDK 7.1.2 EDK_H.12.5.1
Copyright (c) 2004 Xilinx, Inc.  All rights reserved.

mnt:
des.mnt  3072
src.mnt  3072
MFS block usage (used / free / total) 3D% 14 / 16 / 30
Size of memory is 15960 bytes
Block size is 532
mfsgen done!

Quoted text here. Click to load it
PPC

created dow.txt with the content "dow TestApp_Memory/executable.elf"

then created the imagefile as below
$ mfsgen -cvbfs dummy.mfs 30 mnt
mfsgen
Xilinx EDK 7.1.2 EDK_H.12.5.1
Copyright (c) 2004 Xilinx, Inc.  All rights reserved.
mnt:
dow.txt  35
MFS block usage (used / free / total) 3D% 3 / 27 / 30
Size of memory is 15960 bytes
Block size is 532
mfsgen done!
and then downloaded the image
dow -data dummy.mfs 0x22000000

and then read back the value at 0x22000000 thru XMD as below
XMD% mrd 0x22000000 35 b
22000000:   4D   M
22000001:   46   F
22000002:   53   S
22000003:   32   2
22000004:   00
22000005:   00
22000006:   00
22000007:   00
22000008:   02   E2%98BB%
22000009:   00
2200000A:   00
2200000B:   00
2200000C:   00
2200000D:   00
2200000E:   00
2200000F:   00
22000010:   00
22000011:   00
22000012:   00
22000013:   00
22000014:   00
22000015:   00
22000016:   00
22000017:   00
22000018:   03   E2%99A5%
22000019:   00
2200001A:   00
2200001B:   00
2200001C:   2E   .
2200001D:   2E   .
2200001E:   00
2200001F:   00
22000020:   00
22000021:   00
22000022:   00
the contents doesn't map to the contents of the file dow.txt

thanx for your patience and help.
Rajashekar

Joseph wrote:

Quoted text here. Click to load it


Re: xilmfs on flash
Well Raj,

I don't know what else to say.  For the little text file, I would try
and make a really small image with just the text file so you can
examine the entire memory range where the file lives.  The actual text
can be buried pretty deep.

Looking at your code from above vs mine:

 mfs_init_fs(MFS_NUMBYTES, MFS_BASE_ADDRESS, MFSINIT_ROM_IMAGE);
 mnt1 = mfs_file_open("1_1_0.mnt", MFS_MODE_READ);
 xil_printf("\n%d\n",mnt1); // receiving -1 for mnt1 : the file opening
was unsuccessful

___________________

 mfs_init_genimage(53200, (char *) MFS_BASE_ADDRESS, MFS_INIT_TYPE);
 xilmfs_result = mfs_change_dir("my_fs");
 xilmfs_result = mfs_get_current_ dir_name(dirname);


There are clearly some differences for you to investigate (if you
haven't already).  First what is difference between mfs_init_fs and
mfs_init_genimage (I am not sure, don't have documentation open)?  And
did you ever do an mfs_change_dir before trying to open a file within
it?  You need to do so.  That is why I do an mfs_get_current_dir_name
to see if I am in the correct directory.  I don't remember even
how/what these functions do at the nuts and bolts level, but I do know
that my system did eventually work, so I know these functions do the
trick.

OK, looked it up:   mfs_init_fs:  Initialize the memory file system.
This function must be called before any file system operation. Use
mfs_init_genimage instead of this function if the filesystem is being
initialized with an image generated by mfsgen.

I remember that this has to do with the actual pointer to the file
system, it needs to be adjusted properly.  Try that with the correct
'cd'  call before opening a file.


Keep me posted!  Good luck!
Joey


Re: xilmfs on flash
hi joey,

as you suggested in your first message i tried the following and didnot
get positive result (i have mentioned about this in my 2nd message)

    mfs_init_genimage(MFS_NUMBYTES, (char *) MFS_BASE_ADDRESS,
MFSINIT_ROM_IMAGE);
    xilmfs_result = mfs_change_dir("mnt");
    xilmfs_result = mfs_get_current_dir_name(dirname);
    if(xilmfs_result == 0) {
        xil_printf("Couldn't get current_dir_name.\r\n");
        xil_printf("Exiting...\n");
        exit(1);
     }
    xil_printf("\n %s \n",dirname);

regarding the filesystem size for the small file you have made a good
point and i will try that and get back to you

thank you,
rajashekar


Site Timeline