* [ECOS] Problems in programming in FLASH - EB40A
@ 2004-08-20 23:43 Giri Raja
2004-08-21 7:54 ` Andrew Lunn
0 siblings, 1 reply; 2+ messages in thread
From: Giri Raja @ 2004-08-20 23:43 UTC (permalink / raw)
To: ecos-discuss
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.
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]);
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [ECOS] Problems in programming in FLASH - EB40A
2004-08-20 23:43 [ECOS] Problems in programming in FLASH - EB40A Giri Raja
@ 2004-08-21 7:54 ` Andrew Lunn
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2004-08-21 7:54 UTC (permalink / raw)
To: Giri Raja; +Cc: ecos-discuss
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-08-21 7:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-20 23:43 [ECOS] Problems in programming in FLASH - EB40A Giri Raja
2004-08-21 7:54 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).