Author Topic: New software uploads but does not change.  (Read 19267 times)

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
New software uploads but does not change.
« on: November 20, 2008, 11:28:22 PM »
I have an application which is working as expected. I use an AT45DB321 for file system and sw upload. I relinked the application to start at 0x1000. I used the Axiom programmer to program both .ELFs into flash. All seems to work fine. I set both the uTaskerConvert and the bootloader for no encryption. Using the "Administration Page" in the target, it appears that I can upload the new "H_Upload.bin" successfully. When the target resets (either from the software or a power cycle) the old program is still running. I modified the boot loader code as follows to account for a second device on the SPI pins and because I use the nWP pin on the memory chip.

Code: [Select]
extern int fnConfigSPIFileSystem(void)
{
  DDRAS |= PORT_AS_BIT3;
  _SETBITS(AS, PORT_AS_BIT3);                   // raise RC531 nCS   ewan

  DDRAN |= PORT_AN_BIT7;
  _SETBITS(AN, PORT_AN_BIT7);                   // raise AT45DB nWP  ewan

    PORTQS |= QSPI_CS0_LINE;                                         
    DDRQS |= QSPI_CS0_LINE;                                              // Drive CS line high

    PQSPAR |= 0x0015;                                                    // Set QSPI_CLK, QSPI_DIN and QSPI_DOUT on QS port

    QMR = ((QSPI_MSTR | QSPI_8BITS) | 2);                                // set mode and fastest speed

    if (fnCheckAT45dbxxx() == NO_SPI_FLASH_AVAILABLE) {
        QMR = 0;                                                         // disable SPI if no chip connected
        return 1;
    }
    return 0;
}

The affected ports work fine in the application. Any clues?

Regards,

Ewan.

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: New software uploads but does not change.
« Reply #1 on: November 21, 2008, 02:01:50 AM »
I added the following code to "M5223x_boot.c".

Code: [Select]
        case DEVICE_ID_1_DATA_FLASH_32M:
            return AT45DB321D;

And in "fnCheckNewCode" it returns the wrong value for "file_header->usMagicNumber".

Thanks for the help.

Ewan.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: New software uploads but does not change.
« Reply #2 on: November 21, 2008, 02:45:40 AM »
Hi Ewan

If the magic number doesn't match, the uploaded code will be ignored.
Is the header otherwise correct or is it all wrong?

Check that the setting for the magic number is the same in the boot code as in the converter bat file and ensure the SPI FLASH is really blank before uploading (I remember having some chips which were not blank and this can cause a corrupted file content). Check that the location to which the file is being uploaded to is the same location as the boot loader is reading it from.

Finally, if you are uploading to the file system in SPI FLASH then you will see the file when you do a DIR in FTP. You can do a GET of the file to check that it's content is really identical to that which you uploaded. After a successful firmware update the file is deleted and so is never visible. If you are using the method to a fixed location (without it being in the file system) this can also be downloaded via FTP using "GET HS.bin", although it can not be seen with DIR (a useful trick for checking its content).

Regards

Mark

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: New software uploads but does not change.
« Reply #3 on: November 21, 2008, 05:16:26 PM »
It is all wrong. How do I ensure the SPI is really blank? So far, the file is in the memory chip. It has the name "F.BIN" and is 33kBytes in size. The file "H_Upload.bin" is 70kBytes in size so it looks as though the upload is really bad. The files in the chip are:-

0.HTM to 8.HTM, A.HTM, B.GIF then  F.BIN.

Thanks,
Ewan.

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: New software uploads but does not change.
« Reply #4 on: November 21, 2008, 05:22:36 PM »
If I drag and drop using FTP the file appears to arrive intact and with its own name. I then refresh the FTP window and the file reverts to F.BIN with the smaller size.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: New software uploads but does not change.
« Reply #5 on: November 21, 2008, 06:30:48 PM »
Hi Ewan

My first idea is that the file system is not set up correctly. I could imagine the following:
- If the size is set up to allow files from '0'..'9' and 'A'..'F' (that is, limited to this range) any attempts to load a file 'H...* will cause its location to default to the last available one and also be limited to the available memory size from this position. In this case, the copy would complete but the location will give the file the name 'F.*' and its length would be limited to one single file block - the rest is cut off.

Assuming you have defined the file granularity to be 32k (actually 32k * (264/256) when using the ALMEL SPI FLASH due to its block size - 33'792 bytes - header size gives max. file size of 33'787 - possibly displayed as 33k) and the file system size to be 16 x FILE GRANULARITY (approx. 512k) this is probably exactly what happens.

Looking more closely, you say that you are using the AT45DB321D. This has a page size of 528. Check that you have configured correctly for this chip (#define SPI_FLASH_AT45DB321 in app_hw_m5223X.h should automate this). Since this is a big chip you can increase the file system size to 1Meg so that it then fits correctly with this name.

Thinking about it, this may be a problem with the demo configuration when using the larger SPI FLASH page sizes.
Tell me if this is so or whether it was a mistake at your end.

Good luck

regards

Mark



Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: New software uploads but does not change.
« Reply #6 on: November 21, 2008, 08:37:47 PM »
Mark,

I changed the FILE_SYSTEM_SIZE as shown below.

Code: [Select]
#ifdef FLASH_FILE_SYSTEM
    #if defined SPI_FILE_SYSTEM                                          // this is a test setup for external SPI FLASH, with the parameters at the end of internal 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)
        #if SINGLE_FILE_SIZE < 20000                                     // {36}
            #define FILE_SYSTEM_SIZE (64*SINGLE_FILE_SIZE)               // 1Meg reserved for file system (plus parameter blocks) {34} [PAR_BLOCK_SIZE removed]
        #else
//            #define FILE_SYSTEM_SIZE (16*SINGLE_FILE_SIZE)               // 1Meg reserved for file system {35}
            #define FILE_SYSTEM_SIZE (32*SINGLE_FILE_SIZE)   // ewan     // 1Meg reserved for file system {35}
        #endif
    #else                                                                // this is the normal set up for internal FLASH
        #if defined M52210DEMO                                           // {19}
            #define PARAMETER_BLOCK_START 0xe000                         // {34} FLASH location at 56k start
            #define uFILE_START 0xf000                                   // FLASH location at 60k start

            #define SINGLE_FILE_SIZE (1*FLASH_GRANULARITY)               // each file a multiple of 2k
            #define FILE_SYSTEM_SIZE (4*SINGLE_FILE_SIZE)                // 8k reserved for file system
        #elif defined M52211EVB || defined M52221DEMO                    // 64k file system to allow USB SW upload to be tested
            #define PARAMETER_BLOCK_START 0xf000                         // FLASH location at 60k start
            #define uFILE_START 0x10000                                  // FLASH location at 64k start

            #define SINGLE_FILE_SIZE (1*FLASH_GRANULARITY)               // each file a multiple of 2k
            #define FILE_SYSTEM_SIZE (32*SINGLE_FILE_SIZE)               // 64k reserved for file system
        #else
            #define PARAMETER_BLOCK_START 0x18000                        // {34} FLASH location at 96k start
            #define uFILE_START 0x19000                                  // FLASH location at 100k start

            #define SINGLE_FILE_SIZE (1*FLASH_GRANULARITY)               // each file a multiple of 2k
            #define FILE_SYSTEM_SIZE (78*SINGLE_FILE_SIZE)               // 156k reserved for file system
        #endif
    #endif
#else
    #define PARAMETER_BLOCK_START 0x3f000                                // {40} FLASH location at 2 parameter blocks short of end of internal FLASH (suitable for 25k FLASH size)
#endif

This fixed the name change and the croping of the file. I checked that the file retrieved from the chip is identical to the original. I checked that the length reported in the header is correct along with the magic number of 0x1234. I do not know about the checksum.

When I use the debugger, however, "file_header->usMagicNumber" reports 0x6c3e and the length is 1013478509.
Clearly some progress has been made but I am not there yet. Any other ideas while I keep digging will be appreciated.

Thanks,
Ewan.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: New software uploads but does not change.
« Reply #7 on: November 21, 2008, 09:16:46 PM »
Ewan

Yes, this is a step in the right direction. I think that the upload is correct so there must be something still in the boot loader setup which is not correct.

- have you set #define SPI_SW_UPLOAD in the boot loader so that it is really working from external SPI FLASH?

- when you step into the function fnCheckNewCode() you can see the pointer it is using to get the file (UPLOAD_FILE_LOCATION). Is this correct? By my calculations, your file 'H.*' will be loaded at 0x7bc00 from the beginning of the SPI FLASH chip. This is usually located after the internal memory (0x40000) and so the pointer should have the value 0xbbc00 to cause it to get the start of the file. If this is not correct it may be retrieving data from within the file which will not be recognised.
- the following define may position it correctly:  #define UPLOAD_FILE_LOCATION   (unsigned char *)((256*1024) + (0x84000 - 0x8400))
- ensure that #define SPI_FLASH_PAGE_LENGTH  528 is set in the boot load config

Regards

Mark

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: New software uploads but does not change.
« Reply #8 on: November 21, 2008, 10:35:15 PM »
Mark,

I checked and modified the page size (it was incorrect). SPI_SW_UPLOAD was correct. I used your formula for UPLOAD_FILE_LOCATION and the following results:-
1) UPLOAD_FILE_LOCATION == 0xbbc00
2) FILEHEADER == 5
3) SIZE_OF_UPLOAD_HEADER == 8
4) magic number = 0x000c
5) ptrFile == 0xbbc0d

Onward!
Ewan.

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: New software uploads but does not change.
« Reply #9 on: November 22, 2008, 06:52:15 PM »
Another day.

I noticed that I had not defined SPI_FILE_SYSTEM in "config.h". When I changed this I got redefine errors for uFILE_START and SINGLE_FILE_SIZE. I then replaced the files uTaskerBootLoader.c, config.h and types.h with copies of the originals and started again but to no avail. I get these errors whether or not I define FLASH_FILE_SYSTEM. I seem to remember reading some time ago that you cannot have SPI_SW_UPLOAD with FLASH_FILE_SYSTEM, but I can no longer find the reference. It appears I am missing some basics but, after reading "uTasker - uFileSystem" again, I am no further along. What can it be?

Regards,
Ewan.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: New software uploads but does not change.
« Reply #10 on: November 22, 2008, 08:11:00 PM »
Ewan

SPI_FILE_SYSTEM should not be used. See the following:
http://www.utasker.com/forum/index.php?topic=76.msg1722#msg1722

As I understand it, your application is working correctly (you could read it back correctly).
The boot needs only SPI_SW_UPLOAD.

When the boot runs and reads the file (from the correct location) it should return a length (equal to the new SW file plus the header added by the conversion utility) and then the header content should be correct. I think that you were getting this far but maybe the content is still not as expected. I don't think that this is due to an incorrect basic configuration (SPI_SW_UPLOAD is all that is really needed) but possibly still a detail in the exact memory location. Is the file being read slightly after the real start? If you check the header that it returns can you see this as a block of data somewhere in the uploaded file?

Regards

Mark

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: New software uploads but does not change.
« Reply #11 on: November 25, 2008, 12:03:46 AM »
Mark,

I checked the calculations and I find that the file should be at (0x8400 * 17) + 0x40000 = 0xcc400. I debuged the application and it is there with its headers in good order. I then checked the bootloader settings and found some quite wrong (I think). The current settings I have are:-

Code: [Select]
        #define uFILE_START 0x3f000                                      // FLASH location near end
        #define SINGLE_FILE_SIZE (0x8400)                                // each file a multiple of 32k
        #define FILE_SYSTEM_SIZE (32*SINGLE_FILE_SIZE)                   // 1meg reserved for file system

        #ifdef SPI_SW_UPLOAD
            #define QSPI_CS0_LINE          PORT_QS_BIT3                  // CS0 line used when SPI FLASH is enabled
            #define SPI_CS0_PORT           PORTQS                        // for simulator compatibility {5}
            #define CS0_LINE               QSPI_CS0_LINE                 // for backward compatibility {5}

            #define SPI_FLASH_ATMEL                                      // {9} default if nothing else defined
            #define SPI_FLASH_PAGE_LENGTH  528                           // standard page size (AT45DB041 B-device only allows 256)
            #define SPI_FLASH_BLOCK_LENGTH (8*SPI_FLASH_PAGE_LENGTH)     // block size - a block can be deleted
            #define SPI_FLASH_SECTOR_LENGTH (64*4*SPI_FLASH_PAGE_LENGTH) // exception sector 0a is 2k and sector 0b is 62k
            #define SPI_FLASH_PAGES        2048
            #define SPI_DATA_FLASH_SIZE    (SPI_FLASH_PAGES*SPI_FLASH_PAGE_LENGTH)
        #endif

Now it blows its stack or something as it ends up in the default interrupt handler.

Any ideas?

Thanks for you patience.

Regards,
Ewan.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: New software uploads but does not change.
« Reply #12 on: November 25, 2008, 12:54:51 AM »
Hi Ewan

Can you run your application project in the uTasker simulator? If you can, please do the following:
1. Test the firmware upload using it. It should upload and then reset (as teh target does).
2. In the directory \Applications\uTaskerV1.3\Simulator you will find a file called AT45DBXXX.ini which has just been saved. Zip this and send it to me.
The file contains the contents of the simulated SPI FLASH chip that you are using so I can see what the content is like and exactly where it is located in the memory.
3. Send me also your BM-Convert.bat content (best not send the bat file itself because bat files often cause emails to get blocked) so that I know exactly which setting you have been using.

What I do is then run the boot loader project (set up as you have shown) and I can get it to read in your SPI FLASH content. Then I should be able to tell you exactly what is not correct. Once I get this file it shouldn't take more than a few minutes to see what needs to be adjusted. (I have in fact done this quiet a lot of times because it can be a bit tricky to get right, but one set up it then works very well...).

Regards

Mark

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: New software uploads but does not change.
« Reply #13 on: November 25, 2008, 02:33:49 AM »
Mark,

OK, will do. But....... As luck would have it my VC6 has crashed and I have to repair that first.
I don't know how you have the time but I'm glad that you do.

Best Regards,
Ewan.

Offline ewan

  • Newbie
  • *
  • Posts: 43
    • View Profile
Re: New software uploads but does not change.
« Reply #14 on: November 26, 2008, 12:14:21 AM »
Mark,

Here are the files. I sent them by e-mail too.

Regards,
Ewan.