Pages: [1]   Go Down
Author Topic: Arduino uno bootloader issue and flashing of sketches  (Read 914 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have an Arduino uno board.  When connected to USB I see a new communications port in Windows/Device Manager.  From blink example code, if I click upload or burn bootloader from menu, I notice some RX/TX led activity.  Then it stops, I get an error in Windows as "avrdude: stk500_getsync(): not in sync: resp=0x00" from Arduino IDE.  I get this when ever I try burning boot loader or user code (sketch).

I feel my USB cable and connection must be OK since I get power to the Arduino uno board and I get bi-directional communications, as I would not see a COM port in Windows if USB traffic was not working in both directions.  Is it possible I've swapped D- with D+, I doubt I'd get the communications port in Windows as the handshake to transfer the device descriptor requires bidirectional comms.  I mention this because I have had to solder a cable directly to the board because of the physical connector size is to large for my project box.

I have an old STK500, I take out the 328P DIL device, setup it in AVR Studio, read fuses:

BOOTSZ = 256W_1F00
BOOTRST = [ ]
RSTDISBL = [ ]
DWEN = [ ]
SPIEN = [X]
WDTON = [ ]
EESAVE = [ ]
BODLEVEL = 1V8
CKDIV8 = [ ]
CKOUT = [ ]
SUT_CKSEL = EXTXOSC_8MHZ_XX_16KCK_14CK_65MS

EXTENDED = 0xFD (valid)
HIGH = 0xDE (valid)
LOW = 0xFF (valid)

LB = NO_LOCK
BLB0 = NO_LOCK
BLB1 = LPM_SPM_DISABLE

LOCKBIT = 0xCF (valid)

I am not sure if the bootloader is present anymore as this board used to have the blink example working before I attempted to burn bootloader and I only attempted this because normal uploads would not work and finished with the same error as I presented above.  I will try and verify it in my STK500 but I need to know a bit more about the "optiboot_atmega328.hex" file.

1). Are my fuse settings correct for the optiboot to function, it looks like a small bootloader section of 256words.  Assumed at start of device?
2). Is the boot loader simply written to start of flash at 0h.  I assumed it would be at the end of the chip flash but...
3). Is optiboot_atmega328.hex the correct file for Arduino uno?  I got it from the board config file, but there is another interesting hex for my device "optiboot_atmega328-Mini.hex"?

I've had odd behaviour where code in the 328P device flashes the on-board L led but not to the 1S intervals as expected but two fast flashes, almost like it was repeatedly rebooting or perhaps has watchdog timeouts?

Hope any of this makes sense,

Cheers,

giggler
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The fuses look valid for a 512 byte bootloader. The bootloader is loaded into high memory - 512 in this case. The compiled sketch starts at 0.

If you have another board you could use it to work out which bootloader (if any) is actually there:

http://www.gammon.com.au/forum/?id=11633


Try selecting Duemilanove from the Board menu. It is quite possible to have that bootloader on a Uno board.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nick,

Thanks.  I looked at the code for the boot loader and can see now it should be sitting at the end of flash.

I have double checked my USB wires and reversed them, as expected no connectivity so I put them back knowing I got D+ and D- correct.

I used the STK500 to flash both the blink program at 0 and boot loader at or near end of device.  It boots to the blink program fine but still can not get the boot loader to do anything useful through Arduino IDE.

Now if I attempt to upload the blink program from the IDE it seems to overwrite it.  I am not sure with what since the STK500 s/w stopped at first change on verify and that was the first byte as 0xFF.  So the bootloader is writing at least to the first page of flash.

One thing I never mentioned is that it's connected through a USB hub as another uses the hub.  If I leave a mouse connected to the same hub it is fine on power up, but maybe there is an issue with having the uno board connected on POR, by this I mean connecting the hub to my laptop.  I never checked this before removing the connector off the uno board.

I am going to burn a serial demo sketch using STK500 and see if the serial device conneciton and that to the PC are working.

Regards,

giggler
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I used STK500 to write optiboot_atmega328.hex into top of flash and bottom I built this pointless sketch.  It flashs LED every 500ms, outputs 'A' character over hardware serial at 9600 and may also ready a octet which it then uses as the echo character back to PC.

It works fine using the IDE serial monitor.  I conclude that the serial interface and usb seems to work, so why can I not flash my sketches from IDE or burn boot loader?

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}

void loop() {
  static uint8_t c='A';
  static uint8_t l=LOW;
  Serial.println(c);
 
  if (Serial.available()) {
   c=Serial.read();
  }
  delay(500);
  digitalWrite(13, l);   // set the LED on
  if (l==LOW) {
    l=HIGH;
  }else {
      l=LOW;
  }
}

Regards,

giggler
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you can write a hex file you can flash the bootloader, no doubt about that. But maybe the fuses are wrong for the bootloader and it isn't executing it.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nick,

Thanks.  I figured that might be the case which is why I posted the fuse settings??

Anyhow, I have since got avrdude source from github + usblib and compiled them under cygwin.  Anything over verbose 3 seems to output the serial to console and so here it is:

Code:
$ ./avrdude.exe -p m328p -c arduino -P COM4 -b 115200 -v -v -v -v -D -U flash:w:./DigitalReadSerial.cpp.hex

avrdude: Version 5.11, compiled on Oct 24 2012 at 11:58:40
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\cygwin\home\DaveC\avrdude-5.11\avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
         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     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
avrdude: Send: A [41] . [80]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [81]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [04]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82]   [20]
avrdude: ser_send(): write error: sorry no info avail

From stk500.h,

#define STK_GET_PARAMETER   0x41  // 'A'

So it looks like it is getting some parameters, prior to doing a write that fails? Can anyone not suggest the issue?

giggler

Moderator edit: [code] ... [/code] tags added. (Nick Gammon)
« Last Edit: October 24, 2012, 03:08:37 pm by Nick Gammon » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem is solved.  Arduino uno was connected through a self-powered 4port hub with chipset SMSC, USB20H02 device to my laptop.  Removing the hub; the board works, using a different brand hub and it works also.  Question I have now is why does the hub for my project not work with Arduino Uno properly.  It does show the COM port and is a configured usb device, yet it fails.  A mouse and keyboard connected into the same hub also works.

I have installed snoopy pro to sniff the USB traffic in an attempt to find out the difference between my two hubs.

Regards,

giggler
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I had issues with a 4-port hub until I upgraded to a USB v3 hub. There are data-transfer bottlenecks with slower hubs.
Logged

Pages: [1]   Go Up
Jump to: