Author Topic: Bootloader and SPI FLASH  (Read 11342 times)

Offline luizpedrini

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Cianet Networking
Bootloader and SPI FLASH
« on: November 30, 2009, 08:34:07 PM »
Hi,

I´m using the M522XX with an external flash. Now, i´m trying to upload a new software.

I do like usuall. I have send the H_Ipload.bin via FTP, turn off and on the boar, but the file is still in the FTP.

Can someone help me out with this configuration?.

thanks.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Bootloader and SPI FLASH
« Reply #1 on: December 01, 2009, 12:13:46 PM »
Hi

If the uploaded file remains in the external SPI FLASH it means that the boot loader is not recognising it.
This is due to a mis-match between the uploaded file and the boot loader configuration.
Check the following:
- the boot loader must be configured for SPI_SW_UPLOAD and its configuration for the following must match with the settings used when converting the application file:
UPLOAD_FILE_LOCATION, UTASKER_APP_START, UTASK_APP_LENGTH, VALID_VERSION_MAGIC_NUMBER, ucKey[]
- ensure that encryption is set correctly (it may be that encryption is active but not being used)
- finally check that your application is being linked to the correct start address (this will however not be a cause of the file not being recognised).

You should find all details in http://www.utasker.com/docs/uTasker/uTaskerBoot_003.PDF

Regards

Mark


Offline luizpedrini

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Cianet Networking
Re: Bootloader and SPI FLASH
« Reply #2 on: December 01, 2009, 01:28:46 PM »
Hi Mark,

We are using the AT45DB081 and following the configuration shown on uFileSystem in SPI FLASH document (http://www.utasker.com/docs/uTasker/uTaskerFileSystemSPI_FLASH_003.PDF).


We keep the parameters block on the end of internal flash, while the file system is on the SPI FLASH.

We believe that the problem is in the bootloader FILE_LOCATION. We understood that the upload_file_location points to the end of the file system rather then to a specific file.

How can us associate a FILE_LOCATION (address) with the initial char of the file. I´m mean: what will be the address of H.BIN??

My SPI FLASH configuration on uTasker

config.h:
Code: [Select]
#define SPI_FILE_SYSTEM
#define FLASH_FILE_SYSTEM
#define FILE_GRANULARITY (8*SPI_FLASH_BLOCK_LENGTH)
#define uFILE_SYSTEM_START (MEMORY_RANGE_POINTER)(uFILE_START)
#define uFILE_SYSTEM_END   (MEMORY_RANGE_POINTER)(uFILE_START + FILE_SYSTEM_SIZE)

app_hw_xx.h
Code: [Select]
#define FLASH_START_ADDRESS (0x00000000)
#define SIZE_OF_FLASH              (256*1024)

//#define SPI_FLASH_SST25                                          // use SST SPI FLASH rather than ATMEL
//#define SPI_FLASH_ST                                             // use ST FLASH rather than ATMEL
//#define SPI_DATA_FLASH                                           // FLASH type is data FLASH supporting sub-sectors (relevant for ST types)
#define SPI_FLASH_AT45DB081

#define SPI_FLASH_PAGE_LENGTH 264
#define SPI_FLASH_BLOCK_LENGTH (8*SPI_FLASH_PAGE_LENGTH)             // block size - a block can be deleted
#define SPI_FLASH_PAGES         (4*1024)                     // 1Meg part
#define SPI_DATA_FLASH_0_SIZE   (SPI_FLASH_PAGES*SPI_FLASH_PAGE_LENGTH)
#define SPI_FLASH_START        (FLASH_START_ADDRESS + SIZE_OF_FLASH)     // SPI FLASH starts immediately after FLASH

#define PARAMETER_BLOCK_START 0x3f000                            // {34} FLASH location at 2 parameter blocks short of end of internal FLASH
#define uFILE_START 0x40000                                      // immediately after internal FLASH
#define SINGLE_FILE_SIZE (FILE_GRANULARITY)                      // each file a multiple of 16k (64k ST)
#define FILE_SYSTEM_SIZE (64*SINGLE_FILE_SIZE)
#define PARAMETER_BLOCK_SIZE    FLASH_GRANULARITY                    // use the smallest size for the device
#define PAR_BLOCK_SIZE  (2*PARAMETER_BLOCK_SIZE)

Boot definitions

config.h
Code: [Select]
#define SPI_SW_UPLOAD                                                  // new SW is situated in SPI FLASH {1}{2}
//#define SPI_FLASH_SST25                                                // {15} use SST SPI FLASH rather than ATMEL
//#define SPI_FLASH_ST                                                   // define that we are using ST FLASH rather than default ATMEL {9}
//#define SPI_DATA_FLASH

//#define USE_PARAMETER_BLOCK                                            // enable a parameter block for storing and retrieving non-volatile information
 #define USE_PAR_SWAP_BLOCK                                           // we support a backup block which can be restored if desired

//#define SPI_FILE_SYSTEM                                              // we have an external file system via SPI interface, rather than internal in FLASH
#define FLASH_FILE_SYSTEM                                            // we have an internal file system in FLASH

bootloader.c
Code: [Select]
#define UPLOAD_FILE_LOCATION   (uFILE_SYSTEM_END + 0)            // start of SPI FLASH {3}
#define UTASKER_APP_START      0x1000                            // external SPI FLASH solution requires two FLASH block for the boot code
#define UTASK_APP_LENGTH       (MAX_FILE_LENGTH)(0x18000 - UTASKER_APP_START)// 92k


Best Regards.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Bootloader and SPI FLASH
« Reply #3 on: December 01, 2009, 10:25:31 PM »
Hi

It looks as though the boot loader is expecting the firmware to be located at the start of the external SPI FLASH (#define UPLOAD_FILE_LOCATION   (uFILE_SYSTEM_END + 0)).

If you upload a file called H.bin it will be located at the 18th File block in the uFilesystem (see \Applications\uTaskerV1.4\WebPages\WebPagesM5223X\FileSystem for some references). Assuming you have a file size of 16k, this will give #define UPLOAD_FILE_LOCATION   (uFILE_SYSTEM_END + 0x44000)

Note that it is also possible to test this in the uTasker simulator:
1) Run the application in the simulator and perform a file upload.
2) Close the simulator normally so that the memory is saved to the hard disk.
3) Copy the file AT45DBXXX.ini from the application simulation directory to the boot loader simulation directory.
4) Run the boot loader in the simulator. It will load the SPI FLASH content and you can step through the code to ensure that it is reading the data from the correct location and that the data content matches.

Note that AT45DBXXX.ini is a binary image of the SPI FLASH and so can also be opened in a binary editor to check exactly where the data is location.

Regards

Mark





Offline luizpedrini

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Cianet Networking
Re: Bootloader and SPI FLASH
« Reply #4 on: December 03, 2009, 02:42:08 PM »
Hi Mark,

I have been done some tests here. I´ve changed the UPLOAD_FILE_LOCATION to uFILE_SYSTEM_END + 0x44000, but still doesn´t worked.

So i checked that when I upload a H.bin file, it is allocated in the address 0x86200 what gives uFILE_SYSTEM_END + 042200.

Changing again the UPLOAD_FILE_LOCATION to uFILE_SYSTEM_END + 042200, the upload process worked out.

I´m not sure on what causes this difference. Can you help me?

Thanks.
Regards.
« Last Edit: December 03, 2009, 02:44:28 PM by luizpedrini »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Bootloader and SPI FLASH
« Reply #5 on: December 03, 2009, 03:24:00 PM »
Hi

I am also not sure but it may be that one of my define assumptions was incorrect or I made a mistake in calculating an offset (?).

However, if the upload process is successful it means that the boot loader is configured correctly to work together with your application and also the upload converter utility. As long as nothing is changed it will remain correct.

I just however remembered that the SPI FLASH that you are using has 264 bytes per sector instead on 256. I didn't respect that with my calculation so it probably explains the slight offset...
Assuming that the file location is the 16th block (rather than 17th) and the file size of 16k*(264/256) rather than 16k this gives 0x42000, which is closer.

I can't explain where the extra 0x200 (512 bytes) is coming from though...

Regards

Mark



Offline luizpedrini

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Cianet Networking
Re: Bootloader and SPI FLASH
« Reply #6 on: December 03, 2009, 05:19:39 PM »
Hi Mark.

I was also trying to calculate this after I realize the difference in the flash sector size (564 rather than 256).

After that, I decided to use 256k flash block, that makes things easier.

Thanks for your help.

Best Regards.