Atmega328 Does not like Sketch after burning Arduino Bootloader - Page 1
Forum section: electronics / projects

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 20, 2018, 11:26:58 am
content: 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.

author: 3db
author_rank: Frequent Contributor
timestamp: January 20, 2018, 12:51:39 pm
content: 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

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 20, 2018, 12:53:41 pm
content: 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.comEquipments: DSO104z, Hakko FX888D, Brymen BM869s

author: IanJ
author_rank: Unknown
timestamp: January 20, 2018, 01:01:49 pm
content: 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.0Ian.

author: alexanderbrevig
author_rank: Frequent Contributor
timestamp: January 20, 2018, 01:18:15 pm
content: Not sure I understand what you're doing but did you double check the eternal Rx Tx bug? I.e. Rx goes to Tx?

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 20, 2018, 01:27:52 pm
content: 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 timesQuote

author: 3db
author_rank: Frequent Contributor
timestamp: January 20, 2018, 02:12:11 pm
content: 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 converterFYI 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

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 20, 2018, 03:29:49 pm
content: Quote from: 3db on January 20, 2018, 02:12:11 pmYes 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.

author: cowana
author_rank: Frequent Contributor
timestamp: January 20, 2018, 03:53:27 pm
content: Quote from: anishkgt on January 20, 2018, 03:29:49 pmThings to verify:Correct arduino bootloader flashed via ICSPTX/RX lines in correct order (have you tried switching them?)Common GND between boardsEither 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...

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 20, 2018, 06:05:49 pm
content: Things to verify:Correct arduino bootloader flashed via ICSPYes did that from the Arduino several times. Isn't there just one Bootloader that the Uno hasTX/RX lines in correct order (have you tried switching them?)Yes did that several imesCommon GND between boardsChecked continuity of the GND on bothEither 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.

author: sleemanj
author_rank: Super Contributor
timestamp: January 20, 2018, 09:58:45 pm
content: 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.

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 20, 2018, 10:03:19 pm
content: 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.

author: alexanderbrevig
author_rank: Frequent Contributor
timestamp: January 21, 2018, 02:42:20 am
content: Two of us have asked you about RX and TX. Try swapping them

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 21, 2018, 04:28:48 am
content: Tried those as well, nothing.Www.Georgehobby.wordpress.comEquipments: DSO104z, Hakko FX888D, Brymen BM869s

author: cowana
author_rank: Frequent Contributor
timestamp: January 21, 2018, 09:39:53 am
content: 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.

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 21, 2018, 09:42:35 am
content: 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 ?

author: cowana
author_rank: Frequent Contributor
timestamp: January 21, 2018, 09:44:42 am
content: 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...

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 21, 2018, 09:59:41 am
content: 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.QuoteSo does that mean any sketch can run straight away via the ICSP ?

author: cowana
author_rank: Frequent Contributor
timestamp: January 21, 2018, 10:07:43 am
content: Quote from: anishkgt on January 21, 2018, 09:59:41 amYes. 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.

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 21, 2018, 10:12:54 am
content: 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) ?

author: cowana
author_rank: Frequent Contributor
timestamp: January 21, 2018, 10:38:00 am
content: Quote from: anishkgt on January 21, 2018, 10:12:54 amThat 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 ICSPUses pins MOSI, MISO, SCLK and resetUsually uses a 6 pin headerRequires a dedicated programmer (or arduino running the ArduinoISP sketch)This is how you have to program the bootloader initiallyVia the bootloaderUses 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 programRequires a USB/Serial adapter (or arduino board with the AVR removed)

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 21, 2018, 01:16:39 pm
content: 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

author: Buriedcode
author_rank: Super Contributor
timestamp: January 21, 2018, 02:59:07 pm
content: 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/ArduinoToBreadboardNote 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.

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 21, 2018, 03:43:12 pm
content: QuoteTrue, 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.QuoteThe 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?QuoteIs 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.

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 21, 2018, 07:07:11 pm
content: QuoteThanks 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 ?

author: Buriedcode
author_rank: Super Contributor
timestamp: January 21, 2018, 07:38:33 pm
content: Quote from: anishkgt on January 21, 2018, 07:07:11 pmI would say either:1) jumper all 3 signals (TX, RX, reset) with a two-way jumper (a 3 pin header, with one side CP2102N, the other your header, and middle the MCU connection) ... or..2) just put jumpers (two pin header) on all connections to the CP2102. That way you just have to remove jumpers to connect and external interface, and the pin headers will serve has headers for separating the USB and MCU part, allowing you to connect things to it (like using the CP2102N on board without connecting to MCU).Or just use SMD resistors, as jumpers.

author: anishkgt
author_rank: Frequent Contributor
timestamp: January 21, 2018, 08:01:14 pm
content: Thanks before i get t that, just few more things to clear with the serial communications.Is it necessary to have a 1K resistor or 22R resistor in series with Rx and Tx each to the MUC ? i had the 1K earlier and that value seemed a bit high. so i've just merged it without the resistors.