Reply
Highlighted
Regular Contributor
Posts: 26
Registered: ‎09-27-2011
Accepted Solution

Can't initialize Memory File System with image

I'm trying to initialize a file system with the image.mfs webserver image  file used with the Factory Test for the LX16 board.  After initialization the system cannot find a file and the webserver returns a 404 Page Not Found error.  

File system is configured as follows:

BEGIN LIBRARY
 PARAMETER LIBRARY_NAME = xilmfs
 PARAMETER LIBRARY_VER = 1.00.a
 PARAMETER PROC_INSTANCE = microblaze_0
 PARAMETER INIT_TYPE = MFSINIT_IMAGE
 PARAMETER NEED_UTILS = true
 PARAMETER NUMBYTES = 266000
 PARAMETER BASE_ADDRESS = 0xC3E00000
END

 

The image.mfs file size  is 266004 bytes.  I tried NUMBYTES = the file size as well as 4 fewer.  The Factory Test looks like it's using 266000.

 

I copied the file to RAM at 0xC3E00000 and wrote code to confirm the data seems to be there.  It starts with "mfs2" and does include the string "index.html."

 

I tried a number of variations to initialize the file system:

 

mfs_init_fs(MFS_NUMBYTES, (char *)(MFS_BASE_ADDRESS+4), MFS_INIT_TYPE); (this is the one used in the Factory Test)

mfs_init_fs(MFS_NUMBYTES, (char *)(MFS_BASE_ADDRESS), MFS_INIT_TYPE);

mfs_init_genimage(MFS_NUMBYTES, (char*)(MFS_BASE_ADDRESS), MFS_INIT_TYPE);

 

After initialization the  function mfs_exists_file( "index.html") returns zero indicating the file was not found.

 

I'm doing something wrong and looking for help figuring it out.

 

Avnet Employee (Star Contributor)
Posts: 114
Registered: ‎06-09-2009

Re: Can't initialize Memory File System with image

Hi wreinhold,

 

Here is the original LX16 Factory Test DDR memory space:

 

#define XPAR_MCB3_LPDDR_MPMC_BASEADDR 0x44000000
#define XPAR_MCB3_LPDDR_MPMC_HIGHADDR 0x47FFFFFF

 

And here is the location where the MFS was loaded into memory in that example application:

 

BEGIN LIBRARY
    PARAMETER LIBRARY_NAME = xilmfs
    PARAMETER LIBRARY_VER = 1.00.a
    PARAMETER base_address = 0x44800000
    PARAMETER PROC_INSTANCE = microblaze_0
    PARAMETER need_utils = true
    PARAMETER numbytes = 266000
    PARAMETER init_type = MFSINIT_IMAGE
END

 

I noticed that you appear to be using a different memory space (0xC3E00000) for your MFS image than was used in LX16 Factory Test application, which SHOULD be okay.

 

Have you double checked that the memory location that you are using for the BASE_ADDRESS property does not cause the MFS image to load across the end boundary for your SDRAM memory?

 

Regards,

 

-Kevin

 

Regular Contributor
Posts: 26
Registered: ‎09-27-2011

Re: Can't initialize Memory File System with image

Thanks Kevin, but I should be within the SDRAM memory space:

 

#define XPAR_MCB3_LPDDR_S0_AXI_BASEADDR 0xC0000000
#define XPAR_MCB3_LPDDR_S0_AXI_HIGHADDR 0xC3FFFFFF

 

Would there be a reason to put it closer to the beginning of the memory space like you did?

 

-Bill

Avnet Employee (Star Contributor)
Posts: 114
Registered: ‎06-09-2009

Re: Can't initialize Memory File System with image

Hi Bill,

 

Not that I can think of, it seems like it should be okay to put it there in that location that you did.  I did the math and unless you alter the bootloader, it will copy a 2097152 byte long MFS image from SPI flash into memory but even that would take you up to 0xC3FFFFFF, so you should be okay.

 

Seems strange that the included MFS image would not work though.  I was looking through the libmfs_v1_00_a folder and I found this notes section in the readme.txt:

 

...

2. Notes
* It is possible to verify the correctness of an MFS file image by extracting all the files
in a different area and comparing with the original:
a. Create the mfs image:
mfsgen -cvf tmp.mfs original.elf
b. Extract the file in a different area:
mkdir tmp; cd tmp; cp ../tmp.mfs .; ../mfsgen -xvf tmp.mfs
c. Compare the two files:
diff original.elf ../original.elf

...

 

Do you think you could try this on your image.mfs to see if it is corrupted?  If it is not corrupted, you should get an index.html that loads up a browser successfully. 

 

Regards,

 

-Kevin

Regular Contributor
Posts: 26
Registered: ‎09-27-2011

Re: Can't initialize Memory File System with image

[ Edited ]

Hi Kevin,

 

I did as you suggested with the image.mfs file and the extracted index.html file opened fine in a browser.

 

I also tried an mfs address offset closer to the beginning of RAM with the same results.

 

I opened the image.mfs file in a hex editor and then dumped several sections of the mfs block in RAM to the serial port to compare them manually and it looked fine -- the right data was in the right place.  I checked the data at the beginning, end, and middle of the memory block.

 

I'm not using the bootloader from the demo.  The bootloader loads the program and then the program loads the image during initialization (it does load the image before trying to initialize the file system). 

 

One question -- I'm assuming the xilmfs setup for the BSP causes the compiler to reserve the defined memory block for mfs.  Your configuration reserves 4 fewer bytes than you load, and then you initialize the file system with an offset of 4 bytes.  Wouldn't that cause the file system to use 4 bytes past the end of the reserved block? 

 

Bill

 

 

Regular Contributor
Posts: 26
Registered: ‎09-27-2011

Re: Can't initialize Memory File System with image

[ Edited ]

With help from Xilinx tech support I now have the solution.  The command Avnet used to produce the mfs image file was as follows:

 

mfsgen -cvsbf image.mfs 500 index.html css images js yui

 

This command includes the "s" switch, whcih switches endianness.  I recreated the image without it and it works perfectly.

 

The solution took so long to figure out because a dump of memory showed the correct file contents using the image created with the "s" switch, so I initially dismissed it as a possible cause. 

 

Here are a couple other tips for setting up the mfs that would have saved me a lot of time:

 

The setup parameters when loading an image made with mfsgen should be as follows:

BEGIN LIBRARY
    PARAMETER LIBRARY_NAME = xilmfs
    PARAMETER LIBRARY_VER = 1.00.a
    PARAMETER base_address = a beginning address for a block to be reserved within DDR RAM. 

    PARAMETER PROC_INSTANCE = microblaze_0
    PARAMETER need_utils = true (can probably set this to false -- seems to just be some utilities to test the file system)

    PARAMETER numbytes = the exact file size in bytes of the mfs image file

    PARAMETER init_type = MFSINIT_IMAGE (if the file system is writable.  If read only MFSINIT_ROM_IMAGE can be used)
END

 

DDR memory is defined in xparameters.h:

#define XPAR_MCB3_LPDDR_MPMC_BASEADDR 0x44000000
#define XPAR_MCB3_LPDDR_MPMC_HIGHADDR 0x47FFFFFF

 

The compiler will reserve a <numbytes> bytes block of memory starting at <base_address> for the file system.  You need to be sure the block will not overrun the memory space.

 

The correct initilization to be used in this case is:

mfs_init_genimage(MFS_NUMBYTES, (char *)(MFS_BASE_ADDRESS), MFS_INIT_TYPE);

 

The first four bytes of an mfs image are not used by the file system.  The approach I've described saves space for the entire file in RAM and mfs_init_genimage() automatically initializes the file system without those first four bytes (looking at the source code makes this clear).

 

The Avnet factory test code does this slightly differently and I believe they will overrun the reserved memory space by 4 bytes.  It probably doesn't matter because the compiler is most likely not using that memory anyway.

 

 

Avnet Employee (Star Contributor)
Posts: 114
Registered: ‎06-09-2009

Re: Can't initialize Memory File System with image

Hi Bill,

 

Thanks for following up on this.  I had no idea that the endianness would prevent the proper intiialization of the MFS image and it makes me wonder how the LX16 supplied image ever worked in the first place.  

 

Thank you very much for taking the time to explain your findings for the rest of the commuity! 

 

Regards,

 

-Kevin