This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems in programming in FLASH - EB40A


On Fri, Aug 20, 2004 at 04:43:01PM -0700, Giri Raja wrote:
> Hi,
>    I'm using a simple test program to program and read
> from the FLASH memory in EB40A. I have a buffer that
> contains all the data that is needed to store in the
> FLASH. when I make the type of this buffer to be a chr
> array, then I do not get any problems. however if I
> define it to be of type cyg_uint8 or unsigned chr,
> then I'm not sure if the data is written into the
> FLASH properly. I check the validity of the
> flash_program by doing a flash_read and printing out
> the contents. 
> when the type was cyg_uint8 or unsigned chr, I see
> only the first few bytes of the array written
> properly, and then they keep repeating.

The type of char should have no effect on the program to flash.

> 
> here is the code that I'm using.
> 
> #include <cyg/kernel/kapi.h>
> #include <cyg/hal/hal_platform_ints.h>
> #include <cyg/io/io.h>
> #include <cyg/io/ttyio.h>
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
> #include <cyg/hal/hal_io.h>
> #include <cyg/infra/diag.h>
> #include <cyg/io/flash.h>
>                                                       
>                                                       
>                
> extern "C"  {
>         void cyg_user_start(void);
> }
>                                                       
>                                                       
>                
> void cyg_user_start(void)
> {
>         int err,i ;
>         unsigned char input_bytes[10];
>         int length;
>         char *err_address ;
>         unsigned char readStr[10] ;
>         int p_base = 0x01030000;
>                                                       
>                                                       
>                
>         for(i = 0; i < 10; i++)
>                 input_bytes[i] = (unsigned
> char)(i+10);
>                                                       
>                                                       
>                
>         flash_init(diag_printf);
>         length = 10;
>                                                       
>                                                       
>                
>         for(i = 0; i < 10; i++)
>                 diag_printf("the chrs - input_byes[%d]
> = %u\n", i, input_bytes[i]);
>                                                       

What about eraseing before writing?
                                                       
>                
>         err = flash_program((void *)&p_base, (void
> *)input_bytes, length, (void **)&err_address);
>                                                       
>                                                       
>                
>         flash_read((void *)&p_base, (void *)readStr,
> length, (void **)&err_address);
>         for(i = 0; i < length; i++)
>                 diag_printf("byte[%d] = %u\n", i,
> readStr[i]) ;
>                                                       
>                                                       
>                
> Thank you very much.
> 
> Giri.
> 
>         return ;
> }
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> -- 
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
> 

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]