Author Topic: bootloader problem  (Read 9304 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
bootloader problem
« on: November 12, 2008, 03:54:51 PM »
Hi Mark
  I seem to be having problems with the bootloader (I have 1 atmel spi eeprom for this), I am using CW7. 

I done the following: Bootloader project.
1. #define SPI_SW_UPLOAD   within config.h
2. #define _ENCRYPTED  within utaskerbootloader.c within #if defined (_M5223X)
3. erased full memory, then programmed as normal.

I done the following: Application project.
1.Selected bare_min_app_rom_spi
2.#define SPI_SW_UPLOAD   within config.h within #ifdef _M5223X
3.compiled, and erased from 0x1000 to end
4.programmed from 0x1000 to end..

I then ran the board which works.. I changed a bit of code, then compiled the application and ran "bm-convert_encrypt.bat" .

Within my windows application I sent down the encrypted file to the SPI eeprom. I send one page at a time, which gets programmed starting at page 0, then read in and verified with the data sent. An Ack is sent back informing the windows app to send the next page, or NAK if error. The next page gets sent, and so on.
I have a routine that also verfies that the file sent matches the one in spi eeprom

I then restart the board (pressing the restart button), but the same original app is ran. The new one doesnt get copied. Is my procedure wrong?

Do I have to change some location of the start of the file system, so its past the 256k for firmware updates? If so what do I change?
 
Regards
Neil


« Last Edit: November 12, 2008, 06:00:20 PM by neil »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: bootloader problem
« Reply #1 on: November 12, 2008, 09:04:25 PM »
Hi Neil

I suspect that the problem is that the boot loader is not recognising the format of the program stored in SPI FLASH. It expects it to be a uFileSystem file, which means that it has a small file header and then the file content. If you are loading in a binary fashion without saving it as a 'file' it will then not be recognised as valid data.

The uFileSystem format is very simple and there would be two solutions:
1. Save it using the uFileSystem file write functions, which will automatically do this
2. Add the header to the binary file which you created using bm-convert_encrypt.bat. This could be performed as a post convert step which simply adds the file length + the file type to the beginning of the data - see http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF for the exact format (or in the code)

The boot loader is also easy to debug. If you set a break point in fnCheckNewCode() you can see that the file length and a few values in the header are first check and if anything doesn't match it simply quits. Therefore you can identify at which step it gives up to know why it doesn't complete to upgrade.

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: bootloader problem
« Reply #2 on: November 13, 2008, 01:23:06 PM »
Hi Mark,
  Thanks for the information. Worked great, I used method 2, where I added the length if file to send and the file type to the start of file. The type of file  I used was 6 (BIN), as this works I assume its okay?

I also want to use the remaining parts of the eeprom for file system ( I have the 1MB part), what do I set the #defines too to make sure it doesnt overlap the firmware being saved into memory? I am using the 52235 processor.

Many thanks
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: bootloader problem
« Reply #3 on: November 13, 2008, 02:27:41 PM »
Hi Neil

If you set up the file system to avoid the block you would like to reserve for firmware uploading you will have no problems in doing this.

Regards

Mark