This is the mail archive of the ecos-patches@sourceware.org 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: flash/am29xxxxx flash_program_buf length fix


On Thu, Sep 01, 2005 at 09:57:43PM +0200, Peter Korsgaard wrote:
> >>>>> "David" == David Vrabel <dvrabel@arcom.com> 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.

        Andrew


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