µTasker Forum

µTasker Forum => ATMELTM AT91SAM7X and AVR32 => Topic started by: kmjackson on December 13, 2010, 09:19:54 AM

Title: Different FileLength
Post by: kmjackson on December 13, 2010, 09:19:54 AM
Hi Mark,

I have a problem with the uGetFileLength (...) function.  I'm using the EVK1105(AVR32) with a  AT45DB642D Flash memory device.  I'm loading a webpage with your bat file WebPagesAVR32\Copy_all.bat.  Here's my problem, when I put a breakpoint at return (Len) it shows a length = 1151, which is correct.  Now, when it is time to retrieve the file from the external flash and send it to my browser returns a file length of 1058.  Maybe, it has something to do with the 1056 Bytes per Page. When I make the webpage smaller, I don't have a problem with the external flash.  Any Ideas?  Am I missing a compilation switch? BTW, this doesn't happen when I use the internal flash.


//During the writing process
extern MAX_FILE_LENGTH uFileClose(MEMORY_RANGE_POINTER ptrFile){
 ... 
  return (Len);  // Shows 1151 Bytes
}

// Retreiving the eab pages from external Flash
// get the length of the file to be displayed
static int fnDoWebPage(CHAR *cFileName, HTTP *http_session){
 ...
   http_session->FileLength = uGetFileLength(ucFile);  // Shows 1058
}
Title: Re: Different FileLength
Post by: mark on December 14, 2010, 04:51:01 PM
Hi

Essentially there shouldn't be any difference been internal and external memory.

Check where the end of the file system is becasue if a file reaches the end its length will be restricted to the available space.

Regards

Mark
Title: Re: Different FileLength
Post by: kmjackson on December 30, 2010, 05:49:34 PM
Hi Mark,

I finally got back to this issue and the problem was with the page size.  I’m using the EVK1105 with the AT45DB642D FLASH device.  The AT45DB642D has the option to operate with two different page sizes, 1024 vs. 1056 (standard).  uTasker is configured to used the 1056 page size as it should since this is the way the board is shipped.  Sometime is the past, I changed my page size to 1024.  Once the chip has been configured for 1024, it can not be changed back.  Since I was stuck with the 1024 page size, I stepped through the code and made the following changes:

In AVR32.c
Function: extern void fnGetParsFile(unsigned char *ParLocation, unsigned char *ptrValue, MAX_FILE_LENGTH Size)

FROM:
fnSPI_command(CONTINUOUS_ARRAY_READ, (unsigned long)((unsigned long)(usPageNumber << 11) | (usPageOffset)), _EXTENDED_CS ptrValue, Size);

TO:
fnSPI_command(CONTINUOUS_ARRAY_READ, (unsigned long)((unsigned long)(usPageNumber << 10) | (usPageOffset)), _EXTENDED_CS ptrValue, Size);


Also in spi_flash_avr32_atmel.h,
Function:  static void fnSPI_command(unsigned char ucCommand, unsigned long ulPageNumberOffset, volatile unsigned char *ucData, MAX_FILE_LENGTH DataLength)

FROM:       
ucCommandBuffer[0] = (unsigned char)(ulPageNumberOffset >> 5);       
ucCommandBuffer[1] = (unsigned char)(ulPageNumberOffset << 3);

TO:
ucCommandBuffer[0] = (unsigned char)(ulPageNumberOffset >> 6);             
ucCommandBuffer[1] = (unsigned char)(ulPageNumberOffset << 2);



Kenneth