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]

simple Atmel AT91EB40 Flash driver question


The AT91EB40 port uses the flash drivers in
devs/flash/arm/at91 (as far as I can see) and includes
the following code in at91_flash.c:

     if (data[1] == (unsigned short)FLASH_ATMEL_29LV1024) {
         num_regions = 256;    //sector
         region_size = 0x100;  // words in

However, this device actually has 512 sectors with 128 words(16-bit)
per sector

Q1. Is num_regions = 256 because only the top half
of the flash is being made accessible for programming?
Total flash is 0x01000000 to 0x0101FFFF
eCos allows use of 0x01010000 onwards

Q2. Is region_size = 0x100 because this is expressed in bytes
rather than words? I take it the region_size means the same as sector size.

Current init code is below below.

Thanks
Pete


int
flash_hwr_init(void)
{
     unsigned short data[4];
     extern char flash_query, flash_query_end;
     typedef int code_fun(unsigned char *);
     code_fun *_flash_query;
     int code_len, stat, num_regions, region_size;

     // Copy 'program' code to RAM for execution
     code_len = (unsigned long)&flash_query_end - (unsigned long)&flash_query;
     _flash_query = (code_fun *)flash_info.work_space;
     memcpy(_flash_query, &flash_query, code_len);
     HAL_DCACHE_SYNC();  // Should guarantee this code will run

     stat = (*_flash_query)(data);
#if 0
     (*flash_info.pf)("stat = %x\n", stat);
     dump_buf(data, sizeof(data));
#endif

     if (data[0] != FLASH_Atmel_code) {
         (*flash_info.pf)("Not Atmel = %x\n", data[0]);
         return FLASH_ERR_HWR;
     }

     if (data[1] == (unsigned short)FLASH_ATMEL_29LV1024) {
         num_regions = 256;
         region_size = 0x100;
     } else {
         (*flash_info.pf)("Unknown device type: %x\n", data[1]);
         return FLASH_ERR_HWR;
     }

     // Hard wired for now
     flash_info.block_size = region_size;
     flash_info.blocks = num_regions;
     flash_info.start = (void *)0x01010000;
     flash_info.end = (void *)(0x01010000+(num_regions*region_size));
     return FLASH_ERR_OK;
}


-- 
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]