Cannot Program via AVRISP MK2

Forum for problems or queries regarding the Flowcode application and compiler usage.

Moderators: Benj, Mods

Post Reply
iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times
Contact:

Cannot Program via AVRISP MK2

Post by iain wilkie »

I have just installed my purchased copy of Flowcode for AVR's and all is well.
However I cannot get the hex file to program into the micro. The message I get is.....

Launching the programmer...



C:\Program Files\Matrix Multimedia\Flowcode_AVR\Tools\MX_bats\avrc.bat m8535 avrispmkii usb "Flowcode1.hex" 0 2 223 -1 -1





C:\Flowcode>"C:\PROGRA~1\MATRIX~1\FLOWCO~1\Tools\MX_bats\..\AVRDUDEusb\avrdude.exe" -p m8535 -P usb -c avrispmkii -U flash:w:"Flowcode1.hex"



Error returned from [avrdude]



.....................

Return code = 1



Flowcode was unable to transfer the flowchart to the microcontroller. Check the programmer options and physical connections.



FINISHED

Now I also have AVR Stuio 4 and that works fine using the same programmer and target.

What am I getting wrong ?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Cannot Program via AVRISP MK2

Post by Benj »

Hello

This forum topic may help you to get up and running.

http://www.matrixmultimedia.com/mmforum ... ISP#p11055

iain wilkie
Posts: 97
Joined: Tue Jul 14, 2009 4:37 pm
Has thanked: 13 times
Been thanked: 9 times
Contact:

Re: Cannot Program via AVRISP MK2

Post by iain wilkie »

Fantastic..... All up and running now.

Thanks

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Cannot Program via AVRISP MK2

Post by TomasS »

Benj wrote:Hello

This forum topic may help you to get up and running.

http://www.matrixmultimedia.com/mmforum ... ISP#p11055
Hi!

A have a similar problem.

I have bought Flowcode V3 for AVR together with an E-Blocks EB019 Board.

I am able to simulate the flowchart I have made, but when I launch the programmer, it generates the HEX-file, but I get the error message:

Launching the programmer...

C:\Programmer\Matrix Multimedia\Flowcode_AVR\Tools\MX_bats\avrc.bat m32 avrispmkii usb "Tutorial.hex" 0 2 223 255 -1


D:\Dokumenter\Teknikfag\Flowcode>"C:\PROGRA~1\MATRIX~1\FLOWCO~1\Tools\MX_bats\..\AVRDUDEusb\avrdude.exe" -p m32 -P usb -c avrispmkii -U flash:w:"Tutorial.hex"
avrdude.exe: usbdev_open(): did not find any USB device "usb"

Error returned from [avrdude]

Return code = 1

Flowcode was unable to transfer the flowchart to the microcontroller. Check the programmer options and physical connections.

FINISHED

I have updated the files ATMEGA324.fcd and ATMEGA164.fcd as suggested on
viewtopic.php?f=5&t=5161&p=11060&hilit=AVRISP#p11055 . You also need to go into "the Programmer section of the Chip -> Compiler options menu, the following parameters will redirect the programming to AVR Studio. The location setting is an example taken from my machine using the default installation of AVR Studio.

Location:
C:\Program Files\Atmel\AVR Tools\STK500\STK500.exe

Parameters:
-cUSB -d%t -e -if"%D\%f.hex" -pf -vf "

But do you need to change this in Compiler, Linker/Assembler or Burner?
Either way - It doesn't seem to work :cry:

I do have AVR-Studio installed on the location listed above.

BR

Tomas

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Cannot Program via AVRISP MK2

Post by Sean »

Hello Tomas

It is likely that AVRDUDE is not able to locate the USB driver for the AVRISPmkII because the AVR Studio driver is being used.

The recommended changes to the Location and Parameters settings only apply to the Programmer (Burner) values. The Compiler and Linker/Assembler settings are unaffected by the programmer changes.

If the programmer still can not be found after these changes have been made, the system should produce a different set of error messages - based on the STK500 software instead of AVRDUDE.

You can check which driver is being used by the AVRISPmkII by connecting it to your PC and opening Control Panel -> System -> (Hardware) Device Manager.
If the AVR Studio driver is being used, it will be listed under 'Jungo'. If the AVRDUDE driver is being used it will be listed under 'LibUSB'.

If you continue to experience difficulties after changing to the AVR Studio (STK500) settings, please post the error messages generated by Flowcode (similar to the AVRDUDE messages you have already posted) on the forum and confirm the name of the USB driver being used by the programmer.

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Cannot Program via AVRISP MK2

Post by TomasS »

Hi Sean
sean wrote:Hello Tomas

It is likely that AVRDUDE is not able to locate the USB driver for the AVRISPmkII because the AVR Studio driver is being used.

The recommended changes to the Location and Parameters settings only apply to the Programmer (Burner) values. The Compiler and Linker/Assembler settings are unaffected by the programmer changes.
I have done as you suggested.
The programmer runs, but returns with the following result:

HEX file creation successful!

Return code = 0

Launching the programmer...

C:\Programmer\Atmel\AVR Tools\STK500\STK500.exe -cUSB -datmega32 -e -if"D:\DOKUME~1\TEKNIK~1\Flowcode\Tutorial.hex" -pf -vf


...........................................................

STK500 command line programmer, v 2.2 Atmel Corp (C) 2004-2005.

Connected to STK500 V2 on port USB:0000B0047388
Device parameters loaded
Programming mode entered
Device erased
FLASH input file read
Programming FLASH... FLASH programmed
Reading FLASH... Could not read FLASH
Could not leave programming mode
Connection to STK500 V2 closed

WARNING! One or more operations failed! Please examine the output log above!


Return code = 1

Flowcode var unable to transfer the flowchart to the microprocessor. Check programmer options and the physical connections.

FINISHED


After this the LED in the programmer turns red.

sean wrote:You can check which driver is being used by the AVRISPmkII by connecting it to your PC and opening Control Panel -> System -> (Hardware) Device Manager.
If the AVR Studio driver is being used, it will be listed under 'Jungo'. If the AVRDUDE driver is being used it will be listed under 'LibUSB'.
I have checked the driver - It says Jungo. So do I uninstall AVR Studio and then it work or what comes next?

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Cannot Program via AVRISP MK2

Post by Sean »

Hello Tomas,

Communications with your AVR programmer seem to be working correctly using the STK500 option. All your parameters also appear to be correct from your screen shot.

There should be no need to uninstall any drivers or applications.

The programmer indicates that it is erasing and re-programming the target chip, but fails to read the program back. This would seem to be a problem with the link between the programmer and the target device.

Your test program is being compiled for the ATMEGA32. Can you confirm that this is the correct target device? Our recent boards have been shipped with the ATMEGA324P.

If the chip is an ATMEGA32, what clock frequency is it running at?

Can you read the fuse setting and download a program using AVR Studio?

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Cannot Program via AVRISP MK2

Post by TomasS »

Hi Sean!
sean wrote: Communications with your AVR programmer seem to be working correctly using the STK500 option. All your parameters also appear to be correct from your screen shot.

There should be no need to uninstall any drivers or applications.
OK!
sean wrote:The programmer indicates that it is erasing and re-programming the target chip, but fails to read the program back. This would seem to be a problem with the link between the programmer and the target device.

Your test program is being compiled for the ATMEGA32. Can you confirm that this is the correct target device? Our recent boards have been shipped with the ATMEGA324P.
Maybe I should get my eyes checked. You're right. It is the 324P that is present. But it still returns with the following, when doing a programming in Flowcode:

HEX file creation successful!

Return code = 0

Launching the programmer...

C:\Programmer\Atmel\AVR Tools\STK500\STK500.exe -cUSB -datmega324p -e -if"D:\DOKUME~1\TEKNIK~1\Flowcode\Tutorial.hex" -pf -vf


.............................................................

STK500 command line programmer, v 2.2 Atmel Corp (C) 2004-2005.

Connected to STK500 V2 on port USB:0000B0047388
Device parameters loaded
Programming mode entered
Device erased
FLASH input file read
Programming FLASH... FLASH programmed
Reading FLASH... Could not read FLASH
Could not leave programming mode
Connection to STK500 V2 closed

WARNING! One or more operations failed! Please examine the output log above!


Return code = 1
Flowcode was unable to transfer the flowchart to the microcontroller. Check the programmer options and physical connections.
FINISHED

sean wrote:Can you read the fuse setting and download a program using AVR Studio?
It's no problem reading or writing the fuse bits.
But when I try to program the controller using AVR Studio 4, it fails reading the flash afterwards as well as leaving programming mode.

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Cannot Program via AVRISP MK2

Post by Sean »

I have carried out some programming tests using STK500.

Programming an ATMEGA324P chip as an ATMEGA32 from Flowcode did not cause any problems. Flash was programmed and verified correctly - but the program did not run.
Reprogramming as an ATMEGA324P recovered the device immediately.

AVR Studio can be used to read and save various sections of device memory independently. Can the FLASH and EEPROM sections be read using their 'Read' buttons?
I suspect that the FLASH will not be read. If the EEPROM section can be read successfully, this indicates that the programmer is working correctly, but there is a problem with the FLASH memory in the target device (the fuse settings have already been read successfully).

Lock bits can also be read. Can you check that no lock options are enabled? It is possible to completely disable read and write operations.

The ISP Frequency might be significant. 125KHz is a safe option for most configurations. This can also be checked and set from AVR Studio.

If all this fails, it would be useful to try an replacement target device. Would this be a possibility?

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Cannot Program via AVRISP MK2

Post by TomasS »

Hi Sean
sean wrote:
The ISP Frequency might be significant. 125KHz is a safe option for most configurations. This can also be checked and set from AVR Studio.

If all this fails, it would be useful to try an replacement target device. Would this be a possibility?
Success!

Lowering the ISP Frequency to 125 kHz accually helped!
Now the only problem is, that the timing in target doesn't follow the simulation speed. An LED should be led in three seconds, which it does in the simulator, but on the target board this takes ~24 seconds. Wrong Oscillator setting?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Cannot Program via AVRISP MK2

Post by Benj »

Hello

It sounds like you have the internal divide by 8 configuration setting enabled.

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Cannot Program via AVRISP MK2

Post by Sean »

Most newer devices (including the ATMEGA324P) have a CKDIV8 fuse that causes the clock frequency to be divided by 8. The devices are shipped with this option enabled.

Our recommended fuse settings for an ATMEGA324P, running from an external 20MHz crystal, are for all options to be disabled (unchecked) except SPIEN, Brown-out detection to be disabled, BOOTZ to be 256 words, and SUT_CKSEL to be the final option (Ext. Crystal Osc. 8.0- Mhz; Start-up time: 16K CK + 65ms).

The values displayed should be:
EXTENDED 0xFF
HIGH 0xDF
LOW 0xFF

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Cannot Program via AVRISP MK2

Post by TomasS »

Benj wrote:Hello

It sounds like you have the internal divide by 8 configuration setting enabled.
I think you're right :)
I will try to look for it

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Cannot Program via AVRISP MK2

Post by TomasS »

sean wrote:Most newer devices (including the ATMEGA324P) have a CKDIV8 fuse that causes the clock frequency to be divided by 8. The devices are shipped with this option enabled.

Our recommended fuse settings for an ATMEGA324P, running from an external 20MHz crystal, are for all options to be disabled (unchecked) except SPIEN, Brown-out detection to be disabled, BOOTZ to be 256 words, and SUT_CKSEL to be the final option (Ext. Crystal Osc. 8.0- Mhz; Start-up time: 16K CK + 65ms).

The values displayed should be:
EXTENDED 0xFF
HIGH 0xDF
LOW 0xFF
Im still quite new on using Flowcode. Can you please tell me where to correct these settings in Flowcode?

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Cannot Program via AVRISP MK2

Post by Sean »

If you are using the STK500 programming option, the best way to set the device fuses is from AVR Studio.

AVR Studio can be opened while Flowcode is running. When AVR Studio is connected to the programmer, the fuse settings are available under the 'Fuses' tab of the programmer panel.

AVR Studio must be closed again before attempting to download a program from Flowcode.

Flowcode for AVR does not send any fuse information when downloading programs to Flash.

The Flowcode fuse programming option, via the Config menu, is currently only available when using the AVRDUDE programming option.

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Cannot Program via AVRISP MK2

Post by TomasS »

sean wrote:If you are using the STK500 programming option, the best way to set the device fuses is from AVR Studio.

AVR Studio can be opened while Flowcode is running. When AVR Studio is connected to the programmer, the fuse settings are available under the 'Fuses' tab of the programmer panel.

AVR Studio must be closed again before attempting to download a program from Flowcode.

Flowcode for AVR does not send any fuse information when downloading programs to Flash.

The Flowcode fuse programming option, via the Config menu, is currently only available when using the AVRDUDE programming option.
Thank You again Sean.

I have made the changes in AVR Studio. I suppose I have to do these changes each time I start a new project?

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Cannot Program via AVRISP MK2

Post by Sean »

If you are using the same target device and configuration settings for all your future projects, you will never need to program the fuses again.

You will need to re-program the fuses once each time you:
  • Fit a new target device
    Change the device configuration (run from the internal clock, save EEPROM during programming, enable watchdog, enable brown-out, ...... etc.)
The fuses can not be re-programmed as many times as the main program flash. This is why the fuse programming operation is separate from the main program downloads.

TomasS
Posts: 75
Joined: Wed Oct 28, 2009 2:37 pm
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Cannot Program via AVRISP MK2

Post by TomasS »

sean wrote:If you are using the same target device and configuration settings for all your future projects, you will never need to program the fuses again.

You will need to re-program the fuses once each time you:
  • Fit a new target device
    Change the device configuration (run from the internal clock, save EEPROM during programming, enable watchdog, enable brown-out, ...... etc.)
The fuses can not be re-programmed as many times as the main program flash. This is why the fuse programming operation is separate from the main program downloads.
Okay. That makes sence :)

I'm using the "Microcontroller System engineering" by Bert van Dam as textbook.
When starting a new project he explains that you need to go to the Chip menu - Configure and then enter the settings "0x0,0xdf" and "0x1,0xff" for fuse programming, but it cannot be programmed. Therefor I use a former project as master and alter the flowchart - that allways works. But why this error?

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Cannot Program via AVRISP MK2

Post by Sean »

The Flowcode Configure menu is used to send the fuse values to the target device when using the AVRDUDE programming utility supplied with Flowcode.

The STK500 (AVR Studio) programmer option was added later when the AVRISPmkII driver conflict was discovered. This allows Flowcode and AVR Studio to share a common USB driver. And, as AVR Studio provides a more user-friendly fuse programming screen, we decided to rely on this option for fuse programming via STK500.
The fuse settings in the Flowcode Configure menu can not currently be sent to the STK500 programming software.

Programming fresh fuse settings at the start of each project is a good idea if you are also using new hardware with unknown configuration settings. If you are continually re-programming a single device, using the same configuration settings for all projects, there is no need to re-send the fuse information.
The fuse settings are stored in the chip, not in the Flowcode AVR projects.

Note: The PIC version of Flowcode does send configuration fuse data with each program download (by default). The PIC fuses are part of the program memory.

Post Reply