OT Avrdude from batch file, how to capture error code

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Im trying to create a batch file that will program an AVR using avrdude and an avrisp
and and display something only when there is an error in programming
any ideas? this is what I have so far
:begin
@echo off
SETLOCAL
path = S:\Tools\AVRdude

@echo off
SET FILE_PATH=C:\IAR_Projects\Test\Debug\Exe/
SET FILE_NAME=Test.a90
SET PROCESSOR=m128
SET PORT=com1
SET PROGRAMMER=stk500
SET EFUSE=0xFF
SET HFUSE=0x89
SET LFUSE=0x2E
SET LOCK_BITS=0xFF
SET FILE=%FILE_PATH%%FILE_NAME%

@start /wait avrdude ^-P %port% ^-p %PROCESSOR% ^-c %PROGRAMMER% ^-U flash:w:%FILE%:a ^-U efuse:w:%EFUSE%:m ^-U hfuse:w:%HFUSE%:m ^-U lfuse:w:%LFUSE%:m ^-U lock:w:%LOCK_BITS%:m /c >C:\tempfile.txt

ECHO %errorlevel%
@type c:\tempfile.txt

ENDLOCAL

note %errorlevel always returns 0

Thanks
Troy

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

TroyC wrote:
Im trying to create a batch file that will program an AVR using avrdude and an avrisp
and and display something only when there is an error in programming
any ideas? this is what I have so far

Is there something wrong with what you have?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The only thing wrong is the %errorcode% always returns 0
even if there is a failure i.e. stk500 turned off

other than that error it work great.

Thanks
troy

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

:oops: :oops:
oops my bad it does work it! I was always returning 1, I had to remove the lock bit stuff to get it to return a 0
now all is well

Thanks Eric