Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Logic PD support staff and engineers participate, Logic PD does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Logic PD engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Logic PD product download, please subscribe to the TDG Forum of interest.

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 05 Apr 2007 11:59 PM by  ftiernan
Still Trying to get YAFFS to work
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages
ftiernan
New Member
New Member
Posts:


--
30 Dec 2006 08:17 PM
    Hello Aaron,

    I set this aside for a while and am now coming back to it. I cleand out everything and set up a single YAFFS partition just as described in the app note and the logic loader manual. From my CE 5.0 app using Plaftorm Builder 4.2 I can find the YAFFS file using "FindFirstFile" function but when I try to write to that file it fails on "CreateFile". The code snippet and debug output are shown below:
    Code:
    Quote:

    hFlashFile = FindFirstFile ( TEXT("*.*"), &fd);

    if (hFlashFile != INVALID_HANDLE_VALUE) {

    do {
    NKDbgPrintfW(TEXT("Found File: %s \r\n"), fd.cFileName);

    } while (FindNextFile (hFlashFile, &fd));
    FindClose (hFlashFile);
    }


    hFlashFile = CreateFile(TEXT ("YaffsPart1"),GENERIC_READ|GENERIC_WRITE,
    0,NULL,OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL,NULL);

    if (hFlashStore == INVALID_HANDLE_VALUE) {

    NKDbgPrintfW(TEXT("open failed"));
    }

    else {

    my_int = 500;

    WriteFile(hFlashFile, &my_int, 4, &iBytes, NULL);

    iBytes = -1 * iBytes;

    SetFilePointer(hFlashFile, iBytes, NULL, FILE_CURRENT);


    CloseHandle(hFlashFile);
    }


    Debug Output:
    Quote:

    1564681 PID:25dfaf9a TID:25dfa946 0x85dc4d98: Found File: YaffsPart1
    1564681 PID:25dfaf9a TID:25dfa946 0x85dc4d98: Found File: Release
    1564682 PID:25dfaf9a TID:25dfa946 0x85dc4d98: Found File: Recycled
    1564682 PID:25dfaf9a TID:25dfa946 0x85dc4d98: Found File: Application Data
    1564684 PID:25dfaf9a TID:25dfa946 0x85dc4d98: Found File: Control Panel.lnk
    1564684 PID:25dfaf9a TID:25dfa946 0x85dc4d98: Found File: My Documents
    1564686 PID:25dfaf9a TID:25dfa946 0x85dc4d98: Found File: Program Files
    1564686 PID:25dfaf9a TID:25dfa946 0x85dc4d98: Found File: profiles
    1564686 PID:25dfaf9a TID:25dfa946 0x85dc4d98: Found File: Temp
    1564687 PID:25dfaf9a TID:25dfa946 0x85dc4d98: Found File: Windows
    1564689 PID:85fe43da TID:25dfa946 0x85dc4d98: YAFFS::YFSD_CreateFileW unable to get parent node (b4e60,
    1564690 PID:25dfaf9a TID:25dfa946 0x85dc4d98: open failed


    If possible short example of how to write and read to a flash file using your YAFFS driver would be most useful. thanks - Frank T.
    richh@logicpd.com
    New Member
    New Member
    Posts:52


    --
    13 Feb 2007 01:05 PM
    Frank,
    Aaron has left the company to goto Africa to setup water filtering systems, and I'm not a Windows expert, but I'll take a look at your code:

    hFlashFile = FindFirstFile ( TEXT("*.*"), &fd);
    Can you include more of your function? I want to see how you are initializing everything.


    if (hFlashFile != INVALID_HANDLE_VALUE) {

    do {
    NKDbgPrintfW(TEXT("Found File: %s \r\n"), fd.cFileName);

    } while (FindNextFile (hFlashFile, &fd));
    FindClose (hFlashFile);
    }


    hFlashFile = CreateFile(TEXT ("YaffsPart1"),GENERIC_READ|GENERIC_WRITE,
    0,NULL,OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL,NULL);
    I don't think YaffsPart1 is a file, but a directory, right? Can you print out the FILE_ATTRIBUTE_DIRECTORY parameter? Maybe you should try hFlashFile = FindFirstFile ( TEXT("\\YaffsPart1\*.*"), &fd); to see inside the partition? Or maybe try hFlashFile = CreateFile(TEXT ("\\YaffsPart1\testfile"),GENERIC_READ|GENERIC_WRITE,
    0,NULL,OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL,NULL); to create a file?


    if (hFlashStore == INVALID_HANDLE_VALUE) {
    I don't understand where hFlashStore came from. Is this supposed to be hFlashFile?


    NKDbgPrintfW(TEXT("open failed"));
    }

    else {

    my_int = 500;

    WriteFile(hFlashFile, &my_int, 4, &iBytes, NULL);

    iBytes = -1 * iBytes;

    SetFilePointer(hFlashFile, iBytes, NULL, FILE_CURRENT);

    CloseHandle(hFlashFile);
    }
    ftiernan
    New Member
    New Member
    Posts:


    --
    05 Apr 2007 11:59 PM
    Hi Rich,

    Thanks for your help on this. Sorry my reply is so delayed but I went off on some other tasks. Anyway, you were right , the "hFlashStore" variable name was a bug in my code, should have been "hFlashFile". Fixing that and after some experimentation I found that the following code worked

    HANDLE hFlashFile = INVALID_HANDLE_VALUE;
    TCHAR szFilePath[] = TEXT("YaffsPart1\\testfile.txt");
    char buff1[1000];
    DWORD dwPtr;
    DWORD iBytes;

    hFlashFile = CreateFile(szFilePath,GENERIC_READ|GENERIC_WRITE,
    0,NULL,CREATE_ALWAYS,
    0,NULL);


    hFlashFile = CreateFile(szFilePath,GENERIC_READ|GENERIC_WRITE,
    0,NULL,OPEN_EXISTING,
    0,NULL);

    buff1[0] = 'a';

    WriteFile(hFlashFile, buff1, 2, &iBytes, NULL);

    iBytes = -1 * iBytes;

    dwPtr= SetFilePointer(hFlashFile, iBytes, NULL, FILE_CURRENT);

    In case some other poor soul is struggling with this I will mention a couple of things that I discovered along the way.

    1) The file name must have an extension. In my case I used .TXT but others will work as well but no extension i.e. just "testfile" will fail on the CreateFile function.

    2) On the size set up in the .reg file for the yaffs driver needs to be larger than 2 meg. I used
    Quote:
    [HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\lpd_yaffsbd\YAFFS_PARTDRV\PART00]
    "StartAddr"=dword:008C0000
    "EndAddr"=dword:00fc0000
    "Name"="YaffsPart1"
    "PartType"="0"
    "ReadOnly"=dword:0
    in other words 7 Meg. How much lower you can go I do not know but from the documentation I thought 1 meg would be enough (and it is on the logic loader side but when downloading the program to the board it will fail with an obscure debug message about the "yaffs_GutsInitialise" failing. Anyway, thats about it. Thanks again. FT
    You are not authorized to post a reply.