Author Topic: Atmega328 Does not like Sketch after burning Arduino Bootloader  (Read 1690 times)

0 Members and 1 Guest are viewing this topic.

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Atmega328 Does not like Sketch after burning Arduino Bootloader
« on: January 20, 2018, 10:26:58 pm »
Hi All,

I am having trouble uploading sketch via the Rx Tx pin between Arduino and a standalone Arduino.

So what i had done so far ?
I've rechecked all the routes, checked for continuity and all were well. checked the voltage at the Atmega328 and it was 4.9v. So what could it be, i checked continuity of the Tx and Rx routes and that turned out to be ok as well. I did not have a 22R resistor for the Tx and Rx so would be the problem ? Well i managed to upload the sketch once or twice and latter it stopped.

Then i replaced the Atmega with another one, hoping this would work but no no it would not either. I going nuts over this project and cannot move froward stuck with this sketch not uploading issue.
 

Offline 3db

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: gb
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #1 on: January 20, 2018, 11:51:39 pm »
I'm not sure what you are trying to do.
If you mean you are using an Arduino  running the ArduinoAsISCP sketch to program your board then Rx/Tx are NOT involved.
You use the ISCP header to program the chip.
You will also have to program the chip with the Arduino bootloader.
This action will set the chip to run at 16Mhz just for starters !!

3DB


 
 

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #2 on: January 20, 2018, 11:53:41 pm »
Well an sure the sketch are uploaded via the rx tx pins from the arduino board to an external one. Just not sure why it’s not working now.


Www.Georgehobby.wordpress.com

Equipments: DSO104z, Hakko FX888D, Brymen BM869s
 

Offline IanJ

  • Supporter
  • ****
  • Posts: 942
  • Country: scotland
  • Pro EE guy many years ago, now a hobby/home biz.
    • IanJohnston.com
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #3 on: January 21, 2018, 12:01:49 am »
Souns like you are wanting the "Arduino as ISP" to act as a serial relay also.......some info here:-
http://forum.arduino.cc/index.php?topic=131047.0

Ian.
Ian Johnston
www.ianjohnston.com
Manufacturer of the PDVS2
 

Offline alexanderbrevig

  • Frequent Contributor
  • **
  • Posts: 580
  • Country: no
  • Musician, programmer and EE hobbyist
    • alexanderbrevig.com
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #4 on: January 21, 2018, 12:18:15 am »
Not sure I understand what you're doing but did you double check the eternal Rx Tx bug? I.e. Rx goes to Tx?

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #5 on: January 21, 2018, 12:27:52 am »
I get this error when try to upload the sketch and the programmer (Tools> Prorammer: is Arduino as ISP) does not seem to respond as t times
Quote
vrdude: 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 "C:\Users\georget\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\1.0.4/avrdude.conf"

         Using Port                    : COM6
         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=0x3e
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x3e
avrdude: stk500_recv(): programmer is not respon
 

Offline 3db

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: gb
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #6 on: January 21, 2018, 01:12:11 am »
I assume you are using a genuine Arduino Uno.
You would use the arduino as isp to program the bootloader.
When you have done this you no longer need to run the Arduino as the programmer.
If you want to use the Arduino as the USB to serial device then you are supposed to REMOVE the Atmega from the UNO.
You are then just using the arduino as a USB/Serial converter

FYI if you have a real UNO you can use the Atmel Flip program to Flip  the USB/Serial MCU so that it becomes the chip doing the programming.
You can then Flip it back to it's original purpose.
This would give you a DIL chip to experiment with.

3DB
 

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #7 on: January 21, 2018, 02:29:49 am »
I assume you are using a genuine Arduino Uno.
You would use the arduino as isp to program the bootloader.
When you have done this you no longer need to run the Arduino as the programmer.
If you want to use the Arduino as the USB to serial device then you are supposed to REMOVE the Atmega from the UNO.
You are then just using the arduino as a USB/Serial converter

FYI if you have a real UNO you can use the Atmel Flip program to Flip  the USB/Serial MCU so that it becomes the chip doing the programming.
You can then Flip it back to it's original purpose.
This would give you a DIL chip to experiment with.

3DB

Yes i am using the Genuine Arduino Rev3. After buring the bootloader i use the UNO as a USB -Serial interface after removing the on board IC for now, latter i will be incorporating the CP2102N.
 

Offline cowana

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: gb
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #8 on: January 21, 2018, 02:53:27 am »
Yes i am using the Genuine Arduino Rev3. After buring the bootloader i use the UNO as a USB -Serial interface after removing the on board IC for now, latter i will be incorporating the CP2102N.

Things to verify:
  • Correct arduino bootloader flashed via ICSP
  • TX/RX lines in correct order (have you tried switching them?)
  • Common GND between boards
  • Either use the auto reset circuitry on the Uno (connect the RST pin on the Uno board to your board, or connect power right when the 'uploading' dialog appears)

If you can verify you have confirmed it is none of these, we can move on to some slightly more obscure issues...
« Last Edit: January 21, 2018, 03:23:00 am by cowana »
 

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #9 on: January 21, 2018, 05:05:49 am »
Things to verify:
  • Correct arduino bootloader flashed via ICSP
Yes did that from the Arduino several times. Isn't there just one Bootloader that the Uno has
  • TX/RX lines in correct order (have you tried switching them?)
Yes did that several imes
  • Common GND between boards
Checked continuity of the GND on both
  • Either use the auto reset circuitry on the Uno (connect the RST pin on the Uno board to your board, or connect power right when the 'uploading' dialog appears)
Did a reset when the uploading appeared and did power reset as well.
[/list]
 

Online sleemanj

  • Super Contributor
  • ***
  • Posts: 2314
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #10 on: January 21, 2018, 08:58:45 am »
After you burned the bootloader, did you do anything else.  Somebody on reddit a couple days ago was having similar troubles, eventually he mentioned that after burning the bootloader he uploaded blink and that was working.... he didn't realise that uploading a sketch over isp destroys the bootloader.

Anyway, dispense with using the arduino as an inbetween, buy a proper cp2102 based usb-uart adapter and a usbasp programmer, they are very cheap from ebay or ali.
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #11 on: January 21, 2018, 09:03:19 am »
Nothing really, in fact i've never uploaded sketch via ICSP just the usual way, this time using the Arduino as USB to Serial. The boot loader gets done without a problem or is it because the boot loader was not burned for some reason. The Arduino IDE says "burn completed". So am guess it was done.

Like you said I did try using the cheap FTDI breakout board and nothing. Same error as before.
 

Offline alexanderbrevig

  • Frequent Contributor
  • **
  • Posts: 580
  • Country: no
  • Musician, programmer and EE hobbyist
    • alexanderbrevig.com
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #12 on: January 21, 2018, 01:42:20 pm »
Two of us have asked you about RX and TX. Try swapping them :)

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #13 on: January 21, 2018, 03:28:48 pm »
Tried those as well, nothing.


Www.Georgehobby.wordpress.com

Equipments: DSO104z, Hakko FX888D, Brymen BM869s
 
The following users thanked this post: alexanderbrevig

Offline cowana

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: gb
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #14 on: January 21, 2018, 08:39:53 pm »
Have you tried uploading a sketch using ICSP?

While it will wipe the bootloader (so you'll have to reflash it after), running a 'blink' sketch would provide confidence that the oscillator is oscillating at the right speed, and the core is running happily.
 

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #15 on: January 21, 2018, 08:42:35 pm »
yes i did try that but failed, returned an error while uploading it, wouldn't that erase the bootloader as well and without the bootloader would the sketch work ?
 

Offline cowana

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: gb
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #16 on: January 21, 2018, 08:44:42 pm »
The bootloader is only required for uploading new programs via serial.

It's true it would wipe the bootloader, but that won't be an issue - the AVR will just boot up the main program straight away on powerup.

If it returned an error while uploading, that sounds like an indication something isn't right...
 

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #17 on: January 21, 2018, 08:59:41 pm »
If the wiring is the same as when burning boot loader then i do get an error but i will give it a try and see how it goes.

Quote
the AVR will just boot up the main program straight away on powerup.
So does that mean any sketch can run straight away via the ICSP ?
 

Offline cowana

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: gb
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #18 on: January 21, 2018, 09:07:43 pm »
Quote
the AVR will just boot up the main program straight away on powerup.
So does that mean any sketch can run straight away via the ICSP ?

Yes. When I do custom boards, I tend not to bother with the bootloader and serial programming - as long as you don't mind having to use your external ICSP programmer, then that's a totally valid way of uploading sketches. Note you also get a slightly increased amount of FLASH memory, as the bootloader isn't taking up a chunk.
 
The following users thanked this post: anishkgt

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #19 on: January 21, 2018, 09:12:54 pm »
Thanks that was something new down this road.

The ICSP programmer i use is the Arduino Uno as a USB to Serial interface with the Arduino IDE. So what does the Bootloader do when it comes to arduino ? is it just for uploading via the Arduino through the Rx Tx Pins (not sure what they are called) ?
 

Offline cowana

  • Frequent Contributor
  • **
  • Posts: 311
  • Country: gb
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #20 on: January 21, 2018, 09:38:00 pm »
The ICSP programmer i use is the Arduino Uno as a USB to Serial interface with the Arduino IDE. So what does the Bootloader do when it comes to arduino ? is it just for uploading via the Arduino through the Rx Tx Pins (not sure what they are called) ?

That doesn't sound quite right. The USB to Serial interface is for talking to the bootloader, which can only be done after you have flashed the bootloader using an ICSP programmer.

There are two ways of getting a program into an AVR:

Via ICSP
  • Uses pins MOSI, MISO, SCLK and reset
  • Usually uses a 6 pin header
  • Requires a dedicated programmer (or arduino running the ArduinoISP sketch)
  • This is how you have to program the bootloader initially

Via the bootloader
  • Uses pins Serial_TX, Serial_RX, optionally RST (to ensure the AVR enters the bootloader at the right time)
  • Bootloader must be running and 'listening' for a new program
  • Requires a USB/Serial adapter (or arduino board with the AVR removed)
« Last Edit: January 21, 2018, 09:42:16 pm by cowana »
 
The following users thanked this post: anishkgt

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #21 on: January 22, 2018, 12:16:39 am »
Tested that too and it did not work. Sketch could not be uploaded via the ICSP but successfully burned the bootloader again without any errors.

Quote
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 "C:\Users\georget\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\1.0.4/avrdude.conf"

         Using Port                    : COM6
         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=0xda
 

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1132
  • Country: gb
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #22 on: January 22, 2018, 01:59:07 am »
Perhaps I have misread this thread but there seems to be some confusion.

When you use the Arduino as an ISP programmer, the MCU stays in the Arduino.  You then use this along with the ISP header (SCLK, MISO, MOSI, RST) to flash the bootloader to the second Atmega on your board.  Then... removing the MCU form the Arduino to use the board purely as a USB-serial bridge, hook up the tx, rx and the reset - via the 0.1uF cap noted here:

https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard

Note the 'reset' line on the Arduino board already comes from the the 0.1uF, so you don't need one on board.  The 'reset' connection on the Arduino is directly connected to the MCU's reset line, including pull-up and cap.

Look at your schematic, you have your ISP header but no corresponding 'bootloader' header.  Although there is that 6-way SIL header with tx, rx, and reset lines but those are connected to both the MCU and what appears to be a USB-serial chip on board.  You can't have the tx and rx lines from the MCU connected to both the on board USB chip AND an external source, it just won't work. In this case, once you have flashed the bootloader to the Atmega on board - using the Arduino as an ISP programmer - why do you need the Arduino board again to upload the sketch?  Unless this USB-serial bridge on board doesn't have its DTR line hooked to the reset.

There can be other issues too with clocks, IIRC when flashing a virgin Atmega, it defaults to internal oscillator, but if that fuse is changed, it requires an external clock to be flashed.


Ultimately, I think you have confused yourself by putting, what is essentially an Arduino UNO - including the USB-serial part - on the PCB, but treating it as just an MCU.  I could be wrong, but it is hard to understand exactly what you have tried, and in what order because the schematic you have isn't the full schem form that PCB.  As far as I can tell, once you have successfully flashed the bootloader to the board, you no longer need an Arduino UNO - you simply use the on board USB port.
 
The following users thanked this post: anishkgt

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #23 on: January 22, 2018, 02:43:12 am »
Quote
When you use the Arduino as an ISP programmer, the MCU stays in the Arduino.  You then use this along with the ISP header (SCLK, MISO, MOSI, RST) to flash the bootloader to the second Atmega on your board.  Then... removing the MCU form the Arduino to use the board purely as a USB-serial bridge, hook up the tx, rx and the reset - via the 0.1uF cap noted here:

True, that is exactly am doing now. now the USB interface on the PCB does not work for some reason and it shows error similar to "USB not recognized and windows has disabled it" hence using the Arduino as an alternative.

Quote
You can't have the tx and rx lines from the MCU connected to both the on board USB chip AND an external source, it just won't work. In this case, once you have flashed the bootloader to the Atmega on board - using the Arduino as an ISP programmer - why do you need the Arduino board again to upload the sketch?  Unless this USB-serial bridge on board doesn't have its DTR line hooked to the reset.
The female header is used as the Rx Tx for USB to Serial communication.I have this just in case i need to use an external breakout board. I read that the reset should have 0.1uf cap in series, was that only for manual reset via a switch and not when connecting it through USB-bridge or a breakout?

Quote
Look at your schematic, you have your ISP header but no corresponding 'bootloader' header.

Is it the ICSP that your referring to as ISP ? then it is already there next to the Atmega chip (IC 1) which works to burn the bootloader.
I've also attached the other half of the schematic.
 

Offline anishkgt

  • Frequent Contributor
  • **
  • Posts: 741
  • Country: qa
    • George Hobby
Re: Atmega328 Does not like Sketch after burning Arduino Bootloader
« Reply #24 on: January 22, 2018, 06:07:11 am »
Quote
You can't have the tx and rx lines from the MCU connected to both the on board USB chip AND an external source, it just won't work. 

Thanks a bunch Buriedcode. You've just saved me ton of time. :-+

When you said the Rx Tx would not go together i've removed the CP2102N from the PCB and all seems to be working as good. So to address one more concern, How do i an option for the FTDI port the 6 Pin header, maybe jumper  to choose from which interface ? if so which one would it be to choose from the Rx or Tx ?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf