Bug 58150

Summary: AT91 flash driver inconsistencies
Product: [Retired] eCos Reporter: Jesper Skov <jskov>
Component: Flash driverAssignee: eCos bugs internal list <es-ecos-bugs-int>
Status: CLOSED WONTFIX QA Contact: eCos bugs internal list <es-ecos-bugs-int>
Severity: medium Docs Contact:
Priority: medium    
Version: CVS   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-06-20 16:10:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jesper Skov 2002-01-10 06:53:00 UTC
Gary,

Thanks for doing the Atmel AT91/EB40 work in Ecos.  I've noticed some
inconsistencies in flash_program_buf.c

Below is a copy of devs/flash/arm/at91/current/src/flash_program_buf.c
with some notes.

-Tim


int
flash_program_buf(volatile unsigned short *addr, unsigned short *data, int len)
{
    volatile unsigned short *PAGE, *ROM;
    int timeout = 50000;
    int cache_on;
    int i, offset;
    unsigned short hold[FLASH_PAGE_SIZE/2];

    HAL_DCACHE_IS_ENABLED(cache_on);
    if (cache_on) {
        HAL_DCACHE_SYNC();
        HAL_DCACHE_DISABLE();
    }

#
# If len must == FLASH_PAGE_SIZE, then you can't do "partial updates."
#
    if (len != FLASH_PAGE_SIZE) {
        return FLASH_LENGTH_ERROR;
    }

    ROM = (volatile unsigned short *)((unsigned long)addr & 0xFFFF0000);
    PAGE = (volatile unsigned short *)((unsigned long)addr & FLASH_PAGE_MASK);

#
# Seems to want to allow "partial updates."
#
    // Copy current contents (allows for partial updates)
    for (i = 0;  i < FLASH_PAGE_SIZE/2;  i++) {
        hold[i] = PAGE[i];
    }

#
# For the merge, a partial update where offset != 0, will
# cause the coping will run off the end of both arrays. :-(
# Unless len < FLASH_PAGE_SIZE - offset.  Maybe this test on len should
# replace the one above????
#
    // Merge data into holding buffer
    offset = (unsigned long)addr & FLASH_PAGE_OFFSET;
    for (i = 0;  i < (len/2);  i++) {
        hold[offset+i] = data[i];
    }

    // Now write the data

    // Send lead-in sequence
    ROM[FLASH_Key_Addr0] = FLASH_Key0;
    ROM[FLASH_Key_Addr1] = FLASH_Key1;

etc

Comment 1 Alex Schuilenburg 2003-06-20 16:10:46 UTC
This bug has moved to http://bugs.ecos.sourceware.org/show_bug.cgi?id=58150