This is the mail archive of the
mailing list for the eCos project.
Re: flash/am29xxxxx flash_program_buf length fix
- From: Andrew Lunn <andrew at lunn dot ch>
- To: Peter Korsgaard <jacmet at sunsite dot dk>
- Cc: ecos-patches at ecos dot sourceware dot org
- Date: Thu, 1 Sep 2005 22:18:05 +0200
- Subject: Re: flash/am29xxxxx flash_program_buf length fix
- References: <email@example.com> <4316C5FE.firstname.lastname@example.org> <email@example.com>
On Thu, Sep 01, 2005 at 09:57:43PM +0200, Peter Korsgaard wrote:
> >>>>> "David" == David Vrabel <firstname.lastname@example.org> writes:
> David> I don't think this is correct. You're going to overwrite the
> David> partial word following the buffer you're writing with garbage.
> True, it isn't perfect, but neither is the current approach of simply
> discarding the last bytes.
> David> I think instead an check (in addition to the check to ensure
> David> the buffer is word-size aligned) needs to be made at the start
> David> of flash_program_buf() to ensure the len is a multiple of word
> David> size. Something like this, I think:
> David> if (len & (CYGNUM_FLASH_INTERLEAVE * CYGNUM_FLASH_WIDTH /
> David> 8 - 1)) return FLASH_ERR_INVALID;
> David> This will require that you fix the caller.
> But then the caller needs to the flash width - is there a simple way
> to do that?
> The problem comes up fairly often in RedBoot here when we update the (gzip
> compressed) application in flash with a simple:
> fis create app
> If you're lucky this compilation exactly takes up a multiple of the
> flash word size and it works, and if not you get a flash verify error
> because the remaining bytes weren't written :/
Special case the last bytes in the driver. You need to build a word
with 0xff for the bytes you don't want to modify when do a write to
flash for the word. The bits set to 1 won't change and the bits you do
want to change will change.