Topic : Cannot flash STM8AF6166 with Rlink and STM8_pgm

Forum : ST7/STM8

Original Post
Post Information Post
July 30, 2009 - 11:13am
Guest

Hello,

I have a problem with my Rlink and the tools.

I tried to flash my STM8AF6166-Board with the STM8_pgm.exe Tool.
But it fails. See the following log:

C:\Program Files\Raisonance\Ride\bin>.\STM8_pgm TSTM8AF616 R W B E FmyHex.hex
STM8_pgm: software for programming STM8 devices using a RLink as master.
Copyright Raisonance 2007-2009.

(0) Connecting to RLink... OK

(0) Selecting target: STM8AF616... OK

(0) Reading RLink Serial Number... OK
RLink Serial Number: dngSTD000002891
Reading RLink Firmware Version... OK
RLink Firmware Version: 0.0.3

(0) Please press enter to go on...
OK

(10) Connecting to target STM8...
!!! Error 203: Die Id Check failed.
Please make sure you have selected the correct target STM8 device.

What could be the problem?
I have the same problem in the GUI of RFlasher7.
I tried some different devices, but it always failed.

When I'm flashing with the STVP-Tool everything works fine.

Thank you in advance for your help!

Replies
Post Information Post
+1
0
-1
July 30, 2009 - 11:30am
Raisonance Support Team

Hi,

I will ask ST to send me one of these chips, as I only have STM8AF51A8 chips in the STM8A family. (and no problem with them ;) ) But that will take several days at least. Can you please tell me exactly everything that is written on your chip, so that I can request a chip of the same batch?

In the meantime, you can deactivate the Die ID check by modifying this file:
\bin\STM8_SWIM_ProductInfo.txt

Open the file in a text editor, search it for "DieCheckMask" and change the value of the first two occurrences of this attribute to zero. If it's only a problem of die ID, then that will do the trick. If it still doesn't work, then you'll have to wait until I get the device and try it here.

Best Regards,

Vincent

+1
0
-1
July 30, 2009 - 12:39pm
Guest

Thank you for the fast reply!

My chips are:

STM8AF6166TC

Hope that helps you.

I tried the deactivation of the DeviceID.
Now connecting, erasing and programming is possible.
But verify fails:

(5) Verifying flash against file myHex.hex ...
!!! Error 304: Communication error: Timeout error reading on USB: WDU_T
ransfer() failed: error 0x20000002 ("Invalid pipe number")

Any idea?

+1
0
-1
July 30, 2009 - 3:17pm
Raisonance Support Team

Hi,

Does the program run? That would tell us if the problem is in the programming or in the verifying.

Please tell me the version of the Ride7 and RKit-STM8 kits that you are using. You can see that by clicking help->About in Ride or RFlasher.

Also, isn't there anything else written on the chip?
On mine I see this:

STM8AF
51A8TC
991EC V6
MYS 802

Best Regards,

Vincent

+1
0
-1
July 30, 2009 - 3:30pm
Guest

Yes, the program is running.
Verifying or BlankCheck fails.

Ride7 version: 7.22.09.0203
R-Kit version: 2.22.09.0203

Chip:

STM8AF
6166TC
9917G VG
MYS 849
(e4) Y

+1
0
-1
July 31, 2009 - 11:22am
Raisonance Support Team

Hi,

Thanks for the information.

I asked ST to send me some devices like yours, but I will not be able to use them before the second week of August. (I'm on vacation next week) Then I can check the software and correct it. Can you work without the verification until then?

Can you please tell me if the different programming operations work in RFlasher?

Best Regards,

Vincent

+1
0
-1
July 31, 2009 - 12:41pm
Guest

Yes, it doesn't matter, if you need one week more.

With RFlasher Erase and Program works, but BlankCheck and Verify fails with the same error message as in command line mode.

+1
0
-1
July 31, 2009 - 6:12pm
Raisonance Support Team

Hi,

In fact your verification problem is not special to this chip, so I could reproduce it and make a patch that solves it. You will find more information here:
http://raisonance-forum.xsalto.com/viewtopic.php?pid=9978#p9978

Please let us know if it solves your problem. You need to keep your modified config file, as the patch does NOT solve your first Die ID check problem that IS specific to your device.

Best Regards,

Vincent

+1
0
-1
August 3, 2009 - 8:45am
Guest

Yes, it seems that everything works fine now.

Thank you for your help!

+1
0
-1
August 5, 2009 - 8:15am
Guest

The patch is also available on the download page. It is specific to the latest RKit-ST7-STM8 release.

+1
0
-1
August 11, 2009 - 8:34am
Guest

Hello,

it seems to me that verifying is not working well.

I want to verify my device in this way:

STM8_pgm.exe TSTM8AF616 R E B FProgramCode.hex VProgramCode.hex FData.hex VData.hex FOptionBytes.hex

In this case the flasher sais (two times): "Flash content matches file."

If I do the following with an EMPTY hex-file to verify, the same message appears!

STM8_pgm.exe TSTM8AF616 R E B FProgramCode.hex VEmpty.hex FData.hex VEmpty.hex FOptionBytes.hex

So it seems to me that verify does not work correctly.
Do you think that the patch could be the problem? Is this fixed in the next version?
Or am I doing something wrong in the usage of the tool?

Thank you!

+1
0
-1
August 11, 2009 - 10:34am
Raisonance Support Team

Hi,

The Verify command checks that the data referenced by your hex file is the same in the Flash. It does not check anything concerning the memory addresses that are not referenced in the file. (If it did, your second check would always fail ;) ) So verifying against an empty file is the same as doing nothing.

If you want to check the Verify command, I suggest you duplicate one of your hex files, exchange two bytes on one same line of the copy (to avoid checksum issues) and run your command using the original for programming and the modified copy for verifying. Then the program should see the difference.

If you want to verify the unused parts of the memory, then you just have to create a hex file that references the whole memory. You can do that easily with the Save command of RFlasher: open RFlasher, select your derivative, load your hex file to RFlasher's memory using the "Load File" command, and then save the whole range that you want to verify into another hex file using the Save command (right-click in the data dump view). Then, use this file for verifying. (and also for programming if you want)

I hope it helps.

Best Regards,

Vincent

+1
0
-1
August 11, 2009 - 11:01am
Guest

Ok, thank you. It seems that it works now ;-)

One last question:

Is there the possibility to get a return value from STM8_pgm (pass / fail)?

+1
0
-1
August 11, 2009 - 11:36am
Raisonance Support Team

Hi,

Yes, STM8_pgm returns an error code in the standard way:
errorlevel = 0 means "success"
errorlevel != 0 means "failure - see text output for more information"

So you can write for example a batch file like this:

  STM8_pgm.exe TSTM8AF616 R E B FProgramCode.hex VProgramCode.hex FData.hex VData.hex FOptionBytes.hex
  if errorlevel 1 goto stm8pgmerror
  echo !!! SUCCESS !!!
  goto stm8pgmend
:stm8pgmerror
  echo !!! ERROR !!! see detailed error messages above
  pause
:stm8pgmend

I hope it helps.

Best Regards,

Vincent

+1
0
-1
August 11, 2009 - 12:09pm
Guest

Fine! Thank you for your support!

+1
0
-1
August 11, 2009 - 1:19pm
Guest

Sorry for asking again....

But it seems to me that I can't program all option bytes of the STM8A.

Writing to address 0x4810...0x4817 and 0x487E...0x487F does not have any effect. The memory is still 0x00 after programming.

Writing to 0x4800...0x48E0 seems to work properly.

Any idea?

+1
0
-1
August 11, 2009 - 2:13pm
Raisonance Support Team

Hi,

Indeed there is a problem here. Thanks for reporting it. I designed the software using a draft of the STM8 spec that did not mention any option byte after 0x480E, but when looking at the latest version of the spec, I see that there are some up to 0x487F.

I will fix that for the next release of the STM8 kit. In the meantime, as a temp fix, you just need to edit the "STM8_SWIM_ProductInfo.txt" file (again) and change the value of the "OptionBytesSeg_Size" attribute from 0x0F to 0x80. Only change the first occurrence of the value.

Many thanks again for your patience.

Best Regards,

Vincent

+1
0
-1
August 11, 2009 - 2:35pm
Guest

Now it works.

Many thanks!