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: io/flash problem/question


On Tue, 2002-12-17 at 15:42, Mark Salter wrote:
> I'm porting RedBoot to a board which does not allow byte access
> to flash. This caused a bus error in flash_erase.c where it checks
> for an already erased block using byte sized accesses. I made the
> following quick hack in my sandbox, but was wondering if this is
> okay to check in. Ideally, we should have a flash access interface
> and not access it directly with pointers. Also, don't some flash
> use 0x00 for an erased value?
> 

I don't think that any of today's devices use 0x00.

As for the indirect access, yes, this is long overdue.  Happily,
there are only a few places where the FLASH is accessed this way
and it should be fairly easy to add this.  

> --Mark
> 
> 
> Index: io/flash/current/src/flash.c
> ===================================================================
> RCS file: /cvs/ecos/ecos/packages/io/flash/current/src/flash.c,v
> retrieving revision 1.20
> diff -u -p -5 -r1.20 flash.c
> --- io/flash/current/src/flash.c	23 May 2002 23:06:16 -0000	1.20
> +++ io/flash/current/src/flash.c	17 Dec 2002 22:34:03 -0000
> @@ -215,17 +215,16 @@ flash_erase(void *addr, int len, void **
>      HAL_FLASH_CACHES_OFF(d_cache, i_cache);
>      FLASH_Enable(block, end_addr);
>      while (block < end_addr) {
>          // Supply the blocksize for a gross check for erase success
>          int i;
> -        unsigned char *dp;
>          bool erased = true;
> -        unsigned short *tmp_block;
> +        unsigned short *tmp_block, *dp;
>  
> -        dp = (unsigned char *)block;
> -        for (i = 0;  i < flash_info.block_size;  i++) {
> -            if (*dp++ != (unsigned char)0xFF) {
> +        dp = block;
> +        for (i = 0;  i < flash_info.block_size;  i += sizeof(*dp)) {
> +            if (*dp++ != 0xFFFF) {
>                  erased = false;
>                  break;
>              }
>          }
>          if (!erased) {
> 

This change should be safe for now, but we should look into 
fixing things completely.

-- 
------------------------------------------------------------
Gary Thomas                 |
MLB Associates              |  Consulting for the
+1 (970) 229-1963           |    Embedded world
http://www.mlbassoc.com/    |
email: <gary@mlbassoc.com>  |
gpg: http://www.chez-thomas.org/gary/gpg_key.asc
------------------------------------------------------------


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


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