Skip to main content
Topic: Can't load programs to Flash (Read 2816 times) previous topic - next topic

Can't load programs to Flash

I just received my pre-built board from Seeed Studio, and I am trying to load the first network function test demo. The board appears to already have the bootloader installed but whenever I try to load the demo I get a response timeout when trying to erase page 0.
Debug mode tells me that 43520 program words were found in 680 rows and that the bootloader start address is 0x15400.
The dp-wp-stackdemo.v0a.hex hex file is validated ok and the goto user address is 0x153FC and user app address is 0x200.

here is a debug dump:

Initiating download...
      Opening port
      Searching for bl . .
      Found dsPIC33FJ128GP204 fw ver. 1.0.2
      Bootloader placement: 1
      Bootloader size: 1
      Waiting for bootloader to be ready...ok
      Erasing page 0...response timed out
      Tx 8 bytes / Rx 4 bytes / 2.8s

and also

Parsing hex-file...
      Validating hex-file...ok
      Unknown data found, 16 bytes at 0xF80010
      Goto user app address: 0x153FC
      User app address: 0x200
      Flash page 0 is used
      Flash row 0 is used
      Flash row 1 is used
      Flash row 2 is used
      .... etc
      Flash row 678 is used
      Flash row 679 is used
      Config word 0 is used: 0x00CF
      Config word 1 is used: 0x00CF
      Config word 2 is used: 0x0007
      Config word 3 is used: 0xFFF9
      Config word 4 is used: 0xFFFF
      Config word 5 is used: 0xFF7F
      Config word 6 is used: 0x00F7
      Config word 7 is used: 0x0083
      Bootloader start address: 0x15400
      Bootloader start page: 85
      Bootloader end page: 85
      Bootloader start row: 680
      Bootloader end row: 687
      Hex-file successfully parsed


Am I missing something ? Shouldn't it just overwrite the program at the correct address ? How do I get it to erase the existing program and load the new program ?

I don't know what program is currently in the device. It doesn't seem to respond on the network to the MCHPDetect program. Is there any way I can dump out the existing code using MPLAB perhaps ?

Can I test it through the serial port somehow with the bootloader software ? Any suggestions would be appreciated.

Re: Can't load programs to Flash

Reply #1
[quote author="jeffman54"]
I just received my pre-built board from Seeed Studio, and I am trying to load the first network function test demo. The board appears to already have the bootloader installed but whenever I try to load the demo I get a response timeout when trying to erase page 0.
Debug mode tells me that 43520 program words were found in 680 rows and that the bootloader start address is 0x15400.
The dp-wp-stackdemo.v0a.hex hex file is validated ok and the goto user address is 0x153FC and user app address is 0x200.
[/quote]

There is something not quite right about that. Here's what happens when I load the dp-wp-stackdemo.v0a.hex file to my web platform from ds30loader:

Code: [Select]
Initiating download...
      Searching for bl .
      Found dsPIC33FJ128GP204 fw ver. 1.0.2
      Waiting for bootloader to be ready...ok
      Parsing hex-file...
            Validating hex-file...ok
            Hex-file successfully parsed

            87040 program words found in 680 rows
            0 eeprom words found
            8 config words found
      Writing flash...ok
      Download finished
      Tx 132kB / Rx 769 bytes / 24.8s

Quote
Am I missing something ? Shouldn't it just overwrite the program at the correct address ? How do I get it to erase the existing program and load the new program ?

Are you using the copy of ds30loader that came with the web platform? Your output looks rather different to mine (see above).

Re: Can't load programs to Flash

Reply #2
I am using the bootloader that was already loaded on the board from Seeed Studio - fw ver 1.0.2 which appears to be the same as you.

My dump printout was using the debug option under advanced mode in the bootloader GUI software. If I just plug in the device without the advanced settings I get :

Initiating download...
      Searching for bl .
      Found dsPIC33FJ128GP204 fw ver. 1.0.2
      Waiting for bootloader to be ready...ok
      Writing flash...response timed out
      Tx 7 bytes / Rx 4 bytes / 2.3s

So the problem seems to be when I try to write to flash - it doesn't respond because the memory is already loaded with a program.

If I try to overwrite the bootloader program I get :

Initiating download...
      Opening port
      Searching for bl . .
      Found dsPIC33FJ128GP204 fw ver. 1.0.2
      Bootloader placement: 1
      Bootloader size: 1
      Waiting for bootloader to be ready...ok
      Erasing page 0...response timed out
      Tx 8 bytes / Rx 4 bytes / 2.7s

So it would appear that I have a flash write problem (hardware ?) or else the bootloader is corrupted somehow.

Re: Can't load programs to Flash

Reply #3
[quote author="jeffman54"]
My dump printout was using the debug option under advanced mode in the bootloader GUI software.
[/quote]

My ds30loader GUI version is 1.3.1. I don't have a debug option under advanced. Are you sure that you are using the version of ds30loader that came with the web platform software archive?

It is, at the very least, misreading the hex file. The number of program words is exactly half what it should be, but the number of rows is the same. This looks to me like it's expecting a different microcontroller part.

Quote
So the problem seems to be when I try to write to flash - it doesn't respond because the memory is already loaded with a program.

It is flash memory. Seeedstudio was not shipping the web platform with other than the bootloader pre-programmed. In the normal course of events, any program in the flash memory would simply be overwritten when you loaded a new one. That's not the problem.

Quote
If I try to overwrite the bootloader program I get :

The hex file does not include a replacement bootloader. The original bootloader should not be overwritten. Normally ds30loader would not let you try to overwrite it.

Quote
So it would appear that I have a flash write problem (hardware ?) or else the bootloader is corrupted somehow.

I think the bootloader is still ok, the hex file is ok, but there's an issue with what you're using to load it. The number of program words is out by exactly 50%. I would:

0. test the integrity of your web platform archive;
1. delete the existing files and re-extract the files from the archive;
1. ensure you are using the ds30loader that came in the web platform firmware archive;
2. ensure your hex file is 489,816 bytes in size;
3. delete any .xml files in the same directory as the ds30loader;
4. setup the ds30loader, pic family, actual pic part, com port and baud rate (115200);
5. load the hex file.

and try again. It should work :)

Re: Can't load programs to Flash

Reply #4
OK the dsloader GUI I was using was 1.3.5 from the dsloader web site. The dp-wp-stackdemo.v0a.hex hex file is 489,816 bytes in size. The PIC family is set to dsPIC33FJ128GP204. When I tried to overwrite the bootloader, I first set the option under the Advanced tab to allow the overwriting of the bootloader.

Using the version 1.3.1 from the web platform archive, I get :

Initiating download...
      Searching for bl .
      Found dsPIC33FJ128GP204 fw ver. 1.0.2
      Waiting for bootloader to be ready...ok
      Parsing hex-file...
            Validating hex-file...ok
            Hex-file successfully parsed

            87040 program words found in 680 rows
            0 eeprom words found
            8 config words found
      Writing flash...response timed out
      Tx 7 bytes / Rx 4 bytes / 2.6s

The debug option appears in the Options menu when the Advanced mode is set in the View menu.

When in debug mode I get:

Initiating download...
      Searching for bl . .
      Found dsPIC33FJ128GP204 fw ver. 1.0.2
      Waiting for bootloader to be ready...ok
      Parsing hex-file...
            Validating hex-file...ok
            program page 0 is used
            program page 1 is used
            ... etc
            program row 678 is used
            program row 679 is used
            Hex-file successfully parsed

            87040 program words found in 680 rows
            0 eeprom words found
            8 config words found
      Writing flash...
      Erasing page 0 response timed out
      Tx 8 bytes / Rx 4 bytes / 11.3s

So I still appear to have a problem erasing flash :(

Re: Can't load programs to Flash

Reply #5
I have found the problem. The 6V DC adapter I was using had too much AC ripple on the supply voltage. When I used a different adapter with a lot less ripple this is what the bootloader said:

Initiating download...
      Searching for bl .
      Found dsPIC33FJ128GP204 fw ver. 1.0.2
      Waiting for bootloader to be ready...ok
      Writing flash...ok
      Download finished
      Tx 132kB / Rx 769 bytes / 24.8s

Thanks for your help I guess sometimes the problems are not always software related. Now I can see if I can actually get the thing working.

 

Re: Can't load programs to Flash

Reply #6
Glad you've resolved it! Not sure I would have ever guessed it was the DC plug pack - I'll file that away for future reference.