This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: io/flash problem/question
- From: Jay Foster <jay at systech dot com>
- To: 'Gary Thomas' <gary at mlbassoc dot com>, Mark Salter <msalter at redhat dot com>
- Cc: eCos Discussion <ecos-discuss at sources dot redhat dot com>
- Date: Tue, 17 Dec 2002 14:51:48 -0800
- Subject: RE: [ECOS] io/flash problem/question
Perhaps the FLASH_BlankValue defined in
packages/io/flash/current/include/flash_dev.h should be used for the erase
value? It looks to be configurable with the CYGNUM_FLASH_BLANK definition.
I'm not so sure that accessing the flash with 16-bit words is necessarily
better than 8-bit words (there could be an implementation that only works
with 32-bit words - ugh). Perhaps using the flash_data_t size word would be
better? This is the magic used in the flash drivers to access flash arrays
of 1, 2, or 4 chips in parallel (typically 8-, 16-, or 32-bit wide
accesses).
Jay
-----Original Message-----
From: Gary Thomas [mailto:gary@mlbassoc.com]
Sent: Tuesday, December 17, 2002 2:49 PM
To: Mark Salter
Cc: eCos Discussion
Subject: Re: [ECOS] 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
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss