Go Down

Topic: Got the avrdude stk500 error after bad testing from my part (Read 234 times) previous topic - next topic

john_wick

Hello.

I am doing a project for a class I'm taking and the teacher asked us to do it in Bare Metal programming in C. That means using only native C functions and libraries and deal with registers directly.

So, I was doing some tests with the avr-gcc compiler and the avrdude command line and I think I bricked my Arduino!

When I was using this code, everything was working fine:

Code: [Select]
$ avr-gcc -Os -DF_CPU=16000000UL -mmcu=atmega328p -c -o test.o test.c
$ avr-gcc -mmcu=atmega328p test.o -o test
$ avr-objcopy -O ihex -R .eeprom test test.hex
$ avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:test.hex


Just to be clear, I used this kit with both Arduino IDE and avr-gcc plus avrdude several times with sucess, so I know exactly the event that caused this error.

Then, I tried this out and avrdude output was regular as usual, but after this I'm having problems uploading with both Arduino IDE and avrdude.

Code: [Select]
$ avr-gcc -Os -c -o test.o test.c
$ avr-gcc test.o -o test
$ avr-objcopy -O ihex -R .eeprom test test.hex
$ avrdude -F -V -c arduino -p ATMEGA328P -P /dev/ttyACM0 -b 115200 -U flash:w:test.hex


After that, I did a loopback test and everything I typed did echoed back.

Just to sum it up:

- Operating system: Ubuntu 16.04
- Board: Arduino UNO with ATMEGA328P-PU
- I was able to upload to the board before.
- The error message from Arduino IDE:

Code: [Select]
Arduino: 1.8.5 (Linux), Board: "Arduino/Genuino Uno"

/home/john/arduino-1.8.5/arduino-builder -dump-prefs -logger=machine -hardware /home/john/arduino-1.8.5/hardware -tools /home/john/arduino-1.8.5/tools-builder -tools /home/john/arduino-1.8.5/hardware/tools/avr -built-in-libraries /home/john/arduino-1.8.5/libraries -libraries /home/john/Arduino/libraries -fqbn=arduino:avr:uno -vid-pid=0X2341_0X0043 -ide-version=10805 -build-path /tmp/arduino_build_998545 -warnings=none -build-cache /tmp/arduino_cache_444475 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=/home/john/arduino-1.8.5/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/home/john/arduino-1.8.5/hardware/tools/avr -prefs=runtime.tools.avrdude.path=/home/john/arduino-1.8.5/hardware/tools/avr -verbose /home/john/Arduino/projeto-usart/projeto-usart.ino
/home/john/arduino-1.8.5/arduino-builder -compile -logger=machine -hardware /home/john/arduino-1.8.5/hardware -tools /home/john/arduino-1.8.5/tools-builder -tools /home/john/arduino-1.8.5/hardware/tools/avr -built-in-libraries /home/john/arduino-1.8.5/libraries -libraries /home/john/Arduino/libraries -fqbn=arduino:avr:uno -vid-pid=0X2341_0X0043 -ide-version=10805 -build-path /tmp/arduino_build_998545 -warnings=none -build-cache /tmp/arduino_cache_444475 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=/home/john/arduino-1.8.5/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/home/john/arduino-1.8.5/hardware/tools/avr -prefs=runtime.tools.avrdude.path=/home/john/arduino-1.8.5/hardware/tools/avr -verbose /home/john/Arduino/projeto-usart/projeto-usart.ino
Using board 'uno' from platform in folder: /home/john/arduino-1.8.5/hardware/arduino/avr
Using core 'arduino' from platform in folder: /home/john/arduino-1.8.5/hardware/arduino/avr
Detecting libraries used...
"/home/john/arduino-1.8.5/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/home/john/arduino-1.8.5/hardware/arduino/avr/cores/arduino" "-I/home/john/arduino-1.8.5/hardware/arduino/avr/variants/standard" "/tmp/arduino_build_998545/sketch/projeto-usart.ino.cpp" -o "/dev/null"
Generating function prototypes...
"/home/john/arduino-1.8.5/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/home/john/arduino-1.8.5/hardware/arduino/avr/cores/arduino" "-I/home/john/arduino-1.8.5/hardware/arduino/avr/variants/standard" "/tmp/arduino_build_998545/sketch/projeto-usart.ino.cpp" -o "/tmp/arduino_build_998545/preproc/ctags_target_for_gcc_minus_e.cpp"
"/home/john/arduino-1.8.5/tools-builder/ctags/5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/tmp/arduino_build_998545/preproc/ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"/home/john/arduino-1.8.5/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/home/john/arduino-1.8.5/hardware/arduino/avr/cores/arduino" "-I/home/john/arduino-1.8.5/hardware/arduino/avr/variants/standard" "/tmp/arduino_build_998545/sketch/projeto-usart.ino.cpp" -o "/tmp/arduino_build_998545/sketch/projeto-usart.ino.cpp.o"
Compiling libraries...
Compiling core...
Using precompiled core
Linking everything together...
"/home/john/arduino-1.8.5/hardware/tools/avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p  -o "/tmp/arduino_build_998545/projeto-usart.ino.elf" "/tmp/arduino_build_998545/sketch/projeto-usart.ino.cpp.o" "/tmp/arduino_build_998545/../arduino_cache_444475/core/core_arduino_avr_uno_e5517b1ef39c41f9e2ef45cde4a2b37b.a" "-L/tmp/arduino_build_998545" -lm
"/home/john/arduino-1.8.5/hardware/tools/avr/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0  "/tmp/arduino_build_998545/projeto-usart.ino.elf" "/tmp/arduino_build_998545/projeto-usart.ino.eep"
"/home/john/arduino-1.8.5/hardware/tools/avr/bin/avr-objcopy" -O ihex -R .eeprom  "/tmp/arduino_build_998545/projeto-usart.ino.elf" "/tmp/arduino_build_998545/projeto-usart.ino.hex"
Sketch uses 366 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 60 bytes (2%) of dynamic memory, leaving 1988 bytes for local variables. Maximum is 2048 bytes.
/home/john/arduino-1.8.5/hardware/tools/avr/bin/avrdude -C/home/john/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/arduino_build_998545/projeto-usart.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 11:00:16
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/home/john/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/home/john/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.


- The test.c code (although I know it's not the code because it uploaded without error before):
I was going to post the code here, but it was exceeding the character limit.

That's it!

Thank you very much!

john_wick

The test.c code:

Code: [Select]
#define FOSC 16000000                                 // System Clock
#define BAUD 9600                                     // desired Baud Rate
#define UBRRn FOSC/16/BAUD-1                     

unsigned char UBRR0H = 0;
unsigned char UBRR0L = 0;
unsigned char UCSR0B = 0;
unsigned char UCSR0C = 0;
unsigned char RXEN0  = 0;
unsigned char TXEN0  = 0;
unsigned char USBS0  = 0;
unsigned char UCSZ00 = 0;
unsigned char UCSR0A = 0;
unsigned char UDRE0  = 0;
unsigned char UDR0   = 0;

void USART_init(unsigned int ubrr_value)             
{
 
    UBRR0H = (unsigned char)(ubrr_value>>8);
    UBRR0L = (unsigned char)ubrr_value;
    UCSR0B = (1 << RXEN0) | (1 << TXEN0);
    UCSR0C = (1 << USBS0) | (3 << UCSZ00);
 
}

void USART_putchar(char c)                           
{

    do {} while (!(UCSR0A & (1 << UDRE0)));           
                                                     

    UDR0 = c;                                         
   
}

int main(void)
{

    int i = 0;                                       

    USART_init(UBRRn);                               

    while (i < 15)
    {

      char nome[15]="Test successful";
      {

        USART_putchar(nome[i]);
        i++;
       
      }
     
    }
   
}

hammy

Try re loading the bootloader  via the icsp* port and then run a simple example program as a test


* I keep getting the name of this wrong ( doh)

hammy

Try re loading the bootloader  via the icsp port and then run a simple example program as a test

john_wick

Try re loading the bootloader  via the icsp port and then run a simple example program as a test
Thank you. I will do that and post here the outcome.

Will take some time because I never done it before, but I'm looking it up.

Go Up