- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Problems creating a mfs from data on CF-card on XUPV2P
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
04-24-2009 08:03 AM - edited 04-24-2009 08:16 AM
I recently got a webserver to run on my XUPV2P board in EDK 10.1 sp3 using lwip. Because it's such a hassle to load both the executable.elf as the image.mfs to the DDR every time, I wanted to create the mfs at runtime from data on the CF-card. Although the mfs is created and the files seem to be transfered, none of the files are available after initialization. The code I use is the following:
typedef unsigned char BYTE; #define MAX_DIR_ENTRIES 50 #define MFS_NUMBYTES 8000000 #define MFS_BASE_ADDRESS 0x92000000 #define MFS_INIT_TYPE MFSINIT_IMAGE int initMemFileSystem() { int numDirEntries = 0; dirent de[MAX_DIR_ENTRIES]; SYSACE_FILE* tmp; int i, fd; char* path = "a:\\web"; char buffer[20], charBuff2[15]; BYTE* byteBuffer; xil_printf( "Before mfs_init_FS\r\n" ); mfs_init_fs (MFS_NUMBYTES, (char*)(MFS_BASE_ADDRESS + 4), MFS_INIT_TYPE); xil_printf( "After mfs_init_FS\r\n" ); if( sysace_chdir(path) == -1 ) { xil_printf("ERROR: Can't change directory to %s.\n\r", path); return; } xil_printf( "Before sysace_readdir\r\n" ); numDirEntries = sysace_readdir(path, de, MAX_DIR_ENTRIES ); xil_printf( "Num Dir entries = %d\r\n", numDirEntries ); xil_printf( "After sysace_readdir\r\n" ); for( i = 2; i < numDirEntries; i++ ) { xil_printf( "File %d: %s.%s\r\n", i, de[i].name, de[i].ext ); memset( buffer, '\0', 20); strcat( buffer, strtok(de[i].name, " ") ); strcat( buffer, "." ); strcat( buffer, de[i].ext ); xil_printf("before sysace_fopen ()\r\n"); tmp = sysace_fopen (buffer, "r"); xil_printf("after sysace_fopen ()\r\n"); if ( !tmp ) { xil_printf("ERROR: Can't open SYSACE File %s\n\r", buffer); } xil_printf("Malloc-ing\r\n"); byteBuffer = (BYTE*) malloc( sizeof(BYTE) * de[i].size ); xil_printf("Finished malloc-ing\r\nStarting sysace_fread\r\n"); sysace_fread (byteBuffer, 1, de[i].size, tmp); xil_printf("After sysace_fread\r\n"); if((fd = mfs_file_open(buffer, MFS_MODE_CREATE)) == -1) { xil_printf("ERROR: Can't create %s\n\r", buffer); } if((fd = mfs_file_open(buffer, MFS_MODE_WRITE)) == -1) { xil_printf("ERROR: Can't open MFS File %s for writing\n\r", buffer); } if( mfs_file_write (fd, byteBuffer, de[i].size)==0 ) { xil_printf("ERROR: Can't write to %s\n\r", buffer); } xil_printf("After possible read/create/open errors\n\r"); mfs_file_close( fd ); sysace_fclose( tmp ); //memset( buffer, '\0', 20); free( byteBuffer ); } //for() } int platform_init_fs() { /* initialize the memory file system (MFS) image pre-loaded into memory */ //mfs_init_fs(MFS_NUMBYTES, (char *)(MFS_BASE_ADDRESS+4), MFS_INIT_TYPE); xil_printf("Initializing File system\n\r"); initMemFileSystem(); xil_printf("File system initialized\n\r\n\r"); /* check if we can access index.html */ if (mfs_exists_file("index.html") == 0) { xil_printf("%s: ERROR: unable to locate index.html in MFS\n\r", __FUNCTION__); xil_printf("Please check if Memory File System has been loaded, " "and it has index.html file in root directory\n\r"); return -1; } xil_printf("Memory File System initialized\n\r"); return 0; }
The library in system.mss looks like:
BEGIN LIBRARY PARAMETER LIBRARY_NAME = xilmfs PARAMETER LIBRARY_VER = 1.00.a PARAMETER PROC_INSTANCE = microblaze_0 PARAMETER need_utils = true PARAMETER base_address = 0x92000000 PARAMETER numbytes = 8000000 PARAMETER init_type = MFSINIT_IMAGE END
And this gives the following output in Hyperterminal:
Initializing File system Before mfs_init_FS After mfs_init_FS Before sysace_readdir Num Dir entries = 4 After sysace_readdir File 2: MAIN .CSS before sysace_fopen () after sysace_fopen () Malloc-ing Finished malloc-ing Starting sysace_fread After sysace_fread After possible read/create/open errors File 3: INDEX .HTM before sysace_fopen () after sysace_fopen () Malloc-ing Finished malloc-ing Starting sysace_fread After sysace_fread After possible read/create/open errors File system initialized platform_init_fs: ERROR: unable to locate index.html in MFS Please check if Memory File System has been loaded, and it has index.html file in root directory web server started requested file index.html not found, returning 404
Can anyone help help solve this problem?
Thanks!











