Can't download new sketch after changing serial speed

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

I was diddling around with an AT09, trying to talk to it.  Eventually, it became obvious.

 

In any event, I was using the SoftwareSerial library to talk to the AT09, and regular serial (through usb) to talk to the serial monitor.  (gee, these aren't the same AT codes I was using in 1982!).  I could happily talk to it.  I used "Serial.begin(9600);", which seems to be the source of my problems.

 

The sketch still runs and responds, but it won't take a new one. (It has been disconnected for a matter of days, and I've unplugged several times).  The green light stays on, the red flashes, and I get

 

      User configuration file is "/Users/hawk/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

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

avrdude done.  Thank you.

I've tried hitting reset as compile finishes, holding it down as I apply power trying to hit at various times at the end of the compile, and whatever I do, the old sketch runs.

 

It even sends my test messages (such as ***splat***!) back to the serial monitor.

 

I'm using the same computer with the same cable as when I could change it before, and I've installed the arduinio side on another computer, with the same results.

 

I've put the drivers for the 34x chinese chips on both, and it clearly talks to and sees the chip.

 

The board is a nano clone with mini usb on board.

 

I'm not being a path out other than starting with another board . . .

 

any suggestions would be appreciated.

 

thanks

 

hawk

This topic has a solution.
Last Edited: Wed. Oct 10, 2018 - 04:37 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not enough info for us to help, start by showing us...

1) you AVRDUDE command line (copy/paste, do not type)

2) AT09?  Attiny9?  (if so, then what arduino core are you using? or bootloader s/w?) Show your schematic including how you connect it to your serial interface, or at least a clear picture of the setup

3) show us the sketch that is running on the AT09 and the one your trying to upload to it.

 

Jim

 

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

ki0bk wrote:

Not enough info for us to help, start by showing us...

1) you AVRDUDE command line (copy/paste, do not type)

 

Clipping the compile data and the command, and response, 

 

Sketch uses 444 bytes (1%) of program storage space. Maximum is 30720 bytes.

Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

/Users/hawk/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/Users/hawk/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.wchusbserialfd130 -b115200 -D -Uflash:w:/var/folders/zw/80mmg8352gqb2ldt_d0k9qhr0000gn/T/arduino_build_403974/null_1001.ino.hex:i

 

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35

         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         Copyright (c) 2007-2014 Joerg Wunsch

 

         System wide configuration file is "/Users/hawk/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf"

         User configuration file is "/Users/hawk/.avrduderc"

         User configuration file does not exist or is not a regular file, skipping

 

         Using Port                    : /dev/cu.wchusbserialfd130

         Using Programmer              : arduino

         Overriding Baud Rate          : 115200

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00

avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

 

avrdude done.  Thank you.

 

An error occurred while uploading the sketch

ki0bk wrote:

 

 

2) AT09?  Attiny9?  (if so, then what arduino core are you using? or bootloader s/w?) Show your schematic including how you connect it to your serial interface, or at least a clear picture of the setup

ki0bk wrote:

 

 

At this point, it's not even in the circuit; that's just why the sketch has serial commands at all.  I have SPST switches to ground on D3 and D4, and LEDs with 330 Ohm limiters on D9 & D10.  But that's not the problem; the circuit works and they do their thing.

 

The problem is that I cannot put *any* other sketch onto it, and this sketch survives and does its thing in spite of my efforts to overwrite it.

 

ki0bk wrote:

3) show us the sketch that is running on the AT09 and the one your trying to upload to it.

 

I'm not running on the AT09; it was on there there to play with bluetooth and serial.  (Ultimately, I expect to use  the AT09 or some such as a controller, but right now I'm still trying to get the basics going . . .)

 

The controller is a chinese nano clone, with a 328p and programmed through the mini usb connector.

 

The sketch that won't go away is 

 

#include <SoftwareSerial.h>

//use 11 & 12for RX & TX


int off3 = 0;
int off4 = 0;

int btTx = 12;
int btRx = 11;

SoftwareSerial btSerial(btTx, btRx);


void setup() {
  // put your setup code here, to run once:
  // buttons on 3 & 4
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);

  // LED on 9 & 10
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);

  Serial.begin(9600);
  while (!Serial) {};

  Serial.println("***splat***!");

  btSerial.begin(9600);

  Serial.println("***wham***!");



}

void loop() {


  if (btSerial.available()) {
    //  Serial.println("Data coming:");
    Serial.write(btSerial.read());
  }

  if (Serial.available()) {
    //Serial.println("Sending ");
    btSerial.write(Serial.read());

  }

  if ((digitalRead(3) == LOW) && (millis() > off3)) {

    off3 = millis() + 1000;
    digitalWrite(10, HIGH);
    // Serial.print("button 3 ");
    //Serial.println(off3);
    btSerial.write("AT\n");



  }

  if ((digitalRead(4) == LOW) && (millis() > off4)) {

    off4 = millis() + 1000;
    digitalWrite(9, HIGH);
    // Serial.print("button 4 ");
    //Serial.println(off4);
    btSerial.write("AT");



  }

  if (millis() > off3) {
    digitalWrite(10, LOW);
  };
  if (millis() > off4) {
    digitalWrite( 9, LOW);
  };

}

 

I know that the sketch is running, as the LEDs indeed come on for about a second when their corresponding buttons are pushed.  I also get the splat/wham messages on the IDE serial console.

 

There isn't even a particular sketch that I want on it that is the issue.  I've tried both the blank sketch that the editor comes up with, and this triviality:

 



void setup() {
  // put your setup code here, to run once:
 Serial.begin(9600);
  while (!Serial) {};

  Serial.println("***splat***!");
}

void loop() {
  // put your main code here, to run repeatedly:

}

IN both cases, all 10 attempts to write are made, with all 10 "not in sync:" responses, faster than my eyes can follow. (and, now that I think of it, isn't there supposed to be a wait of some tens of milliseconds between?)

 

I've tried holding down the reset button while inserting USB, holding it until compile, and every variation of this that I can think of (most of which aren't really variations), and it stubbornly stays put.

 

My working assumption is that when I initiate the serial console to 9600, this is somehow blocking the side coming in at a higher speed.

Thanks

 

hawk

 

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

Ok, I miss understood, you have a nano clone the you were able to upload to one time and now you are unable to upload a new sketch.

 

If this is a normal nano, you need an external serial interface to connect the usb cable to it, correct? 

And you have selected from the Tools/Boards menu the Arduino Nano, correct?

 

If the above is correct, the DTR line from the USB interface triggers the reset pin on the nano, some china made nanos have been reported as having a 1k pull up on the reset line, which is too small, should be 10k.

That will have the problem your setup is showing...   

How skilled are you at replacing the SMD resistor on the nano?   You could try just removing the pull up resistor, use a solding iron, bridge both ends of the resistor with a large blob of solder and use tweezers to lift the part off the board.

It's easier to do then to type out how to do it!  video: https://www.youtube.com/watch?v=...

 

Jim

 

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

You have overwritten the boot loader.  That most likely causes getsync() errors on the PC that is trying to write to an Arduino. 

 

What is a AT-09?  Is it a BLE Bluetooth 4.0 Module TI CC2541 (HM-10)?  Are you trying to write code to this board from your PC and are receiving getsync() errors?

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

Simonetta wrote:
You have overwritten the boot loader
How do you conclude that?  The only avrdude command lines the OP has show us use -c arduino.  You can't overwrite the bootloader by talking to the bootloader.

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

joeymorin wrote:
How do you conclude that? 
+1 

 

Though I guess we should ask OP the question: "have you ever connected an ISP programmer or a debugger to this board?"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Last Edited: Fri. Oct 5, 2018 - 08:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:

 

What is a AT-09?  Is it a BLE Bluetooth 4.0 Module TI CC2541 (HM-10)?  Are you trying to write code to this board from your PC and are receiving getsync() errors?

 

It is that type of bluetooth, but I haven't tried to program it; I've only sent AT commands back and forth so see if it's there.

 

 

 

 

clawson wrote:

 

Though I guess we should ask OP the question: "have you ever connected an ISP programmer or a debugger to this board?"

 

I've never connected anything but the USB connector for programming, the parts on the board, and previously the AT-09.

 

hawk

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

In that case you cannot have over-written the bootloader as postulated in #5

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

dochawk wrote:
ki0bk wrote: If this is a normal nano, you need an external serial interface to connect the usb cable to it, correct? No, it was programmed exclusively through its onboard mini USB connector. Or did you mean the external connection from its USB to the mac?

Ah, I was thinking of the pro-mini which needs an external usb adapter, my mistake. 

Ignore what I said about the reset pull up.....

 

I can't think of anything that would prevent your nano from loading any sketch, assuming you have only programmed it from the usb connection. 

Sometimes the Leonardo (and pro-micro which are M32U based) have issues loading because it changes USB modes between code loading and running, but that is not the case with the UNO/MEGA/NANO.

Perhaps another freak will have more ideas.

 

 

Jim

 

 

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dochawk wrote:

Yes. Also:

  processor:ATMega328p

 

If you are out of ideas, try selecting:

   ATmega328P (Old Bootloader)

 

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

Are you using, as a device programmer, an Arduino that has been loaded with the Arduino_As_ISP sketch? 

I use the simple USB cable connection between my Windows PC and the Arduino Nano and this programmer configuration is listed as Tools->Programmer->USBasp.

Have you tried a different new Nano?   I buy the new Nano clones five at a time.  In a situation like this, I would cut open the sealed plastic envelope on a new Nano, load it with your updated program, and see if it works OK. 

 

Do you have a USBasp device for programming the Nano using ISP?  Whenever I have getsync() errors, I install the six-pin header on the Nano and get out my six-pin USBasp device programmer (which costs about $5 on eBay).   The Arduino code is compiled using Sketch -> Export:Compiled Binary.  This creates two hex files in the directory that holds the .ino file:   filename.ino.eightanaloginputs.hex   -and-   filename.ino.with_bootloader.eightanaloginputs.hex

   Copy avrdude.exe and avrdude.conf to the .ino directory.  From the command line, run:  avrdude -F -p m328p -c usbasp -P usb -U flash:w: filename.ino.eightanaloginputs.hex  

  This allows you to load Arduino sketches when you have getsync() errors when using the bootloader.

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

For the love of all that is holy, can you remove the 9MB image from post #8?  I get a few new grey hairs every time I click on this thread.  Either upload a smaller image, or attach it instead of inlining it.

 

[cliff: I'll rescale and replace it! ;-)]

[is that still too big??]

[joey: That's (a bit) better!  Thanks!]

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Fri. Oct 5, 2018 - 03:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Arduino Avrdude command line:

 

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM4 -b57600 -D -Uflash:w:C:\Users\J1B50~1.STA\AppData\Local\Temp\arduino_build_203103/Fade.ino.hex:i

 

Notice -b57600

 

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

From: https://store.arduino.cc/arduino...

Nanos have 1K resister on reset.

I have used many from China with the CH340 with no problem.  Maybe Simonetta can comment

 

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

jstampfl wrote:
Notice -b57600  
jstampfl wrote:
Notice -b57600  

 

That sort occurred to me in the middle of a bad night (winds here turned vegas into an allergy hell . . .)

 

If my problem is related to having changed the speed in the sketch, I should manually edit to try 9600 . . . (I've been letting the IDE handle all this).

 

I'll try both that and 57600 when I get back this afternoon.

 

As far as the reset resistor goes, I assume the green rest corner attaches to the chip reset line/

 

And are reset and DTR the same pin?  I'm still less than clear on this, and have read enough that I didn't quite understand yet that I'm paranoid.

 

And whether the same or not, can I cause any damage shorting DTR or/same Reset to ground?

 

thanks

 

hawk

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

I wouldn't worry about the 1K resistor, I often use Nanos and never have a problem.

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

1.  examine the number printed on the AVR.   Is it ATmega168 or ATmega328P?

2.  have you ever connected an external programmer to the 3x2 header?

 

3.  remove the Nano from the breadboard.

4.  plug in the USB cable.

5.  start the Arduino IDE

6.  select Board: Nano

7.  select Processor:  168 or 328P

8.  select Port: COM#

 

9.  if you unplug the Nano and select Port again,  the COM# will have disappeared (if you had identified the correct port for the Nano)

 

10.  plug the USB cable into the Nano

11. try to build and upload a sketch.

 

Answer those numbered steps.   None of them require more than a Y or N

 

If you answer N to (2),   I bet that everything else should work fine.    If not,  post your numbered answers

 

This "problem" does not need 18 messages.   If you take 5 minutes of your life to answer those steps.

 

David.

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

david.prentice wrote:

1.  examine the number printed on the AVR.   Is it ATmega168 or ATmega328P?

 

It's a 328p.  I think all nanos are . . .

 

david.prentice wrote:

2.  have you ever connected an external programmer to the 3x2 header?

 

No.  It was repeatedly reprogrammed successfully by the USB port under the settings of nano, ATMega328p, and selecting the port.

 

david.prentice wrote:

 

3.  remove the Nano from the breadboard.

4.  plug in the USB cable.

5.  start the Arduino IDE

6.  select Board: Nano

7.  select Processor:  168 or 328P

8.  select Port: COM#

9.  if you unplug the Nano and select Port again,  the COM# will have disappeared (if you had identified the correct port for the Nano)

 

Yes.  All of these are as in the prior runs.

 

david.prentice wrote:

10.  plug the USB cable into the Nano

11. try to build and upload a sketch.

Quote:

 

Exactly the same error as before.

 

Answer those numbered steps.   None of them require more than a Y or N

 

If you answer N to (2),   I bet that everything else should work fine.    If not,  post your numbered answers

 

This "problem" does not need 18 messages.   If you take 5 minutes of your life to answer those steps.

 

 

Thanks, but these didn't get there.

 

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

Chuck99 wrote:
If you are out of ideas, try selecting:    ATmega328P (Old Bootloader)

 

And this, indeed, did it.

 

I note that it is also running at 

  Overriding Baud Rate          : 57600

Whereas the "current" version shows 

 

  Overriding Baud Rate          : 115200

 

So, being the suspicious type, I copied the install line from the Arduino IDE, but edited to 

/Users/hawk/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/bin/avrdude -C/Users/hawk/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino9/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.wchusbserialfd130 -b57600 -D -Uflash:w:/var/folders/zw/80mmg8352gqb2ldt_d0k9qhr0000gn/T/arduino_build_688265/null_1001.ino.hex:i

(changing only the baud rate) and it happily installed.

 

Further checking found that I cannot install as-is with the current bootloader setting (although that is what I used the first few days!), but either by setting to the old boot loader, OR by compiling in the IDE set to the new version and pasting the command line, with the speed edited, I can install arbitrary sketches.

 

From the command line, I do get the messages at the end of 

 

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

avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

 

Could I have somehow hurt this?  Could the old bootloader have somehow been reinstalled by something I unwittingly did in the IDE?

 

thanks to all

 

hawk

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

My apologies.    I had noted that your message #1 showed 115200 baud.

 

I had always known the Nano to use 57600 baud.   So I had assumed you had a wrong selection somewhere.

 

It is very unusual for a named product to change the bootloader.   Every Nano that I own uses 57600 baud.

I am fairly active on the Arduino.cc Forum.   I was not aware that current IDE has the extra options as in Chuck's message #12.

I would have expected to hear a lot of noise from Nano owners.

 

My Desktop has IDE v1.8.1 and this Laptop has IDE v1.8.3

It looks as if I should upgrade one of the machines.   It looks like the Laptop is going to be v1.8.7.    I like to keep an older version on the Desktop.  

 

Oh,  it is perfectly resonable to change the factory bootloader.    I use a Uno bootloader on a Duemilanove.    You can use the Uno bootloader on a 16MHz Nano if you want.    It just means that you select the board as "Uno".

 

David.

Last Edited: Tue. Oct 9, 2018 - 06:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dochawk wrote:
Could I have somehow hurt this? Could the old bootloader have somehow been reinstalled by something I unwittingly did in the IDE?

 

The only way to change the bootloader is to use an external programmer connected to the 6-pin header on the Nano.

 

I suspect that between the time the sketch download that worked and the download that failed, the Arduino IDE on your computer was updated.

The old IDE version knew only about the Nano with the old bootloader and that was used and worked.

The updated version knows about both old and new bootloaders, and the new bootloader was used until you specified the old bootloader.

 

If you want, you can use an external programmer connected to the 6-pin header to program the Nano with the new bootloader using the Arduino IDE.

Another Arduino board can be programmed to act as the external ISP programmer.

 

Edit: ISP changed to IDE

 

Last Edited: Wed. Oct 10, 2018 - 07:02 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks; that makes sense.  There were indeed a slew of updates that I patiently waited to install.

 

 

So even if I selected the 328p bootloader, it would have overrides and used the old boot loader?  (or, I just plain missed when I selected from the menu ??? [but multiple times and days?])

 

 

(Either that, or my father's theory that machines are out to get me is correct . . . if *I* thought that, I'd be paranoid--but I have to admit that the empirical evidence is on his side . . .)

 

 

thanks

 

hawk

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

Do yourself a favor and buy an ICSP programmer.  They can be had for around $10 like this one:  USBtinyISP on Amazon 

 

I've had 3 of my Nano clones loose their ability to take a download using their USB port.  I'm pretty sure once it was my

fault by shorting out the TX/RX pins but sometimes they seem to just stop working on their own.   The ISP programmer

always works.  I think the USB to Serial chip on the Nano clones is fairly static sensitive.  I've also noticed that they 

are very unlikely to take a download over their USB port if they are plugged into anything else at the same time.  When

using the ICSP port, you can keep them plugged into your breadboard without issue.

 

- Jeff Wahaus -

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

Do NOT buy a USBtinyISP for $10 when you can buy a USBAsp for $1..$2

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

The difference between $3 and $10 is not going to break the bank.

 

Look at the ease of use.   e.g. 3x2 socket or 5x2 socket.   USB cable or plug dongle straight into PC USB.

 

The TinyISP firmware is never upgradeable.   The onboard controller is too small.

An USBASP can use different firmwares.

 

In practice,  most people never change firmware.    You just want something that is convenient to use.

I would choose a USBASP with 3x2 adapter.    Or dongle with 3x2 header.

 

David.