EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

writing to flash memory fails: help please! :-(

Started by idesoete September 22, 2003
Hi,

I'm trying to write to flash, but after some more than a week, I'm
becomming quite desperate of the ongoing failures....

my define setting are:

#define XMEM_RESERVE_SIZE 0x80000L
#define FS2_RAM_RESERVE 0

#define FS2_USE_PROGRAM_FLASH 64

and my program says:

lxnFlash = fs_get_flash_lx();
lxnRam = fs_get_ram_lx();

rc=fs_init(0, 0);

fs_print_lxs(0);

//rc=fs_set_lx(lxnFlash,lxnFlash);

rclete(TESTFILE);
if(rc=fopen_wr(&file,TESTFILE))
if ((rceate(&file,TESTFILE)))
{
printf("error opening TESTFILE %d\n", errno);
return -1;
}
memSize=fs_get_lx_size(lxnRam,0,0);
memSize=fs_get_lx_size(lxnRam,1,0);
memSize=fs_get_lx_size(lxnFlash,0,0);
memSize=fs_get_lx_size(lxnFlash,1,0);

rc=fseek(&file,0,SEEK_SET);
rc=fwrite(&file,"aiai",5);

rc=fseek(&file,0,SEEK_SET);
while(rc=fread(&file,buffer,5)>0)
{
printf("%s\n",buffer);
}

rcose(&file);

Writing doesn't succeed, and more: fs_get_lx_size(lxnFlash,0,0);
return zero

Anyone any suggestion, please??

Thnx a lot!


#define XMEM_RESERVE_SIZE 0x80000L   look like weird
 
extract of rabbitbios.c

#define XMEM_RESERVE_SIZE 0x0000L //  Amount of space in the first flash to
                                  //  reserve. Dynamic C will not use this
                                  //  much flash for xmemory code space.
                                  //  This allows the filesystem to be used on
                                  //  the first flash.
 
 
try to compil and run the samples in filesystem directory
 
they work fine for me,

*--*
*  Rene Lefebvre                       *
*  Software engineer  WEBDYN S.A.      *
*  Tel : +33 (1) 39 04 29 53           *
http://www.webdyn.com               *
mailto:r...@webdyn.com     *
*--*

 

-----Message d'origine-----
De : idesoete [mailto:i...@yahoo.com]
Envoynbsp;: lundi 22 septembre 2003 16:59
nbsp;: r...@yahoogroups.com
Objet : [rabbit-semi] writing to flash memory fails: help please! :-(

Hi,

I'm trying to write to flash, but after some more than a week, I'm
becomming quite desperate of the ongoing failures....

my define setting are:

#define XMEM_RESERVE_SIZE 0x80000L
#define FS2_RAM_RESERVE 0

#define FS2_USE_PROGRAM_FLASH      64

and my program says:

   lxnFlash = fs_get_flash_lx();
   lxnRam = fs_get_ram_lx();

   rc=fs_init(0, 0);

   fs_print_lxs(0);

   //rc=fs_set_lx(lxnFlash,lxnFlash);

   rclete(TESTFILE);
   if(rc=fopen_wr(&file,TESTFILE))
    if ((rceate(&file,TESTFILE)))
    {
      printf("error opening TESTFILE %d\n", errno);
      return -1;
    }
   memSize=fs_get_lx_size(lxnRam,0,0);
   memSize=fs_get_lx_size(lxnRam,1,0);
   memSize=fs_get_lx_size(lxnFlash,0,0);
   memSize=fs_get_lx_size(lxnFlash,1,0);

   rc=fseek(&file,0,SEEK_SET);
   rc=fwrite(&file,"aiai",5);

   rc=fseek(&file,0,SEEK_SET);
   while(rc=fread(&file,buffer,5)>0)
   {
      printf("%s\n",buffer);
   }

   rcose(&file);

Writing doesn't succeed, and more: fs_get_lx_size(lxnFlash,0,0);
return zero

Anyone any suggestion, please??

Thnx a lot!







">Yahoo! Terms of Service.


How large is your board's first flash? The "#define XMEM_RESERVE_SIZE
0x80000L" below tells Dynamic C to reserve 512KB for a first-flash FS2 file
system, and the "#define FS2_USE_PROGRAM_FLASH 64" tells FS2 to use 64KB
for a first flash file system.

I suggest trying the same 64KB number in each #define at first to check
that it works, and thereafter perhaps slowly increasing them together in
step until you find the point where the FS2 first flash file system no
longer fits. Remember that the size of each #define's value should be a
multiple of the flash sector size, which is typically 4KB for recent ZW
Rabbit boards. (If using a custom board, also note that FS2 does not
support flash types with large or nonuniform sector sizes.)

How many flash devices are installed on your board? If using a board with
two flashes, then FS2 works best when the first flash is ignored and the
flash file system uses (consumes) the second flash.

If the board has two flash devices and you want to use a flash file system
on the first flash, then the first flash LXN is returned by
"fs_get_other_lx()" but if the board has only a single flash then your test
code is correct to use "fs_get_flash_lx()" to determine the first flash's LXN.

At 07:59 AM 9/22/03, you wrote:
>Hi,
>
>I'm trying to write to flash, but after some more than a week, I'm
>becomming quite desperate of the ongoing failures....
>
>my define setting are:
>
>#define XMEM_RESERVE_SIZE 0x80000L
>#define FS2_RAM_RESERVE 0
>
>#define FS2_USE_PROGRAM_FLASH 64
>
>and my program says:
>
> lxnFlash = fs_get_flash_lx();
> lxnRam = fs_get_ram_lx();
>
> rc=fs_init(0, 0);
>
> fs_print_lxs(0);
>
> //rc=fs_set_lx(lxnFlash,lxnFlash);
>
> rclete(TESTFILE);
> if(rc=fopen_wr(&file,TESTFILE))
> if ((rceate(&file,TESTFILE)))
> {
> printf("error opening TESTFILE %d\n", errno);
> return -1;
> }
> memSize=fs_get_lx_size(lxnRam,0,0);
> memSize=fs_get_lx_size(lxnRam,1,0);
> memSize=fs_get_lx_size(lxnFlash,0,0);
> memSize=fs_get_lx_size(lxnFlash,1,0);
>
> rc=fseek(&file,0,SEEK_SET);
> rc=fwrite(&file,"aiai",5);
>
> rc=fseek(&file,0,SEEK_SET);
> while(rc=fread(&file,buffer,5)>0)
> {
> printf("%s\n",buffer);
> }
>
> rcose(&file);
>
>Writing doesn't succeed, and more: fs_get_lx_size(lxnFlash,0,0);
>return zero
>
>Anyone any suggestion, please??
>
>Thnx a lot! >
>To unsubscribe from this group, send an email to:
>rabbit-semi-unsubscribe@rabb... >
>">http://docs.yahoo.com/info/terms/



The 2024 Embedded Online Conference