Go Down

Topic: Programming ATmega328P using Sparkfun Bus Pirate  (Read 228 times) previous topic - next topic

mygodetjy

Hi

Currently I am trying to use Sparkfun bus pirate board to program the ATmega328p. I already used the red board to burn the boot load into the ATmega328p. I first flashed my one sketch which is just simply blink the LED, everything seem works fine.
While I am trying to upload my real project sketch into the ATmega328p, the error says:

An error occurred while uploading the sketch

It doesn't say what's the cause of this error.

I am thinking if there is a pin conflict since my project involves a LCD and SPI pins. The way the Bus Pirate uploads the sketch to the ATmega328p is also using SPI MOSI MISO SCK RESET and GND as you can see from the attachment.

But seems not the case

Red           GND
Purple        SCK
Green        CS/RESET
Yellow       MOSI
Blue          MISO

Upon to setup loop
all possible pin definitions is showing below:
Code: [Select]

#include <DallasTemperature.h>
//#include <SPI.h>
#include <SoftwareSerial.h>
#include <OneWire.h>
#include <SoftwareSerial.h>
//#include "LCD_Functions.h"
#include <EEPROM.h>
#include "LowPower.h"
//#define wakeupPin 15
#define upper 100
#define lower 108
#define ONE_WIRE_BUS 8
#define interruptPin 2
int batteryLength=1;
int battery_data;
enum fsm_state {init_st,daq0, daq01, daq02, daq03, daq04, daq05, daq06, daq07, daq08, daq09, daq10, daq11, daq12,Wifi_st,data_tx,C2D};
fsm_state state = init_st;
int state_flag; //high alarm = 1, high hysterisis = 2, normal = 3, lower hysterisis = 4, low alarm = 5
int high_flag, low_flag; // 1 for alarm, 0 for no alarm
int alert_b0, alert_b1; //alert truth table to indicate the alert action, (alert_b1, alert_b0) 00 = lower reset, 01 = low set, 10 = high reset, 11 = high set
bool c2d_msg_flag;
float myFloat[3]={};
String stringone;
String stringDAQ0;
SoftwareSerial mySerial(10, 11);//RX:4, TX:5
String stringAlert;
unsigned long start_t;
unsigned long start_t1;
unsigned long start_t2;
unsigned long start_t3;
int mycurrent_st;
int i=0;
int timesout = 30000;
int ALERTSTATUS;
char state_counter='0';

char temperatureF[10];
char temperatureC[10];
OneWire oneWire(ONE_WIRE_BUS);  //type 0 sensor
DallasTemperature sensor_four(&oneWire);
int init_loop=0;

void green_blink_test(){
  digitalWrite(15, HIGH);
  delay(3000);
  digitalWrite(15, LOW);
  delay(300);
}
void green_blink(){
  digitalWrite(15, HIGH);
  delay(1000);
  digitalWrite(15, LOW);
  delay(300);
}
//SoftwareSerial Serial(10,11);

//**************************************************set up **********************************************//

//initialize the serial port and lcd interrupt pin
//Sending the first AT+AP command after wake up the ESP
void setup() {

 // lcdBegin(); // This will setup our pins, and initialize the LCD
 // updateDisplay(); // with displayMap untouched, SFE logo
  pinMode(15,OUTPUT);
  //setContrast(60); // Good values range from 40-60
 // pinMode(interruptPin,INPUT_PULLUP);
 // attachInterrupt(digitalPinToInterrupt(interruptPin), interruptText, LOW);
 
  Serial.begin(9600);
mySerial.begin(9600);
  while(!Serial);
  Serial.println("System initialization");
  delay(2000);
  mySerial.println("System initialization mySerial");
  /************System Initialization*****************/
  //add initialize esp8266 function here
  led_blink();
  lcd_on_off();
  //digitalWrite(wakeupPin, LOW);
  delay(500);
  /*************************************************/

 // clearDisplay(WHITE);
 // updateDisplay();
  green_blink_test();
  delay(5000);
  Serial.write("AT+AP");
  Serial.write('\n');
while(true)
  {
  delay(250);
      if (Serial.available())
   {
    String x = Serial.readStringUntil('\n');
      if (x=="AT+ACK")
    {
      state=daq0;
    //  Serial.write("AT+WIFISTART");
      break;
    }
   }
  }
}

pert

Please do this:
  • File > Preferences > Show verbose output during: > compilation (uncheck) > upload (check) > OK
  • Do the upload
  • After the upload fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • Paste the error messages in a reply here USING CODE TAGS (</> button on the toolbar).

mygodetjy

Please do this:
  • File > Preferences > Show verbose output during: > compilation (uncheck) > upload (check) > OK
  • Do the upload
  • After the upload fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
  • Paste the error messages in a reply here USING CODE TAGS (</> button on the toolbar).

Hi,

Thanks for your reply and please see the error message:

Code: [Select]


Arduino: 1.8.5 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328P (3.3V, 8 MHz)"

Archiving built core (caching) in: C:\Users\User\AppData\Local\Temp\arduino_cache_721521\core\core_arduino_avr_pro_cpu_8MHzatmega328_010bb19088174a0bd8df67e87b61a05b.a
Sketch uses 14628 bytes (47%) of program storage space. Maximum is 30720 bytes.
Global variables use 749 bytes (36%) of dynamic memory, leaving 1299 bytes for local variables. Maximum is 2048 bytes.
E:\arduino-1.8.5\hardware\tools\avr/bin/avrdude -CE:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cbuspirate -PCOM7 -Uflash:w:C:\Users\User\AppData\Local\Temp\arduino_build_683114/atmega_state_machine.ino.hex:i

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

         System wide configuration file is "E:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM7
         Using Programmer              : buspirate
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : BusPirate
         Description     : The Bus Pirate

Attempting to initiate BusPirate binary mode...
BusPirate binmode version: 1
BusPirate SPI version: 1
avrdude: Paged flash write enabled.
AVR Extended Commands not found.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.07s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Users\User\AppData\Local\Temp\arduino_build_683114/atmega_state_machine.ino.hex"
avrdude: writing flash (14628 bytes):

Writing | ################################################## | 100% 28.01s

avrdude: 14628 bytes of flash written
avrdude: verifying flash memory against C:\Users\User\AppData\Local\Temp\arduino_build_683114/atmega_state_machine.ino.hex:
avrdude: load data flash data from input file C:\Users\User\AppData\Local\Temp\arduino_build_683114/atmega_state_machine.ino.hex:
avrdude: input file C:\Users\User\AppData\Local\Temp\arduino_build_683114/atmega_state_machine.ino.hex contains 14628 bytes
avrdude: reading on-chip flash data:

Reading | ############An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

pert

It's failing during the verification stage but without useful output. I don't have any experience with the Bus Pirate so I can't offer any advice. Maybe someone else here can help. You can get more information by running the avrdude upload command from the command line and adding more -v flags, up to the maximum verbosity of -v -v -v -v. Interpreting that output may be difficult.

It is possible to turn off verification at File > Preferences > Verify code after upload but the question is whether it's failing during verification because the data was not correctly written (in which case you want it to fail) or whether the data was written correctly and the failure during verification is unrelated to reading bad data.

mygodetjy

It's failing during the verification stage but without useful output. I don't have any experience with the Bus Pirate so I can't offer any advice. Maybe someone else here can help. You can get more information by running the avrdude upload command from the command line and adding more -v flags, up to the maximum verbosity of -v -v -v -v. Interpreting that output may be difficult.

It is possible to turn off verification at File > Preferences > Verify code after upload but the question is whether it's failing during verification because the data was not correctly written (in which case you want it to fail) or whether the data was written correctly and the failure during verification is unrelated to reading bad data.
Hi,

Regarding the avrdude command line. I will do some research on how to send that command from the command line.

Besides, this morning I got this error. Looks like there is a ASCII translation issue.

Code: [Select]

Sketch uses 4104 bytes (13%) of program storage space. Maximum is 30720 bytes.
Global variables use 286 bytes (13%) of dynamic memory, leaving 1762 bytes for local variables. Maximum is 2048 bytes.
E:\arduino-1.8.5\hardware\tools\avr/bin/avrdude -CE:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cbuspirate -PCOM5 -Uflash:w:C:\Users\User\AppData\Local\Temp\arduino_build_216595/atmega_state_machine.ino.hex:i

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

         System wide configuration file is "E:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM5
         Using Programmer              : buspirate
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : BusPirate
         Description     : The Bus Pirate

Attempting to initiate BusPirate binary mode...
Binary mode not confirmed: ''
BusPirate: Internal error: buspirate_send_bin() called from ascii mode
BusPirate is back in the text mode
avrdude: Failed to start binary mode, falling back to ASCII...
Attempting to initiate BusPirate ASCII mode...
avrdude: Fatal: Programmer is not responding.

pert

Regarding the avrdude command line. I will do some research on how to send that command from the command line.
All you need to do is first attempt the process via the Arduino IDE with the verbose upload output turned on, then copy the command generated by the Arduino IDE from the console window. In your last post the command was:
Code: [Select]
E:\arduino-1.8.5\hardware\tools\avr/bin/avrdude -CE:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cbuspirate -PCOM5 -Uflash:w:C:\Users\User\AppData\Local\Temp\arduino_build_216595/atmega_state_machine.ino.hex:i

So if you wanted to modify that for the highest verbosity level you would run this command from the Windows command line (cmd):
Code: [Select]
E:\arduino-1.8.5\hardware\tools\avr/bin/avrdude -CE:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf -v -v -v -v -patmega328p -cbuspirate -PCOM5 -Uflash:w:C:\Users\User\AppData\Local\Temp\arduino_build_216595/atmega_state_machine.ino.hex:i

The one thing you need to be aware of is that the Arduino IDE stores the compiled .hex file that will be uploaded in a temporary build folder with a randomly generated name (C:\Users\User\AppData\Local\Temp\arduino_build_216595/atmega_state_machine.ino.hex in this case). That folder is deleted when you close the Arduino IDE. So you need to leave the Arduino IDE open, otherwise, when you run the arduino command from the command line it will fail with a file not found error.

mygodetjy

E:\arduino-1.8.5\hardware\tools\avr/bin/avrdude -CE:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf -v -v -v -v -patmega328p -cbuspirate -PCOM5 -Uflash:w:C:\Users\User\AppData\Local\Temp\arduino_build_216595/atmega_state_machine.ino.hex:i
I tried this on windows machine command window as the message shows below:

Code: [Select]


C:\Users\User>E:\arduino-1.8.5\hardware\tools\avr/bin/avrdude -CE:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cbuspirate -PCOM7 -Uflash:w:C:\Users\User\AppData\Local\Temp\arduino_build_909009/atmega_state_machine.ino.hex:i

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

         System wide configuration file is "E:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM7
         Using Programmer              : buspirate
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : BusPirate
         Description     : The Bus Pirate

Attempting to initiate BusPirate binary mode...
BusPirate binmode version: 1
BusPirate SPI version: 1
avrdude: Paged flash write enabled.
AVR Extended Commands not found.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.11s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as FD
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Users\User\AppData\Local\Temp\arduino_build_909009/atmega_state_machine.ino.hex"
avrdude: writing flash (17484 bytes):

Writing | ################################################## | 100% 32.87s

avrdude: 17484 bytes of flash written
avrdude: verifying flash memory against C:\Users\User\AppData\Local\Temp\arduino_build_909009/atmega_state_machine.ino.hex:
avrdude: load data flash data from input file C:\Users\User\AppData\Local\Temp\arduino_build_909009/atmega_state_machine.ino.hex:
avrdude: input file C:\Users\User\AppData\Local\Temp\arduino_build_909009/atmega_state_machine.ino.hex contains 17484 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 558.33s

avrdude: verifying ...
avrdude: 17484 bytes of flash verified

avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK (E:FD, H:DA, L:FF)
BusPirate is back in the text mode

avrdude done.  Thank you.





Everything works fine this time if I use windows command window to run this command. Why it does not work on the Arduino IDE tho. So weird

pert

That is weird. What happens if you run the command exactly like the one the Arduino IDE generated, with out the extra -v added?

mygodetjy

That is weird. What happens if you run the command exactly like the one the Arduino IDE generated, with out the extra -v added?
still works. I wrote a sample program into it and it also works, but while I upload my project sketch it would never work unless I uploaded it via the command line.  Do you think if it's my code issue? But still if it succeeds on the command line, even if it says all done but it's just not working.

mygodetjy

this time when I try to upload the sketch from the Arduino IDE, I got this error:
Code: [Select]

Arduino: 1.8.5 (Windows 10), Board: "Arduino Pro or Pro Mini, ATmega328P (5V, 16 MHz)"

Sketch uses 17484 bytes (56%) of program storage space. Maximum is 30720 bytes.
Global variables use 1106 bytes (54%) of dynamic memory, leaving 942 bytes for local variables. Maximum is 2048 bytes.
E:\arduino-1.8.5\hardware\tools\avr/bin/avrdude -CE:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cbuspirate -PCOM7 -Uflash:w:C:\Users\User\AppData\Local\Temp\arduino_build_432433/atmega_state_machine.ino.hex:i
java.io.IOException: Cannot run program "E:\arduino-1.8.5\hardware\tools\avr/bin/avrdude": CreateProcess error=193, %1 is not a valid Win32 application
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at processing.app.helpers.ProcessUtils.exec(ProcessUtils.java:26)
at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:129)
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingProgrammer(SerialUploader.java:343)
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:89)
at cc.arduino.UploaderUtils.upload(UploaderUtils.java:78)
at processing.app.SketchController.upload(SketchController.java:713)
at processing.app.SketchController.exportApplet(SketchController.java:686)
at processing.app.Editor$DefaultExportAppHandler.run(Editor.java:2265)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: CreateProcess error=193, %1 is not a valid Win32 application
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 9 more
An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

pert

What happens if you run the command from command line?

mygodetjy

I got this error:

Code: [Select]

C:\Users\User>E:\arduino-1.8.5\hardware\tools\avr/bin/avrdude -CE:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cbuspirate -PCOM7 -Uflash:w:C:\Users\User\AppData\Local\Temp\arduino_build_432433/atmega_state_machine.ino.hex:i

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

         System wide configuration file is "E:\arduino-1.8.5\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM7
         Using Programmer              : buspirate
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : BusPirate
         Description     : The Bus Pirate

Attempting to initiate BusPirate binary mode...
BusPirate binmode version: 1
SPI mode not confirmed: 'BBIO'
BusPirate is back in the text mode
avrdude: Failed to start binary mode, falling back to ASCII...
Attempting to initiate BusPirate ASCII mode...
BusPirate: using ASCII mode
BusPirate is now configured for SPI
avrdude: warning: did not get a response to PowerUp command.
avrdude: warning: Trying to continue anyway...
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.09s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as FD
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: warning: did not get a response to PowerUp command.
avrdude: warning: Trying to continue anyway...
avrdude: reading input file "C:\Users\User\AppData\Local\Temp\arduino_build_432433/atmega_state_machine.ino.hex"
avrdude: writing flash (17484 bytes):

Writing | ################################################## | 100% 494.37s

avrdude: 17484 bytes of flash written
avrdude: verifying flash memory against C:\Users\User\AppData\Local\Temp\arduino_build_432433/atmega_state_machine.ino.hex:
avrdude: load data flash data from input file C:\Users\User\AppData\Local\Temp\arduino_build_432433/atmega_state_machine.ino.hex:
avrdude: input file C:\Users\User\AppData\Local\Temp\arduino_build_432433/atmega_state_machine.ino.hex contains 17484 bytes
avrdude: reading on-chip flash data:

Reading |                                                    | 0% 0.00sBusPirate: buspirate_paged_load(..,flash,128,0,128)
BusPirate: Paged Read command returned zero.
avrdude: buspirate_readline(): programmer is not responding
avrdude: buspirate_readline(): programmer is not responding
avr_read(): error reading address 0x0000
    read operation not supported for memory "flash"
avrdude: failed to read all of flash memory, rc=-2

avrdude: safemode: hfuse reads as DA
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK (E:FD, H:DA, L:FF)
avrdude: warning: did not get a response to PowerDown command.

mygodetjy

What happens if you run the command from command line?
Hi,

I finally found out the issue. So my ATmega238P is connecting with LCD which used a LCD library. In that particular library, the SPI pin has been defined. However, the way Pirate Bus flash the sketch to the ATmega328P is also using the SPI pins. It causes a conflict. So I need to find another way to program the chip. I tried use the UART pins last time but it's very difficult to control the reset timing. I have to rely on luck as many times I encounter failures.

pert

Connect the DTR or CTS or RTS pin on the USB to serial chip to the reset pin on the ATmega328P via a 0.1 uF capacitor and it will be automatically reset at just the right time. That's how real Arduino boards work.

Go Up